{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.SimulatePolicyResponse
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IAM.Types.SimulatePolicyResponse where

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

-- | Contains the response to a successful SimulatePrincipalPolicy or
-- SimulateCustomPolicy request.
--
-- /See:/ 'newSimulatePolicyResponse' smart constructor.
data SimulatePolicyResponse = SimulatePolicyResponse'
  { -- | The results of the simulation.
    SimulatePolicyResponse -> Maybe [EvaluationResult]
evaluationResults :: Prelude.Maybe [EvaluationResult],
    -- | 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.
    SimulatePolicyResponse -> Maybe Bool
isTruncated :: Prelude.Maybe Prelude.Bool,
    -- | When @IsTruncated@ is @true@, this element is present and contains the
    -- value to use for the @Marker@ parameter in a subsequent pagination
    -- request.
    SimulatePolicyResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text
  }
  deriving (SimulatePolicyResponse -> SimulatePolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimulatePolicyResponse -> SimulatePolicyResponse -> Bool
$c/= :: SimulatePolicyResponse -> SimulatePolicyResponse -> Bool
== :: SimulatePolicyResponse -> SimulatePolicyResponse -> Bool
$c== :: SimulatePolicyResponse -> SimulatePolicyResponse -> Bool
Prelude.Eq, ReadPrec [SimulatePolicyResponse]
ReadPrec SimulatePolicyResponse
Int -> ReadS SimulatePolicyResponse
ReadS [SimulatePolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimulatePolicyResponse]
$creadListPrec :: ReadPrec [SimulatePolicyResponse]
readPrec :: ReadPrec SimulatePolicyResponse
$creadPrec :: ReadPrec SimulatePolicyResponse
readList :: ReadS [SimulatePolicyResponse]
$creadList :: ReadS [SimulatePolicyResponse]
readsPrec :: Int -> ReadS SimulatePolicyResponse
$creadsPrec :: Int -> ReadS SimulatePolicyResponse
Prelude.Read, Int -> SimulatePolicyResponse -> ShowS
[SimulatePolicyResponse] -> ShowS
SimulatePolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimulatePolicyResponse] -> ShowS
$cshowList :: [SimulatePolicyResponse] -> ShowS
show :: SimulatePolicyResponse -> String
$cshow :: SimulatePolicyResponse -> String
showsPrec :: Int -> SimulatePolicyResponse -> ShowS
$cshowsPrec :: Int -> SimulatePolicyResponse -> ShowS
Prelude.Show, forall x. Rep SimulatePolicyResponse x -> SimulatePolicyResponse
forall x. SimulatePolicyResponse -> Rep SimulatePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SimulatePolicyResponse x -> SimulatePolicyResponse
$cfrom :: forall x. SimulatePolicyResponse -> Rep SimulatePolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'SimulatePolicyResponse' 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:
--
-- 'evaluationResults', 'simulatePolicyResponse_evaluationResults' - The results of the simulation.
--
-- 'isTruncated', 'simulatePolicyResponse_isTruncated' - A flag that indicates whether there are more items to return. If your
-- results were truncated, you can make a subsequent pagination request
-- using the @Marker@ request parameter to retrieve more items. Note that
-- IAM might return fewer than the @MaxItems@ number of results even when
-- there are more results available. We recommend that you check
-- @IsTruncated@ after every call to ensure that you receive all your
-- results.
--
-- 'marker', 'simulatePolicyResponse_marker' - When @IsTruncated@ is @true@, this element is present and contains the
-- value to use for the @Marker@ parameter in a subsequent pagination
-- request.
newSimulatePolicyResponse ::
  SimulatePolicyResponse
newSimulatePolicyResponse :: SimulatePolicyResponse
newSimulatePolicyResponse =
  SimulatePolicyResponse'
    { $sel:evaluationResults:SimulatePolicyResponse' :: Maybe [EvaluationResult]
evaluationResults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:isTruncated:SimulatePolicyResponse' :: Maybe Bool
isTruncated = forall a. Maybe a
Prelude.Nothing,
      $sel:marker:SimulatePolicyResponse' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing
    }

-- | The results of the simulation.
simulatePolicyResponse_evaluationResults :: Lens.Lens' SimulatePolicyResponse (Prelude.Maybe [EvaluationResult])
simulatePolicyResponse_evaluationResults :: Lens' SimulatePolicyResponse (Maybe [EvaluationResult])
simulatePolicyResponse_evaluationResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimulatePolicyResponse' {Maybe [EvaluationResult]
evaluationResults :: Maybe [EvaluationResult]
$sel:evaluationResults:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe [EvaluationResult]
evaluationResults} -> Maybe [EvaluationResult]
evaluationResults) (\s :: SimulatePolicyResponse
s@SimulatePolicyResponse' {} Maybe [EvaluationResult]
a -> SimulatePolicyResponse
s {$sel:evaluationResults:SimulatePolicyResponse' :: Maybe [EvaluationResult]
evaluationResults = Maybe [EvaluationResult]
a} :: SimulatePolicyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Data.FromXML SimulatePolicyResponse where
  parseXML :: [Node] -> Either String SimulatePolicyResponse
parseXML [Node]
x =
    Maybe [EvaluationResult]
-> Maybe Bool -> Maybe Text -> SimulatePolicyResponse
SimulatePolicyResponse'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"EvaluationResults"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"IsTruncated")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Marker")

instance Prelude.Hashable SimulatePolicyResponse where
  hashWithSalt :: Int -> SimulatePolicyResponse -> Int
hashWithSalt Int
_salt SimulatePolicyResponse' {Maybe Bool
Maybe [EvaluationResult]
Maybe Text
marker :: Maybe Text
isTruncated :: Maybe Bool
evaluationResults :: Maybe [EvaluationResult]
$sel:marker:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe Text
$sel:isTruncated:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe Bool
$sel:evaluationResults:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe [EvaluationResult]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EvaluationResult]
evaluationResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isTruncated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
marker

instance Prelude.NFData SimulatePolicyResponse where
  rnf :: SimulatePolicyResponse -> ()
rnf SimulatePolicyResponse' {Maybe Bool
Maybe [EvaluationResult]
Maybe Text
marker :: Maybe Text
isTruncated :: Maybe Bool
evaluationResults :: Maybe [EvaluationResult]
$sel:marker:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe Text
$sel:isTruncated:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe Bool
$sel:evaluationResults:SimulatePolicyResponse' :: SimulatePolicyResponse -> Maybe [EvaluationResult]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [EvaluationResult]
evaluationResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isTruncated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
marker