{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Chime.GetEventsConfiguration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets details for an events configuration that allows a bot to receive
-- outgoing events, such as an HTTPS endpoint or Lambda function ARN.
module Amazonka.Chime.GetEventsConfiguration
  ( -- * Creating a Request
    GetEventsConfiguration (..),
    newGetEventsConfiguration,

    -- * Request Lenses
    getEventsConfiguration_accountId,
    getEventsConfiguration_botId,

    -- * Destructuring the Response
    GetEventsConfigurationResponse (..),
    newGetEventsConfigurationResponse,

    -- * Response Lenses
    getEventsConfigurationResponse_eventsConfiguration,
    getEventsConfigurationResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetEventsConfiguration' smart constructor.
data GetEventsConfiguration = GetEventsConfiguration'
  { -- | The Amazon Chime account ID.
    GetEventsConfiguration -> Text
accountId :: Prelude.Text,
    -- | The bot ID.
    GetEventsConfiguration -> Text
botId :: Prelude.Text
  }
  deriving (GetEventsConfiguration -> GetEventsConfiguration -> Bool
(GetEventsConfiguration -> GetEventsConfiguration -> Bool)
-> (GetEventsConfiguration -> GetEventsConfiguration -> Bool)
-> Eq GetEventsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventsConfiguration -> GetEventsConfiguration -> Bool
$c/= :: GetEventsConfiguration -> GetEventsConfiguration -> Bool
== :: GetEventsConfiguration -> GetEventsConfiguration -> Bool
$c== :: GetEventsConfiguration -> GetEventsConfiguration -> Bool
Prelude.Eq, ReadPrec [GetEventsConfiguration]
ReadPrec GetEventsConfiguration
Int -> ReadS GetEventsConfiguration
ReadS [GetEventsConfiguration]
(Int -> ReadS GetEventsConfiguration)
-> ReadS [GetEventsConfiguration]
-> ReadPrec GetEventsConfiguration
-> ReadPrec [GetEventsConfiguration]
-> Read GetEventsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEventsConfiguration]
$creadListPrec :: ReadPrec [GetEventsConfiguration]
readPrec :: ReadPrec GetEventsConfiguration
$creadPrec :: ReadPrec GetEventsConfiguration
readList :: ReadS [GetEventsConfiguration]
$creadList :: ReadS [GetEventsConfiguration]
readsPrec :: Int -> ReadS GetEventsConfiguration
$creadsPrec :: Int -> ReadS GetEventsConfiguration
Prelude.Read, Int -> GetEventsConfiguration -> ShowS
[GetEventsConfiguration] -> ShowS
GetEventsConfiguration -> String
(Int -> GetEventsConfiguration -> ShowS)
-> (GetEventsConfiguration -> String)
-> ([GetEventsConfiguration] -> ShowS)
-> Show GetEventsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventsConfiguration] -> ShowS
$cshowList :: [GetEventsConfiguration] -> ShowS
show :: GetEventsConfiguration -> String
$cshow :: GetEventsConfiguration -> String
showsPrec :: Int -> GetEventsConfiguration -> ShowS
$cshowsPrec :: Int -> GetEventsConfiguration -> ShowS
Prelude.Show, (forall x. GetEventsConfiguration -> Rep GetEventsConfiguration x)
-> (forall x.
    Rep GetEventsConfiguration x -> GetEventsConfiguration)
-> Generic GetEventsConfiguration
forall x. Rep GetEventsConfiguration x -> GetEventsConfiguration
forall x. GetEventsConfiguration -> Rep GetEventsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventsConfiguration x -> GetEventsConfiguration
$cfrom :: forall x. GetEventsConfiguration -> Rep GetEventsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetEventsConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'accountId', 'getEventsConfiguration_accountId' - The Amazon Chime account ID.
--
-- 'botId', 'getEventsConfiguration_botId' - The bot ID.
newGetEventsConfiguration ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'botId'
  Prelude.Text ->
  GetEventsConfiguration
newGetEventsConfiguration :: Text -> Text -> GetEventsConfiguration
newGetEventsConfiguration Text
pAccountId_ Text
pBotId_ =
  GetEventsConfiguration' :: Text -> Text -> GetEventsConfiguration
GetEventsConfiguration'
    { $sel:accountId:GetEventsConfiguration' :: Text
accountId = Text
pAccountId_,
      $sel:botId:GetEventsConfiguration' :: Text
botId = Text
pBotId_
    }

-- | The Amazon Chime account ID.
getEventsConfiguration_accountId :: Lens.Lens' GetEventsConfiguration Prelude.Text
getEventsConfiguration_accountId :: (Text -> f Text)
-> GetEventsConfiguration -> f GetEventsConfiguration
getEventsConfiguration_accountId = (GetEventsConfiguration -> Text)
-> (GetEventsConfiguration -> Text -> GetEventsConfiguration)
-> Lens GetEventsConfiguration GetEventsConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventsConfiguration' {Text
accountId :: Text
$sel:accountId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
accountId} -> Text
accountId) (\s :: GetEventsConfiguration
s@GetEventsConfiguration' {} Text
a -> GetEventsConfiguration
s {$sel:accountId:GetEventsConfiguration' :: Text
accountId = Text
a} :: GetEventsConfiguration)

-- | The bot ID.
getEventsConfiguration_botId :: Lens.Lens' GetEventsConfiguration Prelude.Text
getEventsConfiguration_botId :: (Text -> f Text)
-> GetEventsConfiguration -> f GetEventsConfiguration
getEventsConfiguration_botId = (GetEventsConfiguration -> Text)
-> (GetEventsConfiguration -> Text -> GetEventsConfiguration)
-> Lens GetEventsConfiguration GetEventsConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventsConfiguration' {Text
botId :: Text
$sel:botId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
botId} -> Text
botId) (\s :: GetEventsConfiguration
s@GetEventsConfiguration' {} Text
a -> GetEventsConfiguration
s {$sel:botId:GetEventsConfiguration' :: Text
botId = Text
a} :: GetEventsConfiguration)

instance Core.AWSRequest GetEventsConfiguration where
  type
    AWSResponse GetEventsConfiguration =
      GetEventsConfigurationResponse
  request :: GetEventsConfiguration -> Request GetEventsConfiguration
request = Service -> GetEventsConfiguration -> Request GetEventsConfiguration
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetEventsConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEventsConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetEventsConfiguration))
-> Logger
-> Service
-> Proxy GetEventsConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEventsConfiguration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe EventsConfiguration -> Int -> GetEventsConfigurationResponse
GetEventsConfigurationResponse'
            (Maybe EventsConfiguration
 -> Int -> GetEventsConfigurationResponse)
-> Either String (Maybe EventsConfiguration)
-> Either String (Int -> GetEventsConfigurationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe EventsConfiguration)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EventsConfiguration")
            Either String (Int -> GetEventsConfigurationResponse)
-> Either String Int
-> Either String GetEventsConfigurationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetEventsConfiguration

instance Prelude.NFData GetEventsConfiguration

instance Core.ToHeaders GetEventsConfiguration where
  toHeaders :: GetEventsConfiguration -> ResponseHeaders
toHeaders = ResponseHeaders -> GetEventsConfiguration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetEventsConfiguration where
  toPath :: GetEventsConfiguration -> ByteString
toPath GetEventsConfiguration' {Text
botId :: Text
accountId :: Text
$sel:botId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
$sel:accountId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/bots/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
botId,
        ByteString
"/events-configuration"
      ]

instance Core.ToQuery GetEventsConfiguration where
  toQuery :: GetEventsConfiguration -> QueryString
toQuery = QueryString -> GetEventsConfiguration -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetEventsConfigurationResponse' smart constructor.
data GetEventsConfigurationResponse = GetEventsConfigurationResponse'
  { -- | The events configuration details.
    GetEventsConfigurationResponse -> Maybe EventsConfiguration
eventsConfiguration :: Prelude.Maybe EventsConfiguration,
    -- | The response's http status code.
    GetEventsConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetEventsConfigurationResponse
-> GetEventsConfigurationResponse -> Bool
(GetEventsConfigurationResponse
 -> GetEventsConfigurationResponse -> Bool)
-> (GetEventsConfigurationResponse
    -> GetEventsConfigurationResponse -> Bool)
-> Eq GetEventsConfigurationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventsConfigurationResponse
-> GetEventsConfigurationResponse -> Bool
$c/= :: GetEventsConfigurationResponse
-> GetEventsConfigurationResponse -> Bool
== :: GetEventsConfigurationResponse
-> GetEventsConfigurationResponse -> Bool
$c== :: GetEventsConfigurationResponse
-> GetEventsConfigurationResponse -> Bool
Prelude.Eq, Int -> GetEventsConfigurationResponse -> ShowS
[GetEventsConfigurationResponse] -> ShowS
GetEventsConfigurationResponse -> String
(Int -> GetEventsConfigurationResponse -> ShowS)
-> (GetEventsConfigurationResponse -> String)
-> ([GetEventsConfigurationResponse] -> ShowS)
-> Show GetEventsConfigurationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventsConfigurationResponse] -> ShowS
$cshowList :: [GetEventsConfigurationResponse] -> ShowS
show :: GetEventsConfigurationResponse -> String
$cshow :: GetEventsConfigurationResponse -> String
showsPrec :: Int -> GetEventsConfigurationResponse -> ShowS
$cshowsPrec :: Int -> GetEventsConfigurationResponse -> ShowS
Prelude.Show, (forall x.
 GetEventsConfigurationResponse
 -> Rep GetEventsConfigurationResponse x)
-> (forall x.
    Rep GetEventsConfigurationResponse x
    -> GetEventsConfigurationResponse)
-> Generic GetEventsConfigurationResponse
forall x.
Rep GetEventsConfigurationResponse x
-> GetEventsConfigurationResponse
forall x.
GetEventsConfigurationResponse
-> Rep GetEventsConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEventsConfigurationResponse x
-> GetEventsConfigurationResponse
$cfrom :: forall x.
GetEventsConfigurationResponse
-> Rep GetEventsConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEventsConfigurationResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'eventsConfiguration', 'getEventsConfigurationResponse_eventsConfiguration' - The events configuration details.
--
-- 'httpStatus', 'getEventsConfigurationResponse_httpStatus' - The response's http status code.
newGetEventsConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEventsConfigurationResponse
newGetEventsConfigurationResponse :: Int -> GetEventsConfigurationResponse
newGetEventsConfigurationResponse Int
pHttpStatus_ =
  GetEventsConfigurationResponse' :: Maybe EventsConfiguration -> Int -> GetEventsConfigurationResponse
GetEventsConfigurationResponse'
    { $sel:eventsConfiguration:GetEventsConfigurationResponse' :: Maybe EventsConfiguration
eventsConfiguration =
        Maybe EventsConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEventsConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The events configuration details.
getEventsConfigurationResponse_eventsConfiguration :: Lens.Lens' GetEventsConfigurationResponse (Prelude.Maybe EventsConfiguration)
getEventsConfigurationResponse_eventsConfiguration :: (Maybe EventsConfiguration -> f (Maybe EventsConfiguration))
-> GetEventsConfigurationResponse
-> f GetEventsConfigurationResponse
getEventsConfigurationResponse_eventsConfiguration = (GetEventsConfigurationResponse -> Maybe EventsConfiguration)
-> (GetEventsConfigurationResponse
    -> Maybe EventsConfiguration -> GetEventsConfigurationResponse)
-> Lens
     GetEventsConfigurationResponse
     GetEventsConfigurationResponse
     (Maybe EventsConfiguration)
     (Maybe EventsConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventsConfigurationResponse' {Maybe EventsConfiguration
eventsConfiguration :: Maybe EventsConfiguration
$sel:eventsConfiguration:GetEventsConfigurationResponse' :: GetEventsConfigurationResponse -> Maybe EventsConfiguration
eventsConfiguration} -> Maybe EventsConfiguration
eventsConfiguration) (\s :: GetEventsConfigurationResponse
s@GetEventsConfigurationResponse' {} Maybe EventsConfiguration
a -> GetEventsConfigurationResponse
s {$sel:eventsConfiguration:GetEventsConfigurationResponse' :: Maybe EventsConfiguration
eventsConfiguration = Maybe EventsConfiguration
a} :: GetEventsConfigurationResponse)

-- | The response's http status code.
getEventsConfigurationResponse_httpStatus :: Lens.Lens' GetEventsConfigurationResponse Prelude.Int
getEventsConfigurationResponse_httpStatus :: (Int -> f Int)
-> GetEventsConfigurationResponse
-> f GetEventsConfigurationResponse
getEventsConfigurationResponse_httpStatus = (GetEventsConfigurationResponse -> Int)
-> (GetEventsConfigurationResponse
    -> Int -> GetEventsConfigurationResponse)
-> Lens
     GetEventsConfigurationResponse
     GetEventsConfigurationResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventsConfigurationResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetEventsConfigurationResponse' :: GetEventsConfigurationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetEventsConfigurationResponse
s@GetEventsConfigurationResponse' {} Int
a -> GetEventsConfigurationResponse
s {$sel:httpStatus:GetEventsConfigurationResponse' :: Int
httpStatus = Int
a} :: GetEventsConfigurationResponse)

instance
  Prelude.NFData
    GetEventsConfigurationResponse