{-# 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-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)
module Amazonka.IAM.Types.SimulatePolicyResponse where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.EvaluationResult
import qualified Amazonka.Lens as Lens
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],
    -- | 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,
    -- | 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
  }
  deriving (SimulatePolicyResponse -> SimulatePolicyResponse -> Bool
(SimulatePolicyResponse -> SimulatePolicyResponse -> Bool)
-> (SimulatePolicyResponse -> SimulatePolicyResponse -> Bool)
-> Eq SimulatePolicyResponse
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]
(Int -> ReadS SimulatePolicyResponse)
-> ReadS [SimulatePolicyResponse]
-> ReadPrec SimulatePolicyResponse
-> ReadPrec [SimulatePolicyResponse]
-> Read 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
(Int -> SimulatePolicyResponse -> ShowS)
-> (SimulatePolicyResponse -> String)
-> ([SimulatePolicyResponse] -> ShowS)
-> Show SimulatePolicyResponse
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. SimulatePolicyResponse -> Rep SimulatePolicyResponse x)
-> (forall x.
    Rep SimulatePolicyResponse x -> SimulatePolicyResponse)
-> Generic SimulatePolicyResponse
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.
--
-- '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.
--
-- '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.
newSimulatePolicyResponse ::
  SimulatePolicyResponse
newSimulatePolicyResponse :: SimulatePolicyResponse
newSimulatePolicyResponse =
  SimulatePolicyResponse' :: Maybe [EvaluationResult]
-> Maybe Text -> Maybe Bool -> SimulatePolicyResponse
SimulatePolicyResponse'
    { $sel:evaluationResults:SimulatePolicyResponse' :: Maybe [EvaluationResult]
evaluationResults =
        Maybe [EvaluationResult]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:SimulatePolicyResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isTruncated:SimulatePolicyResponse' :: Maybe Bool
isTruncated = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The results of the simulation.
simulatePolicyResponse_evaluationResults :: Lens.Lens' SimulatePolicyResponse (Prelude.Maybe [EvaluationResult])
simulatePolicyResponse_evaluationResults :: (Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> SimulatePolicyResponse -> f SimulatePolicyResponse
simulatePolicyResponse_evaluationResults = (SimulatePolicyResponse -> Maybe [EvaluationResult])
-> (SimulatePolicyResponse
    -> Maybe [EvaluationResult] -> SimulatePolicyResponse)
-> Lens
     SimulatePolicyResponse
     SimulatePolicyResponse
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
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) ((Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
 -> SimulatePolicyResponse -> f SimulatePolicyResponse)
-> ((Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
    -> Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> (Maybe [EvaluationResult] -> f (Maybe [EvaluationResult]))
-> SimulatePolicyResponse
-> f SimulatePolicyResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
-> Iso
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
     (Maybe [EvaluationResult])
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
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
  [EvaluationResult]
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.
simulatePolicyResponse_marker :: Lens.Lens' SimulatePolicyResponse (Prelude.Maybe Prelude.Text)
simulatePolicyResponse_marker :: (Maybe Text -> f (Maybe Text))
-> SimulatePolicyResponse -> f SimulatePolicyResponse
simulatePolicyResponse_marker = (SimulatePolicyResponse -> Maybe Text)
-> (SimulatePolicyResponse -> Maybe Text -> SimulatePolicyResponse)
-> Lens
     SimulatePolicyResponse
     SimulatePolicyResponse
     (Maybe Text)
     (Maybe Text)
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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> SimulatePolicyResponse -> f SimulatePolicyResponse
simulatePolicyResponse_isTruncated = (SimulatePolicyResponse -> Maybe Bool)
-> (SimulatePolicyResponse -> Maybe Bool -> SimulatePolicyResponse)
-> Lens
     SimulatePolicyResponse
     SimulatePolicyResponse
     (Maybe Bool)
     (Maybe Bool)
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)

instance Core.FromXML SimulatePolicyResponse where
  parseXML :: [Node] -> Either String SimulatePolicyResponse
parseXML [Node]
x =
    Maybe [EvaluationResult]
-> Maybe Text -> Maybe Bool -> SimulatePolicyResponse
SimulatePolicyResponse'
      (Maybe [EvaluationResult]
 -> Maybe Text -> Maybe Bool -> SimulatePolicyResponse)
-> Either String (Maybe [EvaluationResult])
-> Either
     String (Maybe Text -> Maybe Bool -> SimulatePolicyResponse)
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
"EvaluationResults"
                      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 [EvaluationResult]))
-> Either String (Maybe [EvaluationResult])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [EvaluationResult])
-> [Node] -> Either String (Maybe [EvaluationResult])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [EvaluationResult]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe Text -> Maybe Bool -> SimulatePolicyResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> SimulatePolicyResponse)
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 -> SimulatePolicyResponse)
-> Either String (Maybe Bool)
-> Either String SimulatePolicyResponse
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")

instance Prelude.Hashable SimulatePolicyResponse

instance Prelude.NFData SimulatePolicyResponse