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

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

instance Prelude.Hashable IamRoleConfiguration

instance Prelude.NFData IamRoleConfiguration

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