{-# 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.GetIdentityPoolRoles
(
getIdentityPoolRoles
, GetIdentityPoolRoles
, giprIdentityPoolId
, getIdentityPoolRolesResponse
, GetIdentityPoolRolesResponse
, giprrsRoles
, giprrsIdentityPoolId
, giprrsRoleMappings
, giprrsResponseStatus
) 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
newtype GetIdentityPoolRoles = GetIdentityPoolRoles'
{ _giprIdentityPoolId :: Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getIdentityPoolRoles
:: Text
-> GetIdentityPoolRoles
getIdentityPoolRoles pIdentityPoolId_ =
GetIdentityPoolRoles' {_giprIdentityPoolId = pIdentityPoolId_}
giprIdentityPoolId :: Lens' GetIdentityPoolRoles Text
giprIdentityPoolId = lens _giprIdentityPoolId (\ s a -> s{_giprIdentityPoolId = a})
instance AWSRequest GetIdentityPoolRoles where
type Rs GetIdentityPoolRoles =
GetIdentityPoolRolesResponse
request = postJSON cognitoIdentity
response
= receiveJSON
(\ s h x ->
GetIdentityPoolRolesResponse' <$>
(x .?> "Roles" .!@ mempty) <*>
(x .?> "IdentityPoolId")
<*> (x .?> "RoleMappings" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable GetIdentityPoolRoles where
instance NFData GetIdentityPoolRoles where
instance ToHeaders GetIdentityPoolRoles where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityService.GetIdentityPoolRoles" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetIdentityPoolRoles where
toJSON GetIdentityPoolRoles'{..}
= object
(catMaybes
[Just ("IdentityPoolId" .= _giprIdentityPoolId)])
instance ToPath GetIdentityPoolRoles where
toPath = const "/"
instance ToQuery GetIdentityPoolRoles where
toQuery = const mempty
data GetIdentityPoolRolesResponse = GetIdentityPoolRolesResponse'
{ _giprrsRoles :: !(Maybe (Map Text Text))
, _giprrsIdentityPoolId :: !(Maybe Text)
, _giprrsRoleMappings :: !(Maybe (Map Text RoleMapping))
, _giprrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getIdentityPoolRolesResponse
:: Int
-> GetIdentityPoolRolesResponse
getIdentityPoolRolesResponse pResponseStatus_ =
GetIdentityPoolRolesResponse'
{ _giprrsRoles = Nothing
, _giprrsIdentityPoolId = Nothing
, _giprrsRoleMappings = Nothing
, _giprrsResponseStatus = pResponseStatus_
}
giprrsRoles :: Lens' GetIdentityPoolRolesResponse (HashMap Text Text)
giprrsRoles = lens _giprrsRoles (\ s a -> s{_giprrsRoles = a}) . _Default . _Map
giprrsIdentityPoolId :: Lens' GetIdentityPoolRolesResponse (Maybe Text)
giprrsIdentityPoolId = lens _giprrsIdentityPoolId (\ s a -> s{_giprrsIdentityPoolId = a})
giprrsRoleMappings :: Lens' GetIdentityPoolRolesResponse (HashMap Text RoleMapping)
giprrsRoleMappings = lens _giprrsRoleMappings (\ s a -> s{_giprrsRoleMappings = a}) . _Default . _Map
giprrsResponseStatus :: Lens' GetIdentityPoolRolesResponse Int
giprrsResponseStatus = lens _giprrsResponseStatus (\ s a -> s{_giprrsResponseStatus = a})
instance NFData GetIdentityPoolRolesResponse where