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

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

-- | Contains information about a role that a managed policy is attached to.
--
-- This data type is used as a response element in the
-- ListEntitiesForPolicy operation.
--
-- For more information about managed policies, refer to
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html Managed policies and inline policies>
-- in the /IAM User Guide/.
--
-- /See:/ 'newPolicyRole' smart constructor.
data PolicyRole = PolicyRole'
  { -- | The name (friendly name, not ARN) identifying the role.
    PolicyRole -> Maybe Text
roleName :: Prelude.Maybe Prelude.Text,
    -- | The stable and unique string identifying the role. For more information
    -- about IDs, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    PolicyRole -> Maybe Text
roleId :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyRole -> PolicyRole -> Bool
(PolicyRole -> PolicyRole -> Bool)
-> (PolicyRole -> PolicyRole -> Bool) -> Eq PolicyRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyRole -> PolicyRole -> Bool
$c/= :: PolicyRole -> PolicyRole -> Bool
== :: PolicyRole -> PolicyRole -> Bool
$c== :: PolicyRole -> PolicyRole -> Bool
Prelude.Eq, ReadPrec [PolicyRole]
ReadPrec PolicyRole
Int -> ReadS PolicyRole
ReadS [PolicyRole]
(Int -> ReadS PolicyRole)
-> ReadS [PolicyRole]
-> ReadPrec PolicyRole
-> ReadPrec [PolicyRole]
-> Read PolicyRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyRole]
$creadListPrec :: ReadPrec [PolicyRole]
readPrec :: ReadPrec PolicyRole
$creadPrec :: ReadPrec PolicyRole
readList :: ReadS [PolicyRole]
$creadList :: ReadS [PolicyRole]
readsPrec :: Int -> ReadS PolicyRole
$creadsPrec :: Int -> ReadS PolicyRole
Prelude.Read, Int -> PolicyRole -> ShowS
[PolicyRole] -> ShowS
PolicyRole -> String
(Int -> PolicyRole -> ShowS)
-> (PolicyRole -> String)
-> ([PolicyRole] -> ShowS)
-> Show PolicyRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyRole] -> ShowS
$cshowList :: [PolicyRole] -> ShowS
show :: PolicyRole -> String
$cshow :: PolicyRole -> String
showsPrec :: Int -> PolicyRole -> ShowS
$cshowsPrec :: Int -> PolicyRole -> ShowS
Prelude.Show, (forall x. PolicyRole -> Rep PolicyRole x)
-> (forall x. Rep PolicyRole x -> PolicyRole) -> Generic PolicyRole
forall x. Rep PolicyRole x -> PolicyRole
forall x. PolicyRole -> Rep PolicyRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyRole x -> PolicyRole
$cfrom :: forall x. PolicyRole -> Rep PolicyRole x
Prelude.Generic)

-- |
-- Create a value of 'PolicyRole' 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:
--
-- 'roleName', 'policyRole_roleName' - The name (friendly name, not ARN) identifying the role.
--
-- 'roleId', 'policyRole_roleId' - The stable and unique string identifying the role. For more information
-- about IDs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
newPolicyRole ::
  PolicyRole
newPolicyRole :: PolicyRole
newPolicyRole =
  PolicyRole' :: Maybe Text -> Maybe Text -> PolicyRole
PolicyRole'
    { $sel:roleName:PolicyRole' :: Maybe Text
roleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleId:PolicyRole' :: Maybe Text
roleId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name (friendly name, not ARN) identifying the role.
policyRole_roleName :: Lens.Lens' PolicyRole (Prelude.Maybe Prelude.Text)
policyRole_roleName :: (Maybe Text -> f (Maybe Text)) -> PolicyRole -> f PolicyRole
policyRole_roleName = (PolicyRole -> Maybe Text)
-> (PolicyRole -> Maybe Text -> PolicyRole)
-> Lens PolicyRole PolicyRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyRole' {Maybe Text
roleName :: Maybe Text
$sel:roleName:PolicyRole' :: PolicyRole -> Maybe Text
roleName} -> Maybe Text
roleName) (\s :: PolicyRole
s@PolicyRole' {} Maybe Text
a -> PolicyRole
s {$sel:roleName:PolicyRole' :: Maybe Text
roleName = Maybe Text
a} :: PolicyRole)

-- | The stable and unique string identifying the role. For more information
-- about IDs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
policyRole_roleId :: Lens.Lens' PolicyRole (Prelude.Maybe Prelude.Text)
policyRole_roleId :: (Maybe Text -> f (Maybe Text)) -> PolicyRole -> f PolicyRole
policyRole_roleId = (PolicyRole -> Maybe Text)
-> (PolicyRole -> Maybe Text -> PolicyRole)
-> Lens PolicyRole PolicyRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyRole' {Maybe Text
roleId :: Maybe Text
$sel:roleId:PolicyRole' :: PolicyRole -> Maybe Text
roleId} -> Maybe Text
roleId) (\s :: PolicyRole
s@PolicyRole' {} Maybe Text
a -> PolicyRole
s {$sel:roleId:PolicyRole' :: Maybe Text
roleId = Maybe Text
a} :: PolicyRole)

instance Core.FromXML PolicyRole where
  parseXML :: [Node] -> Either String PolicyRole
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> PolicyRole
PolicyRole'
      (Maybe Text -> Maybe Text -> PolicyRole)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> PolicyRole)
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
"RoleName")
      Either String (Maybe Text -> PolicyRole)
-> Either String (Maybe Text) -> Either String PolicyRole
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
"RoleId")

instance Prelude.Hashable PolicyRole

instance Prelude.NFData PolicyRole