module Network.AWS.Support.DescribeCommunications
(
DescribeCommunications
, describeCommunications
, dc1AfterTime
, dc1BeforeTime
, dc1CaseId
, dc1MaxResults
, dc1NextToken
, DescribeCommunicationsResponse
, describeCommunicationsResponse
, dcrCommunications
, dcrNextToken
) where
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.Support.Types
import qualified GHC.Exts
data DescribeCommunications = DescribeCommunications
{ _dc1AfterTime :: Maybe Text
, _dc1BeforeTime :: Maybe Text
, _dc1CaseId :: Text
, _dc1MaxResults :: Maybe Nat
, _dc1NextToken :: Maybe Text
} deriving (Eq, Ord, Show)
describeCommunications :: Text
-> DescribeCommunications
describeCommunications p1 = DescribeCommunications
{ _dc1CaseId = p1
, _dc1BeforeTime = Nothing
, _dc1AfterTime = Nothing
, _dc1NextToken = Nothing
, _dc1MaxResults = Nothing
}
dc1AfterTime :: Lens' DescribeCommunications (Maybe Text)
dc1AfterTime = lens _dc1AfterTime (\s a -> s { _dc1AfterTime = a })
dc1BeforeTime :: Lens' DescribeCommunications (Maybe Text)
dc1BeforeTime = lens _dc1BeforeTime (\s a -> s { _dc1BeforeTime = a })
dc1CaseId :: Lens' DescribeCommunications Text
dc1CaseId = lens _dc1CaseId (\s a -> s { _dc1CaseId = a })
dc1MaxResults :: Lens' DescribeCommunications (Maybe Natural)
dc1MaxResults = lens _dc1MaxResults (\s a -> s { _dc1MaxResults = a }) . mapping _Nat
dc1NextToken :: Lens' DescribeCommunications (Maybe Text)
dc1NextToken = lens _dc1NextToken (\s a -> s { _dc1NextToken = a })
data DescribeCommunicationsResponse = DescribeCommunicationsResponse
{ _dcrCommunications :: List "communications" Communication
, _dcrNextToken :: Maybe Text
} deriving (Eq, Show)
describeCommunicationsResponse :: DescribeCommunicationsResponse
describeCommunicationsResponse = DescribeCommunicationsResponse
{ _dcrCommunications = mempty
, _dcrNextToken = Nothing
}
dcrCommunications :: Lens' DescribeCommunicationsResponse [Communication]
dcrCommunications =
lens _dcrCommunications (\s a -> s { _dcrCommunications = a })
. _List
dcrNextToken :: Lens' DescribeCommunicationsResponse (Maybe Text)
dcrNextToken = lens _dcrNextToken (\s a -> s { _dcrNextToken = a })
instance ToPath DescribeCommunications where
toPath = const "/"
instance ToQuery DescribeCommunications where
toQuery = const mempty
instance ToHeaders DescribeCommunications
instance ToJSON DescribeCommunications where
toJSON DescribeCommunications{..} = object
[ "caseId" .= _dc1CaseId
, "beforeTime" .= _dc1BeforeTime
, "afterTime" .= _dc1AfterTime
, "nextToken" .= _dc1NextToken
, "maxResults" .= _dc1MaxResults
]
instance AWSRequest DescribeCommunications where
type Sv DescribeCommunications = Support
type Rs DescribeCommunications = DescribeCommunicationsResponse
request = post "DescribeCommunications"
response = jsonResponse
instance FromJSON DescribeCommunicationsResponse where
parseJSON = withObject "DescribeCommunicationsResponse" $ \o -> DescribeCommunicationsResponse
<$> o .:? "communications" .!= mempty
<*> o .:? "nextToken"
instance AWSPager DescribeCommunications where
page rq rs
| stop (rq ^. dc1NextToken) = Nothing
| otherwise = (\x -> rq & dc1NextToken ?~ x)
<$> (rs ^. dcrNextToken)