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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 name (friendly name, not ARN) identifying the user.
    PolicyUser -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (PolicyUser -> PolicyUser -> Bool
(PolicyUser -> PolicyUser -> Bool)
-> (PolicyUser -> PolicyUser -> Bool) -> Eq PolicyUser
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]
(Int -> ReadS PolicyUser)
-> ReadS [PolicyUser]
-> ReadPrec PolicyUser
-> ReadPrec [PolicyUser]
-> Read 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
(Int -> PolicyUser -> ShowS)
-> (PolicyUser -> String)
-> ([PolicyUser] -> ShowS)
-> Show PolicyUser
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. PolicyUser -> Rep PolicyUser x)
-> (forall x. Rep PolicyUser x -> PolicyUser) -> Generic PolicyUser
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:
--
-- 'userName', 'policyUser_userName' - The name (friendly name, not ARN) identifying the user.
--
-- '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/.
newPolicyUser ::
  PolicyUser
newPolicyUser :: PolicyUser
newPolicyUser =
  PolicyUser' :: Maybe Text -> Maybe Text -> PolicyUser
PolicyUser'
    { $sel:userName:PolicyUser' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userId:PolicyUser' :: Maybe Text
userId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name (friendly name, not ARN) identifying the user.
policyUser_userName :: Lens.Lens' PolicyUser (Prelude.Maybe Prelude.Text)
policyUser_userName :: (Maybe Text -> f (Maybe Text)) -> PolicyUser -> f PolicyUser
policyUser_userName = (PolicyUser -> Maybe Text)
-> (PolicyUser -> Maybe Text -> PolicyUser)
-> Lens PolicyUser PolicyUser (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> PolicyUser -> f PolicyUser
policyUser_userId = (PolicyUser -> Maybe Text)
-> (PolicyUser -> Maybe Text -> PolicyUser)
-> Lens PolicyUser PolicyUser (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable PolicyUser

instance Prelude.NFData PolicyUser