{-# 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.ListPolicyVersions
-- 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 information about the versions of the specified managed policy,
-- including the version that is currently set as the policy\'s default
-- version.
--
-- 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/.
--
-- This operation returns paginated results.
module Amazonka.IAM.ListPolicyVersions
  ( -- * Creating a Request
    ListPolicyVersions (..),
    newListPolicyVersions,

    -- * Request Lenses
    listPolicyVersions_marker,
    listPolicyVersions_maxItems,
    listPolicyVersions_policyArn,

    -- * Destructuring the Response
    ListPolicyVersionsResponse (..),
    newListPolicyVersionsResponse,

    -- * Response Lenses
    listPolicyVersionsResponse_versions,
    listPolicyVersionsResponse_marker,
    listPolicyVersionsResponse_isTruncated,
    listPolicyVersionsResponse_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:/ 'newListPolicyVersions' smart constructor.
data ListPolicyVersions = ListPolicyVersions'
  { -- | 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.
    ListPolicyVersions -> 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.
    ListPolicyVersions -> Maybe Natural
maxItems :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the IAM policy for which you want the
    -- versions.
    --
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /Amazon Web Services General Reference/.
    ListPolicyVersions -> Text
policyArn :: Prelude.Text
  }
  deriving (ListPolicyVersions -> ListPolicyVersions -> Bool
(ListPolicyVersions -> ListPolicyVersions -> Bool)
-> (ListPolicyVersions -> ListPolicyVersions -> Bool)
-> Eq ListPolicyVersions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPolicyVersions -> ListPolicyVersions -> Bool
$c/= :: ListPolicyVersions -> ListPolicyVersions -> Bool
== :: ListPolicyVersions -> ListPolicyVersions -> Bool
$c== :: ListPolicyVersions -> ListPolicyVersions -> Bool
Prelude.Eq, ReadPrec [ListPolicyVersions]
ReadPrec ListPolicyVersions
Int -> ReadS ListPolicyVersions
ReadS [ListPolicyVersions]
(Int -> ReadS ListPolicyVersions)
-> ReadS [ListPolicyVersions]
-> ReadPrec ListPolicyVersions
-> ReadPrec [ListPolicyVersions]
-> Read ListPolicyVersions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPolicyVersions]
$creadListPrec :: ReadPrec [ListPolicyVersions]
readPrec :: ReadPrec ListPolicyVersions
$creadPrec :: ReadPrec ListPolicyVersions
readList :: ReadS [ListPolicyVersions]
$creadList :: ReadS [ListPolicyVersions]
readsPrec :: Int -> ReadS ListPolicyVersions
$creadsPrec :: Int -> ReadS ListPolicyVersions
Prelude.Read, Int -> ListPolicyVersions -> ShowS
[ListPolicyVersions] -> ShowS
ListPolicyVersions -> String
(Int -> ListPolicyVersions -> ShowS)
-> (ListPolicyVersions -> String)
-> ([ListPolicyVersions] -> ShowS)
-> Show ListPolicyVersions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPolicyVersions] -> ShowS
$cshowList :: [ListPolicyVersions] -> ShowS
show :: ListPolicyVersions -> String
$cshow :: ListPolicyVersions -> String
showsPrec :: Int -> ListPolicyVersions -> ShowS
$cshowsPrec :: Int -> ListPolicyVersions -> ShowS
Prelude.Show, (forall x. ListPolicyVersions -> Rep ListPolicyVersions x)
-> (forall x. Rep ListPolicyVersions x -> ListPolicyVersions)
-> Generic ListPolicyVersions
forall x. Rep ListPolicyVersions x -> ListPolicyVersions
forall x. ListPolicyVersions -> Rep ListPolicyVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPolicyVersions x -> ListPolicyVersions
$cfrom :: forall x. ListPolicyVersions -> Rep ListPolicyVersions x
Prelude.Generic)

-- |
-- Create a value of 'ListPolicyVersions' 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', 'listPolicyVersions_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', 'listPolicyVersions_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.
--
-- 'policyArn', 'listPolicyVersions_policyArn' - The Amazon Resource Name (ARN) of the IAM policy for which you want the
-- versions.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /Amazon Web Services General Reference/.
newListPolicyVersions ::
  -- | 'policyArn'
  Prelude.Text ->
  ListPolicyVersions
newListPolicyVersions :: Text -> ListPolicyVersions
newListPolicyVersions Text
pPolicyArn_ =
  ListPolicyVersions' :: Maybe Text -> Maybe Natural -> Text -> ListPolicyVersions
ListPolicyVersions'
    { $sel:marker:ListPolicyVersions' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListPolicyVersions' :: Maybe Natural
maxItems = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:policyArn:ListPolicyVersions' :: Text
policyArn = Text
pPolicyArn_
    }

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

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

-- | The Amazon Resource Name (ARN) of the IAM policy for which you want the
-- versions.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /Amazon Web Services General Reference/.
listPolicyVersions_policyArn :: Lens.Lens' ListPolicyVersions Prelude.Text
listPolicyVersions_policyArn :: (Text -> f Text) -> ListPolicyVersions -> f ListPolicyVersions
listPolicyVersions_policyArn = (ListPolicyVersions -> Text)
-> (ListPolicyVersions -> Text -> ListPolicyVersions)
-> Lens ListPolicyVersions ListPolicyVersions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyVersions' {Text
policyArn :: Text
$sel:policyArn:ListPolicyVersions' :: ListPolicyVersions -> Text
policyArn} -> Text
policyArn) (\s :: ListPolicyVersions
s@ListPolicyVersions' {} Text
a -> ListPolicyVersions
s {$sel:policyArn:ListPolicyVersions' :: Text
policyArn = Text
a} :: ListPolicyVersions)

instance Core.AWSPager ListPolicyVersions where
  page :: ListPolicyVersions
-> AWSResponse ListPolicyVersions -> Maybe ListPolicyVersions
page ListPolicyVersions
rq AWSResponse ListPolicyVersions
rs
    | Maybe Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPolicyVersions
ListPolicyVersionsResponse
rs
            ListPolicyVersionsResponse
-> Getting (First Bool) ListPolicyVersionsResponse Bool
-> Maybe Bool
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Bool -> Const (First Bool) (Maybe Bool))
-> ListPolicyVersionsResponse
-> Const (First Bool) ListPolicyVersionsResponse
Lens' ListPolicyVersionsResponse (Maybe Bool)
listPolicyVersionsResponse_isTruncated
              ((Maybe Bool -> Const (First Bool) (Maybe Bool))
 -> ListPolicyVersionsResponse
 -> Const (First Bool) ListPolicyVersionsResponse)
-> ((Bool -> Const (First Bool) Bool)
    -> Maybe Bool -> Const (First Bool) (Maybe Bool))
-> Getting (First Bool) ListPolicyVersionsResponse 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 ListPolicyVersions
forall a. Maybe a
Prelude.Nothing
    | Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
        ( AWSResponse ListPolicyVersions
ListPolicyVersionsResponse
rs
            ListPolicyVersionsResponse
-> Getting (First Text) ListPolicyVersionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPolicyVersionsResponse
-> Const (First Text) ListPolicyVersionsResponse
Lens' ListPolicyVersionsResponse (Maybe Text)
listPolicyVersionsResponse_marker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPolicyVersionsResponse
 -> Const (First Text) ListPolicyVersionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPolicyVersionsResponse 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 ListPolicyVersions
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListPolicyVersions -> Maybe ListPolicyVersions
forall a. a -> Maybe a
Prelude.Just (ListPolicyVersions -> Maybe ListPolicyVersions)
-> ListPolicyVersions -> Maybe ListPolicyVersions
forall a b. (a -> b) -> a -> b
Prelude.$
        ListPolicyVersions
rq
          ListPolicyVersions
-> (ListPolicyVersions -> ListPolicyVersions) -> ListPolicyVersions
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListPolicyVersions -> Identity ListPolicyVersions
Lens
  ListPolicyVersions ListPolicyVersions (Maybe Text) (Maybe Text)
listPolicyVersions_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> ListPolicyVersions -> Identity ListPolicyVersions)
-> Maybe Text -> ListPolicyVersions -> ListPolicyVersions
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPolicyVersions
ListPolicyVersionsResponse
rs
          ListPolicyVersionsResponse
-> Getting (First Text) ListPolicyVersionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPolicyVersionsResponse
-> Const (First Text) ListPolicyVersionsResponse
Lens' ListPolicyVersionsResponse (Maybe Text)
listPolicyVersionsResponse_marker
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPolicyVersionsResponse
 -> Const (First Text) ListPolicyVersionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPolicyVersionsResponse 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 ListPolicyVersions where
  type
    AWSResponse ListPolicyVersions =
      ListPolicyVersionsResponse
  request :: ListPolicyVersions -> Request ListPolicyVersions
request = Service -> ListPolicyVersions -> Request ListPolicyVersions
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListPolicyVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListPolicyVersions)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListPolicyVersions))
-> Logger
-> Service
-> Proxy ListPolicyVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListPolicyVersions)))
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
"ListPolicyVersionsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [PolicyVersion]
-> Maybe Text -> Maybe Bool -> Int -> ListPolicyVersionsResponse
ListPolicyVersionsResponse'
            (Maybe [PolicyVersion]
 -> Maybe Text -> Maybe Bool -> Int -> ListPolicyVersionsResponse)
-> Either String (Maybe [PolicyVersion])
-> Either
     String
     (Maybe Text -> Maybe Bool -> Int -> ListPolicyVersionsResponse)
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
"Versions" 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 [PolicyVersion]))
-> Either String (Maybe [PolicyVersion])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [PolicyVersion])
-> [Node] -> Either String (Maybe [PolicyVersion])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [PolicyVersion]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either
  String
  (Maybe Text -> Maybe Bool -> Int -> ListPolicyVersionsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> Int -> ListPolicyVersionsResponse)
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 -> ListPolicyVersionsResponse)
-> Either String (Maybe Bool)
-> Either String (Int -> ListPolicyVersionsResponse)
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 -> ListPolicyVersionsResponse)
-> Either String Int -> Either String ListPolicyVersionsResponse
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 ListPolicyVersions

instance Prelude.NFData ListPolicyVersions

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

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

instance Core.ToQuery ListPolicyVersions where
  toQuery :: ListPolicyVersions -> QueryString
toQuery ListPolicyVersions' {Maybe Natural
Maybe Text
Text
policyArn :: Text
maxItems :: Maybe Natural
marker :: Maybe Text
$sel:policyArn:ListPolicyVersions' :: ListPolicyVersions -> Text
$sel:maxItems:ListPolicyVersions' :: ListPolicyVersions -> Maybe Natural
$sel:marker:ListPolicyVersions' :: ListPolicyVersions -> 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
"ListPolicyVersions" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        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
"PolicyArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
policyArn
      ]

-- | Contains the response to a successful ListPolicyVersions request.
--
-- /See:/ 'newListPolicyVersionsResponse' smart constructor.
data ListPolicyVersionsResponse = ListPolicyVersionsResponse'
  { -- | A list of policy versions.
    --
    -- For more information about managed policy versions, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html Versioning for managed policies>
    -- in the /IAM User Guide/.
    ListPolicyVersionsResponse -> Maybe [PolicyVersion]
versions :: Prelude.Maybe [PolicyVersion],
    -- | When @IsTruncated@ is @true@, this element is present and contains the
    -- value to use for the @Marker@ parameter in a subsequent pagination
    -- request.
    ListPolicyVersionsResponse -> 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.
    ListPolicyVersionsResponse -> Maybe Bool
isTruncated :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    ListPolicyVersionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPolicyVersionsResponse -> ListPolicyVersionsResponse -> Bool
(ListPolicyVersionsResponse -> ListPolicyVersionsResponse -> Bool)
-> (ListPolicyVersionsResponse
    -> ListPolicyVersionsResponse -> Bool)
-> Eq ListPolicyVersionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPolicyVersionsResponse -> ListPolicyVersionsResponse -> Bool
$c/= :: ListPolicyVersionsResponse -> ListPolicyVersionsResponse -> Bool
== :: ListPolicyVersionsResponse -> ListPolicyVersionsResponse -> Bool
$c== :: ListPolicyVersionsResponse -> ListPolicyVersionsResponse -> Bool
Prelude.Eq, ReadPrec [ListPolicyVersionsResponse]
ReadPrec ListPolicyVersionsResponse
Int -> ReadS ListPolicyVersionsResponse
ReadS [ListPolicyVersionsResponse]
(Int -> ReadS ListPolicyVersionsResponse)
-> ReadS [ListPolicyVersionsResponse]
-> ReadPrec ListPolicyVersionsResponse
-> ReadPrec [ListPolicyVersionsResponse]
-> Read ListPolicyVersionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPolicyVersionsResponse]
$creadListPrec :: ReadPrec [ListPolicyVersionsResponse]
readPrec :: ReadPrec ListPolicyVersionsResponse
$creadPrec :: ReadPrec ListPolicyVersionsResponse
readList :: ReadS [ListPolicyVersionsResponse]
$creadList :: ReadS [ListPolicyVersionsResponse]
readsPrec :: Int -> ReadS ListPolicyVersionsResponse
$creadsPrec :: Int -> ReadS ListPolicyVersionsResponse
Prelude.Read, Int -> ListPolicyVersionsResponse -> ShowS
[ListPolicyVersionsResponse] -> ShowS
ListPolicyVersionsResponse -> String
(Int -> ListPolicyVersionsResponse -> ShowS)
-> (ListPolicyVersionsResponse -> String)
-> ([ListPolicyVersionsResponse] -> ShowS)
-> Show ListPolicyVersionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPolicyVersionsResponse] -> ShowS
$cshowList :: [ListPolicyVersionsResponse] -> ShowS
show :: ListPolicyVersionsResponse -> String
$cshow :: ListPolicyVersionsResponse -> String
showsPrec :: Int -> ListPolicyVersionsResponse -> ShowS
$cshowsPrec :: Int -> ListPolicyVersionsResponse -> ShowS
Prelude.Show, (forall x.
 ListPolicyVersionsResponse -> Rep ListPolicyVersionsResponse x)
-> (forall x.
    Rep ListPolicyVersionsResponse x -> ListPolicyVersionsResponse)
-> Generic ListPolicyVersionsResponse
forall x.
Rep ListPolicyVersionsResponse x -> ListPolicyVersionsResponse
forall x.
ListPolicyVersionsResponse -> Rep ListPolicyVersionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPolicyVersionsResponse x -> ListPolicyVersionsResponse
$cfrom :: forall x.
ListPolicyVersionsResponse -> Rep ListPolicyVersionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPolicyVersionsResponse' 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:
--
-- 'versions', 'listPolicyVersionsResponse_versions' - A list of policy versions.
--
-- For more information about managed policy versions, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html Versioning for managed policies>
-- in the /IAM User Guide/.
--
-- 'marker', 'listPolicyVersionsResponse_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', 'listPolicyVersionsResponse_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', 'listPolicyVersionsResponse_httpStatus' - The response's http status code.
newListPolicyVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPolicyVersionsResponse
newListPolicyVersionsResponse :: Int -> ListPolicyVersionsResponse
newListPolicyVersionsResponse Int
pHttpStatus_ =
  ListPolicyVersionsResponse' :: Maybe [PolicyVersion]
-> Maybe Text -> Maybe Bool -> Int -> ListPolicyVersionsResponse
ListPolicyVersionsResponse'
    { $sel:versions:ListPolicyVersionsResponse' :: Maybe [PolicyVersion]
versions =
        Maybe [PolicyVersion]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListPolicyVersionsResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isTruncated:ListPolicyVersionsResponse' :: Maybe Bool
isTruncated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPolicyVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of policy versions.
--
-- For more information about managed policy versions, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html Versioning for managed policies>
-- in the /IAM User Guide/.
listPolicyVersionsResponse_versions :: Lens.Lens' ListPolicyVersionsResponse (Prelude.Maybe [PolicyVersion])
listPolicyVersionsResponse_versions :: (Maybe [PolicyVersion] -> f (Maybe [PolicyVersion]))
-> ListPolicyVersionsResponse -> f ListPolicyVersionsResponse
listPolicyVersionsResponse_versions = (ListPolicyVersionsResponse -> Maybe [PolicyVersion])
-> (ListPolicyVersionsResponse
    -> Maybe [PolicyVersion] -> ListPolicyVersionsResponse)
-> Lens
     ListPolicyVersionsResponse
     ListPolicyVersionsResponse
     (Maybe [PolicyVersion])
     (Maybe [PolicyVersion])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyVersionsResponse' {Maybe [PolicyVersion]
versions :: Maybe [PolicyVersion]
$sel:versions:ListPolicyVersionsResponse' :: ListPolicyVersionsResponse -> Maybe [PolicyVersion]
versions} -> Maybe [PolicyVersion]
versions) (\s :: ListPolicyVersionsResponse
s@ListPolicyVersionsResponse' {} Maybe [PolicyVersion]
a -> ListPolicyVersionsResponse
s {$sel:versions:ListPolicyVersionsResponse' :: Maybe [PolicyVersion]
versions = Maybe [PolicyVersion]
a} :: ListPolicyVersionsResponse) ((Maybe [PolicyVersion] -> f (Maybe [PolicyVersion]))
 -> ListPolicyVersionsResponse -> f ListPolicyVersionsResponse)
-> ((Maybe [PolicyVersion] -> f (Maybe [PolicyVersion]))
    -> Maybe [PolicyVersion] -> f (Maybe [PolicyVersion]))
-> (Maybe [PolicyVersion] -> f (Maybe [PolicyVersion]))
-> ListPolicyVersionsResponse
-> f ListPolicyVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PolicyVersion] [PolicyVersion] [PolicyVersion] [PolicyVersion]
-> Iso
     (Maybe [PolicyVersion])
     (Maybe [PolicyVersion])
     (Maybe [PolicyVersion])
     (Maybe [PolicyVersion])
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
  [PolicyVersion] [PolicyVersion] [PolicyVersion] [PolicyVersion]
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.
listPolicyVersionsResponse_marker :: Lens.Lens' ListPolicyVersionsResponse (Prelude.Maybe Prelude.Text)
listPolicyVersionsResponse_marker :: (Maybe Text -> f (Maybe Text))
-> ListPolicyVersionsResponse -> f ListPolicyVersionsResponse
listPolicyVersionsResponse_marker = (ListPolicyVersionsResponse -> Maybe Text)
-> (ListPolicyVersionsResponse
    -> Maybe Text -> ListPolicyVersionsResponse)
-> Lens' ListPolicyVersionsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyVersionsResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPolicyVersionsResponse' :: ListPolicyVersionsResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPolicyVersionsResponse
s@ListPolicyVersionsResponse' {} Maybe Text
a -> ListPolicyVersionsResponse
s {$sel:marker:ListPolicyVersionsResponse' :: Maybe Text
marker = Maybe Text
a} :: ListPolicyVersionsResponse)

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

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

instance Prelude.NFData ListPolicyVersionsResponse