{-# 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.GetBlueprints
(
getBlueprints
, GetBlueprints
, gbIncludeInactive
, gbPageToken
, getBlueprintsResponse
, GetBlueprintsResponse
, gbsrsBlueprints
, gbsrsNextPageToken
, gbsrsResponseStatus
) 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
data GetBlueprints = GetBlueprints'
{ _gbIncludeInactive :: !(Maybe Bool)
, _gbPageToken :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getBlueprints
:: GetBlueprints
getBlueprints =
GetBlueprints' {_gbIncludeInactive = Nothing, _gbPageToken = Nothing}
gbIncludeInactive :: Lens' GetBlueprints (Maybe Bool)
gbIncludeInactive = lens _gbIncludeInactive (\ s a -> s{_gbIncludeInactive = a})
gbPageToken :: Lens' GetBlueprints (Maybe Text)
gbPageToken = lens _gbPageToken (\ s a -> s{_gbPageToken = a})
instance AWSPager GetBlueprints where
page rq rs
| stop (rs ^. gbsrsNextPageToken) = Nothing
| stop (rs ^. gbsrsBlueprints) = Nothing
| otherwise =
Just $ rq & gbPageToken .~ rs ^. gbsrsNextPageToken
instance AWSRequest GetBlueprints where
type Rs GetBlueprints = GetBlueprintsResponse
request = postJSON lightsail
response
= receiveJSON
(\ s h x ->
GetBlueprintsResponse' <$>
(x .?> "blueprints" .!@ mempty) <*>
(x .?> "nextPageToken")
<*> (pure (fromEnum s)))
instance Hashable GetBlueprints where
instance NFData GetBlueprints where
instance ToHeaders GetBlueprints where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Lightsail_20161128.GetBlueprints" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetBlueprints where
toJSON GetBlueprints'{..}
= object
(catMaybes
[("includeInactive" .=) <$> _gbIncludeInactive,
("pageToken" .=) <$> _gbPageToken])
instance ToPath GetBlueprints where
toPath = const "/"
instance ToQuery GetBlueprints where
toQuery = const mempty
data GetBlueprintsResponse = GetBlueprintsResponse'
{ _gbsrsBlueprints :: !(Maybe [Blueprint])
, _gbsrsNextPageToken :: !(Maybe Text)
, _gbsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getBlueprintsResponse
:: Int
-> GetBlueprintsResponse
getBlueprintsResponse pResponseStatus_ =
GetBlueprintsResponse'
{ _gbsrsBlueprints = Nothing
, _gbsrsNextPageToken = Nothing
, _gbsrsResponseStatus = pResponseStatus_
}
gbsrsBlueprints :: Lens' GetBlueprintsResponse [Blueprint]
gbsrsBlueprints = lens _gbsrsBlueprints (\ s a -> s{_gbsrsBlueprints = a}) . _Default . _Coerce
gbsrsNextPageToken :: Lens' GetBlueprintsResponse (Maybe Text)
gbsrsNextPageToken = lens _gbsrsNextPageToken (\ s a -> s{_gbsrsNextPageToken = a})
gbsrsResponseStatus :: Lens' GetBlueprintsResponse Int
gbsrsResponseStatus = lens _gbsrsResponseStatus (\ s a -> s{_gbsrsResponseStatus = a})
instance NFData GetBlueprintsResponse where