{-# 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.Snowball.DescribeAddresses
(
describeAddresses
, DescribeAddresses
, daNextToken
, daMaxResults
, describeAddressesResponse
, DescribeAddressesResponse
, drsAddresses
, drsNextToken
, drsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Snowball.Types
import Network.AWS.Snowball.Types.Product
data DescribeAddresses = DescribeAddresses'
{ _daNextToken :: !(Maybe Text)
, _daMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeAddresses
:: DescribeAddresses
describeAddresses =
DescribeAddresses' {_daNextToken = Nothing, _daMaxResults = Nothing}
daNextToken :: Lens' DescribeAddresses (Maybe Text)
daNextToken = lens _daNextToken (\ s a -> s{_daNextToken = a})
daMaxResults :: Lens' DescribeAddresses (Maybe Natural)
daMaxResults = lens _daMaxResults (\ s a -> s{_daMaxResults = a}) . mapping _Nat
instance AWSPager DescribeAddresses where
page rq rs
| stop (rs ^. drsNextToken) = Nothing
| stop (rs ^. drsAddresses) = Nothing
| otherwise =
Just $ rq & daNextToken .~ rs ^. drsNextToken
instance AWSRequest DescribeAddresses where
type Rs DescribeAddresses = DescribeAddressesResponse
request = postJSON snowball
response
= receiveJSON
(\ s h x ->
DescribeAddressesResponse' <$>
(x .?> "Addresses" .!@ mempty) <*>
(x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable DescribeAddresses where
instance NFData DescribeAddresses where
instance ToHeaders DescribeAddresses where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSIESnowballJobManagementService.DescribeAddresses"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DescribeAddresses where
toJSON DescribeAddresses'{..}
= object
(catMaybes
[("NextToken" .=) <$> _daNextToken,
("MaxResults" .=) <$> _daMaxResults])
instance ToPath DescribeAddresses where
toPath = const "/"
instance ToQuery DescribeAddresses where
toQuery = const mempty
data DescribeAddressesResponse = DescribeAddressesResponse'
{ _drsAddresses :: !(Maybe [Address])
, _drsNextToken :: !(Maybe Text)
, _drsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeAddressesResponse
:: Int
-> DescribeAddressesResponse
describeAddressesResponse pResponseStatus_ =
DescribeAddressesResponse'
{ _drsAddresses = Nothing
, _drsNextToken = Nothing
, _drsResponseStatus = pResponseStatus_
}
drsAddresses :: Lens' DescribeAddressesResponse [Address]
drsAddresses = lens _drsAddresses (\ s a -> s{_drsAddresses = a}) . _Default . _Coerce
drsNextToken :: Lens' DescribeAddressesResponse (Maybe Text)
drsNextToken = lens _drsNextToken (\ s a -> s{_drsNextToken = a})
drsResponseStatus :: Lens' DescribeAddressesResponse Int
drsResponseStatus = lens _drsResponseStatus (\ s a -> s{_drsResponseStatus = a})
instance NFData DescribeAddressesResponse where