{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.EnableUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enables a user in the user pool. After being enabled, users can sign in
-- to AppStream 2.0 and open applications from the stacks to which they are
-- assigned.
module Amazonka.AppStream.EnableUser
  ( -- * Creating a Request
    EnableUser (..),
    newEnableUser,

    -- * Request Lenses
    enableUser_userName,
    enableUser_authenticationType,

    -- * Destructuring the Response
    EnableUserResponse (..),
    newEnableUserResponse,

    -- * Response Lenses
    enableUserResponse_httpStatus,
  )
where

import Amazonka.AppStream.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newEnableUser' smart constructor.
data EnableUser = EnableUser'
  { -- | The email address of the user.
    --
    -- Users\' email addresses are case-sensitive. During login, if they
    -- specify an email address that doesn\'t use the same capitalization as
    -- the email address specified when their user pool account was created, a
    -- \"user does not exist\" error message displays.
    EnableUser -> Sensitive Text
userName :: Data.Sensitive Prelude.Text,
    -- | The authentication type for the user. You must specify USERPOOL.
    EnableUser -> AuthenticationType
authenticationType :: AuthenticationType
  }
  deriving (EnableUser -> EnableUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableUser -> EnableUser -> Bool
$c/= :: EnableUser -> EnableUser -> Bool
== :: EnableUser -> EnableUser -> Bool
$c== :: EnableUser -> EnableUser -> Bool
Prelude.Eq, Int -> EnableUser -> ShowS
[EnableUser] -> ShowS
EnableUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableUser] -> ShowS
$cshowList :: [EnableUser] -> ShowS
show :: EnableUser -> String
$cshow :: EnableUser -> String
showsPrec :: Int -> EnableUser -> ShowS
$cshowsPrec :: Int -> EnableUser -> ShowS
Prelude.Show, forall x. Rep EnableUser x -> EnableUser
forall x. EnableUser -> Rep EnableUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableUser x -> EnableUser
$cfrom :: forall x. EnableUser -> Rep EnableUser x
Prelude.Generic)

-- |
-- Create a value of 'EnableUser' 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', 'enableUser_userName' - The email address of the user.
--
-- Users\' email addresses are case-sensitive. During login, if they
-- specify an email address that doesn\'t use the same capitalization as
-- the email address specified when their user pool account was created, a
-- \"user does not exist\" error message displays.
--
-- 'authenticationType', 'enableUser_authenticationType' - The authentication type for the user. You must specify USERPOOL.
newEnableUser ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'authenticationType'
  AuthenticationType ->
  EnableUser
newEnableUser :: Text -> AuthenticationType -> EnableUser
newEnableUser Text
pUserName_ AuthenticationType
pAuthenticationType_ =
  EnableUser'
    { $sel:userName:EnableUser' :: Sensitive Text
userName =
        forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUserName_,
      $sel:authenticationType:EnableUser' :: AuthenticationType
authenticationType = AuthenticationType
pAuthenticationType_
    }

-- | The email address of the user.
--
-- Users\' email addresses are case-sensitive. During login, if they
-- specify an email address that doesn\'t use the same capitalization as
-- the email address specified when their user pool account was created, a
-- \"user does not exist\" error message displays.
enableUser_userName :: Lens.Lens' EnableUser Prelude.Text
enableUser_userName :: Lens' EnableUser Text
enableUser_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableUser' {Sensitive Text
userName :: Sensitive Text
$sel:userName:EnableUser' :: EnableUser -> Sensitive Text
userName} -> Sensitive Text
userName) (\s :: EnableUser
s@EnableUser' {} Sensitive Text
a -> EnableUser
s {$sel:userName:EnableUser' :: Sensitive Text
userName = Sensitive Text
a} :: EnableUser) 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. You must specify USERPOOL.
enableUser_authenticationType :: Lens.Lens' EnableUser AuthenticationType
enableUser_authenticationType :: Lens' EnableUser AuthenticationType
enableUser_authenticationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableUser' {AuthenticationType
authenticationType :: AuthenticationType
$sel:authenticationType:EnableUser' :: EnableUser -> AuthenticationType
authenticationType} -> AuthenticationType
authenticationType) (\s :: EnableUser
s@EnableUser' {} AuthenticationType
a -> EnableUser
s {$sel:authenticationType:EnableUser' :: AuthenticationType
authenticationType = AuthenticationType
a} :: EnableUser)

instance Core.AWSRequest EnableUser where
  type AWSResponse EnableUser = EnableUserResponse
  request :: (Service -> Service) -> EnableUser -> Request EnableUser
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy EnableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableUser)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> EnableUserResponse
EnableUserResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable EnableUser where
  hashWithSalt :: Int -> EnableUser -> Int
hashWithSalt Int
_salt EnableUser' {Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
$sel:authenticationType:EnableUser' :: EnableUser -> AuthenticationType
$sel:userName:EnableUser' :: EnableUser -> Sensitive Text
..} =
    Int
_salt
      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 EnableUser where
  rnf :: EnableUser -> ()
rnf EnableUser' {Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
$sel:authenticationType:EnableUser' :: EnableUser -> AuthenticationType
$sel:userName:EnableUser' :: EnableUser -> Sensitive Text
..} =
    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.ToHeaders EnableUser where
  toHeaders :: EnableUser -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"PhotonAdminProxyService.EnableUser" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON EnableUser where
  toJSON :: EnableUser -> Value
toJSON EnableUser' {Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
$sel:authenticationType:EnableUser' :: EnableUser -> AuthenticationType
$sel:userName:EnableUser' :: EnableUser -> Sensitive Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )

instance Data.ToPath EnableUser where
  toPath :: EnableUser -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery EnableUser where
  toQuery :: EnableUser -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newEnableUserResponse' smart constructor.
data EnableUserResponse = EnableUserResponse'
  { -- | The response's http status code.
    EnableUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (EnableUserResponse -> EnableUserResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableUserResponse -> EnableUserResponse -> Bool
$c/= :: EnableUserResponse -> EnableUserResponse -> Bool
== :: EnableUserResponse -> EnableUserResponse -> Bool
$c== :: EnableUserResponse -> EnableUserResponse -> Bool
Prelude.Eq, ReadPrec [EnableUserResponse]
ReadPrec EnableUserResponse
Int -> ReadS EnableUserResponse
ReadS [EnableUserResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableUserResponse]
$creadListPrec :: ReadPrec [EnableUserResponse]
readPrec :: ReadPrec EnableUserResponse
$creadPrec :: ReadPrec EnableUserResponse
readList :: ReadS [EnableUserResponse]
$creadList :: ReadS [EnableUserResponse]
readsPrec :: Int -> ReadS EnableUserResponse
$creadsPrec :: Int -> ReadS EnableUserResponse
Prelude.Read, Int -> EnableUserResponse -> ShowS
[EnableUserResponse] -> ShowS
EnableUserResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableUserResponse] -> ShowS
$cshowList :: [EnableUserResponse] -> ShowS
show :: EnableUserResponse -> String
$cshow :: EnableUserResponse -> String
showsPrec :: Int -> EnableUserResponse -> ShowS
$cshowsPrec :: Int -> EnableUserResponse -> ShowS
Prelude.Show, forall x. Rep EnableUserResponse x -> EnableUserResponse
forall x. EnableUserResponse -> Rep EnableUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableUserResponse x -> EnableUserResponse
$cfrom :: forall x. EnableUserResponse -> Rep EnableUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'EnableUserResponse' 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:
--
-- 'httpStatus', 'enableUserResponse_httpStatus' - The response's http status code.
newEnableUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  EnableUserResponse
newEnableUserResponse :: Int -> EnableUserResponse
newEnableUserResponse Int
pHttpStatus_ =
  EnableUserResponse' {$sel:httpStatus:EnableUserResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
enableUserResponse_httpStatus :: Lens.Lens' EnableUserResponse Prelude.Int
enableUserResponse_httpStatus :: Lens' EnableUserResponse Int
enableUserResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableUserResponse' {Int
httpStatus :: Int
$sel:httpStatus:EnableUserResponse' :: EnableUserResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: EnableUserResponse
s@EnableUserResponse' {} Int
a -> EnableUserResponse
s {$sel:httpStatus:EnableUserResponse' :: Int
httpStatus = Int
a} :: EnableUserResponse)

instance Prelude.NFData EnableUserResponse where
  rnf :: EnableUserResponse -> ()
rnf EnableUserResponse' {Int
httpStatus :: Int
$sel:httpStatus:EnableUserResponse' :: EnableUserResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus