module Network.AWS.CognitoIdentity.GetId
(
getId
, GetId
, giAccountId
, giLogins
, giIdentityPoolId
, getIdResponse
, GetIdResponse
, girsIdentityId
, girsResponseStatus
) where
import Network.AWS.CognitoIdentity.Types
import Network.AWS.CognitoIdentity.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetId = GetId'
{ _giAccountId :: !(Maybe Text)
, _giLogins :: !(Maybe (Map Text Text))
, _giIdentityPoolId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getId
:: Text
-> GetId
getId pIdentityPoolId_ =
GetId'
{ _giAccountId = Nothing
, _giLogins = Nothing
, _giIdentityPoolId = pIdentityPoolId_
}
giAccountId :: Lens' GetId (Maybe Text)
giAccountId = lens _giAccountId (\ s a -> s{_giAccountId = a});
giLogins :: Lens' GetId (HashMap Text Text)
giLogins = lens _giLogins (\ s a -> s{_giLogins = a}) . _Default . _Map;
giIdentityPoolId :: Lens' GetId Text
giIdentityPoolId = lens _giIdentityPoolId (\ s a -> s{_giIdentityPoolId = a});
instance AWSRequest GetId where
type Rs GetId = GetIdResponse
request = postJSON cognitoIdentity
response
= receiveJSON
(\ s h x ->
GetIdResponse' <$>
(x .?> "IdentityId") <*> (pure (fromEnum s)))
instance ToHeaders GetId where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityService.GetId" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetId where
toJSON GetId'{..}
= object
(catMaybes
[("AccountId" .=) <$> _giAccountId,
("Logins" .=) <$> _giLogins,
Just ("IdentityPoolId" .= _giIdentityPoolId)])
instance ToPath GetId where
toPath = const "/"
instance ToQuery GetId where
toQuery = const mempty
data GetIdResponse = GetIdResponse'
{ _girsIdentityId :: !(Maybe Text)
, _girsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getIdResponse
:: Int
-> GetIdResponse
getIdResponse pResponseStatus_ =
GetIdResponse'
{ _girsIdentityId = Nothing
, _girsResponseStatus = pResponseStatus_
}
girsIdentityId :: Lens' GetIdResponse (Maybe Text)
girsIdentityId = lens _girsIdentityId (\ s a -> s{_girsIdentityId = a});
girsResponseStatus :: Lens' GetIdResponse Int
girsResponseStatus = lens _girsResponseStatus (\ s a -> s{_girsResponseStatus = a});