{-# 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.ListAttachedRolePolicies
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all managed policies that are attached to the specified IAM role.
--
-- An IAM role can also have inline policies embedded with it. To list the
-- inline policies for a role, use ListRolePolicies. For information about
-- 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/.
--
-- You can paginate the results using the @MaxItems@ and @Marker@
-- parameters. You can use the @PathPrefix@ parameter to limit the list of
-- policies to only those matching the specified path prefix. If there are
-- no policies attached to the specified role (or none that match the
-- specified path prefix), the operation returns an empty list.
--
-- This operation returns paginated results.
module Amazonka.IAM.ListAttachedRolePolicies
  ( -- * Creating a Request
    ListAttachedRolePolicies (..),
    newListAttachedRolePolicies,

    -- * Request Lenses
    listAttachedRolePolicies_pathPrefix,
    listAttachedRolePolicies_marker,
    listAttachedRolePolicies_maxItems,
    listAttachedRolePolicies_roleName,

    -- * Destructuring the Response
    ListAttachedRolePoliciesResponse (..),
    newListAttachedRolePoliciesResponse,

    -- * Response Lenses
    listAttachedRolePoliciesResponse_attachedPolicies,
    listAttachedRolePoliciesResponse_marker,
    listAttachedRolePoliciesResponse_isTruncated,
    listAttachedRolePoliciesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListAttachedRolePolicies' smart constructor.
data ListAttachedRolePolicies = ListAttachedRolePolicies'
  { -- | 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.
    ListAttachedRolePolicies -> Maybe Text
pathPrefix :: Prelude.Maybe Prelude.Text,
    -- | 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.
    ListAttachedRolePolicies -> 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.
    ListAttachedRolePolicies -> Maybe Natural
maxItems :: Prelude.Maybe Prelude.Natural,
    -- | The name (friendly name, not ARN) of the role to list attached policies
    -- for.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    ListAttachedRolePolicies -> Text
roleName :: Prelude.Text
  }
  deriving (ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool
(ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool)
-> (ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool)
-> Eq ListAttachedRolePolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool
$c/= :: ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool
== :: ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool
$c== :: ListAttachedRolePolicies -> ListAttachedRolePolicies -> Bool
Prelude.Eq, ReadPrec [ListAttachedRolePolicies]
ReadPrec ListAttachedRolePolicies
Int -> ReadS ListAttachedRolePolicies
ReadS [ListAttachedRolePolicies]
(Int -> ReadS ListAttachedRolePolicies)
-> ReadS [ListAttachedRolePolicies]
-> ReadPrec ListAttachedRolePolicies
-> ReadPrec [ListAttachedRolePolicies]
-> Read ListAttachedRolePolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttachedRolePolicies]
$creadListPrec :: ReadPrec [ListAttachedRolePolicies]
readPrec :: ReadPrec ListAttachedRolePolicies
$creadPrec :: ReadPrec ListAttachedRolePolicies
readList :: ReadS [ListAttachedRolePolicies]
$creadList :: ReadS [ListAttachedRolePolicies]
readsPrec :: Int -> ReadS ListAttachedRolePolicies
$creadsPrec :: Int -> ReadS ListAttachedRolePolicies
Prelude.Read, Int -> ListAttachedRolePolicies -> ShowS
[ListAttachedRolePolicies] -> ShowS
ListAttachedRolePolicies -> String
(Int -> ListAttachedRolePolicies -> ShowS)
-> (ListAttachedRolePolicies -> String)
-> ([ListAttachedRolePolicies] -> ShowS)
-> Show ListAttachedRolePolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttachedRolePolicies] -> ShowS
$cshowList :: [ListAttachedRolePolicies] -> ShowS
show :: ListAttachedRolePolicies -> String
$cshow :: ListAttachedRolePolicies -> String
showsPrec :: Int -> ListAttachedRolePolicies -> ShowS
$cshowsPrec :: Int -> ListAttachedRolePolicies -> ShowS
Prelude.Show, (forall x.
 ListAttachedRolePolicies -> Rep ListAttachedRolePolicies x)
-> (forall x.
    Rep ListAttachedRolePolicies x -> ListAttachedRolePolicies)
-> Generic ListAttachedRolePolicies
forall x.
Rep ListAttachedRolePolicies x -> ListAttachedRolePolicies
forall x.
ListAttachedRolePolicies -> Rep ListAttachedRolePolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAttachedRolePolicies x -> ListAttachedRolePolicies
$cfrom :: forall x.
ListAttachedRolePolicies -> Rep ListAttachedRolePolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListAttachedRolePolicies' 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:
--
-- 'pathPrefix', 'listAttachedRolePolicies_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.
--
-- 'marker', 'listAttachedRolePolicies_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', 'listAttachedRolePolicies_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.
--
-- 'roleName', 'listAttachedRolePolicies_roleName' - The name (friendly name, not ARN) of the role to list attached policies
-- for.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
newListAttachedRolePolicies ::
  -- | 'roleName'
  Prelude.Text ->
  ListAttachedRolePolicies
newListAttachedRolePolicies :: Text -> ListAttachedRolePolicies
newListAttachedRolePolicies Text
pRoleName_ =
  ListAttachedRolePolicies' :: Maybe Text
-> Maybe Text -> Maybe Natural -> Text -> ListAttachedRolePolicies
ListAttachedRolePolicies'
    { $sel:pathPrefix:ListAttachedRolePolicies' :: Maybe Text
pathPrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListAttachedRolePolicies' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListAttachedRolePolicies' :: Maybe Natural
maxItems = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:roleName:ListAttachedRolePolicies' :: Text
roleName = Text
pRoleName_
    }

-- | 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.
listAttachedRolePolicies_pathPrefix :: Lens.Lens' ListAttachedRolePolicies (Prelude.Maybe Prelude.Text)
listAttachedRolePolicies_pathPrefix :: (Maybe Text -> f (Maybe Text))
-> ListAttachedRolePolicies -> f ListAttachedRolePolicies
listAttachedRolePolicies_pathPrefix = (ListAttachedRolePolicies -> Maybe Text)
-> (ListAttachedRolePolicies
    -> Maybe Text -> ListAttachedRolePolicies)
-> Lens
     ListAttachedRolePolicies
     ListAttachedRolePolicies
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedRolePolicies' {Maybe Text
pathPrefix :: Maybe Text
$sel:pathPrefix:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Maybe Text
pathPrefix} -> Maybe Text
pathPrefix) (\s :: ListAttachedRolePolicies
s@ListAttachedRolePolicies' {} Maybe Text
a -> ListAttachedRolePolicies
s {$sel:pathPrefix:ListAttachedRolePolicies' :: Maybe Text
pathPrefix = Maybe Text
a} :: ListAttachedRolePolicies)

-- | 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.
listAttachedRolePolicies_marker :: Lens.Lens' ListAttachedRolePolicies (Prelude.Maybe Prelude.Text)
listAttachedRolePolicies_marker :: (Maybe Text -> f (Maybe Text))
-> ListAttachedRolePolicies -> f ListAttachedRolePolicies
listAttachedRolePolicies_marker = (ListAttachedRolePolicies -> Maybe Text)
-> (ListAttachedRolePolicies
    -> Maybe Text -> ListAttachedRolePolicies)
-> Lens
     ListAttachedRolePolicies
     ListAttachedRolePolicies
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedRolePolicies' {Maybe Text
marker :: Maybe Text
$sel:marker:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListAttachedRolePolicies
s@ListAttachedRolePolicies' {} Maybe Text
a -> ListAttachedRolePolicies
s {$sel:marker:ListAttachedRolePolicies' :: Maybe Text
marker = Maybe Text
a} :: ListAttachedRolePolicies)

-- | 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.
listAttachedRolePolicies_maxItems :: Lens.Lens' ListAttachedRolePolicies (Prelude.Maybe Prelude.Natural)
listAttachedRolePolicies_maxItems :: (Maybe Natural -> f (Maybe Natural))
-> ListAttachedRolePolicies -> f ListAttachedRolePolicies
listAttachedRolePolicies_maxItems = (ListAttachedRolePolicies -> Maybe Natural)
-> (ListAttachedRolePolicies
    -> Maybe Natural -> ListAttachedRolePolicies)
-> Lens
     ListAttachedRolePolicies
     ListAttachedRolePolicies
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedRolePolicies' {Maybe Natural
maxItems :: Maybe Natural
$sel:maxItems:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Maybe Natural
maxItems} -> Maybe Natural
maxItems) (\s :: ListAttachedRolePolicies
s@ListAttachedRolePolicies' {} Maybe Natural
a -> ListAttachedRolePolicies
s {$sel:maxItems:ListAttachedRolePolicies' :: Maybe Natural
maxItems = Maybe Natural
a} :: ListAttachedRolePolicies)

-- | The name (friendly name, not ARN) of the role to list attached policies
-- for.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
listAttachedRolePolicies_roleName :: Lens.Lens' ListAttachedRolePolicies Prelude.Text
listAttachedRolePolicies_roleName :: (Text -> f Text)
-> ListAttachedRolePolicies -> f ListAttachedRolePolicies
listAttachedRolePolicies_roleName = (ListAttachedRolePolicies -> Text)
-> (ListAttachedRolePolicies -> Text -> ListAttachedRolePolicies)
-> Lens ListAttachedRolePolicies ListAttachedRolePolicies Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedRolePolicies' {Text
roleName :: Text
$sel:roleName:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Text
roleName} -> Text
roleName) (\s :: ListAttachedRolePolicies
s@ListAttachedRolePolicies' {} Text
a -> ListAttachedRolePolicies
s {$sel:roleName:ListAttachedRolePolicies' :: Text
roleName = Text
a} :: ListAttachedRolePolicies)

instance Core.AWSPager ListAttachedRolePolicies where
  page :: ListAttachedRolePolicies
-> AWSResponse ListAttachedRolePolicies
-> Maybe ListAttachedRolePolicies
page ListAttachedRolePolicies
rq AWSResponse ListAttachedRolePolicies
rs
    | Maybe Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAttachedRolePolicies
ListAttachedRolePoliciesResponse
rs
            ListAttachedRolePoliciesResponse
-> Getting (First Bool) ListAttachedRolePoliciesResponse Bool
-> Maybe Bool
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Bool -> Const (First Bool) (Maybe Bool))
-> ListAttachedRolePoliciesResponse
-> Const (First Bool) ListAttachedRolePoliciesResponse
Lens' ListAttachedRolePoliciesResponse (Maybe Bool)
listAttachedRolePoliciesResponse_isTruncated
              ((Maybe Bool -> Const (First Bool) (Maybe Bool))
 -> ListAttachedRolePoliciesResponse
 -> Const (First Bool) ListAttachedRolePoliciesResponse)
-> ((Bool -> Const (First Bool) Bool)
    -> Maybe Bool -> Const (First Bool) (Maybe Bool))
-> Getting (First Bool) ListAttachedRolePoliciesResponse Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Bool -> Const (First Bool) Bool)
-> Maybe Bool -> Const (First Bool) (Maybe Bool)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListAttachedRolePolicies
forall a. Maybe a
Prelude.Nothing
    | Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
        ( AWSResponse ListAttachedRolePolicies
ListAttachedRolePoliciesResponse
rs
            ListAttachedRolePoliciesResponse
-> Getting (First Text) ListAttachedRolePoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAttachedRolePoliciesResponse
-> Const (First Text) ListAttachedRolePoliciesResponse
Lens' ListAttachedRolePoliciesResponse (Maybe Text)
listAttachedRolePoliciesResponse_marker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAttachedRolePoliciesResponse
 -> Const (First Text) ListAttachedRolePoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAttachedRolePoliciesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListAttachedRolePolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAttachedRolePolicies -> Maybe ListAttachedRolePolicies
forall a. a -> Maybe a
Prelude.Just (ListAttachedRolePolicies -> Maybe ListAttachedRolePolicies)
-> ListAttachedRolePolicies -> Maybe ListAttachedRolePolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAttachedRolePolicies
rq
          ListAttachedRolePolicies
-> (ListAttachedRolePolicies -> ListAttachedRolePolicies)
-> ListAttachedRolePolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAttachedRolePolicies -> Identity ListAttachedRolePolicies
Lens
  ListAttachedRolePolicies
  ListAttachedRolePolicies
  (Maybe Text)
  (Maybe Text)
listAttachedRolePolicies_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAttachedRolePolicies -> Identity ListAttachedRolePolicies)
-> Maybe Text
-> ListAttachedRolePolicies
-> ListAttachedRolePolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAttachedRolePolicies
ListAttachedRolePoliciesResponse
rs
          ListAttachedRolePoliciesResponse
-> Getting (First Text) ListAttachedRolePoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAttachedRolePoliciesResponse
-> Const (First Text) ListAttachedRolePoliciesResponse
Lens' ListAttachedRolePoliciesResponse (Maybe Text)
listAttachedRolePoliciesResponse_marker
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAttachedRolePoliciesResponse
 -> Const (First Text) ListAttachedRolePoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAttachedRolePoliciesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

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

instance Prelude.Hashable ListAttachedRolePolicies

instance Prelude.NFData ListAttachedRolePolicies

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

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

instance Core.ToQuery ListAttachedRolePolicies where
  toQuery :: ListAttachedRolePolicies -> QueryString
toQuery ListAttachedRolePolicies' {Maybe Natural
Maybe Text
Text
roleName :: Text
maxItems :: Maybe Natural
marker :: Maybe Text
pathPrefix :: Maybe Text
$sel:roleName:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Text
$sel:maxItems:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Maybe Natural
$sel:marker:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Maybe Text
$sel:pathPrefix:ListAttachedRolePolicies' :: ListAttachedRolePolicies -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListAttachedRolePolicies" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"PathPrefix" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
pathPrefix,
        ByteString
"Marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"MaxItems" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxItems,
        ByteString
"RoleName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleName
      ]

-- | Contains the response to a successful ListAttachedRolePolicies request.
--
-- /See:/ 'newListAttachedRolePoliciesResponse' smart constructor.
data ListAttachedRolePoliciesResponse = ListAttachedRolePoliciesResponse'
  { -- | A list of the attached policies.
    ListAttachedRolePoliciesResponse -> Maybe [AttachedPolicy]
attachedPolicies :: Prelude.Maybe [AttachedPolicy],
    -- | When @IsTruncated@ is @true@, this element is present and contains the
    -- value to use for the @Marker@ parameter in a subsequent pagination
    -- request.
    ListAttachedRolePoliciesResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | 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.
    ListAttachedRolePoliciesResponse -> Maybe Bool
isTruncated :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    ListAttachedRolePoliciesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAttachedRolePoliciesResponse
-> ListAttachedRolePoliciesResponse -> Bool
(ListAttachedRolePoliciesResponse
 -> ListAttachedRolePoliciesResponse -> Bool)
-> (ListAttachedRolePoliciesResponse
    -> ListAttachedRolePoliciesResponse -> Bool)
-> Eq ListAttachedRolePoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttachedRolePoliciesResponse
-> ListAttachedRolePoliciesResponse -> Bool
$c/= :: ListAttachedRolePoliciesResponse
-> ListAttachedRolePoliciesResponse -> Bool
== :: ListAttachedRolePoliciesResponse
-> ListAttachedRolePoliciesResponse -> Bool
$c== :: ListAttachedRolePoliciesResponse
-> ListAttachedRolePoliciesResponse -> Bool
Prelude.Eq, ReadPrec [ListAttachedRolePoliciesResponse]
ReadPrec ListAttachedRolePoliciesResponse
Int -> ReadS ListAttachedRolePoliciesResponse
ReadS [ListAttachedRolePoliciesResponse]
(Int -> ReadS ListAttachedRolePoliciesResponse)
-> ReadS [ListAttachedRolePoliciesResponse]
-> ReadPrec ListAttachedRolePoliciesResponse
-> ReadPrec [ListAttachedRolePoliciesResponse]
-> Read ListAttachedRolePoliciesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttachedRolePoliciesResponse]
$creadListPrec :: ReadPrec [ListAttachedRolePoliciesResponse]
readPrec :: ReadPrec ListAttachedRolePoliciesResponse
$creadPrec :: ReadPrec ListAttachedRolePoliciesResponse
readList :: ReadS [ListAttachedRolePoliciesResponse]
$creadList :: ReadS [ListAttachedRolePoliciesResponse]
readsPrec :: Int -> ReadS ListAttachedRolePoliciesResponse
$creadsPrec :: Int -> ReadS ListAttachedRolePoliciesResponse
Prelude.Read, Int -> ListAttachedRolePoliciesResponse -> ShowS
[ListAttachedRolePoliciesResponse] -> ShowS
ListAttachedRolePoliciesResponse -> String
(Int -> ListAttachedRolePoliciesResponse -> ShowS)
-> (ListAttachedRolePoliciesResponse -> String)
-> ([ListAttachedRolePoliciesResponse] -> ShowS)
-> Show ListAttachedRolePoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttachedRolePoliciesResponse] -> ShowS
$cshowList :: [ListAttachedRolePoliciesResponse] -> ShowS
show :: ListAttachedRolePoliciesResponse -> String
$cshow :: ListAttachedRolePoliciesResponse -> String
showsPrec :: Int -> ListAttachedRolePoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListAttachedRolePoliciesResponse -> ShowS
Prelude.Show, (forall x.
 ListAttachedRolePoliciesResponse
 -> Rep ListAttachedRolePoliciesResponse x)
-> (forall x.
    Rep ListAttachedRolePoliciesResponse x
    -> ListAttachedRolePoliciesResponse)
-> Generic ListAttachedRolePoliciesResponse
forall x.
Rep ListAttachedRolePoliciesResponse x
-> ListAttachedRolePoliciesResponse
forall x.
ListAttachedRolePoliciesResponse
-> Rep ListAttachedRolePoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAttachedRolePoliciesResponse x
-> ListAttachedRolePoliciesResponse
$cfrom :: forall x.
ListAttachedRolePoliciesResponse
-> Rep ListAttachedRolePoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAttachedRolePoliciesResponse' 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:
--
-- 'attachedPolicies', 'listAttachedRolePoliciesResponse_attachedPolicies' - A list of the attached policies.
--
-- 'marker', 'listAttachedRolePoliciesResponse_marker' - When @IsTruncated@ is @true@, this element is present and contains the
-- value to use for the @Marker@ parameter in a subsequent pagination
-- request.
--
-- 'isTruncated', 'listAttachedRolePoliciesResponse_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.
--
-- 'httpStatus', 'listAttachedRolePoliciesResponse_httpStatus' - The response's http status code.
newListAttachedRolePoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAttachedRolePoliciesResponse
newListAttachedRolePoliciesResponse :: Int -> ListAttachedRolePoliciesResponse
newListAttachedRolePoliciesResponse Int
pHttpStatus_ =
  ListAttachedRolePoliciesResponse' :: Maybe [AttachedPolicy]
-> Maybe Text
-> Maybe Bool
-> Int
-> ListAttachedRolePoliciesResponse
ListAttachedRolePoliciesResponse'
    { $sel:attachedPolicies:ListAttachedRolePoliciesResponse' :: Maybe [AttachedPolicy]
attachedPolicies =
        Maybe [AttachedPolicy]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListAttachedRolePoliciesResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isTruncated:ListAttachedRolePoliciesResponse' :: Maybe Bool
isTruncated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAttachedRolePoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the attached policies.
listAttachedRolePoliciesResponse_attachedPolicies :: Lens.Lens' ListAttachedRolePoliciesResponse (Prelude.Maybe [AttachedPolicy])
listAttachedRolePoliciesResponse_attachedPolicies :: (Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
-> ListAttachedRolePoliciesResponse
-> f ListAttachedRolePoliciesResponse
listAttachedRolePoliciesResponse_attachedPolicies = (ListAttachedRolePoliciesResponse -> Maybe [AttachedPolicy])
-> (ListAttachedRolePoliciesResponse
    -> Maybe [AttachedPolicy] -> ListAttachedRolePoliciesResponse)
-> Lens
     ListAttachedRolePoliciesResponse
     ListAttachedRolePoliciesResponse
     (Maybe [AttachedPolicy])
     (Maybe [AttachedPolicy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedRolePoliciesResponse' {Maybe [AttachedPolicy]
attachedPolicies :: Maybe [AttachedPolicy]
$sel:attachedPolicies:ListAttachedRolePoliciesResponse' :: ListAttachedRolePoliciesResponse -> Maybe [AttachedPolicy]
attachedPolicies} -> Maybe [AttachedPolicy]
attachedPolicies) (\s :: ListAttachedRolePoliciesResponse
s@ListAttachedRolePoliciesResponse' {} Maybe [AttachedPolicy]
a -> ListAttachedRolePoliciesResponse
s {$sel:attachedPolicies:ListAttachedRolePoliciesResponse' :: Maybe [AttachedPolicy]
attachedPolicies = Maybe [AttachedPolicy]
a} :: ListAttachedRolePoliciesResponse) ((Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
 -> ListAttachedRolePoliciesResponse
 -> f ListAttachedRolePoliciesResponse)
-> ((Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
    -> Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
-> (Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
-> ListAttachedRolePoliciesResponse
-> f ListAttachedRolePoliciesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttachedPolicy] [AttachedPolicy] [AttachedPolicy] [AttachedPolicy]
-> Iso
     (Maybe [AttachedPolicy])
     (Maybe [AttachedPolicy])
     (Maybe [AttachedPolicy])
     (Maybe [AttachedPolicy])
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 AnIso
  [AttachedPolicy] [AttachedPolicy] [AttachedPolicy] [AttachedPolicy]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | 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.
listAttachedRolePoliciesResponse_isTruncated :: Lens.Lens' ListAttachedRolePoliciesResponse (Prelude.Maybe Prelude.Bool)
listAttachedRolePoliciesResponse_isTruncated :: (Maybe Bool -> f (Maybe Bool))
-> ListAttachedRolePoliciesResponse
-> f ListAttachedRolePoliciesResponse
listAttachedRolePoliciesResponse_isTruncated = (ListAttachedRolePoliciesResponse -> Maybe Bool)
-> (ListAttachedRolePoliciesResponse
    -> Maybe Bool -> ListAttachedRolePoliciesResponse)
-> Lens' ListAttachedRolePoliciesResponse (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedRolePoliciesResponse' {Maybe Bool
isTruncated :: Maybe Bool
$sel:isTruncated:ListAttachedRolePoliciesResponse' :: ListAttachedRolePoliciesResponse -> Maybe Bool
isTruncated} -> Maybe Bool
isTruncated) (\s :: ListAttachedRolePoliciesResponse
s@ListAttachedRolePoliciesResponse' {} Maybe Bool
a -> ListAttachedRolePoliciesResponse
s {$sel:isTruncated:ListAttachedRolePoliciesResponse' :: Maybe Bool
isTruncated = Maybe Bool
a} :: ListAttachedRolePoliciesResponse)

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

instance
  Prelude.NFData
    ListAttachedRolePoliciesResponse