{-# 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.Statement
-- 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.Statement where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.PolicySourceType
import Amazonka.IAM.Types.Position
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a reference to a @Statement@ element in a policy document that
-- determines the result of the simulation.
--
-- This data type is used by the @MatchedStatements@ member of the
-- @ EvaluationResult @ type.
--
-- /See:/ 'newStatement' smart constructor.
data Statement = Statement'
  { -- | The type of the policy.
    Statement -> Maybe PolicySourceType
sourcePolicyType :: Prelude.Maybe PolicySourceType,
    -- | The identifier of the policy that was provided as an input.
    Statement -> Maybe Text
sourcePolicyId :: Prelude.Maybe Prelude.Text,
    -- | The row and column of the end of a @Statement@ in an IAM policy.
    Statement -> Maybe Position
endPosition :: Prelude.Maybe Position,
    -- | The row and column of the beginning of the @Statement@ in an IAM policy.
    Statement -> Maybe Position
startPosition :: Prelude.Maybe Position
  }
  deriving (Statement -> Statement -> Bool
(Statement -> Statement -> Bool)
-> (Statement -> Statement -> Bool) -> Eq Statement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Statement -> Statement -> Bool
$c/= :: Statement -> Statement -> Bool
== :: Statement -> Statement -> Bool
$c== :: Statement -> Statement -> Bool
Prelude.Eq, ReadPrec [Statement]
ReadPrec Statement
Int -> ReadS Statement
ReadS [Statement]
(Int -> ReadS Statement)
-> ReadS [Statement]
-> ReadPrec Statement
-> ReadPrec [Statement]
-> Read Statement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Statement]
$creadListPrec :: ReadPrec [Statement]
readPrec :: ReadPrec Statement
$creadPrec :: ReadPrec Statement
readList :: ReadS [Statement]
$creadList :: ReadS [Statement]
readsPrec :: Int -> ReadS Statement
$creadsPrec :: Int -> ReadS Statement
Prelude.Read, Int -> Statement -> ShowS
[Statement] -> ShowS
Statement -> String
(Int -> Statement -> ShowS)
-> (Statement -> String)
-> ([Statement] -> ShowS)
-> Show Statement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Statement] -> ShowS
$cshowList :: [Statement] -> ShowS
show :: Statement -> String
$cshow :: Statement -> String
showsPrec :: Int -> Statement -> ShowS
$cshowsPrec :: Int -> Statement -> ShowS
Prelude.Show, (forall x. Statement -> Rep Statement x)
-> (forall x. Rep Statement x -> Statement) -> Generic Statement
forall x. Rep Statement x -> Statement
forall x. Statement -> Rep Statement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Statement x -> Statement
$cfrom :: forall x. Statement -> Rep Statement x
Prelude.Generic)

-- |
-- Create a value of 'Statement' 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:
--
-- 'sourcePolicyType', 'statement_sourcePolicyType' - The type of the policy.
--
-- 'sourcePolicyId', 'statement_sourcePolicyId' - The identifier of the policy that was provided as an input.
--
-- 'endPosition', 'statement_endPosition' - The row and column of the end of a @Statement@ in an IAM policy.
--
-- 'startPosition', 'statement_startPosition' - The row and column of the beginning of the @Statement@ in an IAM policy.
newStatement ::
  Statement
newStatement :: Statement
newStatement =
  Statement' :: Maybe PolicySourceType
-> Maybe Text -> Maybe Position -> Maybe Position -> Statement
Statement'
    { $sel:sourcePolicyType:Statement' :: Maybe PolicySourceType
sourcePolicyType = Maybe PolicySourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePolicyId:Statement' :: Maybe Text
sourcePolicyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endPosition:Statement' :: Maybe Position
endPosition = Maybe Position
forall a. Maybe a
Prelude.Nothing,
      $sel:startPosition:Statement' :: Maybe Position
startPosition = Maybe Position
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the policy.
statement_sourcePolicyType :: Lens.Lens' Statement (Prelude.Maybe PolicySourceType)
statement_sourcePolicyType :: (Maybe PolicySourceType -> f (Maybe PolicySourceType))
-> Statement -> f Statement
statement_sourcePolicyType = (Statement -> Maybe PolicySourceType)
-> (Statement -> Maybe PolicySourceType -> Statement)
-> Lens
     Statement
     Statement
     (Maybe PolicySourceType)
     (Maybe PolicySourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe PolicySourceType
sourcePolicyType :: Maybe PolicySourceType
$sel:sourcePolicyType:Statement' :: Statement -> Maybe PolicySourceType
sourcePolicyType} -> Maybe PolicySourceType
sourcePolicyType) (\s :: Statement
s@Statement' {} Maybe PolicySourceType
a -> Statement
s {$sel:sourcePolicyType:Statement' :: Maybe PolicySourceType
sourcePolicyType = Maybe PolicySourceType
a} :: Statement)

-- | The identifier of the policy that was provided as an input.
statement_sourcePolicyId :: Lens.Lens' Statement (Prelude.Maybe Prelude.Text)
statement_sourcePolicyId :: (Maybe Text -> f (Maybe Text)) -> Statement -> f Statement
statement_sourcePolicyId = (Statement -> Maybe Text)
-> (Statement -> Maybe Text -> Statement)
-> Lens Statement Statement (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Text
sourcePolicyId :: Maybe Text
$sel:sourcePolicyId:Statement' :: Statement -> Maybe Text
sourcePolicyId} -> Maybe Text
sourcePolicyId) (\s :: Statement
s@Statement' {} Maybe Text
a -> Statement
s {$sel:sourcePolicyId:Statement' :: Maybe Text
sourcePolicyId = Maybe Text
a} :: Statement)

-- | The row and column of the end of a @Statement@ in an IAM policy.
statement_endPosition :: Lens.Lens' Statement (Prelude.Maybe Position)
statement_endPosition :: (Maybe Position -> f (Maybe Position)) -> Statement -> f Statement
statement_endPosition = (Statement -> Maybe Position)
-> (Statement -> Maybe Position -> Statement)
-> Lens Statement Statement (Maybe Position) (Maybe Position)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Position
endPosition :: Maybe Position
$sel:endPosition:Statement' :: Statement -> Maybe Position
endPosition} -> Maybe Position
endPosition) (\s :: Statement
s@Statement' {} Maybe Position
a -> Statement
s {$sel:endPosition:Statement' :: Maybe Position
endPosition = Maybe Position
a} :: Statement)

-- | The row and column of the beginning of the @Statement@ in an IAM policy.
statement_startPosition :: Lens.Lens' Statement (Prelude.Maybe Position)
statement_startPosition :: (Maybe Position -> f (Maybe Position)) -> Statement -> f Statement
statement_startPosition = (Statement -> Maybe Position)
-> (Statement -> Maybe Position -> Statement)
-> Lens Statement Statement (Maybe Position) (Maybe Position)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Position
startPosition :: Maybe Position
$sel:startPosition:Statement' :: Statement -> Maybe Position
startPosition} -> Maybe Position
startPosition) (\s :: Statement
s@Statement' {} Maybe Position
a -> Statement
s {$sel:startPosition:Statement' :: Maybe Position
startPosition = Maybe Position
a} :: Statement)

instance Core.FromXML Statement where
  parseXML :: [Node] -> Either String Statement
parseXML [Node]
x =
    Maybe PolicySourceType
-> Maybe Text -> Maybe Position -> Maybe Position -> Statement
Statement'
      (Maybe PolicySourceType
 -> Maybe Text -> Maybe Position -> Maybe Position -> Statement)
-> Either String (Maybe PolicySourceType)
-> Either
     String
     (Maybe Text -> Maybe Position -> Maybe Position -> Statement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe PolicySourceType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourcePolicyType")
      Either
  String
  (Maybe Text -> Maybe Position -> Maybe Position -> Statement)
-> Either String (Maybe Text)
-> Either String (Maybe Position -> Maybe Position -> Statement)
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
"SourcePolicyId")
      Either String (Maybe Position -> Maybe Position -> Statement)
-> Either String (Maybe Position)
-> Either String (Maybe Position -> Statement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Position)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"EndPosition")
      Either String (Maybe Position -> Statement)
-> Either String (Maybe Position) -> Either String Statement
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Position)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StartPosition")

instance Prelude.Hashable Statement

instance Prelude.NFData Statement