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

import Amazonka.AccessAnalyzer.Types.GeneratedPolicy
import Amazonka.AccessAnalyzer.Types.GeneratedPolicyProperties
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 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
(GeneratedPolicyResult -> GeneratedPolicyResult -> Bool)
-> (GeneratedPolicyResult -> GeneratedPolicyResult -> Bool)
-> Eq GeneratedPolicyResult
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]
(Int -> ReadS GeneratedPolicyResult)
-> ReadS [GeneratedPolicyResult]
-> ReadPrec GeneratedPolicyResult
-> ReadPrec [GeneratedPolicyResult]
-> Read 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
(Int -> GeneratedPolicyResult -> ShowS)
-> (GeneratedPolicyResult -> String)
-> ([GeneratedPolicyResult] -> ShowS)
-> Show GeneratedPolicyResult
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. GeneratedPolicyResult -> Rep GeneratedPolicyResult x)
-> (forall x. Rep GeneratedPolicyResult x -> GeneratedPolicyResult)
-> Generic GeneratedPolicyResult
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' :: Maybe [GeneratedPolicy]
-> GeneratedPolicyProperties -> GeneratedPolicyResult
GeneratedPolicyResult'
    { $sel:generatedPolicies:GeneratedPolicyResult' :: Maybe [GeneratedPolicy]
generatedPolicies =
        Maybe [GeneratedPolicy]
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 :: (Maybe [GeneratedPolicy] -> f (Maybe [GeneratedPolicy]))
-> GeneratedPolicyResult -> f GeneratedPolicyResult
generatedPolicyResult_generatedPolicies = (GeneratedPolicyResult -> Maybe [GeneratedPolicy])
-> (GeneratedPolicyResult
    -> Maybe [GeneratedPolicy] -> GeneratedPolicyResult)
-> Lens
     GeneratedPolicyResult
     GeneratedPolicyResult
     (Maybe [GeneratedPolicy])
     (Maybe [GeneratedPolicy])
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) ((Maybe [GeneratedPolicy] -> f (Maybe [GeneratedPolicy]))
 -> GeneratedPolicyResult -> f GeneratedPolicyResult)
-> ((Maybe [GeneratedPolicy] -> f (Maybe [GeneratedPolicy]))
    -> Maybe [GeneratedPolicy] -> f (Maybe [GeneratedPolicy]))
-> (Maybe [GeneratedPolicy] -> f (Maybe [GeneratedPolicy]))
-> GeneratedPolicyResult
-> f GeneratedPolicyResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GeneratedPolicy]
  [GeneratedPolicy]
  [GeneratedPolicy]
  [GeneratedPolicy]
-> Iso
     (Maybe [GeneratedPolicy])
     (Maybe [GeneratedPolicy])
     (Maybe [GeneratedPolicy])
     (Maybe [GeneratedPolicy])
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 AnIso
  [GeneratedPolicy]
  [GeneratedPolicy]
  [GeneratedPolicy]
  [GeneratedPolicy]
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 :: (GeneratedPolicyProperties -> f GeneratedPolicyProperties)
-> GeneratedPolicyResult -> f GeneratedPolicyResult
generatedPolicyResult_properties = (GeneratedPolicyResult -> GeneratedPolicyProperties)
-> (GeneratedPolicyResult
    -> GeneratedPolicyProperties -> GeneratedPolicyResult)
-> Lens
     GeneratedPolicyResult
     GeneratedPolicyResult
     GeneratedPolicyProperties
     GeneratedPolicyProperties
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 Core.FromJSON GeneratedPolicyResult where
  parseJSON :: Value -> Parser GeneratedPolicyResult
parseJSON =
    String
-> (Object -> Parser GeneratedPolicyResult)
-> Value
-> Parser GeneratedPolicyResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GeneratedPolicyResult"
      ( \Object
x ->
          Maybe [GeneratedPolicy]
-> GeneratedPolicyProperties -> GeneratedPolicyResult
GeneratedPolicyResult'
            (Maybe [GeneratedPolicy]
 -> GeneratedPolicyProperties -> GeneratedPolicyResult)
-> Parser (Maybe [GeneratedPolicy])
-> Parser (GeneratedPolicyProperties -> GeneratedPolicyResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [GeneratedPolicy]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"generatedPolicies"
                            Parser (Maybe (Maybe [GeneratedPolicy]))
-> Maybe [GeneratedPolicy] -> Parser (Maybe [GeneratedPolicy])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GeneratedPolicy]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (GeneratedPolicyProperties -> GeneratedPolicyResult)
-> Parser GeneratedPolicyProperties -> Parser GeneratedPolicyResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser GeneratedPolicyProperties
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"properties")
      )

instance Prelude.Hashable GeneratedPolicyResult

instance Prelude.NFData GeneratedPolicyResult