module Network.AWS.AutoScaling.DescribeAutoScalingGroups
(
DescribeAutoScalingGroups
, describeAutoScalingGroups
, dasgAutoScalingGroupNames
, dasgMaxRecords
, dasgNextToken
, DescribeAutoScalingGroupsResponse
, describeAutoScalingGroupsResponse
, dasgrAutoScalingGroups
, dasgrNextToken
) where
import Network.AWS.Prelude
import Network.AWS.Request.Query
import Network.AWS.AutoScaling.Types
import qualified GHC.Exts
data DescribeAutoScalingGroups = DescribeAutoScalingGroups
{ _dasgAutoScalingGroupNames :: List "member" Text
, _dasgMaxRecords :: Maybe Int
, _dasgNextToken :: Maybe Text
} deriving (Eq, Ord, Read, Show)
describeAutoScalingGroups :: DescribeAutoScalingGroups
describeAutoScalingGroups = DescribeAutoScalingGroups
{ _dasgAutoScalingGroupNames = mempty
, _dasgNextToken = Nothing
, _dasgMaxRecords = Nothing
}
dasgAutoScalingGroupNames :: Lens' DescribeAutoScalingGroups [Text]
dasgAutoScalingGroupNames =
lens _dasgAutoScalingGroupNames
(\s a -> s { _dasgAutoScalingGroupNames = a })
. _List
dasgMaxRecords :: Lens' DescribeAutoScalingGroups (Maybe Int)
dasgMaxRecords = lens _dasgMaxRecords (\s a -> s { _dasgMaxRecords = a })
dasgNextToken :: Lens' DescribeAutoScalingGroups (Maybe Text)
dasgNextToken = lens _dasgNextToken (\s a -> s { _dasgNextToken = a })
data DescribeAutoScalingGroupsResponse = DescribeAutoScalingGroupsResponse
{ _dasgrAutoScalingGroups :: List "member" AutoScalingGroup
, _dasgrNextToken :: Maybe Text
} deriving (Eq, Read, Show)
describeAutoScalingGroupsResponse :: DescribeAutoScalingGroupsResponse
describeAutoScalingGroupsResponse = DescribeAutoScalingGroupsResponse
{ _dasgrAutoScalingGroups = mempty
, _dasgrNextToken = Nothing
}
dasgrAutoScalingGroups :: Lens' DescribeAutoScalingGroupsResponse [AutoScalingGroup]
dasgrAutoScalingGroups =
lens _dasgrAutoScalingGroups (\s a -> s { _dasgrAutoScalingGroups = a })
. _List
dasgrNextToken :: Lens' DescribeAutoScalingGroupsResponse (Maybe Text)
dasgrNextToken = lens _dasgrNextToken (\s a -> s { _dasgrNextToken = a })
instance ToPath DescribeAutoScalingGroups where
toPath = const "/"
instance ToQuery DescribeAutoScalingGroups where
toQuery DescribeAutoScalingGroups{..} = mconcat
[ "AutoScalingGroupNames" =? _dasgAutoScalingGroupNames
, "MaxRecords" =? _dasgMaxRecords
, "NextToken" =? _dasgNextToken
]
instance ToHeaders DescribeAutoScalingGroups
instance AWSRequest DescribeAutoScalingGroups where
type Sv DescribeAutoScalingGroups = AutoScaling
type Rs DescribeAutoScalingGroups = DescribeAutoScalingGroupsResponse
request = post "DescribeAutoScalingGroups"
response = xmlResponse
instance FromXML DescribeAutoScalingGroupsResponse where
parseXML = withElement "DescribeAutoScalingGroupsResult" $ \x -> DescribeAutoScalingGroupsResponse
<$> x .@? "AutoScalingGroups" .!@ mempty
<*> x .@? "NextToken"
instance AWSPager DescribeAutoScalingGroups where
page rq rs
| stop (rs ^. dasgrNextToken) = Nothing
| otherwise = (\x -> rq & dasgNextToken ?~ x)
<$> (rs ^. dasgrNextToken)