{-# 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.Support.DescribeCommunications
(
describeCommunications
, DescribeCommunications
, dAfterTime
, dBeforeTime
, dNextToken
, dMaxResults
, dCaseId
, describeCommunicationsResponse
, DescribeCommunicationsResponse
, dcrsNextToken
, dcrsCommunications
, dcrsResponseStatus
) where
import Network.AWS.Lens
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)
, _dBeforeTime :: !(Maybe Text)
, _dNextToken :: !(Maybe Text)
, _dMaxResults :: !(Maybe Nat)
, _dCaseId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeCommunications
:: Text
-> DescribeCommunications
describeCommunications pCaseId_ =
DescribeCommunications'
{ _dAfterTime = Nothing
, _dBeforeTime = Nothing
, _dNextToken = Nothing
, _dMaxResults = Nothing
, _dCaseId = pCaseId_
}
dAfterTime :: Lens' DescribeCommunications (Maybe Text)
dAfterTime = lens _dAfterTime (\ s a -> s{_dAfterTime = a})
dBeforeTime :: Lens' DescribeCommunications (Maybe Text)
dBeforeTime = lens _dBeforeTime (\ s a -> s{_dBeforeTime = a})
dNextToken :: Lens' DescribeCommunications (Maybe Text)
dNextToken = lens _dNextToken (\ s a -> s{_dNextToken = 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 Rs DescribeCommunications =
DescribeCommunicationsResponse
request = postJSON support
response
= receiveJSON
(\ s h x ->
DescribeCommunicationsResponse' <$>
(x .?> "nextToken") <*>
(x .?> "communications" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable DescribeCommunications where
instance NFData DescribeCommunications where
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
(catMaybes
[("afterTime" .=) <$> _dAfterTime,
("beforeTime" .=) <$> _dBeforeTime,
("nextToken" .=) <$> _dNextToken,
("maxResults" .=) <$> _dMaxResults,
Just ("caseId" .= _dCaseId)])
instance ToPath DescribeCommunications where
toPath = const "/"
instance ToQuery DescribeCommunications where
toQuery = const mempty
data DescribeCommunicationsResponse = DescribeCommunicationsResponse'
{ _dcrsNextToken :: !(Maybe Text)
, _dcrsCommunications :: !(Maybe [Communication])
, _dcrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeCommunicationsResponse
:: Int
-> DescribeCommunicationsResponse
describeCommunicationsResponse pResponseStatus_ =
DescribeCommunicationsResponse'
{ _dcrsNextToken = Nothing
, _dcrsCommunications = Nothing
, _dcrsResponseStatus = pResponseStatus_
}
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
dcrsResponseStatus :: Lens' DescribeCommunicationsResponse Int
dcrsResponseStatus = lens _dcrsResponseStatus (\ s a -> s{_dcrsResponseStatus = a})
instance NFData DescribeCommunicationsResponse where