{-# 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.CognitoIdentity.GetCredentialsForIdentity
(
getCredentialsForIdentity
, GetCredentialsForIdentity
, gcfiCustomRoleARN
, gcfiLogins
, gcfiIdentityId
, getCredentialsForIdentityResponse
, GetCredentialsForIdentityResponse
, gcfirsCredentials
, gcfirsIdentityId
, gcfirsResponseStatus
) where
import Network.AWS.CognitoIdentity.Types
import Network.AWS.CognitoIdentity.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetCredentialsForIdentity = GetCredentialsForIdentity'
{ _gcfiCustomRoleARN :: !(Maybe Text)
, _gcfiLogins :: !(Maybe (Map Text Text))
, _gcfiIdentityId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getCredentialsForIdentity
:: Text
-> GetCredentialsForIdentity
getCredentialsForIdentity pIdentityId_ =
GetCredentialsForIdentity'
{ _gcfiCustomRoleARN = Nothing
, _gcfiLogins = Nothing
, _gcfiIdentityId = pIdentityId_
}
gcfiCustomRoleARN :: Lens' GetCredentialsForIdentity (Maybe Text)
gcfiCustomRoleARN = lens _gcfiCustomRoleARN (\ s a -> s{_gcfiCustomRoleARN = a});
gcfiLogins :: Lens' GetCredentialsForIdentity (HashMap Text Text)
gcfiLogins = lens _gcfiLogins (\ s a -> s{_gcfiLogins = a}) . _Default . _Map;
gcfiIdentityId :: Lens' GetCredentialsForIdentity Text
gcfiIdentityId = lens _gcfiIdentityId (\ s a -> s{_gcfiIdentityId = a});
instance AWSRequest GetCredentialsForIdentity where
type Rs GetCredentialsForIdentity =
GetCredentialsForIdentityResponse
request = postJSON cognitoIdentity
response
= receiveJSON
(\ s h x ->
GetCredentialsForIdentityResponse' <$>
(x .?> "Credentials") <*> (x .?> "IdentityId") <*>
(pure (fromEnum s)))
instance Hashable GetCredentialsForIdentity
instance NFData GetCredentialsForIdentity
instance ToHeaders GetCredentialsForIdentity where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityService.GetCredentialsForIdentity"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetCredentialsForIdentity where
toJSON GetCredentialsForIdentity'{..}
= object
(catMaybes
[("CustomRoleArn" .=) <$> _gcfiCustomRoleARN,
("Logins" .=) <$> _gcfiLogins,
Just ("IdentityId" .= _gcfiIdentityId)])
instance ToPath GetCredentialsForIdentity where
toPath = const "/"
instance ToQuery GetCredentialsForIdentity where
toQuery = const mempty
data GetCredentialsForIdentityResponse = GetCredentialsForIdentityResponse'
{ _gcfirsCredentials :: !(Maybe Credentials)
, _gcfirsIdentityId :: !(Maybe Text)
, _gcfirsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getCredentialsForIdentityResponse
:: Int
-> GetCredentialsForIdentityResponse
getCredentialsForIdentityResponse pResponseStatus_ =
GetCredentialsForIdentityResponse'
{ _gcfirsCredentials = Nothing
, _gcfirsIdentityId = Nothing
, _gcfirsResponseStatus = pResponseStatus_
}
gcfirsCredentials :: Lens' GetCredentialsForIdentityResponse (Maybe Credentials)
gcfirsCredentials = lens _gcfirsCredentials (\ s a -> s{_gcfirsCredentials = a});
gcfirsIdentityId :: Lens' GetCredentialsForIdentityResponse (Maybe Text)
gcfirsIdentityId = lens _gcfirsIdentityId (\ s a -> s{_gcfirsIdentityId = a});
gcfirsResponseStatus :: Lens' GetCredentialsForIdentityResponse Int
gcfirsResponseStatus = lens _gcfirsResponseStatus (\ s a -> s{_gcfirsResponseStatus = a});
instance NFData GetCredentialsForIdentityResponse