module Network.AWS.CloudFormation.DescribeStacks
(
describeStacks
, DescribeStacks
, dNextToken
, dStackName
, describeStacksResponse
, DescribeStacksResponse
, dsrsNextToken
, dsrsStacks
, dsrsResponseStatus
) where
import Network.AWS.CloudFormation.Types
import Network.AWS.CloudFormation.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeStacks = DescribeStacks'
{ _dNextToken :: !(Maybe Text)
, _dStackName :: !(Maybe Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeStacks
:: DescribeStacks
describeStacks =
DescribeStacks'
{ _dNextToken = Nothing
, _dStackName = Nothing
}
dNextToken :: Lens' DescribeStacks (Maybe Text)
dNextToken = lens _dNextToken (\ s a -> s{_dNextToken = a});
dStackName :: Lens' DescribeStacks (Maybe Text)
dStackName = lens _dStackName (\ s a -> s{_dStackName = a});
instance AWSPager DescribeStacks where
page rq rs
| stop (rs ^. dsrsNextToken) = Nothing
| stop (rs ^. dsrsStacks) = Nothing
| otherwise =
Just $ rq & dNextToken .~ rs ^. dsrsNextToken
instance AWSRequest DescribeStacks where
type Rs DescribeStacks = DescribeStacksResponse
request = postQuery cloudFormation
response
= receiveXMLWrapper "DescribeStacksResult"
(\ s h x ->
DescribeStacksResponse' <$>
(x .@? "NextToken") <*>
(x .@? "Stacks" .!@ mempty >>=
may (parseXMLList "member"))
<*> (pure (fromEnum s)))
instance ToHeaders DescribeStacks where
toHeaders = const mempty
instance ToPath DescribeStacks where
toPath = const "/"
instance ToQuery DescribeStacks where
toQuery DescribeStacks'{..}
= mconcat
["Action" =: ("DescribeStacks" :: ByteString),
"Version" =: ("2010-05-15" :: ByteString),
"NextToken" =: _dNextToken,
"StackName" =: _dStackName]
data DescribeStacksResponse = DescribeStacksResponse'
{ _dsrsNextToken :: !(Maybe Text)
, _dsrsStacks :: !(Maybe [Stack])
, _dsrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeStacksResponse
:: Int
-> DescribeStacksResponse
describeStacksResponse pResponseStatus_ =
DescribeStacksResponse'
{ _dsrsNextToken = Nothing
, _dsrsStacks = Nothing
, _dsrsResponseStatus = pResponseStatus_
}
dsrsNextToken :: Lens' DescribeStacksResponse (Maybe Text)
dsrsNextToken = lens _dsrsNextToken (\ s a -> s{_dsrsNextToken = a});
dsrsStacks :: Lens' DescribeStacksResponse [Stack]
dsrsStacks = lens _dsrsStacks (\ s a -> s{_dsrsStacks = a}) . _Default . _Coerce;
dsrsResponseStatus :: Lens' DescribeStacksResponse Int
dsrsResponseStatus = lens _dsrsResponseStatus (\ s a -> s{_dsrsResponseStatus = a});