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

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

-- | A managed policy that is attached to an IAM principal.
--
-- /See:/ 'newAwsIamAttachedManagedPolicy' smart constructor.
data AwsIamAttachedManagedPolicy = AwsIamAttachedManagedPolicy'
  { -- | The name of the policy.
    AwsIamAttachedManagedPolicy -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the policy.
    AwsIamAttachedManagedPolicy -> Maybe Text
policyArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsIamAttachedManagedPolicy -> AwsIamAttachedManagedPolicy -> Bool
(AwsIamAttachedManagedPolicy
 -> AwsIamAttachedManagedPolicy -> Bool)
-> (AwsIamAttachedManagedPolicy
    -> AwsIamAttachedManagedPolicy -> Bool)
-> Eq AwsIamAttachedManagedPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsIamAttachedManagedPolicy -> AwsIamAttachedManagedPolicy -> Bool
$c/= :: AwsIamAttachedManagedPolicy -> AwsIamAttachedManagedPolicy -> Bool
== :: AwsIamAttachedManagedPolicy -> AwsIamAttachedManagedPolicy -> Bool
$c== :: AwsIamAttachedManagedPolicy -> AwsIamAttachedManagedPolicy -> Bool
Prelude.Eq, ReadPrec [AwsIamAttachedManagedPolicy]
ReadPrec AwsIamAttachedManagedPolicy
Int -> ReadS AwsIamAttachedManagedPolicy
ReadS [AwsIamAttachedManagedPolicy]
(Int -> ReadS AwsIamAttachedManagedPolicy)
-> ReadS [AwsIamAttachedManagedPolicy]
-> ReadPrec AwsIamAttachedManagedPolicy
-> ReadPrec [AwsIamAttachedManagedPolicy]
-> Read AwsIamAttachedManagedPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsIamAttachedManagedPolicy]
$creadListPrec :: ReadPrec [AwsIamAttachedManagedPolicy]
readPrec :: ReadPrec AwsIamAttachedManagedPolicy
$creadPrec :: ReadPrec AwsIamAttachedManagedPolicy
readList :: ReadS [AwsIamAttachedManagedPolicy]
$creadList :: ReadS [AwsIamAttachedManagedPolicy]
readsPrec :: Int -> ReadS AwsIamAttachedManagedPolicy
$creadsPrec :: Int -> ReadS AwsIamAttachedManagedPolicy
Prelude.Read, Int -> AwsIamAttachedManagedPolicy -> ShowS
[AwsIamAttachedManagedPolicy] -> ShowS
AwsIamAttachedManagedPolicy -> String
(Int -> AwsIamAttachedManagedPolicy -> ShowS)
-> (AwsIamAttachedManagedPolicy -> String)
-> ([AwsIamAttachedManagedPolicy] -> ShowS)
-> Show AwsIamAttachedManagedPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsIamAttachedManagedPolicy] -> ShowS
$cshowList :: [AwsIamAttachedManagedPolicy] -> ShowS
show :: AwsIamAttachedManagedPolicy -> String
$cshow :: AwsIamAttachedManagedPolicy -> String
showsPrec :: Int -> AwsIamAttachedManagedPolicy -> ShowS
$cshowsPrec :: Int -> AwsIamAttachedManagedPolicy -> ShowS
Prelude.Show, (forall x.
 AwsIamAttachedManagedPolicy -> Rep AwsIamAttachedManagedPolicy x)
-> (forall x.
    Rep AwsIamAttachedManagedPolicy x -> AwsIamAttachedManagedPolicy)
-> Generic AwsIamAttachedManagedPolicy
forall x.
Rep AwsIamAttachedManagedPolicy x -> AwsIamAttachedManagedPolicy
forall x.
AwsIamAttachedManagedPolicy -> Rep AwsIamAttachedManagedPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsIamAttachedManagedPolicy x -> AwsIamAttachedManagedPolicy
$cfrom :: forall x.
AwsIamAttachedManagedPolicy -> Rep AwsIamAttachedManagedPolicy x
Prelude.Generic)

-- |
-- Create a value of 'AwsIamAttachedManagedPolicy' 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', 'awsIamAttachedManagedPolicy_policyName' - The name of the policy.
--
-- 'policyArn', 'awsIamAttachedManagedPolicy_policyArn' - The ARN of the policy.
newAwsIamAttachedManagedPolicy ::
  AwsIamAttachedManagedPolicy
newAwsIamAttachedManagedPolicy :: AwsIamAttachedManagedPolicy
newAwsIamAttachedManagedPolicy =
  AwsIamAttachedManagedPolicy' :: Maybe Text -> Maybe Text -> AwsIamAttachedManagedPolicy
AwsIamAttachedManagedPolicy'
    { $sel:policyName:AwsIamAttachedManagedPolicy' :: Maybe Text
policyName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyArn:AwsIamAttachedManagedPolicy' :: Maybe Text
policyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The ARN of the policy.
awsIamAttachedManagedPolicy_policyArn :: Lens.Lens' AwsIamAttachedManagedPolicy (Prelude.Maybe Prelude.Text)
awsIamAttachedManagedPolicy_policyArn :: (Maybe Text -> f (Maybe Text))
-> AwsIamAttachedManagedPolicy -> f AwsIamAttachedManagedPolicy
awsIamAttachedManagedPolicy_policyArn = (AwsIamAttachedManagedPolicy -> Maybe Text)
-> (AwsIamAttachedManagedPolicy
    -> Maybe Text -> AwsIamAttachedManagedPolicy)
-> Lens
     AwsIamAttachedManagedPolicy
     AwsIamAttachedManagedPolicy
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamAttachedManagedPolicy' {Maybe Text
policyArn :: Maybe Text
$sel:policyArn:AwsIamAttachedManagedPolicy' :: AwsIamAttachedManagedPolicy -> Maybe Text
policyArn} -> Maybe Text
policyArn) (\s :: AwsIamAttachedManagedPolicy
s@AwsIamAttachedManagedPolicy' {} Maybe Text
a -> AwsIamAttachedManagedPolicy
s {$sel:policyArn:AwsIamAttachedManagedPolicy' :: Maybe Text
policyArn = Maybe Text
a} :: AwsIamAttachedManagedPolicy)

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

instance Prelude.Hashable AwsIamAttachedManagedPolicy

instance Prelude.NFData AwsIamAttachedManagedPolicy

instance Core.ToJSON AwsIamAttachedManagedPolicy where
  toJSON :: AwsIamAttachedManagedPolicy -> Value
toJSON AwsIamAttachedManagedPolicy' {Maybe Text
policyArn :: Maybe Text
policyName :: Maybe Text
$sel:policyArn:AwsIamAttachedManagedPolicy' :: AwsIamAttachedManagedPolicy -> Maybe Text
$sel:policyName:AwsIamAttachedManagedPolicy' :: AwsIamAttachedManagedPolicy -> 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,
            (Text
"PolicyArn" 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
policyArn
          ]
      )