{-# 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.GetDevice
(
getDevice
, GetDevice
, gdAccessToken
, gdDeviceKey
, getDeviceResponse
, GetDeviceResponse
, gdrsResponseStatus
, gdrsDevice
) 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 GetDevice = GetDevice'
{ _gdAccessToken :: !(Maybe (Sensitive Text))
, _gdDeviceKey :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getDevice
:: Text
-> GetDevice
getDevice pDeviceKey_ =
GetDevice'
{ _gdAccessToken = Nothing
, _gdDeviceKey = pDeviceKey_
}
gdAccessToken :: Lens' GetDevice (Maybe Text)
gdAccessToken = lens _gdAccessToken (\ s a -> s{_gdAccessToken = a}) . mapping _Sensitive;
gdDeviceKey :: Lens' GetDevice Text
gdDeviceKey = lens _gdDeviceKey (\ s a -> s{_gdDeviceKey = a});
instance AWSRequest GetDevice where
type Rs GetDevice = GetDeviceResponse
request = postJSON cognitoIdentityProvider
response
= receiveJSON
(\ s h x ->
GetDeviceResponse' <$>
(pure (fromEnum s)) <*> (x .:> "Device"))
instance Hashable GetDevice
instance NFData GetDevice
instance ToHeaders GetDevice where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityProviderService.GetDevice" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetDevice where
toJSON GetDevice'{..}
= object
(catMaybes
[("AccessToken" .=) <$> _gdAccessToken,
Just ("DeviceKey" .= _gdDeviceKey)])
instance ToPath GetDevice where
toPath = const "/"
instance ToQuery GetDevice where
toQuery = const mempty
data GetDeviceResponse = GetDeviceResponse'
{ _gdrsResponseStatus :: !Int
, _gdrsDevice :: !DeviceType
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getDeviceResponse
:: Int
-> DeviceType
-> GetDeviceResponse
getDeviceResponse pResponseStatus_ pDevice_ =
GetDeviceResponse'
{ _gdrsResponseStatus = pResponseStatus_
, _gdrsDevice = pDevice_
}
gdrsResponseStatus :: Lens' GetDeviceResponse Int
gdrsResponseStatus = lens _gdrsResponseStatus (\ s a -> s{_gdrsResponseStatus = a});
gdrsDevice :: Lens' GetDeviceResponse DeviceType
gdrsDevice = lens _gdrsDevice (\ s a -> s{_gdrsDevice = a});
instance NFData GetDeviceResponse