module Network.AWS.Support.DescribeCommunications
(
describeCommunications
, DescribeCommunications
, dAfterTime
, dNextToken
, dBeforeTime
, dMaxResults
, dCaseId
, describeCommunicationsResponse
, DescribeCommunicationsResponse
, dcrsNextToken
, dcrsCommunications
, dcrsStatus
) where
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Support.Types
import Network.AWS.Support.Types.Product
data DescribeCommunications = DescribeCommunications'
{ _dAfterTime :: !(Maybe Text)
, _dNextToken :: !(Maybe Text)
, _dBeforeTime :: !(Maybe Text)
, _dMaxResults :: !(Maybe Nat)
, _dCaseId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeCommunications
:: Text
-> DescribeCommunications
describeCommunications pCaseId_ =
DescribeCommunications'
{ _dAfterTime = Nothing
, _dNextToken = Nothing
, _dBeforeTime = Nothing
, _dMaxResults = Nothing
, _dCaseId = pCaseId_
}
dAfterTime :: Lens' DescribeCommunications (Maybe Text)
dAfterTime = lens _dAfterTime (\ s a -> s{_dAfterTime = a});
dNextToken :: Lens' DescribeCommunications (Maybe Text)
dNextToken = lens _dNextToken (\ s a -> s{_dNextToken = a});
dBeforeTime :: Lens' DescribeCommunications (Maybe Text)
dBeforeTime = lens _dBeforeTime (\ s a -> s{_dBeforeTime = a});
dMaxResults :: Lens' DescribeCommunications (Maybe Natural)
dMaxResults = lens _dMaxResults (\ s a -> s{_dMaxResults = a}) . mapping _Nat;
dCaseId :: Lens' DescribeCommunications Text
dCaseId = lens _dCaseId (\ s a -> s{_dCaseId = a});
instance AWSPager DescribeCommunications where
page rq rs
| stop (rs ^. dcrsNextToken) = Nothing
| stop (rs ^. dcrsCommunications) = Nothing
| otherwise =
Just $ rq & dNextToken .~ rs ^. dcrsNextToken
instance AWSRequest DescribeCommunications where
type Sv DescribeCommunications = Support
type Rs DescribeCommunications =
DescribeCommunicationsResponse
request = postJSON
response
= receiveJSON
(\ s h x ->
DescribeCommunicationsResponse' <$>
(x .?> "nextToken") <*>
(x .?> "communications" .!@ mempty)
<*> (pure (fromEnum s)))
instance ToHeaders DescribeCommunications where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSSupport_20130415.DescribeCommunications" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DescribeCommunications where
toJSON DescribeCommunications'{..}
= object
["afterTime" .= _dAfterTime,
"nextToken" .= _dNextToken,
"beforeTime" .= _dBeforeTime,
"maxResults" .= _dMaxResults, "caseId" .= _dCaseId]
instance ToPath DescribeCommunications where
toPath = const "/"
instance ToQuery DescribeCommunications where
toQuery = const mempty
data DescribeCommunicationsResponse = DescribeCommunicationsResponse'
{ _dcrsNextToken :: !(Maybe Text)
, _dcrsCommunications :: !(Maybe [Communication])
, _dcrsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeCommunicationsResponse
:: Int
-> DescribeCommunicationsResponse
describeCommunicationsResponse pStatus_ =
DescribeCommunicationsResponse'
{ _dcrsNextToken = Nothing
, _dcrsCommunications = Nothing
, _dcrsStatus = pStatus_
}
dcrsNextToken :: Lens' DescribeCommunicationsResponse (Maybe Text)
dcrsNextToken = lens _dcrsNextToken (\ s a -> s{_dcrsNextToken = a});
dcrsCommunications :: Lens' DescribeCommunicationsResponse [Communication]
dcrsCommunications = lens _dcrsCommunications (\ s a -> s{_dcrsCommunications = a}) . _Default . _Coerce;
dcrsStatus :: Lens' DescribeCommunicationsResponse Int
dcrsStatus = lens _dcrsStatus (\ s a -> s{_dcrsStatus = a});