{-# 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.Lightsail.GetKeyPairs
(
getKeyPairs
, GetKeyPairs
, gkpPageToken
, getKeyPairsResponse
, GetKeyPairsResponse
, gkpsrsNextPageToken
, gkpsrsKeyPairs
, gkpsrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Lightsail.Types
import Network.AWS.Lightsail.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
newtype GetKeyPairs = GetKeyPairs'
{ _gkpPageToken :: Maybe Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getKeyPairs
:: GetKeyPairs
getKeyPairs = GetKeyPairs' {_gkpPageToken = Nothing}
gkpPageToken :: Lens' GetKeyPairs (Maybe Text)
gkpPageToken = lens _gkpPageToken (\ s a -> s{_gkpPageToken = a})
instance AWSPager GetKeyPairs where
page rq rs
| stop (rs ^. gkpsrsNextPageToken) = Nothing
| stop (rs ^. gkpsrsKeyPairs) = Nothing
| otherwise =
Just $ rq & gkpPageToken .~ rs ^. gkpsrsNextPageToken
instance AWSRequest GetKeyPairs where
type Rs GetKeyPairs = GetKeyPairsResponse
request = postJSON lightsail
response
= receiveJSON
(\ s h x ->
GetKeyPairsResponse' <$>
(x .?> "nextPageToken") <*>
(x .?> "keyPairs" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable GetKeyPairs where
instance NFData GetKeyPairs where
instance ToHeaders GetKeyPairs where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Lightsail_20161128.GetKeyPairs" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetKeyPairs where
toJSON GetKeyPairs'{..}
= object
(catMaybes [("pageToken" .=) <$> _gkpPageToken])
instance ToPath GetKeyPairs where
toPath = const "/"
instance ToQuery GetKeyPairs where
toQuery = const mempty
data GetKeyPairsResponse = GetKeyPairsResponse'
{ _gkpsrsNextPageToken :: !(Maybe Text)
, _gkpsrsKeyPairs :: !(Maybe [KeyPair])
, _gkpsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getKeyPairsResponse
:: Int
-> GetKeyPairsResponse
getKeyPairsResponse pResponseStatus_ =
GetKeyPairsResponse'
{ _gkpsrsNextPageToken = Nothing
, _gkpsrsKeyPairs = Nothing
, _gkpsrsResponseStatus = pResponseStatus_
}
gkpsrsNextPageToken :: Lens' GetKeyPairsResponse (Maybe Text)
gkpsrsNextPageToken = lens _gkpsrsNextPageToken (\ s a -> s{_gkpsrsNextPageToken = a})
gkpsrsKeyPairs :: Lens' GetKeyPairsResponse [KeyPair]
gkpsrsKeyPairs = lens _gkpsrsKeyPairs (\ s a -> s{_gkpsrsKeyPairs = a}) . _Default . _Coerce
gkpsrsResponseStatus :: Lens' GetKeyPairsResponse Int
gkpsrsResponseStatus = lens _gkpsrsResponseStatus (\ s a -> s{_gkpsrsResponseStatus = a})
instance NFData GetKeyPairsResponse where