{-# 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.IdentityStore.Types.User
-- 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.IdentityStore.Types.User where

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

-- | A user object, which contains a specified user’s metadata and
-- attributes.
--
-- /See:/ 'newUser' smart constructor.
data User = User'
  { -- | Contains the user’s user name value. The length limit is 128 characters.
    -- This value can consist of letters, accented characters, symbols,
    -- numbers, and punctuation. The characters @\<>;:%@ are excluded. This
    -- value is specified at the time the user is created and stored as an
    -- attribute of the user object in the identity store.
    User -> Sensitive Text
userName :: Core.Sensitive Prelude.Text,
    -- | The identifier for a user in the identity store.
    User -> Text
userId :: Prelude.Text
  }
  deriving (User -> User -> Bool
(User -> User -> Bool) -> (User -> User -> Bool) -> Eq User
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: User -> User -> Bool
$c/= :: User -> User -> Bool
== :: User -> User -> Bool
$c== :: User -> User -> Bool
Prelude.Eq, Int -> User -> ShowS
[User] -> ShowS
User -> String
(Int -> User -> ShowS)
-> (User -> String) -> ([User] -> ShowS) -> Show User
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [User] -> ShowS
$cshowList :: [User] -> ShowS
show :: User -> String
$cshow :: User -> String
showsPrec :: Int -> User -> ShowS
$cshowsPrec :: Int -> User -> ShowS
Prelude.Show, (forall x. User -> Rep User x)
-> (forall x. Rep User x -> User) -> Generic User
forall x. Rep User x -> User
forall x. User -> Rep User x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep User x -> User
$cfrom :: forall x. User -> Rep User x
Prelude.Generic)

-- |
-- Create a value of 'User' 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', 'user_userName' - Contains the user’s user name value. The length limit is 128 characters.
-- This value can consist of letters, accented characters, symbols,
-- numbers, and punctuation. The characters @\<>;:%@ are excluded. This
-- value is specified at the time the user is created and stored as an
-- attribute of the user object in the identity store.
--
-- 'userId', 'user_userId' - The identifier for a user in the identity store.
newUser ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  User
newUser :: Text -> Text -> User
newUser Text
pUserName_ Text
pUserId_ =
  User' :: Sensitive Text -> Text -> User
User'
    { $sel:userName:User' :: Sensitive Text
userName = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pUserName_,
      $sel:userId:User' :: Text
userId = Text
pUserId_
    }

-- | Contains the user’s user name value. The length limit is 128 characters.
-- This value can consist of letters, accented characters, symbols,
-- numbers, and punctuation. The characters @\<>;:%@ are excluded. This
-- value is specified at the time the user is created and stored as an
-- attribute of the user object in the identity store.
user_userName :: Lens.Lens' User Prelude.Text
user_userName :: (Text -> f Text) -> User -> f User
user_userName = (User -> Sensitive Text)
-> (User -> Sensitive Text -> User)
-> Lens User User (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Sensitive Text
userName :: Sensitive Text
$sel:userName:User' :: User -> Sensitive Text
userName} -> Sensitive Text
userName) (\s :: User
s@User' {} Sensitive Text
a -> User
s {$sel:userName:User' :: Sensitive Text
userName = Sensitive Text
a} :: User) ((Sensitive Text -> f (Sensitive Text)) -> User -> f User)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> User
-> f User
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The identifier for a user in the identity store.
user_userId :: Lens.Lens' User Prelude.Text
user_userId :: (Text -> f Text) -> User -> f User
user_userId = (User -> Text)
-> (User -> Text -> User) -> Lens User User Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Text
userId :: Text
$sel:userId:User' :: User -> Text
userId} -> Text
userId) (\s :: User
s@User' {} Text
a -> User
s {$sel:userId:User' :: Text
userId = Text
a} :: User)

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

instance Prelude.Hashable User

instance Prelude.NFData User