{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.DynamoDB.CreateGlobalTable
(
createGlobalTable
, CreateGlobalTable
, cgtGlobalTableName
, cgtReplicationGroup
, createGlobalTableResponse
, CreateGlobalTableResponse
, cgtrsGlobalTableDescription
, cgtrsResponseStatus
) where
import Network.AWS.DynamoDB.Types
import Network.AWS.DynamoDB.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateGlobalTable = CreateGlobalTable'
{ _cgtGlobalTableName :: !Text
, _cgtReplicationGroup :: ![Replica]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createGlobalTable
:: Text
-> CreateGlobalTable
createGlobalTable pGlobalTableName_ =
CreateGlobalTable'
{_cgtGlobalTableName = pGlobalTableName_, _cgtReplicationGroup = mempty}
cgtGlobalTableName :: Lens' CreateGlobalTable Text
cgtGlobalTableName = lens _cgtGlobalTableName (\ s a -> s{_cgtGlobalTableName = a})
cgtReplicationGroup :: Lens' CreateGlobalTable [Replica]
cgtReplicationGroup = lens _cgtReplicationGroup (\ s a -> s{_cgtReplicationGroup = a}) . _Coerce
instance AWSRequest CreateGlobalTable where
type Rs CreateGlobalTable = CreateGlobalTableResponse
request = postJSON dynamoDB
response
= receiveJSON
(\ s h x ->
CreateGlobalTableResponse' <$>
(x .?> "GlobalTableDescription") <*>
(pure (fromEnum s)))
instance Hashable CreateGlobalTable where
instance NFData CreateGlobalTable where
instance ToHeaders CreateGlobalTable where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("DynamoDB_20120810.CreateGlobalTable" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.0" :: ByteString)])
instance ToJSON CreateGlobalTable where
toJSON CreateGlobalTable'{..}
= object
(catMaybes
[Just ("GlobalTableName" .= _cgtGlobalTableName),
Just ("ReplicationGroup" .= _cgtReplicationGroup)])
instance ToPath CreateGlobalTable where
toPath = const "/"
instance ToQuery CreateGlobalTable where
toQuery = const mempty
data CreateGlobalTableResponse = CreateGlobalTableResponse'
{ _cgtrsGlobalTableDescription :: !(Maybe GlobalTableDescription)
, _cgtrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createGlobalTableResponse
:: Int
-> CreateGlobalTableResponse
createGlobalTableResponse pResponseStatus_ =
CreateGlobalTableResponse'
{ _cgtrsGlobalTableDescription = Nothing
, _cgtrsResponseStatus = pResponseStatus_
}
cgtrsGlobalTableDescription :: Lens' CreateGlobalTableResponse (Maybe GlobalTableDescription)
cgtrsGlobalTableDescription = lens _cgtrsGlobalTableDescription (\ s a -> s{_cgtrsGlobalTableDescription = a})
cgtrsResponseStatus :: Lens' CreateGlobalTableResponse Int
cgtrsResponseStatus = lens _cgtrsResponseStatus (\ s a -> s{_cgtrsResponseStatus = a})
instance NFData CreateGlobalTableResponse where