{-# 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.APIGateway.CreateAPIKey
(
createAPIKey
, CreateAPIKey
, cakEnabled
, cakValue
, cakGenerateDistinctId
, cakName
, cakStageKeys
, cakDescription
, apiKey
, APIKey
, akEnabled
, akValue
, akCreatedDate
, akName
, akId
, akStageKeys
, akLastUpdatedDate
, akDescription
) where
import Network.AWS.APIGateway.Types
import Network.AWS.APIGateway.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateAPIKey = CreateAPIKey'
{ _cakEnabled :: !(Maybe Bool)
, _cakValue :: !(Maybe Text)
, _cakGenerateDistinctId :: !(Maybe Bool)
, _cakName :: !(Maybe Text)
, _cakStageKeys :: !(Maybe [StageKey])
, _cakDescription :: !(Maybe Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createAPIKey
:: CreateAPIKey
createAPIKey =
CreateAPIKey'
{ _cakEnabled = Nothing
, _cakValue = Nothing
, _cakGenerateDistinctId = Nothing
, _cakName = Nothing
, _cakStageKeys = Nothing
, _cakDescription = Nothing
}
cakEnabled :: Lens' CreateAPIKey (Maybe Bool)
cakEnabled = lens _cakEnabled (\ s a -> s{_cakEnabled = a});
cakValue :: Lens' CreateAPIKey (Maybe Text)
cakValue = lens _cakValue (\ s a -> s{_cakValue = a});
cakGenerateDistinctId :: Lens' CreateAPIKey (Maybe Bool)
cakGenerateDistinctId = lens _cakGenerateDistinctId (\ s a -> s{_cakGenerateDistinctId = a});
cakName :: Lens' CreateAPIKey (Maybe Text)
cakName = lens _cakName (\ s a -> s{_cakName = a});
cakStageKeys :: Lens' CreateAPIKey [StageKey]
cakStageKeys = lens _cakStageKeys (\ s a -> s{_cakStageKeys = a}) . _Default . _Coerce;
cakDescription :: Lens' CreateAPIKey (Maybe Text)
cakDescription = lens _cakDescription (\ s a -> s{_cakDescription = a});
instance AWSRequest CreateAPIKey where
type Rs CreateAPIKey = APIKey
request = postJSON apiGateway
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable CreateAPIKey
instance NFData CreateAPIKey
instance ToHeaders CreateAPIKey where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToJSON CreateAPIKey where
toJSON CreateAPIKey'{..}
= object
(catMaybes
[("enabled" .=) <$> _cakEnabled,
("value" .=) <$> _cakValue,
("generateDistinctId" .=) <$> _cakGenerateDistinctId,
("name" .=) <$> _cakName,
("stageKeys" .=) <$> _cakStageKeys,
("description" .=) <$> _cakDescription])
instance ToPath CreateAPIKey where
toPath = const "/apikeys"
instance ToQuery CreateAPIKey where
toQuery = const mempty