{-# 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.AccessAnalyzer.Types.GeneratedPolicy
-- 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.AccessAnalyzer.Types.GeneratedPolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains the text for the generated policy.
--
-- /See:/ 'newGeneratedPolicy' smart constructor.
data GeneratedPolicy = GeneratedPolicy'
  { -- | The text to use as the content for the new policy. The policy is created
    -- using the
    -- <https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicy.html CreatePolicy>
    -- action.
    GeneratedPolicy -> Text
policy :: Prelude.Text
  }
  deriving (GeneratedPolicy -> GeneratedPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeneratedPolicy -> GeneratedPolicy -> Bool
$c/= :: GeneratedPolicy -> GeneratedPolicy -> Bool
== :: GeneratedPolicy -> GeneratedPolicy -> Bool
$c== :: GeneratedPolicy -> GeneratedPolicy -> Bool
Prelude.Eq, ReadPrec [GeneratedPolicy]
ReadPrec GeneratedPolicy
Int -> ReadS GeneratedPolicy
ReadS [GeneratedPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeneratedPolicy]
$creadListPrec :: ReadPrec [GeneratedPolicy]
readPrec :: ReadPrec GeneratedPolicy
$creadPrec :: ReadPrec GeneratedPolicy
readList :: ReadS [GeneratedPolicy]
$creadList :: ReadS [GeneratedPolicy]
readsPrec :: Int -> ReadS GeneratedPolicy
$creadsPrec :: Int -> ReadS GeneratedPolicy
Prelude.Read, Int -> GeneratedPolicy -> ShowS
[GeneratedPolicy] -> ShowS
GeneratedPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeneratedPolicy] -> ShowS
$cshowList :: [GeneratedPolicy] -> ShowS
show :: GeneratedPolicy -> String
$cshow :: GeneratedPolicy -> String
showsPrec :: Int -> GeneratedPolicy -> ShowS
$cshowsPrec :: Int -> GeneratedPolicy -> ShowS
Prelude.Show, forall x. Rep GeneratedPolicy x -> GeneratedPolicy
forall x. GeneratedPolicy -> Rep GeneratedPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeneratedPolicy x -> GeneratedPolicy
$cfrom :: forall x. GeneratedPolicy -> Rep GeneratedPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GeneratedPolicy' 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:
--
-- 'policy', 'generatedPolicy_policy' - The text to use as the content for the new policy. The policy is created
-- using the
-- <https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicy.html CreatePolicy>
-- action.
newGeneratedPolicy ::
  -- | 'policy'
  Prelude.Text ->
  GeneratedPolicy
newGeneratedPolicy :: Text -> GeneratedPolicy
newGeneratedPolicy Text
pPolicy_ =
  GeneratedPolicy' {$sel:policy:GeneratedPolicy' :: Text
policy = Text
pPolicy_}

-- | The text to use as the content for the new policy. The policy is created
-- using the
-- <https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicy.html CreatePolicy>
-- action.
generatedPolicy_policy :: Lens.Lens' GeneratedPolicy Prelude.Text
generatedPolicy_policy :: Lens' GeneratedPolicy Text
generatedPolicy_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeneratedPolicy' {Text
policy :: Text
$sel:policy:GeneratedPolicy' :: GeneratedPolicy -> Text
policy} -> Text
policy) (\s :: GeneratedPolicy
s@GeneratedPolicy' {} Text
a -> GeneratedPolicy
s {$sel:policy:GeneratedPolicy' :: Text
policy = Text
a} :: GeneratedPolicy)

instance Data.FromJSON GeneratedPolicy where
  parseJSON :: Value -> Parser GeneratedPolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GeneratedPolicy"
      ( \Object
x ->
          Text -> GeneratedPolicy
GeneratedPolicy' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"policy")
      )

instance Prelude.Hashable GeneratedPolicy where
  hashWithSalt :: Int -> GeneratedPolicy -> Int
hashWithSalt Int
_salt GeneratedPolicy' {Text
policy :: Text
$sel:policy:GeneratedPolicy' :: GeneratedPolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policy

instance Prelude.NFData GeneratedPolicy where
  rnf :: GeneratedPolicy -> ()
rnf GeneratedPolicy' {Text
policy :: Text
$sel:policy:GeneratedPolicy' :: GeneratedPolicy -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
policy