{-# 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.IoTSiteWise.Types.IAMUserIdentity
-- 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.IoTSiteWise.Types.IAMUserIdentity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an Identity and Access Management user.
--
-- /See:/ 'newIAMUserIdentity' smart constructor.
data IAMUserIdentity = IAMUserIdentity'
  { -- | The ARN of the IAM user. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
    -- in the /IAM User Guide/.
    --
    -- If you delete the IAM user, access policies that contain this identity
    -- include an empty @arn@. You can delete the access policy for the IAM
    -- user that no longer exists.
    IAMUserIdentity -> Text
arn :: Prelude.Text
  }
  deriving (IAMUserIdentity -> IAMUserIdentity -> Bool
(IAMUserIdentity -> IAMUserIdentity -> Bool)
-> (IAMUserIdentity -> IAMUserIdentity -> Bool)
-> Eq IAMUserIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IAMUserIdentity -> IAMUserIdentity -> Bool
$c/= :: IAMUserIdentity -> IAMUserIdentity -> Bool
== :: IAMUserIdentity -> IAMUserIdentity -> Bool
$c== :: IAMUserIdentity -> IAMUserIdentity -> Bool
Prelude.Eq, ReadPrec [IAMUserIdentity]
ReadPrec IAMUserIdentity
Int -> ReadS IAMUserIdentity
ReadS [IAMUserIdentity]
(Int -> ReadS IAMUserIdentity)
-> ReadS [IAMUserIdentity]
-> ReadPrec IAMUserIdentity
-> ReadPrec [IAMUserIdentity]
-> Read IAMUserIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IAMUserIdentity]
$creadListPrec :: ReadPrec [IAMUserIdentity]
readPrec :: ReadPrec IAMUserIdentity
$creadPrec :: ReadPrec IAMUserIdentity
readList :: ReadS [IAMUserIdentity]
$creadList :: ReadS [IAMUserIdentity]
readsPrec :: Int -> ReadS IAMUserIdentity
$creadsPrec :: Int -> ReadS IAMUserIdentity
Prelude.Read, Int -> IAMUserIdentity -> ShowS
[IAMUserIdentity] -> ShowS
IAMUserIdentity -> String
(Int -> IAMUserIdentity -> ShowS)
-> (IAMUserIdentity -> String)
-> ([IAMUserIdentity] -> ShowS)
-> Show IAMUserIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IAMUserIdentity] -> ShowS
$cshowList :: [IAMUserIdentity] -> ShowS
show :: IAMUserIdentity -> String
$cshow :: IAMUserIdentity -> String
showsPrec :: Int -> IAMUserIdentity -> ShowS
$cshowsPrec :: Int -> IAMUserIdentity -> ShowS
Prelude.Show, (forall x. IAMUserIdentity -> Rep IAMUserIdentity x)
-> (forall x. Rep IAMUserIdentity x -> IAMUserIdentity)
-> Generic IAMUserIdentity
forall x. Rep IAMUserIdentity x -> IAMUserIdentity
forall x. IAMUserIdentity -> Rep IAMUserIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IAMUserIdentity x -> IAMUserIdentity
$cfrom :: forall x. IAMUserIdentity -> Rep IAMUserIdentity x
Prelude.Generic)

-- |
-- Create a value of 'IAMUserIdentity' 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:
--
-- 'arn', 'iAMUserIdentity_arn' - The ARN of the IAM user. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
-- in the /IAM User Guide/.
--
-- If you delete the IAM user, access policies that contain this identity
-- include an empty @arn@. You can delete the access policy for the IAM
-- user that no longer exists.
newIAMUserIdentity ::
  -- | 'arn'
  Prelude.Text ->
  IAMUserIdentity
newIAMUserIdentity :: Text -> IAMUserIdentity
newIAMUserIdentity Text
pArn_ =
  IAMUserIdentity' :: Text -> IAMUserIdentity
IAMUserIdentity' {$sel:arn:IAMUserIdentity' :: Text
arn = Text
pArn_}

-- | The ARN of the IAM user. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
-- in the /IAM User Guide/.
--
-- If you delete the IAM user, access policies that contain this identity
-- include an empty @arn@. You can delete the access policy for the IAM
-- user that no longer exists.
iAMUserIdentity_arn :: Lens.Lens' IAMUserIdentity Prelude.Text
iAMUserIdentity_arn :: (Text -> f Text) -> IAMUserIdentity -> f IAMUserIdentity
iAMUserIdentity_arn = (IAMUserIdentity -> Text)
-> (IAMUserIdentity -> Text -> IAMUserIdentity)
-> Lens IAMUserIdentity IAMUserIdentity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IAMUserIdentity' {Text
arn :: Text
$sel:arn:IAMUserIdentity' :: IAMUserIdentity -> Text
arn} -> Text
arn) (\s :: IAMUserIdentity
s@IAMUserIdentity' {} Text
a -> IAMUserIdentity
s {$sel:arn:IAMUserIdentity' :: Text
arn = Text
a} :: IAMUserIdentity)

instance Core.FromJSON IAMUserIdentity where
  parseJSON :: Value -> Parser IAMUserIdentity
parseJSON =
    String
-> (Object -> Parser IAMUserIdentity)
-> Value
-> Parser IAMUserIdentity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IAMUserIdentity"
      ( \Object
x ->
          Text -> IAMUserIdentity
IAMUserIdentity' (Text -> IAMUserIdentity) -> Parser Text -> Parser IAMUserIdentity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"arn")
      )

instance Prelude.Hashable IAMUserIdentity

instance Prelude.NFData IAMUserIdentity

instance Core.ToJSON IAMUserIdentity where
  toJSON :: IAMUserIdentity -> Value
toJSON IAMUserIdentity' {Text
arn :: Text
$sel:arn:IAMUserIdentity' :: IAMUserIdentity -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )