{-# 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.DynamoDB.CreateGlobalTable
(
CreateGlobalTable (..),
newCreateGlobalTable,
createGlobalTable_globalTableName,
createGlobalTable_replicationGroup,
CreateGlobalTableResponse (..),
newCreateGlobalTableResponse,
createGlobalTableResponse_globalTableDescription,
createGlobalTableResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types
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 CreateGlobalTable = CreateGlobalTable'
{
CreateGlobalTable -> Text
globalTableName :: Prelude.Text,
CreateGlobalTable -> [Replica]
replicationGroup :: [Replica]
}
deriving (CreateGlobalTable -> CreateGlobalTable -> Bool
(CreateGlobalTable -> CreateGlobalTable -> Bool)
-> (CreateGlobalTable -> CreateGlobalTable -> Bool)
-> Eq CreateGlobalTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGlobalTable -> CreateGlobalTable -> Bool
$c/= :: CreateGlobalTable -> CreateGlobalTable -> Bool
== :: CreateGlobalTable -> CreateGlobalTable -> Bool
$c== :: CreateGlobalTable -> CreateGlobalTable -> Bool
Prelude.Eq, ReadPrec [CreateGlobalTable]
ReadPrec CreateGlobalTable
Int -> ReadS CreateGlobalTable
ReadS [CreateGlobalTable]
(Int -> ReadS CreateGlobalTable)
-> ReadS [CreateGlobalTable]
-> ReadPrec CreateGlobalTable
-> ReadPrec [CreateGlobalTable]
-> Read CreateGlobalTable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGlobalTable]
$creadListPrec :: ReadPrec [CreateGlobalTable]
readPrec :: ReadPrec CreateGlobalTable
$creadPrec :: ReadPrec CreateGlobalTable
readList :: ReadS [CreateGlobalTable]
$creadList :: ReadS [CreateGlobalTable]
readsPrec :: Int -> ReadS CreateGlobalTable
$creadsPrec :: Int -> ReadS CreateGlobalTable
Prelude.Read, Int -> CreateGlobalTable -> ShowS
[CreateGlobalTable] -> ShowS
CreateGlobalTable -> String
(Int -> CreateGlobalTable -> ShowS)
-> (CreateGlobalTable -> String)
-> ([CreateGlobalTable] -> ShowS)
-> Show CreateGlobalTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGlobalTable] -> ShowS
$cshowList :: [CreateGlobalTable] -> ShowS
show :: CreateGlobalTable -> String
$cshow :: CreateGlobalTable -> String
showsPrec :: Int -> CreateGlobalTable -> ShowS
$cshowsPrec :: Int -> CreateGlobalTable -> ShowS
Prelude.Show, (forall x. CreateGlobalTable -> Rep CreateGlobalTable x)
-> (forall x. Rep CreateGlobalTable x -> CreateGlobalTable)
-> Generic CreateGlobalTable
forall x. Rep CreateGlobalTable x -> CreateGlobalTable
forall x. CreateGlobalTable -> Rep CreateGlobalTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGlobalTable x -> CreateGlobalTable
$cfrom :: forall x. CreateGlobalTable -> Rep CreateGlobalTable x
Prelude.Generic)
newCreateGlobalTable ::
Prelude.Text ->
CreateGlobalTable
newCreateGlobalTable :: Text -> CreateGlobalTable
newCreateGlobalTable Text
pGlobalTableName_ =
CreateGlobalTable' :: Text -> [Replica] -> CreateGlobalTable
CreateGlobalTable'
{ $sel:globalTableName:CreateGlobalTable' :: Text
globalTableName =
Text
pGlobalTableName_,
$sel:replicationGroup:CreateGlobalTable' :: [Replica]
replicationGroup = [Replica]
forall a. Monoid a => a
Prelude.mempty
}
createGlobalTable_globalTableName :: Lens.Lens' CreateGlobalTable Prelude.Text
createGlobalTable_globalTableName :: (Text -> f Text) -> CreateGlobalTable -> f CreateGlobalTable
createGlobalTable_globalTableName = (CreateGlobalTable -> Text)
-> (CreateGlobalTable -> Text -> CreateGlobalTable)
-> Lens CreateGlobalTable CreateGlobalTable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalTable' {Text
globalTableName :: Text
$sel:globalTableName:CreateGlobalTable' :: CreateGlobalTable -> Text
globalTableName} -> Text
globalTableName) (\s :: CreateGlobalTable
s@CreateGlobalTable' {} Text
a -> CreateGlobalTable
s {$sel:globalTableName:CreateGlobalTable' :: Text
globalTableName = Text
a} :: CreateGlobalTable)
createGlobalTable_replicationGroup :: Lens.Lens' CreateGlobalTable [Replica]
createGlobalTable_replicationGroup :: ([Replica] -> f [Replica])
-> CreateGlobalTable -> f CreateGlobalTable
createGlobalTable_replicationGroup = (CreateGlobalTable -> [Replica])
-> (CreateGlobalTable -> [Replica] -> CreateGlobalTable)
-> Lens CreateGlobalTable CreateGlobalTable [Replica] [Replica]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalTable' {[Replica]
replicationGroup :: [Replica]
$sel:replicationGroup:CreateGlobalTable' :: CreateGlobalTable -> [Replica]
replicationGroup} -> [Replica]
replicationGroup) (\s :: CreateGlobalTable
s@CreateGlobalTable' {} [Replica]
a -> CreateGlobalTable
s {$sel:replicationGroup:CreateGlobalTable' :: [Replica]
replicationGroup = [Replica]
a} :: CreateGlobalTable) (([Replica] -> f [Replica])
-> CreateGlobalTable -> f CreateGlobalTable)
-> (([Replica] -> f [Replica]) -> [Replica] -> f [Replica])
-> ([Replica] -> f [Replica])
-> CreateGlobalTable
-> f CreateGlobalTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Replica] -> f [Replica]) -> [Replica] -> f [Replica]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateGlobalTable where
type
AWSResponse CreateGlobalTable =
CreateGlobalTableResponse
request :: CreateGlobalTable -> Request CreateGlobalTable
request = Service -> CreateGlobalTable -> Request CreateGlobalTable
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateGlobalTable
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateGlobalTable)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateGlobalTable))
-> Logger
-> Service
-> Proxy CreateGlobalTable
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateGlobalTable)))
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 GlobalTableDescription -> Int -> CreateGlobalTableResponse
CreateGlobalTableResponse'
(Maybe GlobalTableDescription -> Int -> CreateGlobalTableResponse)
-> Either String (Maybe GlobalTableDescription)
-> Either String (Int -> CreateGlobalTableResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GlobalTableDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GlobalTableDescription")
Either String (Int -> CreateGlobalTableResponse)
-> Either String Int -> Either String CreateGlobalTableResponse
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 CreateGlobalTable
instance Prelude.NFData CreateGlobalTable
instance Core.ToHeaders CreateGlobalTable where
toHeaders :: CreateGlobalTable -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateGlobalTable -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DynamoDB_20120810.CreateGlobalTable" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateGlobalTable where
toJSON :: CreateGlobalTable -> Value
toJSON CreateGlobalTable' {[Replica]
Text
replicationGroup :: [Replica]
globalTableName :: Text
$sel:replicationGroup:CreateGlobalTable' :: CreateGlobalTable -> [Replica]
$sel:globalTableName:CreateGlobalTable' :: CreateGlobalTable -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"GlobalTableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
globalTableName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ReplicationGroup" Text -> [Replica] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Replica]
replicationGroup)
]
)
instance Core.ToPath CreateGlobalTable where
toPath :: CreateGlobalTable -> ByteString
toPath = ByteString -> CreateGlobalTable -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateGlobalTable where
toQuery :: CreateGlobalTable -> QueryString
toQuery = QueryString -> CreateGlobalTable -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateGlobalTableResponse = CreateGlobalTableResponse'
{
CreateGlobalTableResponse -> Maybe GlobalTableDescription
globalTableDescription :: Prelude.Maybe GlobalTableDescription,
CreateGlobalTableResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool
(CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool)
-> (CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool)
-> Eq CreateGlobalTableResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool
$c/= :: CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool
== :: CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool
$c== :: CreateGlobalTableResponse -> CreateGlobalTableResponse -> Bool
Prelude.Eq, ReadPrec [CreateGlobalTableResponse]
ReadPrec CreateGlobalTableResponse
Int -> ReadS CreateGlobalTableResponse
ReadS [CreateGlobalTableResponse]
(Int -> ReadS CreateGlobalTableResponse)
-> ReadS [CreateGlobalTableResponse]
-> ReadPrec CreateGlobalTableResponse
-> ReadPrec [CreateGlobalTableResponse]
-> Read CreateGlobalTableResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGlobalTableResponse]
$creadListPrec :: ReadPrec [CreateGlobalTableResponse]
readPrec :: ReadPrec CreateGlobalTableResponse
$creadPrec :: ReadPrec CreateGlobalTableResponse
readList :: ReadS [CreateGlobalTableResponse]
$creadList :: ReadS [CreateGlobalTableResponse]
readsPrec :: Int -> ReadS CreateGlobalTableResponse
$creadsPrec :: Int -> ReadS CreateGlobalTableResponse
Prelude.Read, Int -> CreateGlobalTableResponse -> ShowS
[CreateGlobalTableResponse] -> ShowS
CreateGlobalTableResponse -> String
(Int -> CreateGlobalTableResponse -> ShowS)
-> (CreateGlobalTableResponse -> String)
-> ([CreateGlobalTableResponse] -> ShowS)
-> Show CreateGlobalTableResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGlobalTableResponse] -> ShowS
$cshowList :: [CreateGlobalTableResponse] -> ShowS
show :: CreateGlobalTableResponse -> String
$cshow :: CreateGlobalTableResponse -> String
showsPrec :: Int -> CreateGlobalTableResponse -> ShowS
$cshowsPrec :: Int -> CreateGlobalTableResponse -> ShowS
Prelude.Show, (forall x.
CreateGlobalTableResponse -> Rep CreateGlobalTableResponse x)
-> (forall x.
Rep CreateGlobalTableResponse x -> CreateGlobalTableResponse)
-> Generic CreateGlobalTableResponse
forall x.
Rep CreateGlobalTableResponse x -> CreateGlobalTableResponse
forall x.
CreateGlobalTableResponse -> Rep CreateGlobalTableResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateGlobalTableResponse x -> CreateGlobalTableResponse
$cfrom :: forall x.
CreateGlobalTableResponse -> Rep CreateGlobalTableResponse x
Prelude.Generic)
newCreateGlobalTableResponse ::
Prelude.Int ->
CreateGlobalTableResponse
newCreateGlobalTableResponse :: Int -> CreateGlobalTableResponse
newCreateGlobalTableResponse Int
pHttpStatus_ =
CreateGlobalTableResponse' :: Maybe GlobalTableDescription -> Int -> CreateGlobalTableResponse
CreateGlobalTableResponse'
{ $sel:globalTableDescription:CreateGlobalTableResponse' :: Maybe GlobalTableDescription
globalTableDescription =
Maybe GlobalTableDescription
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateGlobalTableResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createGlobalTableResponse_globalTableDescription :: Lens.Lens' CreateGlobalTableResponse (Prelude.Maybe GlobalTableDescription)
createGlobalTableResponse_globalTableDescription :: (Maybe GlobalTableDescription -> f (Maybe GlobalTableDescription))
-> CreateGlobalTableResponse -> f CreateGlobalTableResponse
createGlobalTableResponse_globalTableDescription = (CreateGlobalTableResponse -> Maybe GlobalTableDescription)
-> (CreateGlobalTableResponse
-> Maybe GlobalTableDescription -> CreateGlobalTableResponse)
-> Lens
CreateGlobalTableResponse
CreateGlobalTableResponse
(Maybe GlobalTableDescription)
(Maybe GlobalTableDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalTableResponse' {Maybe GlobalTableDescription
globalTableDescription :: Maybe GlobalTableDescription
$sel:globalTableDescription:CreateGlobalTableResponse' :: CreateGlobalTableResponse -> Maybe GlobalTableDescription
globalTableDescription} -> Maybe GlobalTableDescription
globalTableDescription) (\s :: CreateGlobalTableResponse
s@CreateGlobalTableResponse' {} Maybe GlobalTableDescription
a -> CreateGlobalTableResponse
s {$sel:globalTableDescription:CreateGlobalTableResponse' :: Maybe GlobalTableDescription
globalTableDescription = Maybe GlobalTableDescription
a} :: CreateGlobalTableResponse)
createGlobalTableResponse_httpStatus :: Lens.Lens' CreateGlobalTableResponse Prelude.Int
createGlobalTableResponse_httpStatus :: (Int -> f Int)
-> CreateGlobalTableResponse -> f CreateGlobalTableResponse
createGlobalTableResponse_httpStatus = (CreateGlobalTableResponse -> Int)
-> (CreateGlobalTableResponse -> Int -> CreateGlobalTableResponse)
-> Lens CreateGlobalTableResponse CreateGlobalTableResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalTableResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateGlobalTableResponse' :: CreateGlobalTableResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateGlobalTableResponse
s@CreateGlobalTableResponse' {} Int
a -> CreateGlobalTableResponse
s {$sel:httpStatus:CreateGlobalTableResponse' :: Int
httpStatus = Int
a} :: CreateGlobalTableResponse)
instance Prelude.NFData CreateGlobalTableResponse