{-# 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.IAM.Types.PolicyDetail
-- 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.IAM.Types.PolicyDetail where

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

-- | Contains information about an IAM policy, including the policy document.
--
-- This data type is used as a response element in the
-- GetAccountAuthorizationDetails operation.
--
-- /See:/ 'newPolicyDetail' smart constructor.
data PolicyDetail = PolicyDetail'
  { -- | The policy document.
    PolicyDetail -> Maybe Text
policyDocument :: Prelude.Maybe Prelude.Text,
    -- | The name of the policy.
    PolicyDetail -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyDetail -> PolicyDetail -> Bool
(PolicyDetail -> PolicyDetail -> Bool)
-> (PolicyDetail -> PolicyDetail -> Bool) -> Eq PolicyDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyDetail -> PolicyDetail -> Bool
$c/= :: PolicyDetail -> PolicyDetail -> Bool
== :: PolicyDetail -> PolicyDetail -> Bool
$c== :: PolicyDetail -> PolicyDetail -> Bool
Prelude.Eq, ReadPrec [PolicyDetail]
ReadPrec PolicyDetail
Int -> ReadS PolicyDetail
ReadS [PolicyDetail]
(Int -> ReadS PolicyDetail)
-> ReadS [PolicyDetail]
-> ReadPrec PolicyDetail
-> ReadPrec [PolicyDetail]
-> Read PolicyDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyDetail]
$creadListPrec :: ReadPrec [PolicyDetail]
readPrec :: ReadPrec PolicyDetail
$creadPrec :: ReadPrec PolicyDetail
readList :: ReadS [PolicyDetail]
$creadList :: ReadS [PolicyDetail]
readsPrec :: Int -> ReadS PolicyDetail
$creadsPrec :: Int -> ReadS PolicyDetail
Prelude.Read, Int -> PolicyDetail -> ShowS
[PolicyDetail] -> ShowS
PolicyDetail -> String
(Int -> PolicyDetail -> ShowS)
-> (PolicyDetail -> String)
-> ([PolicyDetail] -> ShowS)
-> Show PolicyDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyDetail] -> ShowS
$cshowList :: [PolicyDetail] -> ShowS
show :: PolicyDetail -> String
$cshow :: PolicyDetail -> String
showsPrec :: Int -> PolicyDetail -> ShowS
$cshowsPrec :: Int -> PolicyDetail -> ShowS
Prelude.Show, (forall x. PolicyDetail -> Rep PolicyDetail x)
-> (forall x. Rep PolicyDetail x -> PolicyDetail)
-> Generic PolicyDetail
forall x. Rep PolicyDetail x -> PolicyDetail
forall x. PolicyDetail -> Rep PolicyDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyDetail x -> PolicyDetail
$cfrom :: forall x. PolicyDetail -> Rep PolicyDetail x
Prelude.Generic)

-- |
-- Create a value of 'PolicyDetail' 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:
--
-- 'policyDocument', 'policyDetail_policyDocument' - The policy document.
--
-- 'policyName', 'policyDetail_policyName' - The name of the policy.
newPolicyDetail ::
  PolicyDetail
newPolicyDetail :: PolicyDetail
newPolicyDetail =
  PolicyDetail' :: Maybe Text -> Maybe Text -> PolicyDetail
PolicyDetail'
    { $sel:policyDocument:PolicyDetail' :: Maybe Text
policyDocument = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyName:PolicyDetail' :: Maybe Text
policyName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The policy document.
policyDetail_policyDocument :: Lens.Lens' PolicyDetail (Prelude.Maybe Prelude.Text)
policyDetail_policyDocument :: (Maybe Text -> f (Maybe Text)) -> PolicyDetail -> f PolicyDetail
policyDetail_policyDocument = (PolicyDetail -> Maybe Text)
-> (PolicyDetail -> Maybe Text -> PolicyDetail)
-> Lens PolicyDetail PolicyDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetail' {Maybe Text
policyDocument :: Maybe Text
$sel:policyDocument:PolicyDetail' :: PolicyDetail -> Maybe Text
policyDocument} -> Maybe Text
policyDocument) (\s :: PolicyDetail
s@PolicyDetail' {} Maybe Text
a -> PolicyDetail
s {$sel:policyDocument:PolicyDetail' :: Maybe Text
policyDocument = Maybe Text
a} :: PolicyDetail)

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

instance Core.FromXML PolicyDetail where
  parseXML :: [Node] -> Either String PolicyDetail
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> PolicyDetail
PolicyDetail'
      (Maybe Text -> Maybe Text -> PolicyDetail)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> PolicyDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PolicyDocument")
      Either String (Maybe Text -> PolicyDetail)
-> Either String (Maybe Text) -> Either String PolicyDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PolicyName")

instance Prelude.Hashable PolicyDetail

instance Prelude.NFData PolicyDetail