{-# 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-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)
--
-- 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.Lens as Lens
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
(GetBot -> GetBot -> Bool)
-> (GetBot -> GetBot -> Bool) -> Eq GetBot
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]
(Int -> ReadS GetBot)
-> ReadS [GetBot]
-> ReadPrec GetBot
-> ReadPrec [GetBot]
-> Read 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
(Int -> GetBot -> ShowS)
-> (GetBot -> String) -> ([GetBot] -> ShowS) -> Show GetBot
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. GetBot -> Rep GetBot x)
-> (forall x. Rep GetBot x -> GetBot) -> Generic GetBot
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' :: Text -> Text -> GetBot
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 :: (Text -> f Text) -> GetBot -> f GetBot
getBot_accountId = (GetBot -> Text)
-> (GetBot -> Text -> GetBot) -> Lens GetBot GetBot Text Text
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 :: (Text -> f Text) -> GetBot -> f GetBot
getBot_botId = (GetBot -> Text)
-> (GetBot -> Text -> GetBot) -> Lens GetBot GetBot Text Text
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 :: GetBot -> Request GetBot
request = Service -> GetBot -> Request GetBot
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBot)))
response =
    (Int
 -> ResponseHeaders -> Object -> Either String (AWSResponse GetBot))
-> Logger
-> Service
-> Proxy GetBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBot)))
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 Bot -> Int -> GetBotResponse
GetBotResponse'
            (Maybe Bot -> Int -> GetBotResponse)
-> Either String (Maybe Bot)
-> Either String (Int -> GetBotResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Bot)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Bot")
            Either String (Int -> GetBotResponse)
-> Either String Int -> Either String GetBotResponse
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 GetBot

instance Prelude.NFData GetBot

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

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

instance Core.ToQuery GetBot where
  toQuery :: GetBot -> QueryString
toQuery = QueryString -> GetBot -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetBotResponse -> GetBotResponse -> Bool)
-> (GetBotResponse -> GetBotResponse -> Bool) -> Eq GetBotResponse
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
(Int -> GetBotResponse -> ShowS)
-> (GetBotResponse -> String)
-> ([GetBotResponse] -> ShowS)
-> Show GetBotResponse
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. GetBotResponse -> Rep GetBotResponse x)
-> (forall x. Rep GetBotResponse x -> GetBotResponse)
-> Generic GetBotResponse
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' :: Maybe Bot -> Int -> GetBotResponse
GetBotResponse'
    { $sel:bot:GetBotResponse' :: Maybe Bot
bot = Maybe 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 :: (Maybe Bot -> f (Maybe Bot)) -> GetBotResponse -> f GetBotResponse
getBotResponse_bot = (GetBotResponse -> Maybe Bot)
-> (GetBotResponse -> Maybe Bot -> GetBotResponse)
-> Lens GetBotResponse GetBotResponse (Maybe Bot) (Maybe 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 :: (Int -> f Int) -> GetBotResponse -> f GetBotResponse
getBotResponse_httpStatus = (GetBotResponse -> Int)
-> (GetBotResponse -> Int -> GetBotResponse)
-> Lens GetBotResponse GetBotResponse Int Int
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