{-# 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.AppSync.CreateAPIKey
(
createAPIKey
, CreateAPIKey
, cakExpires
, cakDescription
, cakApiId
, createAPIKeyResponse
, CreateAPIKeyResponse
, cakrsApiKey
, cakrsResponseStatus
) where
import Network.AWS.AppSync.Types
import Network.AWS.AppSync.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateAPIKey = CreateAPIKey'
{ _cakExpires :: !(Maybe Integer)
, _cakDescription :: !(Maybe Text)
, _cakApiId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createAPIKey
:: Text
-> CreateAPIKey
createAPIKey pApiId_ =
CreateAPIKey'
{_cakExpires = Nothing, _cakDescription = Nothing, _cakApiId = pApiId_}
cakExpires :: Lens' CreateAPIKey (Maybe Integer)
cakExpires = lens _cakExpires (\ s a -> s{_cakExpires = a})
cakDescription :: Lens' CreateAPIKey (Maybe Text)
cakDescription = lens _cakDescription (\ s a -> s{_cakDescription = a})
cakApiId :: Lens' CreateAPIKey Text
cakApiId = lens _cakApiId (\ s a -> s{_cakApiId = a})
instance AWSRequest CreateAPIKey where
type Rs CreateAPIKey = CreateAPIKeyResponse
request = postJSON appSync
response
= receiveJSON
(\ s h x ->
CreateAPIKeyResponse' <$>
(x .?> "apiKey") <*> (pure (fromEnum s)))
instance Hashable CreateAPIKey where
instance NFData CreateAPIKey where
instance ToHeaders CreateAPIKey where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateAPIKey where
toJSON CreateAPIKey'{..}
= object
(catMaybes
[("expires" .=) <$> _cakExpires,
("description" .=) <$> _cakDescription])
instance ToPath CreateAPIKey where
toPath CreateAPIKey'{..}
= mconcat ["/v1/apis/", toBS _cakApiId, "/apikeys"]
instance ToQuery CreateAPIKey where
toQuery = const mempty
data CreateAPIKeyResponse = CreateAPIKeyResponse'
{ _cakrsApiKey :: !(Maybe APIKey)
, _cakrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createAPIKeyResponse
:: Int
-> CreateAPIKeyResponse
createAPIKeyResponse pResponseStatus_ =
CreateAPIKeyResponse'
{_cakrsApiKey = Nothing, _cakrsResponseStatus = pResponseStatus_}
cakrsApiKey :: Lens' CreateAPIKeyResponse (Maybe APIKey)
cakrsApiKey = lens _cakrsApiKey (\ s a -> s{_cakrsApiKey = a})
cakrsResponseStatus :: Lens' CreateAPIKeyResponse Int
cakrsResponseStatus = lens _cakrsResponseStatus (\ s a -> s{_cakrsResponseStatus = a})
instance NFData CreateAPIKeyResponse where