{-# 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.CreateAuthorizer
(
createAuthorizer
, CreateAuthorizer
, caAuthorizerURI
, caIdentityValidationExpression
, caProviderARNs
, caAuthorizerResultTtlInSeconds
, caAuthType
, caAuthorizerCredentials
, caRestAPIId
, caName
, caType
, caIdentitySource
, authorizer
, Authorizer
, aAuthorizerURI
, aIdentityValidationExpression
, aProviderARNs
, aName
, aId
, aAuthorizerResultTtlInSeconds
, aAuthType
, aType
, aIdentitySource
, aAuthorizerCredentials
) 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 CreateAuthorizer = CreateAuthorizer'
{ _caAuthorizerURI :: !(Maybe Text)
, _caIdentityValidationExpression :: !(Maybe Text)
, _caProviderARNs :: !(Maybe [Text])
, _caAuthorizerResultTtlInSeconds :: !(Maybe Int)
, _caAuthType :: !(Maybe Text)
, _caAuthorizerCredentials :: !(Maybe Text)
, _caRestAPIId :: !Text
, _caName :: !Text
, _caType :: !AuthorizerType
, _caIdentitySource :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createAuthorizer
:: Text
-> Text
-> AuthorizerType
-> Text
-> CreateAuthorizer
createAuthorizer pRestAPIId_ pName_ pType_ pIdentitySource_ =
CreateAuthorizer'
{ _caAuthorizerURI = Nothing
, _caIdentityValidationExpression = Nothing
, _caProviderARNs = Nothing
, _caAuthorizerResultTtlInSeconds = Nothing
, _caAuthType = Nothing
, _caAuthorizerCredentials = Nothing
, _caRestAPIId = pRestAPIId_
, _caName = pName_
, _caType = pType_
, _caIdentitySource = pIdentitySource_
}
caAuthorizerURI :: Lens' CreateAuthorizer (Maybe Text)
caAuthorizerURI = lens _caAuthorizerURI (\ s a -> s{_caAuthorizerURI = a});
caIdentityValidationExpression :: Lens' CreateAuthorizer (Maybe Text)
caIdentityValidationExpression = lens _caIdentityValidationExpression (\ s a -> s{_caIdentityValidationExpression = a});
caProviderARNs :: Lens' CreateAuthorizer [Text]
caProviderARNs = lens _caProviderARNs (\ s a -> s{_caProviderARNs = a}) . _Default . _Coerce;
caAuthorizerResultTtlInSeconds :: Lens' CreateAuthorizer (Maybe Int)
caAuthorizerResultTtlInSeconds = lens _caAuthorizerResultTtlInSeconds (\ s a -> s{_caAuthorizerResultTtlInSeconds = a});
caAuthType :: Lens' CreateAuthorizer (Maybe Text)
caAuthType = lens _caAuthType (\ s a -> s{_caAuthType = a});
caAuthorizerCredentials :: Lens' CreateAuthorizer (Maybe Text)
caAuthorizerCredentials = lens _caAuthorizerCredentials (\ s a -> s{_caAuthorizerCredentials = a});
caRestAPIId :: Lens' CreateAuthorizer Text
caRestAPIId = lens _caRestAPIId (\ s a -> s{_caRestAPIId = a});
caName :: Lens' CreateAuthorizer Text
caName = lens _caName (\ s a -> s{_caName = a});
caType :: Lens' CreateAuthorizer AuthorizerType
caType = lens _caType (\ s a -> s{_caType = a});
caIdentitySource :: Lens' CreateAuthorizer Text
caIdentitySource = lens _caIdentitySource (\ s a -> s{_caIdentitySource = a});
instance AWSRequest CreateAuthorizer where
type Rs CreateAuthorizer = Authorizer
request = postJSON apiGateway
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable CreateAuthorizer
instance NFData CreateAuthorizer
instance ToHeaders CreateAuthorizer where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToJSON CreateAuthorizer where
toJSON CreateAuthorizer'{..}
= object
(catMaybes
[("authorizerUri" .=) <$> _caAuthorizerURI,
("identityValidationExpression" .=) <$>
_caIdentityValidationExpression,
("providerARNs" .=) <$> _caProviderARNs,
("authorizerResultTtlInSeconds" .=) <$>
_caAuthorizerResultTtlInSeconds,
("authType" .=) <$> _caAuthType,
("authorizerCredentials" .=) <$>
_caAuthorizerCredentials,
Just ("name" .= _caName), Just ("type" .= _caType),
Just ("identitySource" .= _caIdentitySource)])
instance ToPath CreateAuthorizer where
toPath CreateAuthorizer'{..}
= mconcat
["/restapis/", toBS _caRestAPIId, "/authorizers"]
instance ToQuery CreateAuthorizer where
toQuery = const mempty