{-# 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.CognitoIdentityProvider.CreateIdentityProvider
(
createIdentityProvider
, CreateIdentityProvider
, cipIdpIdentifiers
, cipAttributeMapping
, cipUserPoolId
, cipProviderName
, cipProviderType
, cipProviderDetails
, createIdentityProviderResponse
, CreateIdentityProviderResponse
, ciprsResponseStatus
, ciprsIdentityProvider
) where
import Network.AWS.CognitoIdentityProvider.Types
import Network.AWS.CognitoIdentityProvider.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateIdentityProvider = CreateIdentityProvider'
{ _cipIdpIdentifiers :: !(Maybe [Text])
, _cipAttributeMapping :: !(Maybe (Map Text Text))
, _cipUserPoolId :: !Text
, _cipProviderName :: !Text
, _cipProviderType :: !IdentityProviderTypeType
, _cipProviderDetails :: !(Map Text Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createIdentityProvider
:: Text
-> Text
-> IdentityProviderTypeType
-> CreateIdentityProvider
createIdentityProvider pUserPoolId_ pProviderName_ pProviderType_ =
CreateIdentityProvider'
{ _cipIdpIdentifiers = Nothing
, _cipAttributeMapping = Nothing
, _cipUserPoolId = pUserPoolId_
, _cipProviderName = pProviderName_
, _cipProviderType = pProviderType_
, _cipProviderDetails = mempty
}
cipIdpIdentifiers :: Lens' CreateIdentityProvider [Text]
cipIdpIdentifiers = lens _cipIdpIdentifiers (\ s a -> s{_cipIdpIdentifiers = a}) . _Default . _Coerce
cipAttributeMapping :: Lens' CreateIdentityProvider (HashMap Text Text)
cipAttributeMapping = lens _cipAttributeMapping (\ s a -> s{_cipAttributeMapping = a}) . _Default . _Map
cipUserPoolId :: Lens' CreateIdentityProvider Text
cipUserPoolId = lens _cipUserPoolId (\ s a -> s{_cipUserPoolId = a})
cipProviderName :: Lens' CreateIdentityProvider Text
cipProviderName = lens _cipProviderName (\ s a -> s{_cipProviderName = a})
cipProviderType :: Lens' CreateIdentityProvider IdentityProviderTypeType
cipProviderType = lens _cipProviderType (\ s a -> s{_cipProviderType = a})
cipProviderDetails :: Lens' CreateIdentityProvider (HashMap Text Text)
cipProviderDetails = lens _cipProviderDetails (\ s a -> s{_cipProviderDetails = a}) . _Map
instance AWSRequest CreateIdentityProvider where
type Rs CreateIdentityProvider =
CreateIdentityProviderResponse
request = postJSON cognitoIdentityProvider
response
= receiveJSON
(\ s h x ->
CreateIdentityProviderResponse' <$>
(pure (fromEnum s)) <*> (x .:> "IdentityProvider"))
instance Hashable CreateIdentityProvider where
instance NFData CreateIdentityProvider where
instance ToHeaders CreateIdentityProvider where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityProviderService.CreateIdentityProvider"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateIdentityProvider where
toJSON CreateIdentityProvider'{..}
= object
(catMaybes
[("IdpIdentifiers" .=) <$> _cipIdpIdentifiers,
("AttributeMapping" .=) <$> _cipAttributeMapping,
Just ("UserPoolId" .= _cipUserPoolId),
Just ("ProviderName" .= _cipProviderName),
Just ("ProviderType" .= _cipProviderType),
Just ("ProviderDetails" .= _cipProviderDetails)])
instance ToPath CreateIdentityProvider where
toPath = const "/"
instance ToQuery CreateIdentityProvider where
toQuery = const mempty
data CreateIdentityProviderResponse = CreateIdentityProviderResponse'
{ _ciprsResponseStatus :: !Int
, _ciprsIdentityProvider :: !IdentityProviderType
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createIdentityProviderResponse
:: Int
-> IdentityProviderType
-> CreateIdentityProviderResponse
createIdentityProviderResponse pResponseStatus_ pIdentityProvider_ =
CreateIdentityProviderResponse'
{ _ciprsResponseStatus = pResponseStatus_
, _ciprsIdentityProvider = pIdentityProvider_
}
ciprsResponseStatus :: Lens' CreateIdentityProviderResponse Int
ciprsResponseStatus = lens _ciprsResponseStatus (\ s a -> s{_ciprsResponseStatus = a})
ciprsIdentityProvider :: Lens' CreateIdentityProviderResponse IdentityProviderType
ciprsIdentityProvider = lens _ciprsIdentityProvider (\ s a -> s{_ciprsIdentityProvider = a})
instance NFData CreateIdentityProviderResponse where