{-# 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.ListAttachedUserPolicies
-- 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 user.
--
-- An IAM user can also have inline policies embedded with it. To list the
-- inline policies for a user, use ListUserPolicies. 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 group (or none that match the
-- specified path prefix), the operation returns an empty list.
--
-- This operation returns paginated results.
module Amazonka.IAM.ListAttachedUserPolicies
  ( -- * Creating a Request
    ListAttachedUserPolicies (..),
    newListAttachedUserPolicies,

    -- * Request Lenses
    listAttachedUserPolicies_pathPrefix,
    listAttachedUserPolicies_marker,
    listAttachedUserPolicies_maxItems,
    listAttachedUserPolicies_userName,

    -- * Destructuring the Response
    ListAttachedUserPoliciesResponse (..),
    newListAttachedUserPoliciesResponse,

    -- * Response Lenses
    listAttachedUserPoliciesResponse_attachedPolicies,
    listAttachedUserPoliciesResponse_marker,
    listAttachedUserPoliciesResponse_isTruncated,
    listAttachedUserPoliciesResponse_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:/ 'newListAttachedUserPolicies' smart constructor.
data ListAttachedUserPolicies = ListAttachedUserPolicies'
  { -- | 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.
    ListAttachedUserPolicies -> 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.
    ListAttachedUserPolicies -> 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.
    ListAttachedUserPolicies -> Maybe Natural
maxItems :: Prelude.Maybe Prelude.Natural,
    -- | The name (friendly name, not ARN) of the user 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: _+=,.\@-
    ListAttachedUserPolicies -> Text
userName :: Prelude.Text
  }
  deriving (ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool
(ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool)
-> (ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool)
-> Eq ListAttachedUserPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool
$c/= :: ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool
== :: ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool
$c== :: ListAttachedUserPolicies -> ListAttachedUserPolicies -> Bool
Prelude.Eq, ReadPrec [ListAttachedUserPolicies]
ReadPrec ListAttachedUserPolicies
Int -> ReadS ListAttachedUserPolicies
ReadS [ListAttachedUserPolicies]
(Int -> ReadS ListAttachedUserPolicies)
-> ReadS [ListAttachedUserPolicies]
-> ReadPrec ListAttachedUserPolicies
-> ReadPrec [ListAttachedUserPolicies]
-> Read ListAttachedUserPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttachedUserPolicies]
$creadListPrec :: ReadPrec [ListAttachedUserPolicies]
readPrec :: ReadPrec ListAttachedUserPolicies
$creadPrec :: ReadPrec ListAttachedUserPolicies
readList :: ReadS [ListAttachedUserPolicies]
$creadList :: ReadS [ListAttachedUserPolicies]
readsPrec :: Int -> ReadS ListAttachedUserPolicies
$creadsPrec :: Int -> ReadS ListAttachedUserPolicies
Prelude.Read, Int -> ListAttachedUserPolicies -> ShowS
[ListAttachedUserPolicies] -> ShowS
ListAttachedUserPolicies -> String
(Int -> ListAttachedUserPolicies -> ShowS)
-> (ListAttachedUserPolicies -> String)
-> ([ListAttachedUserPolicies] -> ShowS)
-> Show ListAttachedUserPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttachedUserPolicies] -> ShowS
$cshowList :: [ListAttachedUserPolicies] -> ShowS
show :: ListAttachedUserPolicies -> String
$cshow :: ListAttachedUserPolicies -> String
showsPrec :: Int -> ListAttachedUserPolicies -> ShowS
$cshowsPrec :: Int -> ListAttachedUserPolicies -> ShowS
Prelude.Show, (forall x.
 ListAttachedUserPolicies -> Rep ListAttachedUserPolicies x)
-> (forall x.
    Rep ListAttachedUserPolicies x -> ListAttachedUserPolicies)
-> Generic ListAttachedUserPolicies
forall x.
Rep ListAttachedUserPolicies x -> ListAttachedUserPolicies
forall x.
ListAttachedUserPolicies -> Rep ListAttachedUserPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAttachedUserPolicies x -> ListAttachedUserPolicies
$cfrom :: forall x.
ListAttachedUserPolicies -> Rep ListAttachedUserPolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListAttachedUserPolicies' 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', 'listAttachedUserPolicies_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', 'listAttachedUserPolicies_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', 'listAttachedUserPolicies_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.
--
-- 'userName', 'listAttachedUserPolicies_userName' - The name (friendly name, not ARN) of the user 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: _+=,.\@-
newListAttachedUserPolicies ::
  -- | 'userName'
  Prelude.Text ->
  ListAttachedUserPolicies
newListAttachedUserPolicies :: Text -> ListAttachedUserPolicies
newListAttachedUserPolicies Text
pUserName_ =
  ListAttachedUserPolicies' :: Maybe Text
-> Maybe Text -> Maybe Natural -> Text -> ListAttachedUserPolicies
ListAttachedUserPolicies'
    { $sel:pathPrefix:ListAttachedUserPolicies' :: Maybe Text
pathPrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListAttachedUserPolicies' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListAttachedUserPolicies' :: Maybe Natural
maxItems = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:ListAttachedUserPolicies' :: Text
userName = Text
pUserName_
    }

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

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

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

-- | The name (friendly name, not ARN) of the user 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: _+=,.\@-
listAttachedUserPolicies_userName :: Lens.Lens' ListAttachedUserPolicies Prelude.Text
listAttachedUserPolicies_userName :: (Text -> f Text)
-> ListAttachedUserPolicies -> f ListAttachedUserPolicies
listAttachedUserPolicies_userName = (ListAttachedUserPolicies -> Text)
-> (ListAttachedUserPolicies -> Text -> ListAttachedUserPolicies)
-> Lens ListAttachedUserPolicies ListAttachedUserPolicies Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedUserPolicies' {Text
userName :: Text
$sel:userName:ListAttachedUserPolicies' :: ListAttachedUserPolicies -> Text
userName} -> Text
userName) (\s :: ListAttachedUserPolicies
s@ListAttachedUserPolicies' {} Text
a -> ListAttachedUserPolicies
s {$sel:userName:ListAttachedUserPolicies' :: Text
userName = Text
a} :: ListAttachedUserPolicies)

instance Core.AWSPager ListAttachedUserPolicies where
  page :: ListAttachedUserPolicies
-> AWSResponse ListAttachedUserPolicies
-> Maybe ListAttachedUserPolicies
page ListAttachedUserPolicies
rq AWSResponse ListAttachedUserPolicies
rs
    | Maybe Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAttachedUserPolicies
ListAttachedUserPoliciesResponse
rs
            ListAttachedUserPoliciesResponse
-> Getting (First Bool) ListAttachedUserPoliciesResponse Bool
-> Maybe Bool
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Bool -> Const (First Bool) (Maybe Bool))
-> ListAttachedUserPoliciesResponse
-> Const (First Bool) ListAttachedUserPoliciesResponse
Lens' ListAttachedUserPoliciesResponse (Maybe Bool)
listAttachedUserPoliciesResponse_isTruncated
              ((Maybe Bool -> Const (First Bool) (Maybe Bool))
 -> ListAttachedUserPoliciesResponse
 -> Const (First Bool) ListAttachedUserPoliciesResponse)
-> ((Bool -> Const (First Bool) Bool)
    -> Maybe Bool -> Const (First Bool) (Maybe Bool))
-> Getting (First Bool) ListAttachedUserPoliciesResponse 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 ListAttachedUserPolicies
forall a. Maybe a
Prelude.Nothing
    | Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
        ( AWSResponse ListAttachedUserPolicies
ListAttachedUserPoliciesResponse
rs
            ListAttachedUserPoliciesResponse
-> Getting (First Text) ListAttachedUserPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAttachedUserPoliciesResponse
-> Const (First Text) ListAttachedUserPoliciesResponse
Lens' ListAttachedUserPoliciesResponse (Maybe Text)
listAttachedUserPoliciesResponse_marker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAttachedUserPoliciesResponse
 -> Const (First Text) ListAttachedUserPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAttachedUserPoliciesResponse 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 ListAttachedUserPolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAttachedUserPolicies -> Maybe ListAttachedUserPolicies
forall a. a -> Maybe a
Prelude.Just (ListAttachedUserPolicies -> Maybe ListAttachedUserPolicies)
-> ListAttachedUserPolicies -> Maybe ListAttachedUserPolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAttachedUserPolicies
rq
          ListAttachedUserPolicies
-> (ListAttachedUserPolicies -> ListAttachedUserPolicies)
-> ListAttachedUserPolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAttachedUserPolicies -> Identity ListAttachedUserPolicies
Lens
  ListAttachedUserPolicies
  ListAttachedUserPolicies
  (Maybe Text)
  (Maybe Text)
listAttachedUserPolicies_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAttachedUserPolicies -> Identity ListAttachedUserPolicies)
-> Maybe Text
-> ListAttachedUserPolicies
-> ListAttachedUserPolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAttachedUserPolicies
ListAttachedUserPoliciesResponse
rs
          ListAttachedUserPoliciesResponse
-> Getting (First Text) ListAttachedUserPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAttachedUserPoliciesResponse
-> Const (First Text) ListAttachedUserPoliciesResponse
Lens' ListAttachedUserPoliciesResponse (Maybe Text)
listAttachedUserPoliciesResponse_marker
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAttachedUserPoliciesResponse
 -> Const (First Text) ListAttachedUserPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAttachedUserPoliciesResponse 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 ListAttachedUserPolicies where
  type
    AWSResponse ListAttachedUserPolicies =
      ListAttachedUserPoliciesResponse
  request :: ListAttachedUserPolicies -> Request ListAttachedUserPolicies
request = Service
-> ListAttachedUserPolicies -> Request ListAttachedUserPolicies
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAttachedUserPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAttachedUserPolicies)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListAttachedUserPolicies))
-> Logger
-> Service
-> Proxy ListAttachedUserPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAttachedUserPolicies)))
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
"ListAttachedUserPoliciesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [AttachedPolicy]
-> Maybe Text
-> Maybe Bool
-> Int
-> ListAttachedUserPoliciesResponse
ListAttachedUserPoliciesResponse'
            (Maybe [AttachedPolicy]
 -> Maybe Text
 -> Maybe Bool
 -> Int
 -> ListAttachedUserPoliciesResponse)
-> Either String (Maybe [AttachedPolicy])
-> Either
     String
     (Maybe Text
      -> Maybe Bool -> Int -> ListAttachedUserPoliciesResponse)
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 -> ListAttachedUserPoliciesResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Bool -> Int -> ListAttachedUserPoliciesResponse)
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 -> ListAttachedUserPoliciesResponse)
-> Either String (Maybe Bool)
-> Either String (Int -> ListAttachedUserPoliciesResponse)
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 -> ListAttachedUserPoliciesResponse)
-> Either String Int
-> Either String ListAttachedUserPoliciesResponse
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 ListAttachedUserPolicies

instance Prelude.NFData ListAttachedUserPolicies

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

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

instance Core.ToQuery ListAttachedUserPolicies where
  toQuery :: ListAttachedUserPolicies -> QueryString
toQuery ListAttachedUserPolicies' {Maybe Natural
Maybe Text
Text
userName :: Text
maxItems :: Maybe Natural
marker :: Maybe Text
pathPrefix :: Maybe Text
$sel:userName:ListAttachedUserPolicies' :: ListAttachedUserPolicies -> Text
$sel:maxItems:ListAttachedUserPolicies' :: ListAttachedUserPolicies -> Maybe Natural
$sel:marker:ListAttachedUserPolicies' :: ListAttachedUserPolicies -> Maybe Text
$sel:pathPrefix:ListAttachedUserPolicies' :: ListAttachedUserPolicies -> 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
"ListAttachedUserPolicies" :: 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
"UserName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
userName
      ]

-- | Contains the response to a successful ListAttachedUserPolicies request.
--
-- /See:/ 'newListAttachedUserPoliciesResponse' smart constructor.
data ListAttachedUserPoliciesResponse = ListAttachedUserPoliciesResponse'
  { -- | A list of the attached policies.
    ListAttachedUserPoliciesResponse -> 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.
    ListAttachedUserPoliciesResponse -> 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.
    ListAttachedUserPoliciesResponse -> Maybe Bool
isTruncated :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    ListAttachedUserPoliciesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAttachedUserPoliciesResponse
-> ListAttachedUserPoliciesResponse -> Bool
(ListAttachedUserPoliciesResponse
 -> ListAttachedUserPoliciesResponse -> Bool)
-> (ListAttachedUserPoliciesResponse
    -> ListAttachedUserPoliciesResponse -> Bool)
-> Eq ListAttachedUserPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttachedUserPoliciesResponse
-> ListAttachedUserPoliciesResponse -> Bool
$c/= :: ListAttachedUserPoliciesResponse
-> ListAttachedUserPoliciesResponse -> Bool
== :: ListAttachedUserPoliciesResponse
-> ListAttachedUserPoliciesResponse -> Bool
$c== :: ListAttachedUserPoliciesResponse
-> ListAttachedUserPoliciesResponse -> Bool
Prelude.Eq, ReadPrec [ListAttachedUserPoliciesResponse]
ReadPrec ListAttachedUserPoliciesResponse
Int -> ReadS ListAttachedUserPoliciesResponse
ReadS [ListAttachedUserPoliciesResponse]
(Int -> ReadS ListAttachedUserPoliciesResponse)
-> ReadS [ListAttachedUserPoliciesResponse]
-> ReadPrec ListAttachedUserPoliciesResponse
-> ReadPrec [ListAttachedUserPoliciesResponse]
-> Read ListAttachedUserPoliciesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttachedUserPoliciesResponse]
$creadListPrec :: ReadPrec [ListAttachedUserPoliciesResponse]
readPrec :: ReadPrec ListAttachedUserPoliciesResponse
$creadPrec :: ReadPrec ListAttachedUserPoliciesResponse
readList :: ReadS [ListAttachedUserPoliciesResponse]
$creadList :: ReadS [ListAttachedUserPoliciesResponse]
readsPrec :: Int -> ReadS ListAttachedUserPoliciesResponse
$creadsPrec :: Int -> ReadS ListAttachedUserPoliciesResponse
Prelude.Read, Int -> ListAttachedUserPoliciesResponse -> ShowS
[ListAttachedUserPoliciesResponse] -> ShowS
ListAttachedUserPoliciesResponse -> String
(Int -> ListAttachedUserPoliciesResponse -> ShowS)
-> (ListAttachedUserPoliciesResponse -> String)
-> ([ListAttachedUserPoliciesResponse] -> ShowS)
-> Show ListAttachedUserPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttachedUserPoliciesResponse] -> ShowS
$cshowList :: [ListAttachedUserPoliciesResponse] -> ShowS
show :: ListAttachedUserPoliciesResponse -> String
$cshow :: ListAttachedUserPoliciesResponse -> String
showsPrec :: Int -> ListAttachedUserPoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListAttachedUserPoliciesResponse -> ShowS
Prelude.Show, (forall x.
 ListAttachedUserPoliciesResponse
 -> Rep ListAttachedUserPoliciesResponse x)
-> (forall x.
    Rep ListAttachedUserPoliciesResponse x
    -> ListAttachedUserPoliciesResponse)
-> Generic ListAttachedUserPoliciesResponse
forall x.
Rep ListAttachedUserPoliciesResponse x
-> ListAttachedUserPoliciesResponse
forall x.
ListAttachedUserPoliciesResponse
-> Rep ListAttachedUserPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAttachedUserPoliciesResponse x
-> ListAttachedUserPoliciesResponse
$cfrom :: forall x.
ListAttachedUserPoliciesResponse
-> Rep ListAttachedUserPoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAttachedUserPoliciesResponse' 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', 'listAttachedUserPoliciesResponse_attachedPolicies' - A list of the attached policies.
--
-- 'marker', 'listAttachedUserPoliciesResponse_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', 'listAttachedUserPoliciesResponse_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', 'listAttachedUserPoliciesResponse_httpStatus' - The response's http status code.
newListAttachedUserPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAttachedUserPoliciesResponse
newListAttachedUserPoliciesResponse :: Int -> ListAttachedUserPoliciesResponse
newListAttachedUserPoliciesResponse Int
pHttpStatus_ =
  ListAttachedUserPoliciesResponse' :: Maybe [AttachedPolicy]
-> Maybe Text
-> Maybe Bool
-> Int
-> ListAttachedUserPoliciesResponse
ListAttachedUserPoliciesResponse'
    { $sel:attachedPolicies:ListAttachedUserPoliciesResponse' :: Maybe [AttachedPolicy]
attachedPolicies =
        Maybe [AttachedPolicy]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListAttachedUserPoliciesResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isTruncated:ListAttachedUserPoliciesResponse' :: Maybe Bool
isTruncated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAttachedUserPoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the attached policies.
listAttachedUserPoliciesResponse_attachedPolicies :: Lens.Lens' ListAttachedUserPoliciesResponse (Prelude.Maybe [AttachedPolicy])
listAttachedUserPoliciesResponse_attachedPolicies :: (Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
-> ListAttachedUserPoliciesResponse
-> f ListAttachedUserPoliciesResponse
listAttachedUserPoliciesResponse_attachedPolicies = (ListAttachedUserPoliciesResponse -> Maybe [AttachedPolicy])
-> (ListAttachedUserPoliciesResponse
    -> Maybe [AttachedPolicy] -> ListAttachedUserPoliciesResponse)
-> Lens
     ListAttachedUserPoliciesResponse
     ListAttachedUserPoliciesResponse
     (Maybe [AttachedPolicy])
     (Maybe [AttachedPolicy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedUserPoliciesResponse' {Maybe [AttachedPolicy]
attachedPolicies :: Maybe [AttachedPolicy]
$sel:attachedPolicies:ListAttachedUserPoliciesResponse' :: ListAttachedUserPoliciesResponse -> Maybe [AttachedPolicy]
attachedPolicies} -> Maybe [AttachedPolicy]
attachedPolicies) (\s :: ListAttachedUserPoliciesResponse
s@ListAttachedUserPoliciesResponse' {} Maybe [AttachedPolicy]
a -> ListAttachedUserPoliciesResponse
s {$sel:attachedPolicies:ListAttachedUserPoliciesResponse' :: Maybe [AttachedPolicy]
attachedPolicies = Maybe [AttachedPolicy]
a} :: ListAttachedUserPoliciesResponse) ((Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
 -> ListAttachedUserPoliciesResponse
 -> f ListAttachedUserPoliciesResponse)
-> ((Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
    -> Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
-> (Maybe [AttachedPolicy] -> f (Maybe [AttachedPolicy]))
-> ListAttachedUserPoliciesResponse
-> f ListAttachedUserPoliciesResponse
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.
listAttachedUserPoliciesResponse_marker :: Lens.Lens' ListAttachedUserPoliciesResponse (Prelude.Maybe Prelude.Text)
listAttachedUserPoliciesResponse_marker :: (Maybe Text -> f (Maybe Text))
-> ListAttachedUserPoliciesResponse
-> f ListAttachedUserPoliciesResponse
listAttachedUserPoliciesResponse_marker = (ListAttachedUserPoliciesResponse -> Maybe Text)
-> (ListAttachedUserPoliciesResponse
    -> Maybe Text -> ListAttachedUserPoliciesResponse)
-> Lens' ListAttachedUserPoliciesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedUserPoliciesResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:ListAttachedUserPoliciesResponse' :: ListAttachedUserPoliciesResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListAttachedUserPoliciesResponse
s@ListAttachedUserPoliciesResponse' {} Maybe Text
a -> ListAttachedUserPoliciesResponse
s {$sel:marker:ListAttachedUserPoliciesResponse' :: Maybe Text
marker = Maybe Text
a} :: ListAttachedUserPoliciesResponse)

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

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

instance
  Prelude.NFData
    ListAttachedUserPoliciesResponse