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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types.PolicyOwnerEntityType
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the specified entity (user or role).
--
-- This data type is an element of the EntityDetails object.
--
-- /See:/ 'newEntityInfo' smart constructor.
data EntityInfo = EntityInfo'
  { -- | The path to the entity (user or role). For more information about paths,
    -- see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    EntityInfo -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    EntityInfo -> Text
arn :: Prelude.Text,
    -- | The name of the entity (user or role).
    EntityInfo -> Text
name :: Prelude.Text,
    -- | The type of entity (user or role).
    EntityInfo -> PolicyOwnerEntityType
type' :: PolicyOwnerEntityType,
    -- | The identifier of the entity (user or role).
    EntityInfo -> Text
id :: Prelude.Text
  }
  deriving (EntityInfo -> EntityInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityInfo -> EntityInfo -> Bool
$c/= :: EntityInfo -> EntityInfo -> Bool
== :: EntityInfo -> EntityInfo -> Bool
$c== :: EntityInfo -> EntityInfo -> Bool
Prelude.Eq, ReadPrec [EntityInfo]
ReadPrec EntityInfo
Int -> ReadS EntityInfo
ReadS [EntityInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityInfo]
$creadListPrec :: ReadPrec [EntityInfo]
readPrec :: ReadPrec EntityInfo
$creadPrec :: ReadPrec EntityInfo
readList :: ReadS [EntityInfo]
$creadList :: ReadS [EntityInfo]
readsPrec :: Int -> ReadS EntityInfo
$creadsPrec :: Int -> ReadS EntityInfo
Prelude.Read, Int -> EntityInfo -> ShowS
[EntityInfo] -> ShowS
EntityInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityInfo] -> ShowS
$cshowList :: [EntityInfo] -> ShowS
show :: EntityInfo -> String
$cshow :: EntityInfo -> String
showsPrec :: Int -> EntityInfo -> ShowS
$cshowsPrec :: Int -> EntityInfo -> ShowS
Prelude.Show, forall x. Rep EntityInfo x -> EntityInfo
forall x. EntityInfo -> Rep EntityInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntityInfo x -> EntityInfo
$cfrom :: forall x. EntityInfo -> Rep EntityInfo x
Prelude.Generic)

-- |
-- Create a value of 'EntityInfo' 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:
--
-- 'path', 'entityInfo_path' - The path to the entity (user or role). For more information about paths,
-- see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- 'arn', 'entityInfo_arn' - Undocumented member.
--
-- 'name', 'entityInfo_name' - The name of the entity (user or role).
--
-- 'type'', 'entityInfo_type' - The type of entity (user or role).
--
-- 'id', 'entityInfo_id' - The identifier of the entity (user or role).
newEntityInfo ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  PolicyOwnerEntityType ->
  -- | 'id'
  Prelude.Text ->
  EntityInfo
newEntityInfo :: Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo
newEntityInfo Text
pArn_ Text
pName_ PolicyOwnerEntityType
pType_ Text
pId_ =
  EntityInfo'
    { $sel:path:EntityInfo' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:EntityInfo' :: Text
arn = Text
pArn_,
      $sel:name:EntityInfo' :: Text
name = Text
pName_,
      $sel:type':EntityInfo' :: PolicyOwnerEntityType
type' = PolicyOwnerEntityType
pType_,
      $sel:id:EntityInfo' :: Text
id = Text
pId_
    }

-- | The path to the entity (user or role). For more information about paths,
-- see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
entityInfo_path :: Lens.Lens' EntityInfo (Prelude.Maybe Prelude.Text)
entityInfo_path :: Lens' EntityInfo (Maybe Text)
entityInfo_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityInfo' {Maybe Text
path :: Maybe Text
$sel:path:EntityInfo' :: EntityInfo -> Maybe Text
path} -> Maybe Text
path) (\s :: EntityInfo
s@EntityInfo' {} Maybe Text
a -> EntityInfo
s {$sel:path:EntityInfo' :: Maybe Text
path = Maybe Text
a} :: EntityInfo)

-- | Undocumented member.
entityInfo_arn :: Lens.Lens' EntityInfo Prelude.Text
entityInfo_arn :: Lens' EntityInfo Text
entityInfo_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityInfo' {Text
arn :: Text
$sel:arn:EntityInfo' :: EntityInfo -> Text
arn} -> Text
arn) (\s :: EntityInfo
s@EntityInfo' {} Text
a -> EntityInfo
s {$sel:arn:EntityInfo' :: Text
arn = Text
a} :: EntityInfo)

-- | The name of the entity (user or role).
entityInfo_name :: Lens.Lens' EntityInfo Prelude.Text
entityInfo_name :: Lens' EntityInfo Text
entityInfo_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityInfo' {Text
name :: Text
$sel:name:EntityInfo' :: EntityInfo -> Text
name} -> Text
name) (\s :: EntityInfo
s@EntityInfo' {} Text
a -> EntityInfo
s {$sel:name:EntityInfo' :: Text
name = Text
a} :: EntityInfo)

-- | The type of entity (user or role).
entityInfo_type :: Lens.Lens' EntityInfo PolicyOwnerEntityType
entityInfo_type :: Lens' EntityInfo PolicyOwnerEntityType
entityInfo_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityInfo' {PolicyOwnerEntityType
type' :: PolicyOwnerEntityType
$sel:type':EntityInfo' :: EntityInfo -> PolicyOwnerEntityType
type'} -> PolicyOwnerEntityType
type') (\s :: EntityInfo
s@EntityInfo' {} PolicyOwnerEntityType
a -> EntityInfo
s {$sel:type':EntityInfo' :: PolicyOwnerEntityType
type' = PolicyOwnerEntityType
a} :: EntityInfo)

-- | The identifier of the entity (user or role).
entityInfo_id :: Lens.Lens' EntityInfo Prelude.Text
entityInfo_id :: Lens' EntityInfo Text
entityInfo_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityInfo' {Text
id :: Text
$sel:id:EntityInfo' :: EntityInfo -> Text
id} -> Text
id) (\s :: EntityInfo
s@EntityInfo' {} Text
a -> EntityInfo
s {$sel:id:EntityInfo' :: Text
id = Text
a} :: EntityInfo)

instance Data.FromXML EntityInfo where
  parseXML :: [Node] -> Either String EntityInfo
parseXML [Node]
x =
    Maybe Text
-> Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo
EntityInfo'
      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
"Path")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Arn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Name")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Type")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Id")

instance Prelude.Hashable EntityInfo where
  hashWithSalt :: Int -> EntityInfo -> Int
hashWithSalt Int
_salt EntityInfo' {Maybe Text
Text
PolicyOwnerEntityType
id :: Text
type' :: PolicyOwnerEntityType
name :: Text
arn :: Text
path :: Maybe Text
$sel:id:EntityInfo' :: EntityInfo -> Text
$sel:type':EntityInfo' :: EntityInfo -> PolicyOwnerEntityType
$sel:name:EntityInfo' :: EntityInfo -> Text
$sel:arn:EntityInfo' :: EntityInfo -> Text
$sel:path:EntityInfo' :: EntityInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PolicyOwnerEntityType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData EntityInfo where
  rnf :: EntityInfo -> ()
rnf EntityInfo' {Maybe Text
Text
PolicyOwnerEntityType
id :: Text
type' :: PolicyOwnerEntityType
name :: Text
arn :: Text
path :: Maybe Text
$sel:id:EntityInfo' :: EntityInfo -> Text
$sel:type':EntityInfo' :: EntityInfo -> PolicyOwnerEntityType
$sel:name:EntityInfo' :: EntityInfo -> Text
$sel:arn:EntityInfo' :: EntityInfo -> Text
$sel:path:EntityInfo' :: EntityInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PolicyOwnerEntityType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id