{-# 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-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)
--
-- 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.Lens as Lens
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 :: Core.Sensitive Prelude.Text,
    -- | The authentication type for the user. You must specify USERPOOL.
    DisableUser -> AuthenticationType
authenticationType :: AuthenticationType
  }
  deriving (DisableUser -> DisableUser -> Bool
(DisableUser -> DisableUser -> Bool)
-> (DisableUser -> DisableUser -> Bool) -> Eq DisableUser
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
(Int -> DisableUser -> ShowS)
-> (DisableUser -> String)
-> ([DisableUser] -> ShowS)
-> Show DisableUser
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. DisableUser -> Rep DisableUser x)
-> (forall x. Rep DisableUser x -> DisableUser)
-> Generic DisableUser
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' :: Sensitive Text -> AuthenticationType -> DisableUser
DisableUser'
    { $sel:userName:DisableUser' :: 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: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 :: (Text -> f Text) -> DisableUser -> f DisableUser
disableUser_userName = (DisableUser -> Sensitive Text)
-> (DisableUser -> Sensitive Text -> DisableUser)
-> Lens DisableUser DisableUser (Sensitive Text) (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> DisableUser -> f DisableUser)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DisableUser
-> f DisableUser
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.
disableUser_authenticationType :: Lens.Lens' DisableUser AuthenticationType
disableUser_authenticationType :: (AuthenticationType -> f AuthenticationType)
-> DisableUser -> f DisableUser
disableUser_authenticationType = (DisableUser -> AuthenticationType)
-> (DisableUser -> AuthenticationType -> DisableUser)
-> Lens
     DisableUser DisableUser AuthenticationType 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 :: DisableUser -> Request DisableUser
request = Service -> DisableUser -> Request DisableUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableUser)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DisableUser))
-> Logger
-> Service
-> Proxy DisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableUser)))
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 -> DisableUserResponse
DisableUserResponse'
            (Int -> DisableUserResponse)
-> Either String Int -> Either String DisableUserResponse
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 DisableUser

instance Prelude.NFData DisableUser

instance Core.ToHeaders DisableUser where
  toHeaders :: DisableUser -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisableUser -> 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.DisableUser" ::
                          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 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
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 DisableUser where
  toPath :: DisableUser -> ByteString
toPath = ByteString -> DisableUser -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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