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

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

-- | Contains information for a user identity in an access policy.
--
-- /See:/ 'newUserIdentity' smart constructor.
data UserIdentity = UserIdentity'
  { -- | The Amazon Web Services SSO ID of the user.
    UserIdentity -> Text
id :: Prelude.Text
  }
  deriving (UserIdentity -> UserIdentity -> Bool
(UserIdentity -> UserIdentity -> Bool)
-> (UserIdentity -> UserIdentity -> Bool) -> Eq UserIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserIdentity -> UserIdentity -> Bool
$c/= :: UserIdentity -> UserIdentity -> Bool
== :: UserIdentity -> UserIdentity -> Bool
$c== :: UserIdentity -> UserIdentity -> Bool
Prelude.Eq, ReadPrec [UserIdentity]
ReadPrec UserIdentity
Int -> ReadS UserIdentity
ReadS [UserIdentity]
(Int -> ReadS UserIdentity)
-> ReadS [UserIdentity]
-> ReadPrec UserIdentity
-> ReadPrec [UserIdentity]
-> Read UserIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserIdentity]
$creadListPrec :: ReadPrec [UserIdentity]
readPrec :: ReadPrec UserIdentity
$creadPrec :: ReadPrec UserIdentity
readList :: ReadS [UserIdentity]
$creadList :: ReadS [UserIdentity]
readsPrec :: Int -> ReadS UserIdentity
$creadsPrec :: Int -> ReadS UserIdentity
Prelude.Read, Int -> UserIdentity -> ShowS
[UserIdentity] -> ShowS
UserIdentity -> String
(Int -> UserIdentity -> ShowS)
-> (UserIdentity -> String)
-> ([UserIdentity] -> ShowS)
-> Show UserIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserIdentity] -> ShowS
$cshowList :: [UserIdentity] -> ShowS
show :: UserIdentity -> String
$cshow :: UserIdentity -> String
showsPrec :: Int -> UserIdentity -> ShowS
$cshowsPrec :: Int -> UserIdentity -> ShowS
Prelude.Show, (forall x. UserIdentity -> Rep UserIdentity x)
-> (forall x. Rep UserIdentity x -> UserIdentity)
-> Generic UserIdentity
forall x. Rep UserIdentity x -> UserIdentity
forall x. UserIdentity -> Rep UserIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserIdentity x -> UserIdentity
$cfrom :: forall x. UserIdentity -> Rep UserIdentity x
Prelude.Generic)

-- |
-- Create a value of 'UserIdentity' 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:
--
-- 'id', 'userIdentity_id' - The Amazon Web Services SSO ID of the user.
newUserIdentity ::
  -- | 'id'
  Prelude.Text ->
  UserIdentity
newUserIdentity :: Text -> UserIdentity
newUserIdentity Text
pId_ = UserIdentity' :: Text -> UserIdentity
UserIdentity' {$sel:id:UserIdentity' :: Text
id = Text
pId_}

-- | The Amazon Web Services SSO ID of the user.
userIdentity_id :: Lens.Lens' UserIdentity Prelude.Text
userIdentity_id :: (Text -> f Text) -> UserIdentity -> f UserIdentity
userIdentity_id = (UserIdentity -> Text)
-> (UserIdentity -> Text -> UserIdentity)
-> Lens UserIdentity UserIdentity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Text
id :: Text
$sel:id:UserIdentity' :: UserIdentity -> Text
id} -> Text
id) (\s :: UserIdentity
s@UserIdentity' {} Text
a -> UserIdentity
s {$sel:id:UserIdentity' :: Text
id = Text
a} :: UserIdentity)

instance Core.FromJSON UserIdentity where
  parseJSON :: Value -> Parser UserIdentity
parseJSON =
    String
-> (Object -> Parser UserIdentity) -> Value -> Parser UserIdentity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserIdentity"
      (\Object
x -> Text -> UserIdentity
UserIdentity' (Text -> UserIdentity) -> Parser Text -> Parser UserIdentity
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
"id"))

instance Prelude.Hashable UserIdentity

instance Prelude.NFData UserIdentity

instance Core.ToJSON UserIdentity where
  toJSON :: UserIdentity -> Value
toJSON UserIdentity' {Text
id :: Text
$sel:id:UserIdentity' :: UserIdentity -> 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
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)])