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

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

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

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

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

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

instance Prelude.NFData AwsIamUserPolicy

instance Core.ToJSON AwsIamUserPolicy where
  toJSON :: AwsIamUserPolicy -> Value
toJSON AwsIamUserPolicy' {Maybe Text
policyName :: Maybe Text
$sel:policyName:AwsIamUserPolicy' :: AwsIamUserPolicy -> 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]
      )