{-# 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.SecurityHub.Types.AwsIamRolePolicy
-- 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.SecurityHub.Types.AwsIamRolePolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An inline policy that is embedded in the role.
--
-- /See:/ 'newAwsIamRolePolicy' smart constructor.
data AwsIamRolePolicy = AwsIamRolePolicy'
  { -- | The name of the policy.
    AwsIamRolePolicy -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsIamRolePolicy -> AwsIamRolePolicy -> Bool
(AwsIamRolePolicy -> AwsIamRolePolicy -> Bool)
-> (AwsIamRolePolicy -> AwsIamRolePolicy -> Bool)
-> Eq AwsIamRolePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsIamRolePolicy -> AwsIamRolePolicy -> Bool
$c/= :: AwsIamRolePolicy -> AwsIamRolePolicy -> Bool
== :: AwsIamRolePolicy -> AwsIamRolePolicy -> Bool
$c== :: AwsIamRolePolicy -> AwsIamRolePolicy -> Bool
Prelude.Eq, ReadPrec [AwsIamRolePolicy]
ReadPrec AwsIamRolePolicy
Int -> ReadS AwsIamRolePolicy
ReadS [AwsIamRolePolicy]
(Int -> ReadS AwsIamRolePolicy)
-> ReadS [AwsIamRolePolicy]
-> ReadPrec AwsIamRolePolicy
-> ReadPrec [AwsIamRolePolicy]
-> Read AwsIamRolePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsIamRolePolicy]
$creadListPrec :: ReadPrec [AwsIamRolePolicy]
readPrec :: ReadPrec AwsIamRolePolicy
$creadPrec :: ReadPrec AwsIamRolePolicy
readList :: ReadS [AwsIamRolePolicy]
$creadList :: ReadS [AwsIamRolePolicy]
readsPrec :: Int -> ReadS AwsIamRolePolicy
$creadsPrec :: Int -> ReadS AwsIamRolePolicy
Prelude.Read, Int -> AwsIamRolePolicy -> ShowS
[AwsIamRolePolicy] -> ShowS
AwsIamRolePolicy -> String
(Int -> AwsIamRolePolicy -> ShowS)
-> (AwsIamRolePolicy -> String)
-> ([AwsIamRolePolicy] -> ShowS)
-> Show AwsIamRolePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsIamRolePolicy] -> ShowS
$cshowList :: [AwsIamRolePolicy] -> ShowS
show :: AwsIamRolePolicy -> String
$cshow :: AwsIamRolePolicy -> String
showsPrec :: Int -> AwsIamRolePolicy -> ShowS
$cshowsPrec :: Int -> AwsIamRolePolicy -> ShowS
Prelude.Show, (forall x. AwsIamRolePolicy -> Rep AwsIamRolePolicy x)
-> (forall x. Rep AwsIamRolePolicy x -> AwsIamRolePolicy)
-> Generic AwsIamRolePolicy
forall x. Rep AwsIamRolePolicy x -> AwsIamRolePolicy
forall x. AwsIamRolePolicy -> Rep AwsIamRolePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsIamRolePolicy x -> AwsIamRolePolicy
$cfrom :: forall x. AwsIamRolePolicy -> Rep AwsIamRolePolicy x
Prelude.Generic)

-- |
-- Create a value of 'AwsIamRolePolicy' 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:
--
-- 'policyName', 'awsIamRolePolicy_policyName' - The name of the policy.
newAwsIamRolePolicy ::
  AwsIamRolePolicy
newAwsIamRolePolicy :: AwsIamRolePolicy
newAwsIamRolePolicy =
  AwsIamRolePolicy' :: Maybe Text -> AwsIamRolePolicy
AwsIamRolePolicy' {$sel:policyName:AwsIamRolePolicy' :: Maybe Text
policyName = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The name of the policy.
awsIamRolePolicy_policyName :: Lens.Lens' AwsIamRolePolicy (Prelude.Maybe Prelude.Text)
awsIamRolePolicy_policyName :: (Maybe Text -> f (Maybe Text))
-> AwsIamRolePolicy -> f AwsIamRolePolicy
awsIamRolePolicy_policyName = (AwsIamRolePolicy -> Maybe Text)
-> (AwsIamRolePolicy -> Maybe Text -> AwsIamRolePolicy)
-> Lens AwsIamRolePolicy AwsIamRolePolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamRolePolicy' {Maybe Text
policyName :: Maybe Text
$sel:policyName:AwsIamRolePolicy' :: AwsIamRolePolicy -> Maybe Text
policyName} -> Maybe Text
policyName) (\s :: AwsIamRolePolicy
s@AwsIamRolePolicy' {} Maybe Text
a -> AwsIamRolePolicy
s {$sel:policyName:AwsIamRolePolicy' :: Maybe Text
policyName = Maybe Text
a} :: AwsIamRolePolicy)

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

instance Prelude.Hashable AwsIamRolePolicy

instance Prelude.NFData AwsIamRolePolicy

instance Core.ToJSON AwsIamRolePolicy where
  toJSON :: AwsIamRolePolicy -> Value
toJSON AwsIamRolePolicy' {Maybe Text
policyName :: Maybe Text
$sel:policyName:AwsIamRolePolicy' :: AwsIamRolePolicy -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"PolicyName" 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
policyName]
      )