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

import Amazonka.AccessAnalyzer.Types.GeneratedPolicy
import Amazonka.AccessAnalyzer.Types.GeneratedPolicyProperties
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 and its details.
--
-- /See:/ 'newGeneratedPolicyResult' smart constructor.
data GeneratedPolicyResult = GeneratedPolicyResult'
  { -- | 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.
    GeneratedPolicyResult -> Maybe [GeneratedPolicy]
generatedPolicies :: Prelude.Maybe [GeneratedPolicy],
    -- | A @GeneratedPolicyProperties@ object that contains properties of the
    -- generated policy.
    GeneratedPolicyResult -> GeneratedPolicyProperties
properties :: GeneratedPolicyProperties
  }
  deriving (GeneratedPolicyResult -> GeneratedPolicyResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeneratedPolicyResult -> GeneratedPolicyResult -> Bool
$c/= :: GeneratedPolicyResult -> GeneratedPolicyResult -> Bool
== :: GeneratedPolicyResult -> GeneratedPolicyResult -> Bool
$c== :: GeneratedPolicyResult -> GeneratedPolicyResult -> Bool
Prelude.Eq, ReadPrec [GeneratedPolicyResult]
ReadPrec GeneratedPolicyResult
Int -> ReadS GeneratedPolicyResult
ReadS [GeneratedPolicyResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeneratedPolicyResult]
$creadListPrec :: ReadPrec [GeneratedPolicyResult]
readPrec :: ReadPrec GeneratedPolicyResult
$creadPrec :: ReadPrec GeneratedPolicyResult
readList :: ReadS [GeneratedPolicyResult]
$creadList :: ReadS [GeneratedPolicyResult]
readsPrec :: Int -> ReadS GeneratedPolicyResult
$creadsPrec :: Int -> ReadS GeneratedPolicyResult
Prelude.Read, Int -> GeneratedPolicyResult -> ShowS
[GeneratedPolicyResult] -> ShowS
GeneratedPolicyResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeneratedPolicyResult] -> ShowS
$cshowList :: [GeneratedPolicyResult] -> ShowS
show :: GeneratedPolicyResult -> String
$cshow :: GeneratedPolicyResult -> String
showsPrec :: Int -> GeneratedPolicyResult -> ShowS
$cshowsPrec :: Int -> GeneratedPolicyResult -> ShowS
Prelude.Show, forall x. Rep GeneratedPolicyResult x -> GeneratedPolicyResult
forall x. GeneratedPolicyResult -> Rep GeneratedPolicyResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeneratedPolicyResult x -> GeneratedPolicyResult
$cfrom :: forall x. GeneratedPolicyResult -> Rep GeneratedPolicyResult x
Prelude.Generic)

-- |
-- Create a value of 'GeneratedPolicyResult' 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:
--
-- 'generatedPolicies', 'generatedPolicyResult_generatedPolicies' - 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.
--
-- 'properties', 'generatedPolicyResult_properties' - A @GeneratedPolicyProperties@ object that contains properties of the
-- generated policy.
newGeneratedPolicyResult ::
  -- | 'properties'
  GeneratedPolicyProperties ->
  GeneratedPolicyResult
newGeneratedPolicyResult :: GeneratedPolicyProperties -> GeneratedPolicyResult
newGeneratedPolicyResult GeneratedPolicyProperties
pProperties_ =
  GeneratedPolicyResult'
    { $sel:generatedPolicies:GeneratedPolicyResult' :: Maybe [GeneratedPolicy]
generatedPolicies =
        forall a. Maybe a
Prelude.Nothing,
      $sel:properties:GeneratedPolicyResult' :: GeneratedPolicyProperties
properties = GeneratedPolicyProperties
pProperties_
    }

-- | 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.
generatedPolicyResult_generatedPolicies :: Lens.Lens' GeneratedPolicyResult (Prelude.Maybe [GeneratedPolicy])
generatedPolicyResult_generatedPolicies :: Lens' GeneratedPolicyResult (Maybe [GeneratedPolicy])
generatedPolicyResult_generatedPolicies = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeneratedPolicyResult' {Maybe [GeneratedPolicy]
generatedPolicies :: Maybe [GeneratedPolicy]
$sel:generatedPolicies:GeneratedPolicyResult' :: GeneratedPolicyResult -> Maybe [GeneratedPolicy]
generatedPolicies} -> Maybe [GeneratedPolicy]
generatedPolicies) (\s :: GeneratedPolicyResult
s@GeneratedPolicyResult' {} Maybe [GeneratedPolicy]
a -> GeneratedPolicyResult
s {$sel:generatedPolicies:GeneratedPolicyResult' :: Maybe [GeneratedPolicy]
generatedPolicies = Maybe [GeneratedPolicy]
a} :: GeneratedPolicyResult) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A @GeneratedPolicyProperties@ object that contains properties of the
-- generated policy.
generatedPolicyResult_properties :: Lens.Lens' GeneratedPolicyResult GeneratedPolicyProperties
generatedPolicyResult_properties :: Lens' GeneratedPolicyResult GeneratedPolicyProperties
generatedPolicyResult_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeneratedPolicyResult' {GeneratedPolicyProperties
properties :: GeneratedPolicyProperties
$sel:properties:GeneratedPolicyResult' :: GeneratedPolicyResult -> GeneratedPolicyProperties
properties} -> GeneratedPolicyProperties
properties) (\s :: GeneratedPolicyResult
s@GeneratedPolicyResult' {} GeneratedPolicyProperties
a -> GeneratedPolicyResult
s {$sel:properties:GeneratedPolicyResult' :: GeneratedPolicyProperties
properties = GeneratedPolicyProperties
a} :: GeneratedPolicyResult)

instance Data.FromJSON GeneratedPolicyResult where
  parseJSON :: Value -> Parser GeneratedPolicyResult
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GeneratedPolicyResult"
      ( \Object
x ->
          Maybe [GeneratedPolicy]
-> GeneratedPolicyProperties -> GeneratedPolicyResult
GeneratedPolicyResult'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"generatedPolicies"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"properties")
      )

instance Prelude.Hashable GeneratedPolicyResult where
  hashWithSalt :: Int -> GeneratedPolicyResult -> Int
hashWithSalt Int
_salt GeneratedPolicyResult' {Maybe [GeneratedPolicy]
GeneratedPolicyProperties
properties :: GeneratedPolicyProperties
generatedPolicies :: Maybe [GeneratedPolicy]
$sel:properties:GeneratedPolicyResult' :: GeneratedPolicyResult -> GeneratedPolicyProperties
$sel:generatedPolicies:GeneratedPolicyResult' :: GeneratedPolicyResult -> Maybe [GeneratedPolicy]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GeneratedPolicy]
generatedPolicies
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GeneratedPolicyProperties
properties

instance Prelude.NFData GeneratedPolicyResult where
  rnf :: GeneratedPolicyResult -> ()
rnf GeneratedPolicyResult' {Maybe [GeneratedPolicy]
GeneratedPolicyProperties
properties :: GeneratedPolicyProperties
generatedPolicies :: Maybe [GeneratedPolicy]
$sel:properties:GeneratedPolicyResult' :: GeneratedPolicyResult -> GeneratedPolicyProperties
$sel:generatedPolicies:GeneratedPolicyResult' :: GeneratedPolicyResult -> Maybe [GeneratedPolicy]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [GeneratedPolicy]
generatedPolicies
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GeneratedPolicyProperties
properties