{-# 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 #-}
module Amazonka.Chime.CreateBot
(
CreateBot (..),
newCreateBot,
createBot_domain,
createBot_displayName,
createBot_accountId,
CreateBotResponse (..),
newCreateBotResponse,
createBotResponse_bot,
createBotResponse_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
data CreateBot = CreateBot'
{
CreateBot -> Maybe Text
domain :: Prelude.Maybe Prelude.Text,
CreateBot -> Sensitive Text
displayName :: Core.Sensitive Prelude.Text,
CreateBot -> Text
accountId :: Prelude.Text
}
deriving (CreateBot -> CreateBot -> Bool
(CreateBot -> CreateBot -> Bool)
-> (CreateBot -> CreateBot -> Bool) -> Eq CreateBot
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
(Int -> CreateBot -> ShowS)
-> (CreateBot -> String)
-> ([CreateBot] -> ShowS)
-> Show CreateBot
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. CreateBot -> Rep CreateBot x)
-> (forall x. Rep CreateBot x -> CreateBot) -> Generic CreateBot
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)
newCreateBot ::
Prelude.Text ->
Prelude.Text ->
CreateBot
newCreateBot :: Text -> Text -> CreateBot
newCreateBot Text
pDisplayName_ Text
pAccountId_ =
CreateBot' :: Maybe Text -> Sensitive Text -> Text -> CreateBot
CreateBot'
{ $sel:domain:CreateBot' :: Maybe Text
domain = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:displayName:CreateBot' :: Sensitive Text
displayName = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pDisplayName_,
$sel:accountId:CreateBot' :: Text
accountId = Text
pAccountId_
}
createBot_domain :: Lens.Lens' CreateBot (Prelude.Maybe Prelude.Text)
createBot_domain :: (Maybe Text -> f (Maybe Text)) -> CreateBot -> f CreateBot
createBot_domain = (CreateBot -> Maybe Text)
-> (CreateBot -> Maybe Text -> CreateBot)
-> Lens CreateBot CreateBot (Maybe Text) (Maybe Text)
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)
createBot_displayName :: Lens.Lens' CreateBot Prelude.Text
createBot_displayName :: (Text -> f Text) -> CreateBot -> f CreateBot
createBot_displayName = (CreateBot -> Sensitive Text)
-> (CreateBot -> Sensitive Text -> CreateBot)
-> Lens CreateBot CreateBot (Sensitive Text) (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
-> CreateBot -> f CreateBot)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateBot
-> f CreateBot
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
createBot_accountId :: Lens.Lens' CreateBot Prelude.Text
createBot_accountId :: (Text -> f Text) -> CreateBot -> f CreateBot
createBot_accountId = (CreateBot -> Text)
-> (CreateBot -> Text -> CreateBot)
-> Lens CreateBot CreateBot Text Text
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 :: CreateBot -> Request CreateBot
request = Service -> CreateBot -> Request CreateBot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBot)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateBot))
-> Logger
-> Service
-> Proxy CreateBot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBot)))
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 -> CreateBotResponse
CreateBotResponse'
(Maybe Bot -> Int -> CreateBotResponse)
-> Either String (Maybe Bot)
-> Either String (Int -> CreateBotResponse)
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 -> CreateBotResponse)
-> Either String Int -> Either String CreateBotResponse
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 CreateBot
instance Prelude.NFData CreateBot
instance Core.ToHeaders CreateBot where
toHeaders :: CreateBot -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateBot -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Domain" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
domain,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DisplayName" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
displayName)
]
)
instance Core.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
..} =
[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"]
instance Core.ToQuery CreateBot where
toQuery :: CreateBot -> QueryString
toQuery = QueryString -> CreateBot -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateBotResponse = CreateBotResponse'
{
CreateBotResponse -> Maybe Bot
bot :: Prelude.Maybe Bot,
CreateBotResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateBotResponse -> CreateBotResponse -> Bool
(CreateBotResponse -> CreateBotResponse -> Bool)
-> (CreateBotResponse -> CreateBotResponse -> Bool)
-> Eq CreateBotResponse
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
(Int -> CreateBotResponse -> ShowS)
-> (CreateBotResponse -> String)
-> ([CreateBotResponse] -> ShowS)
-> Show CreateBotResponse
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. CreateBotResponse -> Rep CreateBotResponse x)
-> (forall x. Rep CreateBotResponse x -> CreateBotResponse)
-> Generic CreateBotResponse
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)
newCreateBotResponse ::
Prelude.Int ->
CreateBotResponse
newCreateBotResponse :: Int -> CreateBotResponse
newCreateBotResponse Int
pHttpStatus_ =
CreateBotResponse' :: Maybe Bot -> Int -> CreateBotResponse
CreateBotResponse'
{ $sel:bot:CreateBotResponse' :: Maybe Bot
bot = Maybe Bot
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateBotResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createBotResponse_bot :: Lens.Lens' CreateBotResponse (Prelude.Maybe Bot)
createBotResponse_bot :: (Maybe Bot -> f (Maybe Bot))
-> CreateBotResponse -> f CreateBotResponse
createBotResponse_bot = (CreateBotResponse -> Maybe Bot)
-> (CreateBotResponse -> Maybe Bot -> CreateBotResponse)
-> Lens CreateBotResponse CreateBotResponse (Maybe Bot) (Maybe 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)
createBotResponse_httpStatus :: Lens.Lens' CreateBotResponse Prelude.Int
createBotResponse_httpStatus :: (Int -> f Int) -> CreateBotResponse -> f CreateBotResponse
createBotResponse_httpStatus = (CreateBotResponse -> Int)
-> (CreateBotResponse -> Int -> CreateBotResponse)
-> Lens CreateBotResponse CreateBotResponse Int Int
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