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

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.PermissionsBoundaryAttachmentType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an attached permissions boundary.
--
-- An attached permissions boundary is a managed policy that has been
-- attached to a user or role to set the permissions boundary.
--
-- For more information about permissions boundaries, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html Permissions boundaries for IAM identities>
-- in the /IAM User Guide/.
--
-- /See:/ 'newAttachedPermissionsBoundary' smart constructor.
data AttachedPermissionsBoundary = AttachedPermissionsBoundary'
  { -- | The permissions boundary usage type that indicates what type of IAM
    -- resource is used as the permissions boundary for an entity. This data
    -- type can only have a value of @Policy@.
    AttachedPermissionsBoundary
-> Maybe PermissionsBoundaryAttachmentType
permissionsBoundaryType :: Prelude.Maybe PermissionsBoundaryAttachmentType,
    -- | The ARN of the policy used to set the permissions boundary for the user
    -- or role.
    AttachedPermissionsBoundary -> Maybe Text
permissionsBoundaryArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AttachedPermissionsBoundary -> AttachedPermissionsBoundary -> Bool
(AttachedPermissionsBoundary
 -> AttachedPermissionsBoundary -> Bool)
-> (AttachedPermissionsBoundary
    -> AttachedPermissionsBoundary -> Bool)
-> Eq AttachedPermissionsBoundary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachedPermissionsBoundary -> AttachedPermissionsBoundary -> Bool
$c/= :: AttachedPermissionsBoundary -> AttachedPermissionsBoundary -> Bool
== :: AttachedPermissionsBoundary -> AttachedPermissionsBoundary -> Bool
$c== :: AttachedPermissionsBoundary -> AttachedPermissionsBoundary -> Bool
Prelude.Eq, ReadPrec [AttachedPermissionsBoundary]
ReadPrec AttachedPermissionsBoundary
Int -> ReadS AttachedPermissionsBoundary
ReadS [AttachedPermissionsBoundary]
(Int -> ReadS AttachedPermissionsBoundary)
-> ReadS [AttachedPermissionsBoundary]
-> ReadPrec AttachedPermissionsBoundary
-> ReadPrec [AttachedPermissionsBoundary]
-> Read AttachedPermissionsBoundary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachedPermissionsBoundary]
$creadListPrec :: ReadPrec [AttachedPermissionsBoundary]
readPrec :: ReadPrec AttachedPermissionsBoundary
$creadPrec :: ReadPrec AttachedPermissionsBoundary
readList :: ReadS [AttachedPermissionsBoundary]
$creadList :: ReadS [AttachedPermissionsBoundary]
readsPrec :: Int -> ReadS AttachedPermissionsBoundary
$creadsPrec :: Int -> ReadS AttachedPermissionsBoundary
Prelude.Read, Int -> AttachedPermissionsBoundary -> ShowS
[AttachedPermissionsBoundary] -> ShowS
AttachedPermissionsBoundary -> String
(Int -> AttachedPermissionsBoundary -> ShowS)
-> (AttachedPermissionsBoundary -> String)
-> ([AttachedPermissionsBoundary] -> ShowS)
-> Show AttachedPermissionsBoundary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachedPermissionsBoundary] -> ShowS
$cshowList :: [AttachedPermissionsBoundary] -> ShowS
show :: AttachedPermissionsBoundary -> String
$cshow :: AttachedPermissionsBoundary -> String
showsPrec :: Int -> AttachedPermissionsBoundary -> ShowS
$cshowsPrec :: Int -> AttachedPermissionsBoundary -> ShowS
Prelude.Show, (forall x.
 AttachedPermissionsBoundary -> Rep AttachedPermissionsBoundary x)
-> (forall x.
    Rep AttachedPermissionsBoundary x -> AttachedPermissionsBoundary)
-> Generic AttachedPermissionsBoundary
forall x.
Rep AttachedPermissionsBoundary x -> AttachedPermissionsBoundary
forall x.
AttachedPermissionsBoundary -> Rep AttachedPermissionsBoundary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AttachedPermissionsBoundary x -> AttachedPermissionsBoundary
$cfrom :: forall x.
AttachedPermissionsBoundary -> Rep AttachedPermissionsBoundary x
Prelude.Generic)

-- |
-- Create a value of 'AttachedPermissionsBoundary' 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:
--
-- 'permissionsBoundaryType', 'attachedPermissionsBoundary_permissionsBoundaryType' - The permissions boundary usage type that indicates what type of IAM
-- resource is used as the permissions boundary for an entity. This data
-- type can only have a value of @Policy@.
--
-- 'permissionsBoundaryArn', 'attachedPermissionsBoundary_permissionsBoundaryArn' - The ARN of the policy used to set the permissions boundary for the user
-- or role.
newAttachedPermissionsBoundary ::
  AttachedPermissionsBoundary
newAttachedPermissionsBoundary :: AttachedPermissionsBoundary
newAttachedPermissionsBoundary =
  AttachedPermissionsBoundary' :: Maybe PermissionsBoundaryAttachmentType
-> Maybe Text -> AttachedPermissionsBoundary
AttachedPermissionsBoundary'
    { $sel:permissionsBoundaryType:AttachedPermissionsBoundary' :: Maybe PermissionsBoundaryAttachmentType
permissionsBoundaryType =
        Maybe PermissionsBoundaryAttachmentType
forall a. Maybe a
Prelude.Nothing,
      $sel:permissionsBoundaryArn:AttachedPermissionsBoundary' :: Maybe Text
permissionsBoundaryArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The permissions boundary usage type that indicates what type of IAM
-- resource is used as the permissions boundary for an entity. This data
-- type can only have a value of @Policy@.
attachedPermissionsBoundary_permissionsBoundaryType :: Lens.Lens' AttachedPermissionsBoundary (Prelude.Maybe PermissionsBoundaryAttachmentType)
attachedPermissionsBoundary_permissionsBoundaryType :: (Maybe PermissionsBoundaryAttachmentType
 -> f (Maybe PermissionsBoundaryAttachmentType))
-> AttachedPermissionsBoundary -> f AttachedPermissionsBoundary
attachedPermissionsBoundary_permissionsBoundaryType = (AttachedPermissionsBoundary
 -> Maybe PermissionsBoundaryAttachmentType)
-> (AttachedPermissionsBoundary
    -> Maybe PermissionsBoundaryAttachmentType
    -> AttachedPermissionsBoundary)
-> Lens
     AttachedPermissionsBoundary
     AttachedPermissionsBoundary
     (Maybe PermissionsBoundaryAttachmentType)
     (Maybe PermissionsBoundaryAttachmentType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachedPermissionsBoundary' {Maybe PermissionsBoundaryAttachmentType
permissionsBoundaryType :: Maybe PermissionsBoundaryAttachmentType
$sel:permissionsBoundaryType:AttachedPermissionsBoundary' :: AttachedPermissionsBoundary
-> Maybe PermissionsBoundaryAttachmentType
permissionsBoundaryType} -> Maybe PermissionsBoundaryAttachmentType
permissionsBoundaryType) (\s :: AttachedPermissionsBoundary
s@AttachedPermissionsBoundary' {} Maybe PermissionsBoundaryAttachmentType
a -> AttachedPermissionsBoundary
s {$sel:permissionsBoundaryType:AttachedPermissionsBoundary' :: Maybe PermissionsBoundaryAttachmentType
permissionsBoundaryType = Maybe PermissionsBoundaryAttachmentType
a} :: AttachedPermissionsBoundary)

-- | The ARN of the policy used to set the permissions boundary for the user
-- or role.
attachedPermissionsBoundary_permissionsBoundaryArn :: Lens.Lens' AttachedPermissionsBoundary (Prelude.Maybe Prelude.Text)
attachedPermissionsBoundary_permissionsBoundaryArn :: (Maybe Text -> f (Maybe Text))
-> AttachedPermissionsBoundary -> f AttachedPermissionsBoundary
attachedPermissionsBoundary_permissionsBoundaryArn = (AttachedPermissionsBoundary -> Maybe Text)
-> (AttachedPermissionsBoundary
    -> Maybe Text -> AttachedPermissionsBoundary)
-> Lens
     AttachedPermissionsBoundary
     AttachedPermissionsBoundary
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachedPermissionsBoundary' {Maybe Text
permissionsBoundaryArn :: Maybe Text
$sel:permissionsBoundaryArn:AttachedPermissionsBoundary' :: AttachedPermissionsBoundary -> Maybe Text
permissionsBoundaryArn} -> Maybe Text
permissionsBoundaryArn) (\s :: AttachedPermissionsBoundary
s@AttachedPermissionsBoundary' {} Maybe Text
a -> AttachedPermissionsBoundary
s {$sel:permissionsBoundaryArn:AttachedPermissionsBoundary' :: Maybe Text
permissionsBoundaryArn = Maybe Text
a} :: AttachedPermissionsBoundary)

instance Core.FromXML AttachedPermissionsBoundary where
  parseXML :: [Node] -> Either String AttachedPermissionsBoundary
parseXML [Node]
x =
    Maybe PermissionsBoundaryAttachmentType
-> Maybe Text -> AttachedPermissionsBoundary
AttachedPermissionsBoundary'
      (Maybe PermissionsBoundaryAttachmentType
 -> Maybe Text -> AttachedPermissionsBoundary)
-> Either String (Maybe PermissionsBoundaryAttachmentType)
-> Either String (Maybe Text -> AttachedPermissionsBoundary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node]
-> Text -> Either String (Maybe PermissionsBoundaryAttachmentType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PermissionsBoundaryType")
      Either String (Maybe Text -> AttachedPermissionsBoundary)
-> Either String (Maybe Text)
-> Either String AttachedPermissionsBoundary
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
"PermissionsBoundaryArn")

instance Prelude.Hashable AttachedPermissionsBoundary

instance Prelude.NFData AttachedPermissionsBoundary