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

import Amazonka.AccessAnalyzer.Types.CloudTrailProperties
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the generated policy details.
--
-- /See:/ 'newGeneratedPolicyProperties' smart constructor.
data GeneratedPolicyProperties = GeneratedPolicyProperties'
  { -- | This value is set to @true@ if the generated policy contains all
    -- possible actions for a service that IAM Access Analyzer identified from
    -- the CloudTrail trail that you specified, and @false@ otherwise.
    GeneratedPolicyProperties -> Maybe Bool
isComplete :: Prelude.Maybe Prelude.Bool,
    -- | Lists details about the @Trail@ used to generated policy.
    GeneratedPolicyProperties -> Maybe CloudTrailProperties
cloudTrailProperties :: Prelude.Maybe CloudTrailProperties,
    -- | The ARN of the IAM entity (user or role) for which you are generating a
    -- policy.
    GeneratedPolicyProperties -> Text
principalArn :: Prelude.Text
  }
  deriving (GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool
(GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool)
-> (GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool)
-> Eq GeneratedPolicyProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool
$c/= :: GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool
== :: GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool
$c== :: GeneratedPolicyProperties -> GeneratedPolicyProperties -> Bool
Prelude.Eq, ReadPrec [GeneratedPolicyProperties]
ReadPrec GeneratedPolicyProperties
Int -> ReadS GeneratedPolicyProperties
ReadS [GeneratedPolicyProperties]
(Int -> ReadS GeneratedPolicyProperties)
-> ReadS [GeneratedPolicyProperties]
-> ReadPrec GeneratedPolicyProperties
-> ReadPrec [GeneratedPolicyProperties]
-> Read GeneratedPolicyProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeneratedPolicyProperties]
$creadListPrec :: ReadPrec [GeneratedPolicyProperties]
readPrec :: ReadPrec GeneratedPolicyProperties
$creadPrec :: ReadPrec GeneratedPolicyProperties
readList :: ReadS [GeneratedPolicyProperties]
$creadList :: ReadS [GeneratedPolicyProperties]
readsPrec :: Int -> ReadS GeneratedPolicyProperties
$creadsPrec :: Int -> ReadS GeneratedPolicyProperties
Prelude.Read, Int -> GeneratedPolicyProperties -> ShowS
[GeneratedPolicyProperties] -> ShowS
GeneratedPolicyProperties -> String
(Int -> GeneratedPolicyProperties -> ShowS)
-> (GeneratedPolicyProperties -> String)
-> ([GeneratedPolicyProperties] -> ShowS)
-> Show GeneratedPolicyProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeneratedPolicyProperties] -> ShowS
$cshowList :: [GeneratedPolicyProperties] -> ShowS
show :: GeneratedPolicyProperties -> String
$cshow :: GeneratedPolicyProperties -> String
showsPrec :: Int -> GeneratedPolicyProperties -> ShowS
$cshowsPrec :: Int -> GeneratedPolicyProperties -> ShowS
Prelude.Show, (forall x.
 GeneratedPolicyProperties -> Rep GeneratedPolicyProperties x)
-> (forall x.
    Rep GeneratedPolicyProperties x -> GeneratedPolicyProperties)
-> Generic GeneratedPolicyProperties
forall x.
Rep GeneratedPolicyProperties x -> GeneratedPolicyProperties
forall x.
GeneratedPolicyProperties -> Rep GeneratedPolicyProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GeneratedPolicyProperties x -> GeneratedPolicyProperties
$cfrom :: forall x.
GeneratedPolicyProperties -> Rep GeneratedPolicyProperties x
Prelude.Generic)

-- |
-- Create a value of 'GeneratedPolicyProperties' 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:
--
-- 'isComplete', 'generatedPolicyProperties_isComplete' - This value is set to @true@ if the generated policy contains all
-- possible actions for a service that IAM Access Analyzer identified from
-- the CloudTrail trail that you specified, and @false@ otherwise.
--
-- 'cloudTrailProperties', 'generatedPolicyProperties_cloudTrailProperties' - Lists details about the @Trail@ used to generated policy.
--
-- 'principalArn', 'generatedPolicyProperties_principalArn' - The ARN of the IAM entity (user or role) for which you are generating a
-- policy.
newGeneratedPolicyProperties ::
  -- | 'principalArn'
  Prelude.Text ->
  GeneratedPolicyProperties
newGeneratedPolicyProperties :: Text -> GeneratedPolicyProperties
newGeneratedPolicyProperties Text
pPrincipalArn_ =
  GeneratedPolicyProperties' :: Maybe Bool
-> Maybe CloudTrailProperties -> Text -> GeneratedPolicyProperties
GeneratedPolicyProperties'
    { $sel:isComplete:GeneratedPolicyProperties' :: Maybe Bool
isComplete =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudTrailProperties:GeneratedPolicyProperties' :: Maybe CloudTrailProperties
cloudTrailProperties = Maybe CloudTrailProperties
forall a. Maybe a
Prelude.Nothing,
      $sel:principalArn:GeneratedPolicyProperties' :: Text
principalArn = Text
pPrincipalArn_
    }

-- | This value is set to @true@ if the generated policy contains all
-- possible actions for a service that IAM Access Analyzer identified from
-- the CloudTrail trail that you specified, and @false@ otherwise.
generatedPolicyProperties_isComplete :: Lens.Lens' GeneratedPolicyProperties (Prelude.Maybe Prelude.Bool)
generatedPolicyProperties_isComplete :: (Maybe Bool -> f (Maybe Bool))
-> GeneratedPolicyProperties -> f GeneratedPolicyProperties
generatedPolicyProperties_isComplete = (GeneratedPolicyProperties -> Maybe Bool)
-> (GeneratedPolicyProperties
    -> Maybe Bool -> GeneratedPolicyProperties)
-> Lens
     GeneratedPolicyProperties
     GeneratedPolicyProperties
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeneratedPolicyProperties' {Maybe Bool
isComplete :: Maybe Bool
$sel:isComplete:GeneratedPolicyProperties' :: GeneratedPolicyProperties -> Maybe Bool
isComplete} -> Maybe Bool
isComplete) (\s :: GeneratedPolicyProperties
s@GeneratedPolicyProperties' {} Maybe Bool
a -> GeneratedPolicyProperties
s {$sel:isComplete:GeneratedPolicyProperties' :: Maybe Bool
isComplete = Maybe Bool
a} :: GeneratedPolicyProperties)

-- | Lists details about the @Trail@ used to generated policy.
generatedPolicyProperties_cloudTrailProperties :: Lens.Lens' GeneratedPolicyProperties (Prelude.Maybe CloudTrailProperties)
generatedPolicyProperties_cloudTrailProperties :: (Maybe CloudTrailProperties -> f (Maybe CloudTrailProperties))
-> GeneratedPolicyProperties -> f GeneratedPolicyProperties
generatedPolicyProperties_cloudTrailProperties = (GeneratedPolicyProperties -> Maybe CloudTrailProperties)
-> (GeneratedPolicyProperties
    -> Maybe CloudTrailProperties -> GeneratedPolicyProperties)
-> Lens
     GeneratedPolicyProperties
     GeneratedPolicyProperties
     (Maybe CloudTrailProperties)
     (Maybe CloudTrailProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeneratedPolicyProperties' {Maybe CloudTrailProperties
cloudTrailProperties :: Maybe CloudTrailProperties
$sel:cloudTrailProperties:GeneratedPolicyProperties' :: GeneratedPolicyProperties -> Maybe CloudTrailProperties
cloudTrailProperties} -> Maybe CloudTrailProperties
cloudTrailProperties) (\s :: GeneratedPolicyProperties
s@GeneratedPolicyProperties' {} Maybe CloudTrailProperties
a -> GeneratedPolicyProperties
s {$sel:cloudTrailProperties:GeneratedPolicyProperties' :: Maybe CloudTrailProperties
cloudTrailProperties = Maybe CloudTrailProperties
a} :: GeneratedPolicyProperties)

-- | The ARN of the IAM entity (user or role) for which you are generating a
-- policy.
generatedPolicyProperties_principalArn :: Lens.Lens' GeneratedPolicyProperties Prelude.Text
generatedPolicyProperties_principalArn :: (Text -> f Text)
-> GeneratedPolicyProperties -> f GeneratedPolicyProperties
generatedPolicyProperties_principalArn = (GeneratedPolicyProperties -> Text)
-> (GeneratedPolicyProperties -> Text -> GeneratedPolicyProperties)
-> Lens
     GeneratedPolicyProperties GeneratedPolicyProperties Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeneratedPolicyProperties' {Text
principalArn :: Text
$sel:principalArn:GeneratedPolicyProperties' :: GeneratedPolicyProperties -> Text
principalArn} -> Text
principalArn) (\s :: GeneratedPolicyProperties
s@GeneratedPolicyProperties' {} Text
a -> GeneratedPolicyProperties
s {$sel:principalArn:GeneratedPolicyProperties' :: Text
principalArn = Text
a} :: GeneratedPolicyProperties)

instance Core.FromJSON GeneratedPolicyProperties where
  parseJSON :: Value -> Parser GeneratedPolicyProperties
parseJSON =
    String
-> (Object -> Parser GeneratedPolicyProperties)
-> Value
-> Parser GeneratedPolicyProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GeneratedPolicyProperties"
      ( \Object
x ->
          Maybe Bool
-> Maybe CloudTrailProperties -> Text -> GeneratedPolicyProperties
GeneratedPolicyProperties'
            (Maybe Bool
 -> Maybe CloudTrailProperties -> Text -> GeneratedPolicyProperties)
-> Parser (Maybe Bool)
-> Parser
     (Maybe CloudTrailProperties -> Text -> GeneratedPolicyProperties)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isComplete")
            Parser
  (Maybe CloudTrailProperties -> Text -> GeneratedPolicyProperties)
-> Parser (Maybe CloudTrailProperties)
-> Parser (Text -> GeneratedPolicyProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CloudTrailProperties)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cloudTrailProperties")
            Parser (Text -> GeneratedPolicyProperties)
-> Parser Text -> Parser GeneratedPolicyProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"principalArn")
      )

instance Prelude.Hashable GeneratedPolicyProperties

instance Prelude.NFData GeneratedPolicyProperties