{-# 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.AppStream.Types.UserStackAssociation
-- 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.AppStream.Types.UserStackAssociation where

import Amazonka.AppStream.Types.AuthenticationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a user in the user pool and the associated stack.
--
-- /See:/ 'newUserStackAssociation' smart constructor.
data UserStackAssociation = UserStackAssociation'
  { -- | Specifies whether a welcome email is sent to a user after the user is
    -- created in the user pool.
    UserStackAssociation -> Maybe Bool
sendEmailNotification :: Prelude.Maybe Prelude.Bool,
    -- | The name of the stack that is associated with the user.
    UserStackAssociation -> Text
stackName :: Prelude.Text,
    -- | The email address of the user who is associated with the stack.
    --
    -- Users\' email addresses are case-sensitive.
    UserStackAssociation -> Sensitive Text
userName :: Data.Sensitive Prelude.Text,
    -- | The authentication type for the user.
    UserStackAssociation -> AuthenticationType
authenticationType :: AuthenticationType
  }
  deriving (UserStackAssociation -> UserStackAssociation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserStackAssociation -> UserStackAssociation -> Bool
$c/= :: UserStackAssociation -> UserStackAssociation -> Bool
== :: UserStackAssociation -> UserStackAssociation -> Bool
$c== :: UserStackAssociation -> UserStackAssociation -> Bool
Prelude.Eq, Int -> UserStackAssociation -> ShowS
[UserStackAssociation] -> ShowS
UserStackAssociation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserStackAssociation] -> ShowS
$cshowList :: [UserStackAssociation] -> ShowS
show :: UserStackAssociation -> String
$cshow :: UserStackAssociation -> String
showsPrec :: Int -> UserStackAssociation -> ShowS
$cshowsPrec :: Int -> UserStackAssociation -> ShowS
Prelude.Show, forall x. Rep UserStackAssociation x -> UserStackAssociation
forall x. UserStackAssociation -> Rep UserStackAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserStackAssociation x -> UserStackAssociation
$cfrom :: forall x. UserStackAssociation -> Rep UserStackAssociation x
Prelude.Generic)

-- |
-- Create a value of 'UserStackAssociation' 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:
--
-- 'sendEmailNotification', 'userStackAssociation_sendEmailNotification' - Specifies whether a welcome email is sent to a user after the user is
-- created in the user pool.
--
-- 'stackName', 'userStackAssociation_stackName' - The name of the stack that is associated with the user.
--
-- 'userName', 'userStackAssociation_userName' - The email address of the user who is associated with the stack.
--
-- Users\' email addresses are case-sensitive.
--
-- 'authenticationType', 'userStackAssociation_authenticationType' - The authentication type for the user.
newUserStackAssociation ::
  -- | 'stackName'
  Prelude.Text ->
  -- | 'userName'
  Prelude.Text ->
  -- | 'authenticationType'
  AuthenticationType ->
  UserStackAssociation
newUserStackAssociation :: Text -> Text -> AuthenticationType -> UserStackAssociation
newUserStackAssociation
  Text
pStackName_
  Text
pUserName_
  AuthenticationType
pAuthenticationType_ =
    UserStackAssociation'
      { $sel:sendEmailNotification:UserStackAssociation' :: Maybe Bool
sendEmailNotification =
          forall a. Maybe a
Prelude.Nothing,
        $sel:stackName:UserStackAssociation' :: Text
stackName = Text
pStackName_,
        $sel:userName:UserStackAssociation' :: Sensitive Text
userName = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUserName_,
        $sel:authenticationType:UserStackAssociation' :: AuthenticationType
authenticationType = AuthenticationType
pAuthenticationType_
      }

-- | Specifies whether a welcome email is sent to a user after the user is
-- created in the user pool.
userStackAssociation_sendEmailNotification :: Lens.Lens' UserStackAssociation (Prelude.Maybe Prelude.Bool)
userStackAssociation_sendEmailNotification :: Lens' UserStackAssociation (Maybe Bool)
userStackAssociation_sendEmailNotification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserStackAssociation' {Maybe Bool
sendEmailNotification :: Maybe Bool
$sel:sendEmailNotification:UserStackAssociation' :: UserStackAssociation -> Maybe Bool
sendEmailNotification} -> Maybe Bool
sendEmailNotification) (\s :: UserStackAssociation
s@UserStackAssociation' {} Maybe Bool
a -> UserStackAssociation
s {$sel:sendEmailNotification:UserStackAssociation' :: Maybe Bool
sendEmailNotification = Maybe Bool
a} :: UserStackAssociation)

-- | The name of the stack that is associated with the user.
userStackAssociation_stackName :: Lens.Lens' UserStackAssociation Prelude.Text
userStackAssociation_stackName :: Lens' UserStackAssociation Text
userStackAssociation_stackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserStackAssociation' {Text
stackName :: Text
$sel:stackName:UserStackAssociation' :: UserStackAssociation -> Text
stackName} -> Text
stackName) (\s :: UserStackAssociation
s@UserStackAssociation' {} Text
a -> UserStackAssociation
s {$sel:stackName:UserStackAssociation' :: Text
stackName = Text
a} :: UserStackAssociation)

-- | The email address of the user who is associated with the stack.
--
-- Users\' email addresses are case-sensitive.
userStackAssociation_userName :: Lens.Lens' UserStackAssociation Prelude.Text
userStackAssociation_userName :: Lens' UserStackAssociation Text
userStackAssociation_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserStackAssociation' {Sensitive Text
userName :: Sensitive Text
$sel:userName:UserStackAssociation' :: UserStackAssociation -> Sensitive Text
userName} -> Sensitive Text
userName) (\s :: UserStackAssociation
s@UserStackAssociation' {} Sensitive Text
a -> UserStackAssociation
s {$sel:userName:UserStackAssociation' :: Sensitive Text
userName = Sensitive Text
a} :: UserStackAssociation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The authentication type for the user.
userStackAssociation_authenticationType :: Lens.Lens' UserStackAssociation AuthenticationType
userStackAssociation_authenticationType :: Lens' UserStackAssociation AuthenticationType
userStackAssociation_authenticationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserStackAssociation' {AuthenticationType
authenticationType :: AuthenticationType
$sel:authenticationType:UserStackAssociation' :: UserStackAssociation -> AuthenticationType
authenticationType} -> AuthenticationType
authenticationType) (\s :: UserStackAssociation
s@UserStackAssociation' {} AuthenticationType
a -> UserStackAssociation
s {$sel:authenticationType:UserStackAssociation' :: AuthenticationType
authenticationType = AuthenticationType
a} :: UserStackAssociation)

instance Data.FromJSON UserStackAssociation where
  parseJSON :: Value -> Parser UserStackAssociation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserStackAssociation"
      ( \Object
x ->
          Maybe Bool
-> Text
-> Sensitive Text
-> AuthenticationType
-> UserStackAssociation
UserStackAssociation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SendEmailNotification")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"StackName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"UserName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AuthenticationType")
      )

instance Prelude.Hashable UserStackAssociation where
  hashWithSalt :: Int -> UserStackAssociation -> Int
hashWithSalt Int
_salt UserStackAssociation' {Maybe Bool
Text
Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
stackName :: Text
sendEmailNotification :: Maybe Bool
$sel:authenticationType:UserStackAssociation' :: UserStackAssociation -> AuthenticationType
$sel:userName:UserStackAssociation' :: UserStackAssociation -> Sensitive Text
$sel:stackName:UserStackAssociation' :: UserStackAssociation -> Text
$sel:sendEmailNotification:UserStackAssociation' :: UserStackAssociation -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sendEmailNotification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stackName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AuthenticationType
authenticationType

instance Prelude.NFData UserStackAssociation where
  rnf :: UserStackAssociation -> ()
rnf UserStackAssociation' {Maybe Bool
Text
Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
stackName :: Text
sendEmailNotification :: Maybe Bool
$sel:authenticationType:UserStackAssociation' :: UserStackAssociation -> AuthenticationType
$sel:userName:UserStackAssociation' :: UserStackAssociation -> Sensitive Text
$sel:stackName:UserStackAssociation' :: UserStackAssociation -> Text
$sel:sendEmailNotification:UserStackAssociation' :: UserStackAssociation -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sendEmailNotification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stackName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AuthenticationType
authenticationType

instance Data.ToJSON UserStackAssociation where
  toJSON :: UserStackAssociation -> Value
toJSON UserStackAssociation' {Maybe Bool
Text
Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
stackName :: Text
sendEmailNotification :: Maybe Bool
$sel:authenticationType:UserStackAssociation' :: UserStackAssociation -> AuthenticationType
$sel:userName:UserStackAssociation' :: UserStackAssociation -> Sensitive Text
$sel:stackName:UserStackAssociation' :: UserStackAssociation -> Text
$sel:sendEmailNotification:UserStackAssociation' :: UserStackAssociation -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SendEmailNotification" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
sendEmailNotification,
            forall a. a -> Maybe a
Prelude.Just (Key
"StackName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
stackName),
            forall a. a -> Maybe a
Prelude.Just (Key
"UserName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
userName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AuthenticationType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AuthenticationType
authenticationType)
          ]
      )