{-# 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.CodeDeploy.ListDeploymentGroups
(
listDeploymentGroups
, ListDeploymentGroups
, ldgNextToken
, ldgApplicationName
, listDeploymentGroupsResponse
, ListDeploymentGroupsResponse
, ldgrsNextToken
, ldgrsApplicationName
, ldgrsDeploymentGroups
, ldgrsResponseStatus
) where
import Network.AWS.CodeDeploy.Types
import Network.AWS.CodeDeploy.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListDeploymentGroups = ListDeploymentGroups'
{ _ldgNextToken :: !(Maybe Text)
, _ldgApplicationName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDeploymentGroups
:: Text
-> ListDeploymentGroups
listDeploymentGroups pApplicationName_ =
ListDeploymentGroups'
{_ldgNextToken = Nothing, _ldgApplicationName = pApplicationName_}
ldgNextToken :: Lens' ListDeploymentGroups (Maybe Text)
ldgNextToken = lens _ldgNextToken (\ s a -> s{_ldgNextToken = a})
ldgApplicationName :: Lens' ListDeploymentGroups Text
ldgApplicationName = lens _ldgApplicationName (\ s a -> s{_ldgApplicationName = a})
instance AWSPager ListDeploymentGroups where
page rq rs
| stop (rs ^. ldgrsNextToken) = Nothing
| stop (rs ^. ldgrsDeploymentGroups) = Nothing
| otherwise =
Just $ rq & ldgNextToken .~ rs ^. ldgrsNextToken
instance AWSRequest ListDeploymentGroups where
type Rs ListDeploymentGroups =
ListDeploymentGroupsResponse
request = postJSON codeDeploy
response
= receiveJSON
(\ s h x ->
ListDeploymentGroupsResponse' <$>
(x .?> "nextToken") <*> (x .?> "applicationName") <*>
(x .?> "deploymentGroups" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListDeploymentGroups where
instance NFData ListDeploymentGroups where
instance ToHeaders ListDeploymentGroups where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("CodeDeploy_20141006.ListDeploymentGroups" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListDeploymentGroups where
toJSON ListDeploymentGroups'{..}
= object
(catMaybes
[("nextToken" .=) <$> _ldgNextToken,
Just ("applicationName" .= _ldgApplicationName)])
instance ToPath ListDeploymentGroups where
toPath = const "/"
instance ToQuery ListDeploymentGroups where
toQuery = const mempty
data ListDeploymentGroupsResponse = ListDeploymentGroupsResponse'
{ _ldgrsNextToken :: !(Maybe Text)
, _ldgrsApplicationName :: !(Maybe Text)
, _ldgrsDeploymentGroups :: !(Maybe [Text])
, _ldgrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDeploymentGroupsResponse
:: Int
-> ListDeploymentGroupsResponse
listDeploymentGroupsResponse pResponseStatus_ =
ListDeploymentGroupsResponse'
{ _ldgrsNextToken = Nothing
, _ldgrsApplicationName = Nothing
, _ldgrsDeploymentGroups = Nothing
, _ldgrsResponseStatus = pResponseStatus_
}
ldgrsNextToken :: Lens' ListDeploymentGroupsResponse (Maybe Text)
ldgrsNextToken = lens _ldgrsNextToken (\ s a -> s{_ldgrsNextToken = a})
ldgrsApplicationName :: Lens' ListDeploymentGroupsResponse (Maybe Text)
ldgrsApplicationName = lens _ldgrsApplicationName (\ s a -> s{_ldgrsApplicationName = a})
ldgrsDeploymentGroups :: Lens' ListDeploymentGroupsResponse [Text]
ldgrsDeploymentGroups = lens _ldgrsDeploymentGroups (\ s a -> s{_ldgrsDeploymentGroups = a}) . _Default . _Coerce
ldgrsResponseStatus :: Lens' ListDeploymentGroupsResponse Int
ldgrsResponseStatus = lens _ldgrsResponseStatus (\ s a -> s{_ldgrsResponseStatus = a})
instance NFData ListDeploymentGroupsResponse where