{-# 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.Route53AutoNaming.ListInstances
(
listInstances
, ListInstances
, liNextToken
, liMaxResults
, liServiceId
, listInstancesResponse
, ListInstancesResponse
, lirsNextToken
, lirsInstances
, lirsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Route53AutoNaming.Types
import Network.AWS.Route53AutoNaming.Types.Product
data ListInstances = ListInstances'
{ _liNextToken :: !(Maybe Text)
, _liMaxResults :: !(Maybe Nat)
, _liServiceId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listInstances
:: Text
-> ListInstances
listInstances pServiceId_ =
ListInstances'
{ _liNextToken = Nothing
, _liMaxResults = Nothing
, _liServiceId = pServiceId_
}
liNextToken :: Lens' ListInstances (Maybe Text)
liNextToken = lens _liNextToken (\ s a -> s{_liNextToken = a})
liMaxResults :: Lens' ListInstances (Maybe Natural)
liMaxResults = lens _liMaxResults (\ s a -> s{_liMaxResults = a}) . mapping _Nat
liServiceId :: Lens' ListInstances Text
liServiceId = lens _liServiceId (\ s a -> s{_liServiceId = a})
instance AWSPager ListInstances where
page rq rs
| stop (rs ^. lirsNextToken) = Nothing
| stop (rs ^. lirsInstances) = Nothing
| otherwise =
Just $ rq & liNextToken .~ rs ^. lirsNextToken
instance AWSRequest ListInstances where
type Rs ListInstances = ListInstancesResponse
request = postJSON route53AutoNaming
response
= receiveJSON
(\ s h x ->
ListInstancesResponse' <$>
(x .?> "NextToken") <*>
(x .?> "Instances" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListInstances where
instance NFData ListInstances where
instance ToHeaders ListInstances where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Route53AutoNaming_v20170314.ListInstances" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListInstances where
toJSON ListInstances'{..}
= object
(catMaybes
[("NextToken" .=) <$> _liNextToken,
("MaxResults" .=) <$> _liMaxResults,
Just ("ServiceId" .= _liServiceId)])
instance ToPath ListInstances where
toPath = const "/"
instance ToQuery ListInstances where
toQuery = const mempty
data ListInstancesResponse = ListInstancesResponse'
{ _lirsNextToken :: !(Maybe Text)
, _lirsInstances :: !(Maybe [InstanceSummary])
, _lirsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listInstancesResponse
:: Int
-> ListInstancesResponse
listInstancesResponse pResponseStatus_ =
ListInstancesResponse'
{ _lirsNextToken = Nothing
, _lirsInstances = Nothing
, _lirsResponseStatus = pResponseStatus_
}
lirsNextToken :: Lens' ListInstancesResponse (Maybe Text)
lirsNextToken = lens _lirsNextToken (\ s a -> s{_lirsNextToken = a})
lirsInstances :: Lens' ListInstancesResponse [InstanceSummary]
lirsInstances = lens _lirsInstances (\ s a -> s{_lirsInstances = a}) . _Default . _Coerce
lirsResponseStatus :: Lens' ListInstancesResponse Int
lirsResponseStatus = lens _lirsResponseStatus (\ s a -> s{_lirsResponseStatus = a})
instance NFData ListInstancesResponse where