amazonka-iot-1.4.0: gen/Network/AWS/IoT/ListPolicies.hs
{-# 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 #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.IoT.ListPolicies
-- Copyright : (c) 2013-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists your policies.
module Network.AWS.IoT.ListPolicies
(
-- * Creating a Request
listPolicies
, ListPolicies
-- * Request Lenses
, lpMarker
, lpAscendingOrder
, lpPageSize
-- * Destructuring the Response
, listPoliciesResponse
, ListPoliciesResponse
-- * Response Lenses
, lprsNextMarker
, lprsPolicies
, lprsResponseStatus
) where
import Network.AWS.IoT.Types
import Network.AWS.IoT.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
-- | The input for the ListPolicies operation.
--
-- /See:/ 'listPolicies' smart constructor.
data ListPolicies = ListPolicies'
{ _lpMarker :: !(Maybe Text)
, _lpAscendingOrder :: !(Maybe Bool)
, _lpPageSize :: !(Maybe Nat)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'ListPolicies' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'lpMarker'
--
-- * 'lpAscendingOrder'
--
-- * 'lpPageSize'
listPolicies
:: ListPolicies
listPolicies =
ListPolicies'
{ _lpMarker = Nothing
, _lpAscendingOrder = Nothing
, _lpPageSize = Nothing
}
-- | The marker for the next set of results.
lpMarker :: Lens' ListPolicies (Maybe Text)
lpMarker = lens _lpMarker (\ s a -> s{_lpMarker = a});
-- | Specifies the order for results. If true, the results are returned in
-- ascending creation order.
lpAscendingOrder :: Lens' ListPolicies (Maybe Bool)
lpAscendingOrder = lens _lpAscendingOrder (\ s a -> s{_lpAscendingOrder = a});
-- | The result page size.
lpPageSize :: Lens' ListPolicies (Maybe Natural)
lpPageSize = lens _lpPageSize (\ s a -> s{_lpPageSize = a}) . mapping _Nat;
instance AWSRequest ListPolicies where
type Rs ListPolicies = ListPoliciesResponse
request = get ioT
response
= receiveJSON
(\ s h x ->
ListPoliciesResponse' <$>
(x .?> "nextMarker") <*>
(x .?> "policies" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListPolicies
instance ToHeaders ListPolicies where
toHeaders = const mempty
instance ToPath ListPolicies where
toPath = const "/policies"
instance ToQuery ListPolicies where
toQuery ListPolicies'{..}
= mconcat
["marker" =: _lpMarker,
"isAscendingOrder" =: _lpAscendingOrder,
"pageSize" =: _lpPageSize]
-- | The output from the ListPolicies operation.
--
-- /See:/ 'listPoliciesResponse' smart constructor.
data ListPoliciesResponse = ListPoliciesResponse'
{ _lprsNextMarker :: !(Maybe Text)
, _lprsPolicies :: !(Maybe [Policy])
, _lprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'ListPoliciesResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'lprsNextMarker'
--
-- * 'lprsPolicies'
--
-- * 'lprsResponseStatus'
listPoliciesResponse
:: Int -- ^ 'lprsResponseStatus'
-> ListPoliciesResponse
listPoliciesResponse pResponseStatus_ =
ListPoliciesResponse'
{ _lprsNextMarker = Nothing
, _lprsPolicies = Nothing
, _lprsResponseStatus = pResponseStatus_
}
-- | The marker for the next set of results, or null if there are no
-- additional results.
lprsNextMarker :: Lens' ListPoliciesResponse (Maybe Text)
lprsNextMarker = lens _lprsNextMarker (\ s a -> s{_lprsNextMarker = a});
-- | The descriptions of the policies.
lprsPolicies :: Lens' ListPoliciesResponse [Policy]
lprsPolicies = lens _lprsPolicies (\ s a -> s{_lprsPolicies = a}) . _Default . _Coerce;
-- | The response status code.
lprsResponseStatus :: Lens' ListPoliciesResponse Int
lprsResponseStatus = lens _lprsResponseStatus (\ s a -> s{_lprsResponseStatus = a});