{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IAM.Types.PolicyRole where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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,
    -- | The name (friendly name, not ARN) identifying the role.
    PolicyRole -> Maybe Text
roleName :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyRole -> PolicyRole -> Bool
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]
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
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. 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:
--
-- '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/.
--
-- 'roleName', 'policyRole_roleName' - The name (friendly name, not ARN) identifying the role.
newPolicyRole ::
  PolicyRole
newPolicyRole :: PolicyRole
newPolicyRole =
  PolicyRole'
    { $sel:roleId:PolicyRole' :: Maybe Text
roleId = forall a. Maybe a
Prelude.Nothing,
      $sel:roleName:PolicyRole' :: Maybe Text
roleName = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' PolicyRole (Maybe Text)
policyRole_roleId = 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)

-- | The name (friendly name, not ARN) identifying the role.
policyRole_roleName :: Lens.Lens' PolicyRole (Prelude.Maybe Prelude.Text)
policyRole_roleName :: Lens' PolicyRole (Maybe Text)
policyRole_roleName = 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)

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

instance Prelude.Hashable PolicyRole where
  hashWithSalt :: Int -> PolicyRole -> Int
hashWithSalt Int
_salt PolicyRole' {Maybe Text
roleName :: Maybe Text
roleId :: Maybe Text
$sel:roleName:PolicyRole' :: PolicyRole -> Maybe Text
$sel:roleId:PolicyRole' :: PolicyRole -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleName

instance Prelude.NFData PolicyRole where
  rnf :: PolicyRole -> ()
rnf PolicyRole' {Maybe Text
roleName :: Maybe Text
roleId :: Maybe Text
$sel:roleName:PolicyRole' :: PolicyRole -> Maybe Text
$sel:roleId:PolicyRole' :: PolicyRole -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleName