{-# 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.GetBot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves details for the specified bot, such as bot email address, bot
-- type, status, and display name.
module Amazonka.Chime.GetBot
  ( -- * Creating a Request
    GetBot (..),
    newGetBot,

    -- * Request Lenses
    getBot_accountId,
    getBot_botId,

    -- * Destructuring the Response
    GetBotResponse (..),
    newGetBotResponse,

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

-- |
-- Create a value of 'GetBot' 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', 'getBot_accountId' - The Amazon Chime account ID.
--
-- 'botId', 'getBot_botId' - The bot ID.
newGetBot ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'botId'
  Prelude.Text ->
  GetBot
newGetBot :: Text -> Text -> GetBot
newGetBot Text
pAccountId_ Text
pBotId_ =
  GetBot' {$sel:accountId:GetBot' :: Text
accountId = Text
pAccountId_, $sel:botId:GetBot' :: Text
botId = Text
pBotId_}

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

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

instance Core.AWSRequest GetBot where
  type AWSResponse GetBot = GetBotResponse
  request :: (Service -> Service) -> GetBot -> Request GetBot
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 GetBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBot)))
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 Bot -> Int -> GetBotResponse
GetBotResponse'
            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
"Bot")
            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 GetBot where
  hashWithSalt :: Int -> GetBot -> Int
hashWithSalt Int
_salt GetBot' {Text
botId :: Text
accountId :: Text
$sel:botId:GetBot' :: GetBot -> Text
$sel:accountId:GetBot' :: GetBot -> 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 GetBot where
  rnf :: GetBot -> ()
rnf GetBot' {Text
botId :: Text
accountId :: Text
$sel:botId:GetBot' :: GetBot -> Text
$sel:accountId:GetBot' :: GetBot -> 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 GetBot where
  toHeaders :: GetBot -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath GetBot where
  toPath :: GetBot -> ByteString
toPath GetBot' {Text
botId :: Text
accountId :: Text
$sel:botId:GetBot' :: GetBot -> Text
$sel:accountId:GetBot' :: GetBot -> 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
      ]

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

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

-- |
-- Create a value of 'GetBotResponse' 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:
--
-- 'bot', 'getBotResponse_bot' - The chat bot details.
--
-- 'httpStatus', 'getBotResponse_httpStatus' - The response's http status code.
newGetBotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetBotResponse
newGetBotResponse :: Int -> GetBotResponse
newGetBotResponse Int
pHttpStatus_ =
  GetBotResponse'
    { $sel:bot:GetBotResponse' :: Maybe Bot
bot = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetBotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The chat bot details.
getBotResponse_bot :: Lens.Lens' GetBotResponse (Prelude.Maybe Bot)
getBotResponse_bot :: Lens' GetBotResponse (Maybe Bot)
getBotResponse_bot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBotResponse' {Maybe Bot
bot :: Maybe Bot
$sel:bot:GetBotResponse' :: GetBotResponse -> Maybe Bot
bot} -> Maybe Bot
bot) (\s :: GetBotResponse
s@GetBotResponse' {} Maybe Bot
a -> GetBotResponse
s {$sel:bot:GetBotResponse' :: Maybe Bot
bot = Maybe Bot
a} :: GetBotResponse)

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

instance Prelude.NFData GetBotResponse where
  rnf :: GetBotResponse -> ()
rnf GetBotResponse' {Int
Maybe Bot
httpStatus :: Int
bot :: Maybe Bot
$sel:httpStatus:GetBotResponse' :: GetBotResponse -> Int
$sel:bot:GetBotResponse' :: GetBotResponse -> Maybe Bot
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bot
bot
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus