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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(GeneratedPolicy -> GeneratedPolicy -> Bool)
-> (GeneratedPolicy -> GeneratedPolicy -> Bool)
-> Eq GeneratedPolicy
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]
(Int -> ReadS GeneratedPolicy)
-> ReadS [GeneratedPolicy]
-> ReadPrec GeneratedPolicy
-> ReadPrec [GeneratedPolicy]
-> Read 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
(Int -> GeneratedPolicy -> ShowS)
-> (GeneratedPolicy -> String)
-> ([GeneratedPolicy] -> ShowS)
-> Show GeneratedPolicy
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. GeneratedPolicy -> Rep GeneratedPolicy x)
-> (forall x. Rep GeneratedPolicy x -> GeneratedPolicy)
-> Generic GeneratedPolicy
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' :: Text -> GeneratedPolicy
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 :: (Text -> f Text) -> GeneratedPolicy -> f GeneratedPolicy
generatedPolicy_policy = (GeneratedPolicy -> Text)
-> (GeneratedPolicy -> Text -> GeneratedPolicy)
-> Lens GeneratedPolicy GeneratedPolicy Text Text
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 Core.FromJSON GeneratedPolicy where
  parseJSON :: Value -> Parser GeneratedPolicy
parseJSON =
    String
-> (Object -> Parser GeneratedPolicy)
-> Value
-> Parser GeneratedPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GeneratedPolicy"
      ( \Object
x ->
          Text -> GeneratedPolicy
GeneratedPolicy' (Text -> GeneratedPolicy) -> Parser Text -> Parser GeneratedPolicy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"policy")
      )

instance Prelude.Hashable GeneratedPolicy

instance Prelude.NFData GeneratedPolicy