{-# 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.CreateRoom
(
CreateRoom (..),
newCreateRoom,
createRoom_clientRequestToken,
createRoom_accountId,
createRoom_name,
CreateRoomResponse (..),
newCreateRoomResponse,
createRoomResponse_room,
createRoomResponse_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 CreateRoom = CreateRoom'
{
CreateRoom -> Maybe (Sensitive Text)
clientRequestToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
CreateRoom -> Text
accountId :: Prelude.Text,
CreateRoom -> Sensitive Text
name :: Core.Sensitive Prelude.Text
}
deriving (CreateRoom -> CreateRoom -> Bool
(CreateRoom -> CreateRoom -> Bool)
-> (CreateRoom -> CreateRoom -> Bool) -> Eq CreateRoom
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRoom -> CreateRoom -> Bool
$c/= :: CreateRoom -> CreateRoom -> Bool
== :: CreateRoom -> CreateRoom -> Bool
$c== :: CreateRoom -> CreateRoom -> Bool
Prelude.Eq, Int -> CreateRoom -> ShowS
[CreateRoom] -> ShowS
CreateRoom -> String
(Int -> CreateRoom -> ShowS)
-> (CreateRoom -> String)
-> ([CreateRoom] -> ShowS)
-> Show CreateRoom
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRoom] -> ShowS
$cshowList :: [CreateRoom] -> ShowS
show :: CreateRoom -> String
$cshow :: CreateRoom -> String
showsPrec :: Int -> CreateRoom -> ShowS
$cshowsPrec :: Int -> CreateRoom -> ShowS
Prelude.Show, (forall x. CreateRoom -> Rep CreateRoom x)
-> (forall x. Rep CreateRoom x -> CreateRoom) -> Generic CreateRoom
forall x. Rep CreateRoom x -> CreateRoom
forall x. CreateRoom -> Rep CreateRoom x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRoom x -> CreateRoom
$cfrom :: forall x. CreateRoom -> Rep CreateRoom x
Prelude.Generic)
newCreateRoom ::
Prelude.Text ->
Prelude.Text ->
CreateRoom
newCreateRoom :: Text -> Text -> CreateRoom
newCreateRoom Text
pAccountId_ Text
pName_ =
CreateRoom' :: Maybe (Sensitive Text) -> Text -> Sensitive Text -> CreateRoom
CreateRoom'
{ $sel:clientRequestToken:CreateRoom' :: Maybe (Sensitive Text)
clientRequestToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
$sel:accountId:CreateRoom' :: Text
accountId = Text
pAccountId_,
$sel:name:CreateRoom' :: Sensitive Text
name = 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
pName_
}
createRoom_clientRequestToken :: Lens.Lens' CreateRoom (Prelude.Maybe Prelude.Text)
createRoom_clientRequestToken :: (Maybe Text -> f (Maybe Text)) -> CreateRoom -> f CreateRoom
createRoom_clientRequestToken = (CreateRoom -> Maybe (Sensitive Text))
-> (CreateRoom -> Maybe (Sensitive Text) -> CreateRoom)
-> Lens
CreateRoom
CreateRoom
(Maybe (Sensitive Text))
(Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoom' {Maybe (Sensitive Text)
clientRequestToken :: Maybe (Sensitive Text)
$sel:clientRequestToken:CreateRoom' :: CreateRoom -> Maybe (Sensitive Text)
clientRequestToken} -> Maybe (Sensitive Text)
clientRequestToken) (\s :: CreateRoom
s@CreateRoom' {} Maybe (Sensitive Text)
a -> CreateRoom
s {$sel:clientRequestToken:CreateRoom' :: Maybe (Sensitive Text)
clientRequestToken = Maybe (Sensitive Text)
a} :: CreateRoom) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> CreateRoom -> f CreateRoom)
-> ((Maybe Text -> f (Maybe Text))
-> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> CreateRoom
-> f CreateRoom
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
(Maybe (Sensitive Text))
(Maybe (Sensitive Text))
(Maybe Text)
(Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive
createRoom_accountId :: Lens.Lens' CreateRoom Prelude.Text
createRoom_accountId :: (Text -> f Text) -> CreateRoom -> f CreateRoom
createRoom_accountId = (CreateRoom -> Text)
-> (CreateRoom -> Text -> CreateRoom)
-> Lens CreateRoom CreateRoom Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoom' {Text
accountId :: Text
$sel:accountId:CreateRoom' :: CreateRoom -> Text
accountId} -> Text
accountId) (\s :: CreateRoom
s@CreateRoom' {} Text
a -> CreateRoom
s {$sel:accountId:CreateRoom' :: Text
accountId = Text
a} :: CreateRoom)
createRoom_name :: Lens.Lens' CreateRoom Prelude.Text
createRoom_name :: (Text -> f Text) -> CreateRoom -> f CreateRoom
createRoom_name = (CreateRoom -> Sensitive Text)
-> (CreateRoom -> Sensitive Text -> CreateRoom)
-> Lens CreateRoom CreateRoom (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoom' {Sensitive Text
name :: Sensitive Text
$sel:name:CreateRoom' :: CreateRoom -> Sensitive Text
name} -> Sensitive Text
name) (\s :: CreateRoom
s@CreateRoom' {} Sensitive Text
a -> CreateRoom
s {$sel:name:CreateRoom' :: Sensitive Text
name = Sensitive Text
a} :: CreateRoom) ((Sensitive Text -> f (Sensitive Text))
-> CreateRoom -> f CreateRoom)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateRoom
-> f CreateRoom
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
instance Core.AWSRequest CreateRoom where
type AWSResponse CreateRoom = CreateRoomResponse
request :: CreateRoom -> Request CreateRoom
request = Service -> CreateRoom -> Request CreateRoom
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateRoom
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRoom)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateRoom))
-> Logger
-> Service
-> Proxy CreateRoom
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRoom)))
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 Room -> Int -> CreateRoomResponse
CreateRoomResponse'
(Maybe Room -> Int -> CreateRoomResponse)
-> Either String (Maybe Room)
-> Either String (Int -> CreateRoomResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Room)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Room")
Either String (Int -> CreateRoomResponse)
-> Either String Int -> Either String CreateRoomResponse
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 CreateRoom
instance Prelude.NFData CreateRoom
instance Core.ToHeaders CreateRoom where
toHeaders :: CreateRoom -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateRoom -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateRoom where
toJSON :: CreateRoom -> Value
toJSON CreateRoom' {Maybe (Sensitive Text)
Text
Sensitive Text
name :: Sensitive Text
accountId :: Text
clientRequestToken :: Maybe (Sensitive Text)
$sel:name:CreateRoom' :: CreateRoom -> Sensitive Text
$sel:accountId:CreateRoom' :: CreateRoom -> Text
$sel:clientRequestToken:CreateRoom' :: CreateRoom -> Maybe (Sensitive Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ClientRequestToken" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
clientRequestToken,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
name)
]
)
instance Core.ToPath CreateRoom where
toPath :: CreateRoom -> ByteString
toPath CreateRoom' {Maybe (Sensitive Text)
Text
Sensitive Text
name :: Sensitive Text
accountId :: Text
clientRequestToken :: Maybe (Sensitive Text)
$sel:name:CreateRoom' :: CreateRoom -> Sensitive Text
$sel:accountId:CreateRoom' :: CreateRoom -> Text
$sel:clientRequestToken:CreateRoom' :: CreateRoom -> Maybe (Sensitive 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
"/rooms"]
instance Core.ToQuery CreateRoom where
toQuery :: CreateRoom -> QueryString
toQuery = QueryString -> CreateRoom -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateRoomResponse = CreateRoomResponse'
{
CreateRoomResponse -> Maybe Room
room :: Prelude.Maybe Room,
CreateRoomResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateRoomResponse -> CreateRoomResponse -> Bool
(CreateRoomResponse -> CreateRoomResponse -> Bool)
-> (CreateRoomResponse -> CreateRoomResponse -> Bool)
-> Eq CreateRoomResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRoomResponse -> CreateRoomResponse -> Bool
$c/= :: CreateRoomResponse -> CreateRoomResponse -> Bool
== :: CreateRoomResponse -> CreateRoomResponse -> Bool
$c== :: CreateRoomResponse -> CreateRoomResponse -> Bool
Prelude.Eq, Int -> CreateRoomResponse -> ShowS
[CreateRoomResponse] -> ShowS
CreateRoomResponse -> String
(Int -> CreateRoomResponse -> ShowS)
-> (CreateRoomResponse -> String)
-> ([CreateRoomResponse] -> ShowS)
-> Show CreateRoomResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRoomResponse] -> ShowS
$cshowList :: [CreateRoomResponse] -> ShowS
show :: CreateRoomResponse -> String
$cshow :: CreateRoomResponse -> String
showsPrec :: Int -> CreateRoomResponse -> ShowS
$cshowsPrec :: Int -> CreateRoomResponse -> ShowS
Prelude.Show, (forall x. CreateRoomResponse -> Rep CreateRoomResponse x)
-> (forall x. Rep CreateRoomResponse x -> CreateRoomResponse)
-> Generic CreateRoomResponse
forall x. Rep CreateRoomResponse x -> CreateRoomResponse
forall x. CreateRoomResponse -> Rep CreateRoomResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRoomResponse x -> CreateRoomResponse
$cfrom :: forall x. CreateRoomResponse -> Rep CreateRoomResponse x
Prelude.Generic)
newCreateRoomResponse ::
Prelude.Int ->
CreateRoomResponse
newCreateRoomResponse :: Int -> CreateRoomResponse
newCreateRoomResponse Int
pHttpStatus_ =
CreateRoomResponse' :: Maybe Room -> Int -> CreateRoomResponse
CreateRoomResponse'
{ $sel:room:CreateRoomResponse' :: Maybe Room
room = Maybe Room
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateRoomResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createRoomResponse_room :: Lens.Lens' CreateRoomResponse (Prelude.Maybe Room)
createRoomResponse_room :: (Maybe Room -> f (Maybe Room))
-> CreateRoomResponse -> f CreateRoomResponse
createRoomResponse_room = (CreateRoomResponse -> Maybe Room)
-> (CreateRoomResponse -> Maybe Room -> CreateRoomResponse)
-> Lens
CreateRoomResponse CreateRoomResponse (Maybe Room) (Maybe Room)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoomResponse' {Maybe Room
room :: Maybe Room
$sel:room:CreateRoomResponse' :: CreateRoomResponse -> Maybe Room
room} -> Maybe Room
room) (\s :: CreateRoomResponse
s@CreateRoomResponse' {} Maybe Room
a -> CreateRoomResponse
s {$sel:room:CreateRoomResponse' :: Maybe Room
room = Maybe Room
a} :: CreateRoomResponse)
createRoomResponse_httpStatus :: Lens.Lens' CreateRoomResponse Prelude.Int
createRoomResponse_httpStatus :: (Int -> f Int) -> CreateRoomResponse -> f CreateRoomResponse
createRoomResponse_httpStatus = (CreateRoomResponse -> Int)
-> (CreateRoomResponse -> Int -> CreateRoomResponse)
-> Lens CreateRoomResponse CreateRoomResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoomResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRoomResponse' :: CreateRoomResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRoomResponse
s@CreateRoomResponse' {} Int
a -> CreateRoomResponse
s {$sel:httpStatus:CreateRoomResponse' :: Int
httpStatus = Int
a} :: CreateRoomResponse)
instance Prelude.NFData CreateRoomResponse