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

-- | The row and column of the end of a @Statement@ in an IAM policy.
statement_endPosition :: Lens.Lens' Statement (Prelude.Maybe Position)
statement_endPosition :: Lens' Statement (Maybe Position)
statement_endPosition = 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 identifier of the policy that was provided as an input.
statement_sourcePolicyId :: Lens.Lens' Statement (Prelude.Maybe Prelude.Text)
statement_sourcePolicyId :: Lens' Statement (Maybe Text)
statement_sourcePolicyId = 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 type of the policy.
statement_sourcePolicyType :: Lens.Lens' Statement (Prelude.Maybe PolicySourceType)
statement_sourcePolicyType :: Lens' Statement (Maybe PolicySourceType)
statement_sourcePolicyType = 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 row and column of the beginning of the @Statement@ in an IAM policy.
statement_startPosition :: Lens.Lens' Statement (Prelude.Maybe Position)
statement_startPosition :: Lens' Statement (Maybe Position)
statement_startPosition = 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 Data.FromXML Statement where
  parseXML :: [Node] -> Either String Statement
parseXML [Node]
x =
    Maybe Position
-> Maybe Text
-> Maybe PolicySourceType
-> Maybe Position
-> Statement
Statement'
      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
"EndPosition")
      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
"SourcePolicyId")
      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
"SourcePolicyType")
      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
"StartPosition")

instance Prelude.Hashable Statement where
  hashWithSalt :: Int -> Statement -> Int
hashWithSalt Int
_salt Statement' {Maybe Text
Maybe PolicySourceType
Maybe Position
startPosition :: Maybe Position
sourcePolicyType :: Maybe PolicySourceType
sourcePolicyId :: Maybe Text
endPosition :: Maybe Position
$sel:startPosition:Statement' :: Statement -> Maybe Position
$sel:sourcePolicyType:Statement' :: Statement -> Maybe PolicySourceType
$sel:sourcePolicyId:Statement' :: Statement -> Maybe Text
$sel:endPosition:Statement' :: Statement -> Maybe Position
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Position
endPosition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourcePolicyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PolicySourceType
sourcePolicyType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Position
startPosition

instance Prelude.NFData Statement where
  rnf :: Statement -> ()
rnf Statement' {Maybe Text
Maybe PolicySourceType
Maybe Position
startPosition :: Maybe Position
sourcePolicyType :: Maybe PolicySourceType
sourcePolicyId :: Maybe Text
endPosition :: Maybe Position
$sel:startPosition:Statement' :: Statement -> Maybe Position
$sel:sourcePolicyType:Statement' :: Statement -> Maybe PolicySourceType
$sel:sourcePolicyId:Statement' :: Statement -> Maybe Text
$sel:endPosition:Statement' :: Statement -> Maybe Position
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Position
endPosition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourcePolicyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PolicySourceType
sourcePolicyType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Position
startPosition