{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IAM.ListPolicies
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all the managed policies that are available in your Amazon Web
-- Services account, including your own customer-defined managed policies
-- and all Amazon Web Services managed policies.
--
-- You can filter the list of policies that is returned using the optional
-- @OnlyAttached@, @Scope@, and @PathPrefix@ parameters. For example, to
-- list only the customer managed policies in your Amazon Web Services
-- account, set @Scope@ to @Local@. To list only Amazon Web Services
-- managed policies, set @Scope@ to @AWS@.
--
-- You can paginate the results using the @MaxItems@ and @Marker@
-- parameters.
--
-- For more information about managed policies, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html Managed policies and inline policies>
-- in the /IAM User Guide/.
--
-- IAM resource-listing operations return a subset of the available
-- attributes for the resource. For example, this operation does not return
-- tags, even though they are an attribute of the returned object. To view
-- all of the information for a customer manged policy, see GetPolicy.
--
-- This operation returns paginated results.
module Amazonka.IAM.ListPolicies
  ( -- * Creating a Request
    ListPolicies (..),
    newListPolicies,

    -- * Request Lenses
    listPolicies_marker,
    listPolicies_maxItems,
    listPolicies_onlyAttached,
    listPolicies_pathPrefix,
    listPolicies_policyUsageFilter,
    listPolicies_scope,

    -- * Destructuring the Response
    ListPoliciesResponse (..),
    newListPoliciesResponse,

    -- * Response Lenses
    listPoliciesResponse_isTruncated,
    listPoliciesResponse_marker,
    listPoliciesResponse_policies,
    listPoliciesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListPolicies' smart constructor.
data ListPolicies = ListPolicies'
  { -- | Use this parameter only when paginating results and only after you
    -- receive a response indicating that the results are truncated. Set it to
    -- the value of the @Marker@ element in the response that you received to
    -- indicate where the next call should start.
    ListPolicies -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | Use this only when paginating results to indicate the maximum number of
    -- items you want in the response. If additional items exist beyond the
    -- maximum you specify, the @IsTruncated@ response element is @true@.
    --
    -- If you do not include this parameter, the number of items defaults to
    -- 100. Note that IAM might return fewer results, even when there are more
    -- results available. In that case, the @IsTruncated@ response element
    -- returns @true@, and @Marker@ contains a value to include in the
    -- subsequent call that tells the service where to continue from.
    ListPolicies -> Maybe Natural
maxItems :: Prelude.Maybe Prelude.Natural,
    -- | A flag to filter the results to only the attached policies.
    --
    -- When @OnlyAttached@ is @true@, the returned list contains only the
    -- policies that are attached to an IAM user, group, or role. When
    -- @OnlyAttached@ is @false@, or when the parameter is not included, all
    -- policies are returned.
    ListPolicies -> Maybe Bool
onlyAttached :: Prelude.Maybe Prelude.Bool,
    -- | The path prefix for filtering the results. This parameter is optional.
    -- If it is not included, it defaults to a slash (\/), listing all
    -- policies. This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of either a forward slash (\/) by itself or a string that
    -- must begin and end with forward slashes. In addition, it can contain any
    -- ASCII character from the ! (@\\u0021@) through the DEL character
    -- (@\\u007F@), including most punctuation characters, digits, and upper
    -- and lowercased letters.
    ListPolicies -> Maybe Text
pathPrefix :: Prelude.Maybe Prelude.Text,
    -- | The policy usage method to use for filtering the results.
    --
    -- To list only permissions policies,
    -- set @PolicyUsageFilter@ to @PermissionsPolicy@. To list only the
    -- policies used to set permissions boundaries, set the value
    -- to @PermissionsBoundary@.
    --
    -- This parameter is optional. If it is not included, all policies are
    -- returned.
    ListPolicies -> Maybe PolicyUsageType
policyUsageFilter :: Prelude.Maybe PolicyUsageType,
    -- | The scope to use for filtering the results.
    --
    -- To list only Amazon Web Services managed policies, set @Scope@ to @AWS@.
    -- To list only the customer managed policies in your Amazon Web Services
    -- account, set @Scope@ to @Local@.
    --
    -- This parameter is optional. If it is not included, or if it is set to
    -- @All@, all policies are returned.
    ListPolicies -> Maybe PolicyScopeType
scope :: Prelude.Maybe PolicyScopeType
  }
  deriving (ListPolicies -> ListPolicies -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPolicies -> ListPolicies -> Bool
$c/= :: ListPolicies -> ListPolicies -> Bool
== :: ListPolicies -> ListPolicies -> Bool
$c== :: ListPolicies -> ListPolicies -> Bool
Prelude.Eq, ReadPrec [ListPolicies]
ReadPrec ListPolicies
Int -> ReadS ListPolicies
ReadS [ListPolicies]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPolicies]
$creadListPrec :: ReadPrec [ListPolicies]
readPrec :: ReadPrec ListPolicies
$creadPrec :: ReadPrec ListPolicies
readList :: ReadS [ListPolicies]
$creadList :: ReadS [ListPolicies]
readsPrec :: Int -> ReadS ListPolicies
$creadsPrec :: Int -> ReadS ListPolicies
Prelude.Read, Int -> ListPolicies -> ShowS
[ListPolicies] -> ShowS
ListPolicies -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPolicies] -> ShowS
$cshowList :: [ListPolicies] -> ShowS
show :: ListPolicies -> String
$cshow :: ListPolicies -> String
showsPrec :: Int -> ListPolicies -> ShowS
$cshowsPrec :: Int -> ListPolicies -> ShowS
Prelude.Show, forall x. Rep ListPolicies x -> ListPolicies
forall x. ListPolicies -> Rep ListPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPolicies x -> ListPolicies
$cfrom :: forall x. ListPolicies -> Rep ListPolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListPolicies' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'marker', 'listPolicies_marker' - Use this parameter only when paginating results and only after you
-- receive a response indicating that the results are truncated. Set it to
-- the value of the @Marker@ element in the response that you received to
-- indicate where the next call should start.
--
-- 'maxItems', 'listPolicies_maxItems' - Use this only when paginating results to indicate the maximum number of
-- items you want in the response. If additional items exist beyond the
-- maximum you specify, the @IsTruncated@ response element is @true@.
--
-- If you do not include this parameter, the number of items defaults to
-- 100. Note that IAM might return fewer results, even when there are more
-- results available. In that case, the @IsTruncated@ response element
-- returns @true@, and @Marker@ contains a value to include in the
-- subsequent call that tells the service where to continue from.
--
-- 'onlyAttached', 'listPolicies_onlyAttached' - A flag to filter the results to only the attached policies.
--
-- When @OnlyAttached@ is @true@, the returned list contains only the
-- policies that are attached to an IAM user, group, or role. When
-- @OnlyAttached@ is @false@, or when the parameter is not included, all
-- policies are returned.
--
-- 'pathPrefix', 'listPolicies_pathPrefix' - The path prefix for filtering the results. This parameter is optional.
-- If it is not included, it defaults to a slash (\/), listing all
-- policies. This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
--
-- 'policyUsageFilter', 'listPolicies_policyUsageFilter' - The policy usage method to use for filtering the results.
--
-- To list only permissions policies,
-- set @PolicyUsageFilter@ to @PermissionsPolicy@. To list only the
-- policies used to set permissions boundaries, set the value
-- to @PermissionsBoundary@.
--
-- This parameter is optional. If it is not included, all policies are
-- returned.
--
-- 'scope', 'listPolicies_scope' - The scope to use for filtering the results.
--
-- To list only Amazon Web Services managed policies, set @Scope@ to @AWS@.
-- To list only the customer managed policies in your Amazon Web Services
-- account, set @Scope@ to @Local@.
--
-- This parameter is optional. If it is not included, or if it is set to
-- @All@, all policies are returned.
newListPolicies ::
  ListPolicies
newListPolicies :: ListPolicies
newListPolicies =
  ListPolicies'
    { $sel:marker:ListPolicies' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListPolicies' :: Maybe Natural
maxItems = forall a. Maybe a
Prelude.Nothing,
      $sel:onlyAttached:ListPolicies' :: Maybe Bool
onlyAttached = forall a. Maybe a
Prelude.Nothing,
      $sel:pathPrefix:ListPolicies' :: Maybe Text
pathPrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:policyUsageFilter:ListPolicies' :: Maybe PolicyUsageType
policyUsageFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:scope:ListPolicies' :: Maybe PolicyScopeType
scope = forall a. Maybe a
Prelude.Nothing
    }

-- | Use this parameter only when paginating results and only after you
-- receive a response indicating that the results are truncated. Set it to
-- the value of the @Marker@ element in the response that you received to
-- indicate where the next call should start.
listPolicies_marker :: Lens.Lens' ListPolicies (Prelude.Maybe Prelude.Text)
listPolicies_marker :: Lens' ListPolicies (Maybe Text)
listPolicies_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicies' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPolicies' :: ListPolicies -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPolicies
s@ListPolicies' {} Maybe Text
a -> ListPolicies
s {$sel:marker:ListPolicies' :: Maybe Text
marker = Maybe Text
a} :: ListPolicies)

-- | Use this only when paginating results to indicate the maximum number of
-- items you want in the response. If additional items exist beyond the
-- maximum you specify, the @IsTruncated@ response element is @true@.
--
-- If you do not include this parameter, the number of items defaults to
-- 100. Note that IAM might return fewer results, even when there are more
-- results available. In that case, the @IsTruncated@ response element
-- returns @true@, and @Marker@ contains a value to include in the
-- subsequent call that tells the service where to continue from.
listPolicies_maxItems :: Lens.Lens' ListPolicies (Prelude.Maybe Prelude.Natural)
listPolicies_maxItems :: Lens' ListPolicies (Maybe Natural)
listPolicies_maxItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicies' {Maybe Natural
maxItems :: Maybe Natural
$sel:maxItems:ListPolicies' :: ListPolicies -> Maybe Natural
maxItems} -> Maybe Natural
maxItems) (\s :: ListPolicies
s@ListPolicies' {} Maybe Natural
a -> ListPolicies
s {$sel:maxItems:ListPolicies' :: Maybe Natural
maxItems = Maybe Natural
a} :: ListPolicies)

-- | A flag to filter the results to only the attached policies.
--
-- When @OnlyAttached@ is @true@, the returned list contains only the
-- policies that are attached to an IAM user, group, or role. When
-- @OnlyAttached@ is @false@, or when the parameter is not included, all
-- policies are returned.
listPolicies_onlyAttached :: Lens.Lens' ListPolicies (Prelude.Maybe Prelude.Bool)
listPolicies_onlyAttached :: Lens' ListPolicies (Maybe Bool)
listPolicies_onlyAttached = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicies' {Maybe Bool
onlyAttached :: Maybe Bool
$sel:onlyAttached:ListPolicies' :: ListPolicies -> Maybe Bool
onlyAttached} -> Maybe Bool
onlyAttached) (\s :: ListPolicies
s@ListPolicies' {} Maybe Bool
a -> ListPolicies
s {$sel:onlyAttached:ListPolicies' :: Maybe Bool
onlyAttached = Maybe Bool
a} :: ListPolicies)

-- | The path prefix for filtering the results. This parameter is optional.
-- If it is not included, it defaults to a slash (\/), listing all
-- policies. This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
listPolicies_pathPrefix :: Lens.Lens' ListPolicies (Prelude.Maybe Prelude.Text)
listPolicies_pathPrefix :: Lens' ListPolicies (Maybe Text)
listPolicies_pathPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicies' {Maybe Text
pathPrefix :: Maybe Text
$sel:pathPrefix:ListPolicies' :: ListPolicies -> Maybe Text
pathPrefix} -> Maybe Text
pathPrefix) (\s :: ListPolicies
s@ListPolicies' {} Maybe Text
a -> ListPolicies
s {$sel:pathPrefix:ListPolicies' :: Maybe Text
pathPrefix = Maybe Text
a} :: ListPolicies)

-- | The policy usage method to use for filtering the results.
--
-- To list only permissions policies,
-- set @PolicyUsageFilter@ to @PermissionsPolicy@. To list only the
-- policies used to set permissions boundaries, set the value
-- to @PermissionsBoundary@.
--
-- This parameter is optional. If it is not included, all policies are
-- returned.
listPolicies_policyUsageFilter :: Lens.Lens' ListPolicies (Prelude.Maybe PolicyUsageType)
listPolicies_policyUsageFilter :: Lens' ListPolicies (Maybe PolicyUsageType)
listPolicies_policyUsageFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicies' {Maybe PolicyUsageType
policyUsageFilter :: Maybe PolicyUsageType
$sel:policyUsageFilter:ListPolicies' :: ListPolicies -> Maybe PolicyUsageType
policyUsageFilter} -> Maybe PolicyUsageType
policyUsageFilter) (\s :: ListPolicies
s@ListPolicies' {} Maybe PolicyUsageType
a -> ListPolicies
s {$sel:policyUsageFilter:ListPolicies' :: Maybe PolicyUsageType
policyUsageFilter = Maybe PolicyUsageType
a} :: ListPolicies)

-- | The scope to use for filtering the results.
--
-- To list only Amazon Web Services managed policies, set @Scope@ to @AWS@.
-- To list only the customer managed policies in your Amazon Web Services
-- account, set @Scope@ to @Local@.
--
-- This parameter is optional. If it is not included, or if it is set to
-- @All@, all policies are returned.
listPolicies_scope :: Lens.Lens' ListPolicies (Prelude.Maybe PolicyScopeType)
listPolicies_scope :: Lens' ListPolicies (Maybe PolicyScopeType)
listPolicies_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicies' {Maybe PolicyScopeType
scope :: Maybe PolicyScopeType
$sel:scope:ListPolicies' :: ListPolicies -> Maybe PolicyScopeType
scope} -> Maybe PolicyScopeType
scope) (\s :: ListPolicies
s@ListPolicies' {} Maybe PolicyScopeType
a -> ListPolicies
s {$sel:scope:ListPolicies' :: Maybe PolicyScopeType
scope = Maybe PolicyScopeType
a} :: ListPolicies)

instance Core.AWSPager ListPolicies where
  page :: ListPolicies -> AWSResponse ListPolicies -> Maybe ListPolicies
page ListPolicies
rq AWSResponse ListPolicies
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPolicies
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPoliciesResponse (Maybe Bool)
listPoliciesResponse_isTruncated
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. Maybe a -> Bool
Prelude.isNothing
        ( AWSResponse ListPolicies
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPoliciesResponse (Maybe Text)
listPoliciesResponse_marker
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListPolicies
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListPolicies (Maybe Text)
listPolicies_marker
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPolicies
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPoliciesResponse (Maybe Text)
listPoliciesResponse_marker
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListPolicies where
  type AWSResponse ListPolicies = ListPoliciesResponse
  request :: (Service -> Service) -> ListPolicies -> Request ListPolicies
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListPolicies
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPolicies)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ListPoliciesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Bool
-> Maybe Text -> Maybe [Policy] -> Int -> ListPoliciesResponse
ListPoliciesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"IsTruncated")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Marker")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Policies"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListPolicies where
  hashWithSalt :: Int -> ListPolicies -> Int
hashWithSalt Int
_salt ListPolicies' {Maybe Bool
Maybe Natural
Maybe Text
Maybe PolicyScopeType
Maybe PolicyUsageType
scope :: Maybe PolicyScopeType
policyUsageFilter :: Maybe PolicyUsageType
pathPrefix :: Maybe Text
onlyAttached :: Maybe Bool
maxItems :: Maybe Natural
marker :: Maybe Text
$sel:scope:ListPolicies' :: ListPolicies -> Maybe PolicyScopeType
$sel:policyUsageFilter:ListPolicies' :: ListPolicies -> Maybe PolicyUsageType
$sel:pathPrefix:ListPolicies' :: ListPolicies -> Maybe Text
$sel:onlyAttached:ListPolicies' :: ListPolicies -> Maybe Bool
$sel:maxItems:ListPolicies' :: ListPolicies -> Maybe Natural
$sel:marker:ListPolicies' :: ListPolicies -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
marker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxItems
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
onlyAttached
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pathPrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PolicyUsageType
policyUsageFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PolicyScopeType
scope

instance Prelude.NFData ListPolicies where
  rnf :: ListPolicies -> ()
rnf ListPolicies' {Maybe Bool
Maybe Natural
Maybe Text
Maybe PolicyScopeType
Maybe PolicyUsageType
scope :: Maybe PolicyScopeType
policyUsageFilter :: Maybe PolicyUsageType
pathPrefix :: Maybe Text
onlyAttached :: Maybe Bool
maxItems :: Maybe Natural
marker :: Maybe Text
$sel:scope:ListPolicies' :: ListPolicies -> Maybe PolicyScopeType
$sel:policyUsageFilter:ListPolicies' :: ListPolicies -> Maybe PolicyUsageType
$sel:pathPrefix:ListPolicies' :: ListPolicies -> Maybe Text
$sel:onlyAttached:ListPolicies' :: ListPolicies -> Maybe Bool
$sel:maxItems:ListPolicies' :: ListPolicies -> Maybe Natural
$sel:marker:ListPolicies' :: ListPolicies -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
marker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxItems
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
onlyAttached
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pathPrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PolicyUsageType
policyUsageFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PolicyScopeType
scope

instance Data.ToHeaders ListPolicies where
  toHeaders :: ListPolicies -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ListPolicies where
  toPath :: ListPolicies -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery ListPolicies where
  toQuery :: ListPolicies -> QueryString
toQuery ListPolicies' {Maybe Bool
Maybe Natural
Maybe Text
Maybe PolicyScopeType
Maybe PolicyUsageType
scope :: Maybe PolicyScopeType
policyUsageFilter :: Maybe PolicyUsageType
pathPrefix :: Maybe Text
onlyAttached :: Maybe Bool
maxItems :: Maybe Natural
marker :: Maybe Text
$sel:scope:ListPolicies' :: ListPolicies -> Maybe PolicyScopeType
$sel:policyUsageFilter:ListPolicies' :: ListPolicies -> Maybe PolicyUsageType
$sel:pathPrefix:ListPolicies' :: ListPolicies -> Maybe Text
$sel:onlyAttached:ListPolicies' :: ListPolicies -> Maybe Bool
$sel:maxItems:ListPolicies' :: ListPolicies -> Maybe Natural
$sel:marker:ListPolicies' :: ListPolicies -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ListPolicies" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"Marker" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
marker,
        ByteString
"MaxItems" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxItems,
        ByteString
"OnlyAttached" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
onlyAttached,
        ByteString
"PathPrefix" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
pathPrefix,
        ByteString
"PolicyUsageFilter" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe PolicyUsageType
policyUsageFilter,
        ByteString
"Scope" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe PolicyScopeType
scope
      ]

-- | Contains the response to a successful ListPolicies request.
--
-- /See:/ 'newListPoliciesResponse' smart constructor.
data ListPoliciesResponse = ListPoliciesResponse'
  { -- | A flag that indicates whether there are more items to return. If your
    -- results were truncated, you can make a subsequent pagination request
    -- using the @Marker@ request parameter to retrieve more items. Note that
    -- IAM might return fewer than the @MaxItems@ number of results even when
    -- there are more results available. We recommend that you check
    -- @IsTruncated@ after every call to ensure that you receive all your
    -- results.
    ListPoliciesResponse -> Maybe Bool
isTruncated :: Prelude.Maybe Prelude.Bool,
    -- | When @IsTruncated@ is @true@, this element is present and contains the
    -- value to use for the @Marker@ parameter in a subsequent pagination
    -- request.
    ListPoliciesResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | A list of policies.
    ListPoliciesResponse -> Maybe [Policy]
policies :: Prelude.Maybe [Policy],
    -- | The response's http status code.
    ListPoliciesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPoliciesResponse -> ListPoliciesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPoliciesResponse -> ListPoliciesResponse -> Bool
$c/= :: ListPoliciesResponse -> ListPoliciesResponse -> Bool
== :: ListPoliciesResponse -> ListPoliciesResponse -> Bool
$c== :: ListPoliciesResponse -> ListPoliciesResponse -> Bool
Prelude.Eq, ReadPrec [ListPoliciesResponse]
ReadPrec ListPoliciesResponse
Int -> ReadS ListPoliciesResponse
ReadS [ListPoliciesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPoliciesResponse]
$creadListPrec :: ReadPrec [ListPoliciesResponse]
readPrec :: ReadPrec ListPoliciesResponse
$creadPrec :: ReadPrec ListPoliciesResponse
readList :: ReadS [ListPoliciesResponse]
$creadList :: ReadS [ListPoliciesResponse]
readsPrec :: Int -> ReadS ListPoliciesResponse
$creadsPrec :: Int -> ReadS ListPoliciesResponse
Prelude.Read, Int -> ListPoliciesResponse -> ShowS
[ListPoliciesResponse] -> ShowS
ListPoliciesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPoliciesResponse] -> ShowS
$cshowList :: [ListPoliciesResponse] -> ShowS
show :: ListPoliciesResponse -> String
$cshow :: ListPoliciesResponse -> String
showsPrec :: Int -> ListPoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListPoliciesResponse -> ShowS
Prelude.Show, forall x. Rep ListPoliciesResponse x -> ListPoliciesResponse
forall x. ListPoliciesResponse -> Rep ListPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPoliciesResponse x -> ListPoliciesResponse
$cfrom :: forall x. ListPoliciesResponse -> Rep ListPoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPoliciesResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'isTruncated', 'listPoliciesResponse_isTruncated' - A flag that indicates whether there are more items to return. If your
-- results were truncated, you can make a subsequent pagination request
-- using the @Marker@ request parameter to retrieve more items. Note that
-- IAM might return fewer than the @MaxItems@ number of results even when
-- there are more results available. We recommend that you check
-- @IsTruncated@ after every call to ensure that you receive all your
-- results.
--
-- 'marker', 'listPoliciesResponse_marker' - When @IsTruncated@ is @true@, this element is present and contains the
-- value to use for the @Marker@ parameter in a subsequent pagination
-- request.
--
-- 'policies', 'listPoliciesResponse_policies' - A list of policies.
--
-- 'httpStatus', 'listPoliciesResponse_httpStatus' - The response's http status code.
newListPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPoliciesResponse
newListPoliciesResponse :: Int -> ListPoliciesResponse
newListPoliciesResponse Int
pHttpStatus_ =
  ListPoliciesResponse'
    { $sel:isTruncated:ListPoliciesResponse' :: Maybe Bool
isTruncated =
        forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListPoliciesResponse' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing,
      $sel:policies:ListPoliciesResponse' :: Maybe [Policy]
policies = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A flag that indicates whether there are more items to return. If your
-- results were truncated, you can make a subsequent pagination request
-- using the @Marker@ request parameter to retrieve more items. Note that
-- IAM might return fewer than the @MaxItems@ number of results even when
-- there are more results available. We recommend that you check
-- @IsTruncated@ after every call to ensure that you receive all your
-- results.
listPoliciesResponse_isTruncated :: Lens.Lens' ListPoliciesResponse (Prelude.Maybe Prelude.Bool)
listPoliciesResponse_isTruncated :: Lens' ListPoliciesResponse (Maybe Bool)
listPoliciesResponse_isTruncated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPoliciesResponse' {Maybe Bool
isTruncated :: Maybe Bool
$sel:isTruncated:ListPoliciesResponse' :: ListPoliciesResponse -> Maybe Bool
isTruncated} -> Maybe Bool
isTruncated) (\s :: ListPoliciesResponse
s@ListPoliciesResponse' {} Maybe Bool
a -> ListPoliciesResponse
s {$sel:isTruncated:ListPoliciesResponse' :: Maybe Bool
isTruncated = Maybe Bool
a} :: ListPoliciesResponse)

-- | When @IsTruncated@ is @true@, this element is present and contains the
-- value to use for the @Marker@ parameter in a subsequent pagination
-- request.
listPoliciesResponse_marker :: Lens.Lens' ListPoliciesResponse (Prelude.Maybe Prelude.Text)
listPoliciesResponse_marker :: Lens' ListPoliciesResponse (Maybe Text)
listPoliciesResponse_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPoliciesResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPoliciesResponse' :: ListPoliciesResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPoliciesResponse
s@ListPoliciesResponse' {} Maybe Text
a -> ListPoliciesResponse
s {$sel:marker:ListPoliciesResponse' :: Maybe Text
marker = Maybe Text
a} :: ListPoliciesResponse)

-- | A list of policies.
listPoliciesResponse_policies :: Lens.Lens' ListPoliciesResponse (Prelude.Maybe [Policy])
listPoliciesResponse_policies :: Lens' ListPoliciesResponse (Maybe [Policy])
listPoliciesResponse_policies = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPoliciesResponse' {Maybe [Policy]
policies :: Maybe [Policy]
$sel:policies:ListPoliciesResponse' :: ListPoliciesResponse -> Maybe [Policy]
policies} -> Maybe [Policy]
policies) (\s :: ListPoliciesResponse
s@ListPoliciesResponse' {} Maybe [Policy]
a -> ListPoliciesResponse
s {$sel:policies:ListPoliciesResponse' :: Maybe [Policy]
policies = Maybe [Policy]
a} :: ListPoliciesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listPoliciesResponse_httpStatus :: Lens.Lens' ListPoliciesResponse Prelude.Int
listPoliciesResponse_httpStatus :: Lens' ListPoliciesResponse Int
listPoliciesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPoliciesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPoliciesResponse' :: ListPoliciesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPoliciesResponse
s@ListPoliciesResponse' {} Int
a -> ListPoliciesResponse
s {$sel:httpStatus:ListPoliciesResponse' :: Int
httpStatus = Int
a} :: ListPoliciesResponse)

instance Prelude.NFData ListPoliciesResponse where
  rnf :: ListPoliciesResponse -> ()
rnf ListPoliciesResponse' {Int
Maybe Bool
Maybe [Policy]
Maybe Text
httpStatus :: Int
policies :: Maybe [Policy]
marker :: Maybe Text
isTruncated :: Maybe Bool
$sel:httpStatus:ListPoliciesResponse' :: ListPoliciesResponse -> Int
$sel:policies:ListPoliciesResponse' :: ListPoliciesResponse -> Maybe [Policy]
$sel:marker:ListPoliciesResponse' :: ListPoliciesResponse -> Maybe Text
$sel:isTruncated:ListPoliciesResponse' :: ListPoliciesResponse -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isTruncated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
marker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Policy]
policies
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus