{-# 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.AdminListGroupsForUser
(
adminListGroupsForUser
, AdminListGroupsForUser
, algfuNextToken
, algfuLimit
, algfuUsername
, algfuUserPoolId
, adminListGroupsForUserResponse
, AdminListGroupsForUserResponse
, algfursGroups
, algfursNextToken
, algfursResponseStatus
) 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 AdminListGroupsForUser = AdminListGroupsForUser'
{ _algfuNextToken :: !(Maybe Text)
, _algfuLimit :: !(Maybe Nat)
, _algfuUsername :: !(Sensitive Text)
, _algfuUserPoolId :: !Text
} deriving (Eq, Show, Data, Typeable, Generic)
adminListGroupsForUser
:: Text
-> Text
-> AdminListGroupsForUser
adminListGroupsForUser pUsername_ pUserPoolId_ =
AdminListGroupsForUser'
{ _algfuNextToken = Nothing
, _algfuLimit = Nothing
, _algfuUsername = _Sensitive # pUsername_
, _algfuUserPoolId = pUserPoolId_
}
algfuNextToken :: Lens' AdminListGroupsForUser (Maybe Text)
algfuNextToken = lens _algfuNextToken (\ s a -> s{_algfuNextToken = a})
algfuLimit :: Lens' AdminListGroupsForUser (Maybe Natural)
algfuLimit = lens _algfuLimit (\ s a -> s{_algfuLimit = a}) . mapping _Nat
algfuUsername :: Lens' AdminListGroupsForUser Text
algfuUsername = lens _algfuUsername (\ s a -> s{_algfuUsername = a}) . _Sensitive
algfuUserPoolId :: Lens' AdminListGroupsForUser Text
algfuUserPoolId = lens _algfuUserPoolId (\ s a -> s{_algfuUserPoolId = a})
instance AWSRequest AdminListGroupsForUser where
type Rs AdminListGroupsForUser =
AdminListGroupsForUserResponse
request = postJSON cognitoIdentityProvider
response
= receiveJSON
(\ s h x ->
AdminListGroupsForUserResponse' <$>
(x .?> "Groups" .!@ mempty) <*> (x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable AdminListGroupsForUser where
instance NFData AdminListGroupsForUser where
instance ToHeaders AdminListGroupsForUser where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityProviderService.AdminListGroupsForUser"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON AdminListGroupsForUser where
toJSON AdminListGroupsForUser'{..}
= object
(catMaybes
[("NextToken" .=) <$> _algfuNextToken,
("Limit" .=) <$> _algfuLimit,
Just ("Username" .= _algfuUsername),
Just ("UserPoolId" .= _algfuUserPoolId)])
instance ToPath AdminListGroupsForUser where
toPath = const "/"
instance ToQuery AdminListGroupsForUser where
toQuery = const mempty
data AdminListGroupsForUserResponse = AdminListGroupsForUserResponse'
{ _algfursGroups :: !(Maybe [GroupType])
, _algfursNextToken :: !(Maybe Text)
, _algfursResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
adminListGroupsForUserResponse
:: Int
-> AdminListGroupsForUserResponse
adminListGroupsForUserResponse pResponseStatus_ =
AdminListGroupsForUserResponse'
{ _algfursGroups = Nothing
, _algfursNextToken = Nothing
, _algfursResponseStatus = pResponseStatus_
}
algfursGroups :: Lens' AdminListGroupsForUserResponse [GroupType]
algfursGroups = lens _algfursGroups (\ s a -> s{_algfursGroups = a}) . _Default . _Coerce
algfursNextToken :: Lens' AdminListGroupsForUserResponse (Maybe Text)
algfursNextToken = lens _algfursNextToken (\ s a -> s{_algfursNextToken = a})
algfursResponseStatus :: Lens' AdminListGroupsForUserResponse Int
algfursResponseStatus = lens _algfursResponseStatus (\ s a -> s{_algfursResponseStatus = a})
instance NFData AdminListGroupsForUserResponse where