{-# 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.GlobalSignOut
-- 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. 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.
module Amazonka.CognitoIdentityProvider.GlobalSignOut
  ( -- * Creating a Request
    GlobalSignOut (..),
    newGlobalSignOut,

    -- * Request Lenses
    globalSignOut_accessToken,

    -- * Destructuring the Response
    GlobalSignOutResponse (..),
    newGlobalSignOutResponse,

    -- * Response Lenses
    globalSignOutResponse_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

-- | Represents the request to sign out all devices.
--
-- /See:/ 'newGlobalSignOut' smart constructor.
data GlobalSignOut = GlobalSignOut'
  { -- | The access token.
    GlobalSignOut -> Sensitive Text
accessToken :: Core.Sensitive Prelude.Text
  }
  deriving (GlobalSignOut -> GlobalSignOut -> Bool
(GlobalSignOut -> GlobalSignOut -> Bool)
-> (GlobalSignOut -> GlobalSignOut -> Bool) -> Eq GlobalSignOut
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalSignOut -> GlobalSignOut -> Bool
$c/= :: GlobalSignOut -> GlobalSignOut -> Bool
== :: GlobalSignOut -> GlobalSignOut -> Bool
$c== :: GlobalSignOut -> GlobalSignOut -> Bool
Prelude.Eq, Int -> GlobalSignOut -> ShowS
[GlobalSignOut] -> ShowS
GlobalSignOut -> String
(Int -> GlobalSignOut -> ShowS)
-> (GlobalSignOut -> String)
-> ([GlobalSignOut] -> ShowS)
-> Show GlobalSignOut
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalSignOut] -> ShowS
$cshowList :: [GlobalSignOut] -> ShowS
show :: GlobalSignOut -> String
$cshow :: GlobalSignOut -> String
showsPrec :: Int -> GlobalSignOut -> ShowS
$cshowsPrec :: Int -> GlobalSignOut -> ShowS
Prelude.Show, (forall x. GlobalSignOut -> Rep GlobalSignOut x)
-> (forall x. Rep GlobalSignOut x -> GlobalSignOut)
-> Generic GlobalSignOut
forall x. Rep GlobalSignOut x -> GlobalSignOut
forall x. GlobalSignOut -> Rep GlobalSignOut x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlobalSignOut x -> GlobalSignOut
$cfrom :: forall x. GlobalSignOut -> Rep GlobalSignOut x
Prelude.Generic)

-- |
-- Create a value of 'GlobalSignOut' 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:
--
-- 'accessToken', 'globalSignOut_accessToken' - The access token.
newGlobalSignOut ::
  -- | 'accessToken'
  Prelude.Text ->
  GlobalSignOut
newGlobalSignOut :: Text -> GlobalSignOut
newGlobalSignOut Text
pAccessToken_ =
  GlobalSignOut' :: Sensitive Text -> GlobalSignOut
GlobalSignOut'
    { $sel:accessToken:GlobalSignOut' :: Sensitive Text
accessToken =
        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
pAccessToken_
    }

-- | The access token.
globalSignOut_accessToken :: Lens.Lens' GlobalSignOut Prelude.Text
globalSignOut_accessToken :: (Text -> f Text) -> GlobalSignOut -> f GlobalSignOut
globalSignOut_accessToken = (GlobalSignOut -> Sensitive Text)
-> (GlobalSignOut -> Sensitive Text -> GlobalSignOut)
-> Lens
     GlobalSignOut GlobalSignOut (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalSignOut' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:GlobalSignOut' :: GlobalSignOut -> Sensitive Text
accessToken} -> Sensitive Text
accessToken) (\s :: GlobalSignOut
s@GlobalSignOut' {} Sensitive Text
a -> GlobalSignOut
s {$sel:accessToken:GlobalSignOut' :: Sensitive Text
accessToken = Sensitive Text
a} :: GlobalSignOut) ((Sensitive Text -> f (Sensitive Text))
 -> GlobalSignOut -> f GlobalSignOut)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> GlobalSignOut
-> f GlobalSignOut
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 GlobalSignOut where
  type
    AWSResponse GlobalSignOut =
      GlobalSignOutResponse
  request :: GlobalSignOut -> Request GlobalSignOut
request = Service -> GlobalSignOut -> Request GlobalSignOut
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GlobalSignOut
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GlobalSignOut)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse GlobalSignOut))
-> Logger
-> Service
-> Proxy GlobalSignOut
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GlobalSignOut)))
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 -> GlobalSignOutResponse
GlobalSignOutResponse'
            (Int -> GlobalSignOutResponse)
-> Either String Int -> Either String GlobalSignOutResponse
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 GlobalSignOut

instance Prelude.NFData GlobalSignOut

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

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

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

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

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

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

instance Prelude.NFData GlobalSignOutResponse