{-# 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.IamRoleConfiguration
-- 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.IamRoleConfiguration 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

-- | The proposed access control configuration for an IAM role. You can
-- propose a configuration for a new IAM role or an existing IAM role that
-- you own by specifying the trust policy. If the configuration is for a
-- new IAM role, you must specify the trust policy. If the configuration is
-- for an existing IAM role that you own and you do not propose the trust
-- policy, the access preview uses the existing trust policy for the role.
-- The proposed trust policy cannot be an empty string. For more
-- information about role trust policy limits, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html IAM and STS quotas>.
--
-- /See:/ 'newIamRoleConfiguration' smart constructor.
data IamRoleConfiguration = IamRoleConfiguration'
  { -- | The proposed trust policy for the IAM role.
    IamRoleConfiguration -> Maybe Text
trustPolicy :: Prelude.Maybe Prelude.Text
  }
  deriving (IamRoleConfiguration -> IamRoleConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IamRoleConfiguration -> IamRoleConfiguration -> Bool
$c/= :: IamRoleConfiguration -> IamRoleConfiguration -> Bool
== :: IamRoleConfiguration -> IamRoleConfiguration -> Bool
$c== :: IamRoleConfiguration -> IamRoleConfiguration -> Bool
Prelude.Eq, ReadPrec [IamRoleConfiguration]
ReadPrec IamRoleConfiguration
Int -> ReadS IamRoleConfiguration
ReadS [IamRoleConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IamRoleConfiguration]
$creadListPrec :: ReadPrec [IamRoleConfiguration]
readPrec :: ReadPrec IamRoleConfiguration
$creadPrec :: ReadPrec IamRoleConfiguration
readList :: ReadS [IamRoleConfiguration]
$creadList :: ReadS [IamRoleConfiguration]
readsPrec :: Int -> ReadS IamRoleConfiguration
$creadsPrec :: Int -> ReadS IamRoleConfiguration
Prelude.Read, Int -> IamRoleConfiguration -> ShowS
[IamRoleConfiguration] -> ShowS
IamRoleConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IamRoleConfiguration] -> ShowS
$cshowList :: [IamRoleConfiguration] -> ShowS
show :: IamRoleConfiguration -> String
$cshow :: IamRoleConfiguration -> String
showsPrec :: Int -> IamRoleConfiguration -> ShowS
$cshowsPrec :: Int -> IamRoleConfiguration -> ShowS
Prelude.Show, forall x. Rep IamRoleConfiguration x -> IamRoleConfiguration
forall x. IamRoleConfiguration -> Rep IamRoleConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IamRoleConfiguration x -> IamRoleConfiguration
$cfrom :: forall x. IamRoleConfiguration -> Rep IamRoleConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'IamRoleConfiguration' 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:
--
-- 'trustPolicy', 'iamRoleConfiguration_trustPolicy' - The proposed trust policy for the IAM role.
newIamRoleConfiguration ::
  IamRoleConfiguration
newIamRoleConfiguration :: IamRoleConfiguration
newIamRoleConfiguration =
  IamRoleConfiguration'
    { $sel:trustPolicy:IamRoleConfiguration' :: Maybe Text
trustPolicy =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The proposed trust policy for the IAM role.
iamRoleConfiguration_trustPolicy :: Lens.Lens' IamRoleConfiguration (Prelude.Maybe Prelude.Text)
iamRoleConfiguration_trustPolicy :: Lens' IamRoleConfiguration (Maybe Text)
iamRoleConfiguration_trustPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamRoleConfiguration' {Maybe Text
trustPolicy :: Maybe Text
$sel:trustPolicy:IamRoleConfiguration' :: IamRoleConfiguration -> Maybe Text
trustPolicy} -> Maybe Text
trustPolicy) (\s :: IamRoleConfiguration
s@IamRoleConfiguration' {} Maybe Text
a -> IamRoleConfiguration
s {$sel:trustPolicy:IamRoleConfiguration' :: Maybe Text
trustPolicy = Maybe Text
a} :: IamRoleConfiguration)

instance Data.FromJSON IamRoleConfiguration where
  parseJSON :: Value -> Parser IamRoleConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IamRoleConfiguration"
      ( \Object
x ->
          Maybe Text -> IamRoleConfiguration
IamRoleConfiguration'
            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
"trustPolicy")
      )

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

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

instance Data.ToJSON IamRoleConfiguration where
  toJSON :: IamRoleConfiguration -> Value
toJSON IamRoleConfiguration' {Maybe Text
trustPolicy :: Maybe Text
$sel:trustPolicy:IamRoleConfiguration' :: IamRoleConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"trustPolicy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
trustPolicy]
      )