{-# 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-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)
--
-- 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.Lens as Lens
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 :: Core.Sensitive Prelude.Text,
    -- | The authentication type for the user. You must specify USERPOOL.
    EnableUser -> AuthenticationType
authenticationType :: AuthenticationType
  }
  deriving (EnableUser -> EnableUser -> Bool
(EnableUser -> EnableUser -> Bool)
-> (EnableUser -> EnableUser -> Bool) -> Eq EnableUser
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
(Int -> EnableUser -> ShowS)
-> (EnableUser -> String)
-> ([EnableUser] -> ShowS)
-> Show EnableUser
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. EnableUser -> Rep EnableUser x)
-> (forall x. Rep EnableUser x -> EnableUser) -> Generic EnableUser
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' :: Sensitive Text -> AuthenticationType -> EnableUser
EnableUser'
    { $sel:userName:EnableUser' :: 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: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 :: (Text -> f Text) -> EnableUser -> f EnableUser
enableUser_userName = (EnableUser -> Sensitive Text)
-> (EnableUser -> Sensitive Text -> EnableUser)
-> Lens EnableUser EnableUser (Sensitive Text) (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> EnableUser -> f EnableUser)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> EnableUser
-> f EnableUser
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 authentication type for the user. You must specify USERPOOL.
enableUser_authenticationType :: Lens.Lens' EnableUser AuthenticationType
enableUser_authenticationType :: (AuthenticationType -> f AuthenticationType)
-> EnableUser -> f EnableUser
enableUser_authenticationType = (EnableUser -> AuthenticationType)
-> (EnableUser -> AuthenticationType -> EnableUser)
-> Lens EnableUser EnableUser AuthenticationType 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 :: EnableUser -> Request EnableUser
request = Service -> EnableUser -> Request EnableUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableUser)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse EnableUser))
-> Logger
-> Service
-> Proxy EnableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableUser)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> EnableUserResponse
EnableUserResponse'
            (Int -> EnableUserResponse)
-> Either String Int -> Either String EnableUserResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable EnableUser

instance Prelude.NFData EnableUser

instance Core.ToHeaders EnableUser where
  toHeaders :: EnableUser -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableUser -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"PhotonAdminProxyService.EnableUser" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserName" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
userName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AuthenticationType" Text -> AuthenticationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AuthenticationType
authenticationType)
          ]
      )

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

instance Core.ToQuery EnableUser where
  toQuery :: EnableUser -> QueryString
toQuery = QueryString -> EnableUser -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(EnableUserResponse -> EnableUserResponse -> Bool)
-> (EnableUserResponse -> EnableUserResponse -> Bool)
-> Eq EnableUserResponse
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]
(Int -> ReadS EnableUserResponse)
-> ReadS [EnableUserResponse]
-> ReadPrec EnableUserResponse
-> ReadPrec [EnableUserResponse]
-> Read 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
(Int -> EnableUserResponse -> ShowS)
-> (EnableUserResponse -> String)
-> ([EnableUserResponse] -> ShowS)
-> Show EnableUserResponse
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. EnableUserResponse -> Rep EnableUserResponse x)
-> (forall x. Rep EnableUserResponse x -> EnableUserResponse)
-> Generic EnableUserResponse
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' :: Int -> EnableUserResponse
EnableUserResponse' {$sel:httpStatus:EnableUserResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
enableUserResponse_httpStatus :: Lens.Lens' EnableUserResponse Prelude.Int
enableUserResponse_httpStatus :: (Int -> f Int) -> EnableUserResponse -> f EnableUserResponse
enableUserResponse_httpStatus = (EnableUserResponse -> Int)
-> (EnableUserResponse -> Int -> EnableUserResponse)
-> Lens EnableUserResponse EnableUserResponse Int Int
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