{-# 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.CloudWatch.ListDashboards
(
listDashboards
, ListDashboards
, ldDashboardNamePrefix
, ldNextToken
, listDashboardsResponse
, ListDashboardsResponse
, ldrsDashboardEntries
, ldrsNextToken
, ldrsResponseStatus
) where
import Network.AWS.CloudWatch.Types
import Network.AWS.CloudWatch.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListDashboards = ListDashboards'
{ _ldDashboardNamePrefix :: !(Maybe Text)
, _ldNextToken :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDashboards
:: ListDashboards
listDashboards =
ListDashboards' {_ldDashboardNamePrefix = Nothing, _ldNextToken = Nothing}
ldDashboardNamePrefix :: Lens' ListDashboards (Maybe Text)
ldDashboardNamePrefix = lens _ldDashboardNamePrefix (\ s a -> s{_ldDashboardNamePrefix = a})
ldNextToken :: Lens' ListDashboards (Maybe Text)
ldNextToken = lens _ldNextToken (\ s a -> s{_ldNextToken = a})
instance AWSPager ListDashboards where
page rq rs
| stop (rs ^. ldrsNextToken) = Nothing
| stop (rs ^. ldrsDashboardEntries) = Nothing
| otherwise =
Just $ rq & ldNextToken .~ rs ^. ldrsNextToken
instance AWSRequest ListDashboards where
type Rs ListDashboards = ListDashboardsResponse
request = postQuery cloudWatch
response
= receiveXMLWrapper "ListDashboardsResult"
(\ s h x ->
ListDashboardsResponse' <$>
(x .@? "DashboardEntries" .!@ mempty >>=
may (parseXMLList "member"))
<*> (x .@? "NextToken")
<*> (pure (fromEnum s)))
instance Hashable ListDashboards where
instance NFData ListDashboards where
instance ToHeaders ListDashboards where
toHeaders = const mempty
instance ToPath ListDashboards where
toPath = const "/"
instance ToQuery ListDashboards where
toQuery ListDashboards'{..}
= mconcat
["Action" =: ("ListDashboards" :: ByteString),
"Version" =: ("2010-08-01" :: ByteString),
"DashboardNamePrefix" =: _ldDashboardNamePrefix,
"NextToken" =: _ldNextToken]
data ListDashboardsResponse = ListDashboardsResponse'
{ _ldrsDashboardEntries :: !(Maybe [DashboardEntry])
, _ldrsNextToken :: !(Maybe Text)
, _ldrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDashboardsResponse
:: Int
-> ListDashboardsResponse
listDashboardsResponse pResponseStatus_ =
ListDashboardsResponse'
{ _ldrsDashboardEntries = Nothing
, _ldrsNextToken = Nothing
, _ldrsResponseStatus = pResponseStatus_
}
ldrsDashboardEntries :: Lens' ListDashboardsResponse [DashboardEntry]
ldrsDashboardEntries = lens _ldrsDashboardEntries (\ s a -> s{_ldrsDashboardEntries = a}) . _Default . _Coerce
ldrsNextToken :: Lens' ListDashboardsResponse (Maybe Text)
ldrsNextToken = lens _ldrsNextToken (\ s a -> s{_ldrsNextToken = a})
ldrsResponseStatus :: Lens' ListDashboardsResponse Int
ldrsResponseStatus = lens _ldrsResponseStatus (\ s a -> s{_ldrsResponseStatus = a})
instance NFData ListDashboardsResponse where