{-# 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.CloudWatchLogs.DescribeDestinations
(
describeDestinations
, DescribeDestinations
, ddNextToken
, ddLimit
, ddDestinationNamePrefix
, describeDestinationsResponse
, DescribeDestinationsResponse
, ddrsNextToken
, ddrsDestinations
, ddrsResponseStatus
) where
import Network.AWS.CloudWatchLogs.Types
import Network.AWS.CloudWatchLogs.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeDestinations = DescribeDestinations'
{ _ddNextToken :: !(Maybe Text)
, _ddLimit :: !(Maybe Nat)
, _ddDestinationNamePrefix :: !(Maybe Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeDestinations
:: DescribeDestinations
describeDestinations =
DescribeDestinations'
{ _ddNextToken = Nothing
, _ddLimit = Nothing
, _ddDestinationNamePrefix = Nothing
}
ddNextToken :: Lens' DescribeDestinations (Maybe Text)
ddNextToken = lens _ddNextToken (\ s a -> s{_ddNextToken = a});
ddLimit :: Lens' DescribeDestinations (Maybe Natural)
ddLimit = lens _ddLimit (\ s a -> s{_ddLimit = a}) . mapping _Nat;
ddDestinationNamePrefix :: Lens' DescribeDestinations (Maybe Text)
ddDestinationNamePrefix = lens _ddDestinationNamePrefix (\ s a -> s{_ddDestinationNamePrefix = a});
instance AWSPager DescribeDestinations where
page rq rs
| stop (rs ^. ddrsNextToken) = Nothing
| stop (rs ^. ddrsDestinations) = Nothing
| otherwise =
Just $ rq & ddNextToken .~ rs ^. ddrsNextToken
instance AWSRequest DescribeDestinations where
type Rs DescribeDestinations =
DescribeDestinationsResponse
request = postJSON cloudWatchLogs
response
= receiveJSON
(\ s h x ->
DescribeDestinationsResponse' <$>
(x .?> "nextToken") <*>
(x .?> "destinations" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable DescribeDestinations
instance NFData DescribeDestinations
instance ToHeaders DescribeDestinations where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Logs_20140328.DescribeDestinations" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DescribeDestinations where
toJSON DescribeDestinations'{..}
= object
(catMaybes
[("nextToken" .=) <$> _ddNextToken,
("limit" .=) <$> _ddLimit,
("DestinationNamePrefix" .=) <$>
_ddDestinationNamePrefix])
instance ToPath DescribeDestinations where
toPath = const "/"
instance ToQuery DescribeDestinations where
toQuery = const mempty
data DescribeDestinationsResponse = DescribeDestinationsResponse'
{ _ddrsNextToken :: !(Maybe Text)
, _ddrsDestinations :: !(Maybe [Destination])
, _ddrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeDestinationsResponse
:: Int
-> DescribeDestinationsResponse
describeDestinationsResponse pResponseStatus_ =
DescribeDestinationsResponse'
{ _ddrsNextToken = Nothing
, _ddrsDestinations = Nothing
, _ddrsResponseStatus = pResponseStatus_
}
ddrsNextToken :: Lens' DescribeDestinationsResponse (Maybe Text)
ddrsNextToken = lens _ddrsNextToken (\ s a -> s{_ddrsNextToken = a});
ddrsDestinations :: Lens' DescribeDestinationsResponse [Destination]
ddrsDestinations = lens _ddrsDestinations (\ s a -> s{_ddrsDestinations = a}) . _Default . _Coerce;
ddrsResponseStatus :: Lens' DescribeDestinationsResponse Int
ddrsResponseStatus = lens _ddrsResponseStatus (\ s a -> s{_ddrsResponseStatus = a});
instance NFData DescribeDestinationsResponse