{-# 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.PolicyUser
-- 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.PolicyUser 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 user 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:/ 'newPolicyUser' smart constructor.
data PolicyUser = PolicyUser'
  { -- | The stable and unique string identifying the user. For more information
    -- about IDs, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    PolicyUser -> Maybe Text
userId :: Prelude.Maybe Prelude.Text,
    -- | The name (friendly name, not ARN) identifying the user.
    PolicyUser -> Maybe Text
userName :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyUser -> PolicyUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyUser -> PolicyUser -> Bool
$c/= :: PolicyUser -> PolicyUser -> Bool
== :: PolicyUser -> PolicyUser -> Bool
$c== :: PolicyUser -> PolicyUser -> Bool
Prelude.Eq, ReadPrec [PolicyUser]
ReadPrec PolicyUser
Int -> ReadS PolicyUser
ReadS [PolicyUser]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyUser]
$creadListPrec :: ReadPrec [PolicyUser]
readPrec :: ReadPrec PolicyUser
$creadPrec :: ReadPrec PolicyUser
readList :: ReadS [PolicyUser]
$creadList :: ReadS [PolicyUser]
readsPrec :: Int -> ReadS PolicyUser
$creadsPrec :: Int -> ReadS PolicyUser
Prelude.Read, Int -> PolicyUser -> ShowS
[PolicyUser] -> ShowS
PolicyUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyUser] -> ShowS
$cshowList :: [PolicyUser] -> ShowS
show :: PolicyUser -> String
$cshow :: PolicyUser -> String
showsPrec :: Int -> PolicyUser -> ShowS
$cshowsPrec :: Int -> PolicyUser -> ShowS
Prelude.Show, forall x. Rep PolicyUser x -> PolicyUser
forall x. PolicyUser -> Rep PolicyUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyUser x -> PolicyUser
$cfrom :: forall x. PolicyUser -> Rep PolicyUser x
Prelude.Generic)

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

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

-- | The name (friendly name, not ARN) identifying the user.
policyUser_userName :: Lens.Lens' PolicyUser (Prelude.Maybe Prelude.Text)
policyUser_userName :: Lens' PolicyUser (Maybe Text)
policyUser_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyUser' {Maybe Text
userName :: Maybe Text
$sel:userName:PolicyUser' :: PolicyUser -> Maybe Text
userName} -> Maybe Text
userName) (\s :: PolicyUser
s@PolicyUser' {} Maybe Text
a -> PolicyUser
s {$sel:userName:PolicyUser' :: Maybe Text
userName = Maybe Text
a} :: PolicyUser)

instance Data.FromXML PolicyUser where
  parseXML :: [Node] -> Either String PolicyUser
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> PolicyUser
PolicyUser'
      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
"UserId")
      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
"UserName")

instance Prelude.Hashable PolicyUser where
  hashWithSalt :: Int -> PolicyUser -> Int
hashWithSalt Int
_salt PolicyUser' {Maybe Text
userName :: Maybe Text
userId :: Maybe Text
$sel:userName:PolicyUser' :: PolicyUser -> Maybe Text
$sel:userId:PolicyUser' :: PolicyUser -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userName

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