{-# 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.CognitoIdentityProvider.AdminUserGlobalSignOut
-- 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)
--
-- Signs out users from all devices, as an administrator. It also
-- invalidates all refresh tokens issued to a user. The user\'s current
-- access and Id tokens remain valid until their expiry. Access and Id
-- tokens expire one hour after they are issued.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminUserGlobalSignOut
  ( -- * Creating a Request
    AdminUserGlobalSignOut (..),
    newAdminUserGlobalSignOut,

    -- * Request Lenses
    adminUserGlobalSignOut_userPoolId,
    adminUserGlobalSignOut_username,

    -- * Destructuring the Response
    AdminUserGlobalSignOutResponse (..),
    newAdminUserGlobalSignOutResponse,

    -- * Response Lenses
    adminUserGlobalSignOutResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.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

-- | The request to sign out of all devices, as an administrator.
--
-- /See:/ 'newAdminUserGlobalSignOut' smart constructor.
data AdminUserGlobalSignOut = AdminUserGlobalSignOut'
  { -- | The user pool ID.
    AdminUserGlobalSignOut -> Text
userPoolId :: Prelude.Text,
    -- | The user name.
    AdminUserGlobalSignOut -> Sensitive Text
username :: Core.Sensitive Prelude.Text
  }
  deriving (AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool
(AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool)
-> (AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool)
-> Eq AdminUserGlobalSignOut
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool
$c/= :: AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool
== :: AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool
$c== :: AdminUserGlobalSignOut -> AdminUserGlobalSignOut -> Bool
Prelude.Eq, Int -> AdminUserGlobalSignOut -> ShowS
[AdminUserGlobalSignOut] -> ShowS
AdminUserGlobalSignOut -> String
(Int -> AdminUserGlobalSignOut -> ShowS)
-> (AdminUserGlobalSignOut -> String)
-> ([AdminUserGlobalSignOut] -> ShowS)
-> Show AdminUserGlobalSignOut
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminUserGlobalSignOut] -> ShowS
$cshowList :: [AdminUserGlobalSignOut] -> ShowS
show :: AdminUserGlobalSignOut -> String
$cshow :: AdminUserGlobalSignOut -> String
showsPrec :: Int -> AdminUserGlobalSignOut -> ShowS
$cshowsPrec :: Int -> AdminUserGlobalSignOut -> ShowS
Prelude.Show, (forall x. AdminUserGlobalSignOut -> Rep AdminUserGlobalSignOut x)
-> (forall x.
    Rep AdminUserGlobalSignOut x -> AdminUserGlobalSignOut)
-> Generic AdminUserGlobalSignOut
forall x. Rep AdminUserGlobalSignOut x -> AdminUserGlobalSignOut
forall x. AdminUserGlobalSignOut -> Rep AdminUserGlobalSignOut x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdminUserGlobalSignOut x -> AdminUserGlobalSignOut
$cfrom :: forall x. AdminUserGlobalSignOut -> Rep AdminUserGlobalSignOut x
Prelude.Generic)

-- |
-- Create a value of 'AdminUserGlobalSignOut' 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:
--
-- 'userPoolId', 'adminUserGlobalSignOut_userPoolId' - The user pool ID.
--
-- 'username', 'adminUserGlobalSignOut_username' - The user name.
newAdminUserGlobalSignOut ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminUserGlobalSignOut
newAdminUserGlobalSignOut :: Text -> Text -> AdminUserGlobalSignOut
newAdminUserGlobalSignOut Text
pUserPoolId_ Text
pUsername_ =
  AdminUserGlobalSignOut' :: Text -> Sensitive Text -> AdminUserGlobalSignOut
AdminUserGlobalSignOut'
    { $sel:userPoolId:AdminUserGlobalSignOut' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:username:AdminUserGlobalSignOut' :: 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_
    }

-- | The user pool ID.
adminUserGlobalSignOut_userPoolId :: Lens.Lens' AdminUserGlobalSignOut Prelude.Text
adminUserGlobalSignOut_userPoolId :: (Text -> f Text)
-> AdminUserGlobalSignOut -> f AdminUserGlobalSignOut
adminUserGlobalSignOut_userPoolId = (AdminUserGlobalSignOut -> Text)
-> (AdminUserGlobalSignOut -> Text -> AdminUserGlobalSignOut)
-> Lens AdminUserGlobalSignOut AdminUserGlobalSignOut Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminUserGlobalSignOut' {Text
userPoolId :: Text
$sel:userPoolId:AdminUserGlobalSignOut' :: AdminUserGlobalSignOut -> Text
userPoolId} -> Text
userPoolId) (\s :: AdminUserGlobalSignOut
s@AdminUserGlobalSignOut' {} Text
a -> AdminUserGlobalSignOut
s {$sel:userPoolId:AdminUserGlobalSignOut' :: Text
userPoolId = Text
a} :: AdminUserGlobalSignOut)

-- | The user name.
adminUserGlobalSignOut_username :: Lens.Lens' AdminUserGlobalSignOut Prelude.Text
adminUserGlobalSignOut_username :: (Text -> f Text)
-> AdminUserGlobalSignOut -> f AdminUserGlobalSignOut
adminUserGlobalSignOut_username = (AdminUserGlobalSignOut -> Sensitive Text)
-> (AdminUserGlobalSignOut
    -> Sensitive Text -> AdminUserGlobalSignOut)
-> Lens
     AdminUserGlobalSignOut
     AdminUserGlobalSignOut
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminUserGlobalSignOut' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminUserGlobalSignOut' :: AdminUserGlobalSignOut -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminUserGlobalSignOut
s@AdminUserGlobalSignOut' {} Sensitive Text
a -> AdminUserGlobalSignOut
s {$sel:username:AdminUserGlobalSignOut' :: Sensitive Text
username = Sensitive Text
a} :: AdminUserGlobalSignOut) ((Sensitive Text -> f (Sensitive Text))
 -> AdminUserGlobalSignOut -> f AdminUserGlobalSignOut)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminUserGlobalSignOut
-> f AdminUserGlobalSignOut
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

instance Core.AWSRequest AdminUserGlobalSignOut where
  type
    AWSResponse AdminUserGlobalSignOut =
      AdminUserGlobalSignOutResponse
  request :: AdminUserGlobalSignOut -> Request AdminUserGlobalSignOut
request = Service -> AdminUserGlobalSignOut -> Request AdminUserGlobalSignOut
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AdminUserGlobalSignOut
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AdminUserGlobalSignOut)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AdminUserGlobalSignOut))
-> Logger
-> Service
-> Proxy AdminUserGlobalSignOut
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AdminUserGlobalSignOut)))
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 -> AdminUserGlobalSignOutResponse
AdminUserGlobalSignOutResponse'
            (Int -> AdminUserGlobalSignOutResponse)
-> Either String Int
-> Either String AdminUserGlobalSignOutResponse
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 AdminUserGlobalSignOut

instance Prelude.NFData AdminUserGlobalSignOut

instance Core.ToHeaders AdminUserGlobalSignOut where
  toHeaders :: AdminUserGlobalSignOut -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AdminUserGlobalSignOut -> 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
"AWSCognitoIdentityProviderService.AdminUserGlobalSignOut" ::
                          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 AdminUserGlobalSignOut where
  toJSON :: AdminUserGlobalSignOut -> Value
toJSON AdminUserGlobalSignOut' {Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
$sel:username:AdminUserGlobalSignOut' :: AdminUserGlobalSignOut -> Sensitive Text
$sel:userPoolId:AdminUserGlobalSignOut' :: AdminUserGlobalSignOut -> 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
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            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)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    AdminUserGlobalSignOutResponse