{-# 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.ListDeploymentInstances
(
listDeploymentInstances
, ListDeploymentInstances
, lInstanceStatusFilter
, lNextToken
, lInstanceTypeFilter
, lDeploymentId
, listDeploymentInstancesResponse
, ListDeploymentInstancesResponse
, ldirsNextToken
, ldirsInstancesList
, ldirsResponseStatus
) 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 ListDeploymentInstances = ListDeploymentInstances'
{ _lInstanceStatusFilter :: !(Maybe [InstanceStatus])
, _lNextToken :: !(Maybe Text)
, _lInstanceTypeFilter :: !(Maybe [InstanceType])
, _lDeploymentId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDeploymentInstances
:: Text
-> ListDeploymentInstances
listDeploymentInstances pDeploymentId_ =
ListDeploymentInstances'
{ _lInstanceStatusFilter = Nothing
, _lNextToken = Nothing
, _lInstanceTypeFilter = Nothing
, _lDeploymentId = pDeploymentId_
}
lInstanceStatusFilter :: Lens' ListDeploymentInstances [InstanceStatus]
lInstanceStatusFilter = lens _lInstanceStatusFilter (\ s a -> s{_lInstanceStatusFilter = a}) . _Default . _Coerce
lNextToken :: Lens' ListDeploymentInstances (Maybe Text)
lNextToken = lens _lNextToken (\ s a -> s{_lNextToken = a})
lInstanceTypeFilter :: Lens' ListDeploymentInstances [InstanceType]
lInstanceTypeFilter = lens _lInstanceTypeFilter (\ s a -> s{_lInstanceTypeFilter = a}) . _Default . _Coerce
lDeploymentId :: Lens' ListDeploymentInstances Text
lDeploymentId = lens _lDeploymentId (\ s a -> s{_lDeploymentId = a})
instance AWSPager ListDeploymentInstances where
page rq rs
| stop (rs ^. ldirsNextToken) = Nothing
| stop (rs ^. ldirsInstancesList) = Nothing
| otherwise =
Just $ rq & lNextToken .~ rs ^. ldirsNextToken
instance AWSRequest ListDeploymentInstances where
type Rs ListDeploymentInstances =
ListDeploymentInstancesResponse
request = postJSON codeDeploy
response
= receiveJSON
(\ s h x ->
ListDeploymentInstancesResponse' <$>
(x .?> "nextToken") <*>
(x .?> "instancesList" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListDeploymentInstances where
instance NFData ListDeploymentInstances where
instance ToHeaders ListDeploymentInstances where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("CodeDeploy_20141006.ListDeploymentInstances" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListDeploymentInstances where
toJSON ListDeploymentInstances'{..}
= object
(catMaybes
[("instanceStatusFilter" .=) <$>
_lInstanceStatusFilter,
("nextToken" .=) <$> _lNextToken,
("instanceTypeFilter" .=) <$> _lInstanceTypeFilter,
Just ("deploymentId" .= _lDeploymentId)])
instance ToPath ListDeploymentInstances where
toPath = const "/"
instance ToQuery ListDeploymentInstances where
toQuery = const mempty
data ListDeploymentInstancesResponse = ListDeploymentInstancesResponse'
{ _ldirsNextToken :: !(Maybe Text)
, _ldirsInstancesList :: !(Maybe [Text])
, _ldirsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDeploymentInstancesResponse
:: Int
-> ListDeploymentInstancesResponse
listDeploymentInstancesResponse pResponseStatus_ =
ListDeploymentInstancesResponse'
{ _ldirsNextToken = Nothing
, _ldirsInstancesList = Nothing
, _ldirsResponseStatus = pResponseStatus_
}
ldirsNextToken :: Lens' ListDeploymentInstancesResponse (Maybe Text)
ldirsNextToken = lens _ldirsNextToken (\ s a -> s{_ldirsNextToken = a})
ldirsInstancesList :: Lens' ListDeploymentInstancesResponse [Text]
ldirsInstancesList = lens _ldirsInstancesList (\ s a -> s{_ldirsInstancesList = a}) . _Default . _Coerce
ldirsResponseStatus :: Lens' ListDeploymentInstancesResponse Int
ldirsResponseStatus = lens _ldirsResponseStatus (\ s a -> s{_ldirsResponseStatus = a})
instance NFData ListDeploymentInstancesResponse where