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

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.PolicyOwnerEntityType
import qualified Amazonka.Lens as Lens
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
(EntityInfo -> EntityInfo -> Bool)
-> (EntityInfo -> EntityInfo -> Bool) -> Eq EntityInfo
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]
(Int -> ReadS EntityInfo)
-> ReadS [EntityInfo]
-> ReadPrec EntityInfo
-> ReadPrec [EntityInfo]
-> Read 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
(Int -> EntityInfo -> ShowS)
-> (EntityInfo -> String)
-> ([EntityInfo] -> ShowS)
-> Show EntityInfo
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. EntityInfo -> Rep EntityInfo x)
-> (forall x. Rep EntityInfo x -> EntityInfo) -> Generic EntityInfo
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' :: Maybe Text
-> Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo
EntityInfo'
    { $sel:path:EntityInfo' :: Maybe Text
path = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> EntityInfo -> f EntityInfo
entityInfo_path = (EntityInfo -> Maybe Text)
-> (EntityInfo -> Maybe Text -> EntityInfo)
-> Lens EntityInfo EntityInfo (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> EntityInfo -> f EntityInfo
entityInfo_arn = (EntityInfo -> Text)
-> (EntityInfo -> Text -> EntityInfo)
-> Lens EntityInfo EntityInfo Text Text
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 :: (Text -> f Text) -> EntityInfo -> f EntityInfo
entityInfo_name = (EntityInfo -> Text)
-> (EntityInfo -> Text -> EntityInfo)
-> Lens EntityInfo EntityInfo Text Text
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 :: (PolicyOwnerEntityType -> f PolicyOwnerEntityType)
-> EntityInfo -> f EntityInfo
entityInfo_type = (EntityInfo -> PolicyOwnerEntityType)
-> (EntityInfo -> PolicyOwnerEntityType -> EntityInfo)
-> Lens
     EntityInfo EntityInfo PolicyOwnerEntityType PolicyOwnerEntityType
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 :: (Text -> f Text) -> EntityInfo -> f EntityInfo
entityInfo_id = (EntityInfo -> Text)
-> (EntityInfo -> Text -> EntityInfo)
-> Lens EntityInfo EntityInfo Text Text
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 Core.FromXML EntityInfo where
  parseXML :: [Node] -> Either String EntityInfo
parseXML [Node]
x =
    Maybe Text
-> Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo
EntityInfo'
      (Maybe Text
 -> Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo)
-> Either String (Maybe Text)
-> Either
     String
     (Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo)
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
"Path")
      Either
  String
  (Text -> Text -> PolicyOwnerEntityType -> Text -> EntityInfo)
-> Either String Text
-> Either
     String (Text -> PolicyOwnerEntityType -> Text -> EntityInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Arn")
      Either String (Text -> PolicyOwnerEntityType -> Text -> EntityInfo)
-> Either String Text
-> Either String (PolicyOwnerEntityType -> Text -> EntityInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Name")
      Either String (PolicyOwnerEntityType -> Text -> EntityInfo)
-> Either String PolicyOwnerEntityType
-> Either String (Text -> EntityInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String PolicyOwnerEntityType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Type")
      Either String (Text -> EntityInfo)
-> Either String Text -> Either String EntityInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")

instance Prelude.Hashable EntityInfo

instance Prelude.NFData EntityInfo