{-# 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.CreateBot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a bot for an Amazon Chime Enterprise account.
module Amazonka.Chime.CreateBot
  ( -- * Creating a Request
    CreateBot (..),
    newCreateBot,

    -- * Request Lenses
    createBot_domain,
    createBot_displayName,
    createBot_accountId,

    -- * Destructuring the Response
    CreateBotResponse (..),
    newCreateBotResponse,

    -- * Response Lenses
    createBotResponse_bot,
    createBotResponse_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:/ 'newCreateBot' smart constructor.
data CreateBot = CreateBot'
  { -- | The domain of the Amazon Chime Enterprise account.
    CreateBot -> Maybe Text
domain :: Prelude.Maybe Prelude.Text,
    -- | The bot display name.
    CreateBot -> Sensitive Text
displayName :: Data.Sensitive Prelude.Text,
    -- | The Amazon Chime account ID.
    CreateBot -> Text
accountId :: Prelude.Text
  }
  deriving (CreateBot -> CreateBot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBot -> CreateBot -> Bool
$c/= :: CreateBot -> CreateBot -> Bool
== :: CreateBot -> CreateBot -> Bool
$c== :: CreateBot -> CreateBot -> Bool
Prelude.Eq, Int -> CreateBot -> ShowS
[CreateBot] -> ShowS
CreateBot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBot] -> ShowS
$cshowList :: [CreateBot] -> ShowS
show :: CreateBot -> String
$cshow :: CreateBot -> String
showsPrec :: Int -> CreateBot -> ShowS
$cshowsPrec :: Int -> CreateBot -> ShowS
Prelude.Show, forall x. Rep CreateBot x -> CreateBot
forall x. CreateBot -> Rep CreateBot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBot x -> CreateBot
$cfrom :: forall x. CreateBot -> Rep CreateBot x
Prelude.Generic)

-- |
-- Create a value of 'CreateBot' 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:
--
-- 'domain', 'createBot_domain' - The domain of the Amazon Chime Enterprise account.
--
-- 'displayName', 'createBot_displayName' - The bot display name.
--
-- 'accountId', 'createBot_accountId' - The Amazon Chime account ID.
newCreateBot ::
  -- | 'displayName'
  Prelude.Text ->
  -- | 'accountId'
  Prelude.Text ->
  CreateBot
newCreateBot :: Text -> Text -> CreateBot
newCreateBot Text
pDisplayName_ Text
pAccountId_ =
  CreateBot'
    { $sel:domain:CreateBot' :: Maybe Text
domain = forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:CreateBot' :: Sensitive Text
displayName = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pDisplayName_,
      $sel:accountId:CreateBot' :: Text
accountId = Text
pAccountId_
    }

-- | The domain of the Amazon Chime Enterprise account.
createBot_domain :: Lens.Lens' CreateBot (Prelude.Maybe Prelude.Text)
createBot_domain :: Lens' CreateBot (Maybe Text)
createBot_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBot' {Maybe Text
domain :: Maybe Text
$sel:domain:CreateBot' :: CreateBot -> Maybe Text
domain} -> Maybe Text
domain) (\s :: CreateBot
s@CreateBot' {} Maybe Text
a -> CreateBot
s {$sel:domain:CreateBot' :: Maybe Text
domain = Maybe Text
a} :: CreateBot)

-- | The bot display name.
createBot_displayName :: Lens.Lens' CreateBot Prelude.Text
createBot_displayName :: Lens' CreateBot Text
createBot_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBot' {Sensitive Text
displayName :: Sensitive Text
$sel:displayName:CreateBot' :: CreateBot -> Sensitive Text
displayName} -> Sensitive Text
displayName) (\s :: CreateBot
s@CreateBot' {} Sensitive Text
a -> CreateBot
s {$sel:displayName:CreateBot' :: Sensitive Text
displayName = Sensitive Text
a} :: CreateBot) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

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

instance Core.AWSRequest CreateBot where
  type AWSResponse CreateBot = CreateBotResponse
  request :: (Service -> Service) -> CreateBot -> Request CreateBot
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBot)))
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 -> CreateBotResponse
CreateBotResponse'
            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 CreateBot where
  hashWithSalt :: Int -> CreateBot -> Int
hashWithSalt Int
_salt CreateBot' {Maybe Text
Text
Sensitive Text
accountId :: Text
displayName :: Sensitive Text
domain :: Maybe Text
$sel:accountId:CreateBot' :: CreateBot -> Text
$sel:displayName:CreateBot' :: CreateBot -> Sensitive Text
$sel:domain:CreateBot' :: CreateBot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId

instance Prelude.NFData CreateBot where
  rnf :: CreateBot -> ()
rnf CreateBot' {Maybe Text
Text
Sensitive Text
accountId :: Text
displayName :: Sensitive Text
domain :: Maybe Text
$sel:accountId:CreateBot' :: CreateBot -> Text
$sel:displayName:CreateBot' :: CreateBot -> Sensitive Text
$sel:domain:CreateBot' :: CreateBot -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
accountId

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

instance Data.ToJSON CreateBot where
  toJSON :: CreateBot -> Value
toJSON CreateBot' {Maybe Text
Text
Sensitive Text
accountId :: Text
displayName :: Sensitive Text
domain :: Maybe Text
$sel:accountId:CreateBot' :: CreateBot -> Text
$sel:displayName:CreateBot' :: CreateBot -> Sensitive Text
$sel:domain:CreateBot' :: CreateBot -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Domain" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
domain,
            forall a. a -> Maybe a
Prelude.Just (Key
"DisplayName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
displayName)
          ]
      )

instance Data.ToPath CreateBot where
  toPath :: CreateBot -> ByteString
toPath CreateBot' {Maybe Text
Text
Sensitive Text
accountId :: Text
displayName :: Sensitive Text
domain :: Maybe Text
$sel:accountId:CreateBot' :: CreateBot -> Text
$sel:displayName:CreateBot' :: CreateBot -> Sensitive Text
$sel:domain:CreateBot' :: CreateBot -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/accounts/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
accountId, ByteString
"/bots"]

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

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

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

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

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

instance Prelude.NFData CreateBotResponse where
  rnf :: CreateBotResponse -> ()
rnf CreateBotResponse' {Int
Maybe Bot
httpStatus :: Int
bot :: Maybe Bot
$sel:httpStatus:CreateBotResponse' :: CreateBotResponse -> Int
$sel:bot:CreateBotResponse' :: CreateBotResponse -> 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