{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' GetEventsConfiguration Text
getEventsConfiguration_accountId = 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 :: Lens' GetEventsConfiguration Text
getEventsConfiguration_botId = 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 :: (Service -> Service)
-> GetEventsConfiguration -> Request GetEventsConfiguration
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetEventsConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEventsConfiguration)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe EventsConfiguration -> Int -> GetEventsConfigurationResponse
GetEventsConfigurationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"EventsConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetEventsConfiguration where
  hashWithSalt :: Int -> GetEventsConfiguration -> Int
hashWithSalt Int
_salt GetEventsConfiguration' {Text
botId :: Text
accountId :: Text
$sel:botId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
$sel:accountId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
botId

instance Prelude.NFData GetEventsConfiguration where
  rnf :: GetEventsConfiguration -> ()
rnf GetEventsConfiguration' {Text
botId :: Text
accountId :: Text
$sel:botId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
$sel:accountId:GetEventsConfiguration' :: GetEventsConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
botId

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

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

instance Data.ToQuery GetEventsConfiguration where
  toQuery :: GetEventsConfiguration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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
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.
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'
    { $sel:eventsConfiguration:GetEventsConfigurationResponse' :: Maybe EventsConfiguration
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 :: Lens' GetEventsConfigurationResponse (Maybe EventsConfiguration)
getEventsConfigurationResponse_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 :: Lens' GetEventsConfigurationResponse Int
getEventsConfigurationResponse_httpStatus = 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
  where
  rnf :: GetEventsConfigurationResponse -> ()
rnf GetEventsConfigurationResponse' {Int
Maybe EventsConfiguration
httpStatus :: Int
eventsConfiguration :: Maybe EventsConfiguration
$sel:httpStatus:GetEventsConfigurationResponse' :: GetEventsConfigurationResponse -> Int
$sel:eventsConfiguration:GetEventsConfigurationResponse' :: GetEventsConfigurationResponse -> Maybe EventsConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EventsConfiguration
eventsConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus