{-# 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.DisableUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables the specified user in the user pool. Users can\'t sign in to
-- AppStream 2.0 until they are re-enabled. This action does not delete the
-- user.
module Amazonka.AppStream.DisableUser
  ( -- * Creating a Request
    DisableUser (..),
    newDisableUser,

    -- * Request Lenses
    disableUser_userName,
    disableUser_authenticationType,

    -- * Destructuring the Response
    DisableUserResponse (..),
    newDisableUserResponse,

    -- * Response Lenses
    disableUserResponse_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:/ 'newDisableUser' smart constructor.
data DisableUser = DisableUser'
  { -- | The email address of the user.
    --
    -- Users\' email addresses are case-sensitive.
    DisableUser -> Sensitive Text
userName :: Data.Sensitive Prelude.Text,
    -- | The authentication type for the user. You must specify USERPOOL.
    DisableUser -> AuthenticationType
authenticationType :: AuthenticationType
  }
  deriving (DisableUser -> DisableUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableUser -> DisableUser -> Bool
$c/= :: DisableUser -> DisableUser -> Bool
== :: DisableUser -> DisableUser -> Bool
$c== :: DisableUser -> DisableUser -> Bool
Prelude.Eq, Int -> DisableUser -> ShowS
[DisableUser] -> ShowS
DisableUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableUser] -> ShowS
$cshowList :: [DisableUser] -> ShowS
show :: DisableUser -> String
$cshow :: DisableUser -> String
showsPrec :: Int -> DisableUser -> ShowS
$cshowsPrec :: Int -> DisableUser -> ShowS
Prelude.Show, forall x. Rep DisableUser x -> DisableUser
forall x. DisableUser -> Rep DisableUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableUser x -> DisableUser
$cfrom :: forall x. DisableUser -> Rep DisableUser x
Prelude.Generic)

-- |
-- Create a value of 'DisableUser' 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', 'disableUser_userName' - The email address of the user.
--
-- Users\' email addresses are case-sensitive.
--
-- 'authenticationType', 'disableUser_authenticationType' - The authentication type for the user. You must specify USERPOOL.
newDisableUser ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'authenticationType'
  AuthenticationType ->
  DisableUser
newDisableUser :: Text -> AuthenticationType -> DisableUser
newDisableUser Text
pUserName_ AuthenticationType
pAuthenticationType_ =
  DisableUser'
    { $sel:userName:DisableUser' :: Sensitive Text
userName =
        forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUserName_,
      $sel:authenticationType:DisableUser' :: AuthenticationType
authenticationType = AuthenticationType
pAuthenticationType_
    }

-- | The email address of the user.
--
-- Users\' email addresses are case-sensitive.
disableUser_userName :: Lens.Lens' DisableUser Prelude.Text
disableUser_userName :: Lens' DisableUser Text
disableUser_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableUser' {Sensitive Text
userName :: Sensitive Text
$sel:userName:DisableUser' :: DisableUser -> Sensitive Text
userName} -> Sensitive Text
userName) (\s :: DisableUser
s@DisableUser' {} Sensitive Text
a -> DisableUser
s {$sel:userName:DisableUser' :: Sensitive Text
userName = Sensitive Text
a} :: DisableUser) 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.
disableUser_authenticationType :: Lens.Lens' DisableUser AuthenticationType
disableUser_authenticationType :: Lens' DisableUser AuthenticationType
disableUser_authenticationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableUser' {AuthenticationType
authenticationType :: AuthenticationType
$sel:authenticationType:DisableUser' :: DisableUser -> AuthenticationType
authenticationType} -> AuthenticationType
authenticationType) (\s :: DisableUser
s@DisableUser' {} AuthenticationType
a -> DisableUser
s {$sel:authenticationType:DisableUser' :: AuthenticationType
authenticationType = AuthenticationType
a} :: DisableUser)

instance Core.AWSRequest DisableUser where
  type AWSResponse DisableUser = DisableUserResponse
  request :: (Service -> Service) -> DisableUser -> Request DisableUser
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 DisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableUser)))
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 -> DisableUserResponse
DisableUserResponse'
            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 DisableUser where
  hashWithSalt :: Int -> DisableUser -> Int
hashWithSalt Int
_salt DisableUser' {Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
$sel:authenticationType:DisableUser' :: DisableUser -> AuthenticationType
$sel:userName:DisableUser' :: DisableUser -> 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 DisableUser where
  rnf :: DisableUser -> ()
rnf DisableUser' {Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
$sel:authenticationType:DisableUser' :: DisableUser -> AuthenticationType
$sel:userName:DisableUser' :: DisableUser -> 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 DisableUser where
  toHeaders :: DisableUser -> 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.DisableUser" ::
                          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 DisableUser where
  toJSON :: DisableUser -> Value
toJSON DisableUser' {Sensitive Text
AuthenticationType
authenticationType :: AuthenticationType
userName :: Sensitive Text
$sel:authenticationType:DisableUser' :: DisableUser -> AuthenticationType
$sel:userName:DisableUser' :: DisableUser -> 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 DisableUser where
  toPath :: DisableUser -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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