{-# 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.SSO.Logout
-- 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)
--
-- Removes the client- and server-side session that is associated with the
-- user.
module Amazonka.SSO.Logout
  ( -- * Creating a Request
    Logout (..),
    newLogout,

    -- * Request Lenses
    logout_accessToken,

    -- * Destructuring the Response
    LogoutResponse (..),
    newLogoutResponse,
  )
where

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
import Amazonka.SSO.Types

-- | /See:/ 'newLogout' smart constructor.
data Logout = Logout'
  { -- | The token issued by the @CreateToken@ API call. For more information,
    -- see
    -- <https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html CreateToken>
    -- in the /AWS SSO OIDC API Reference Guide/.
    Logout -> Sensitive Text
accessToken :: Core.Sensitive Prelude.Text
  }
  deriving (Logout -> Logout -> Bool
(Logout -> Logout -> Bool)
-> (Logout -> Logout -> Bool) -> Eq Logout
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Logout -> Logout -> Bool
$c/= :: Logout -> Logout -> Bool
== :: Logout -> Logout -> Bool
$c== :: Logout -> Logout -> Bool
Prelude.Eq, Int -> Logout -> ShowS
[Logout] -> ShowS
Logout -> String
(Int -> Logout -> ShowS)
-> (Logout -> String) -> ([Logout] -> ShowS) -> Show Logout
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Logout] -> ShowS
$cshowList :: [Logout] -> ShowS
show :: Logout -> String
$cshow :: Logout -> String
showsPrec :: Int -> Logout -> ShowS
$cshowsPrec :: Int -> Logout -> ShowS
Prelude.Show, (forall x. Logout -> Rep Logout x)
-> (forall x. Rep Logout x -> Logout) -> Generic Logout
forall x. Rep Logout x -> Logout
forall x. Logout -> Rep Logout x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Logout x -> Logout
$cfrom :: forall x. Logout -> Rep Logout x
Prelude.Generic)

-- |
-- Create a value of 'Logout' 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', 'logout_accessToken' - The token issued by the @CreateToken@ API call. For more information,
-- see
-- <https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html CreateToken>
-- in the /AWS SSO OIDC API Reference Guide/.
newLogout ::
  -- | 'accessToken'
  Prelude.Text ->
  Logout
newLogout :: Text -> Logout
newLogout Text
pAccessToken_ =
  Logout' :: Sensitive Text -> Logout
Logout'
    { $sel:accessToken:Logout' :: 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 token issued by the @CreateToken@ API call. For more information,
-- see
-- <https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html CreateToken>
-- in the /AWS SSO OIDC API Reference Guide/.
logout_accessToken :: Lens.Lens' Logout Prelude.Text
logout_accessToken :: (Text -> f Text) -> Logout -> f Logout
logout_accessToken = (Logout -> Sensitive Text)
-> (Logout -> Sensitive Text -> Logout)
-> Lens Logout Logout (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Logout' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:Logout' :: Logout -> Sensitive Text
accessToken} -> Sensitive Text
accessToken) (\s :: Logout
s@Logout' {} Sensitive Text
a -> Logout
s {$sel:accessToken:Logout' :: Sensitive Text
accessToken = Sensitive Text
a} :: Logout) ((Sensitive Text -> f (Sensitive Text)) -> Logout -> f Logout)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> Logout
-> f Logout
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 Logout where
  type AWSResponse Logout = LogoutResponse
  request :: Logout -> Request Logout
request = Service -> Logout -> Request Logout
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy Logout
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Logout)))
response = AWSResponse Logout
-> Logger
-> Service
-> Proxy Logout
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Logout)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse Logout
LogoutResponse
LogoutResponse'

instance Prelude.Hashable Logout

instance Prelude.NFData Logout

instance Core.ToHeaders Logout where
  toHeaders :: Logout -> [Header]
toHeaders Logout' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:Logout' :: Logout -> Sensitive Text
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-sso_bearer_token" HeaderName -> Sensitive Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Sensitive Text
accessToken,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToJSON Logout where
  toJSON :: Logout -> Value
toJSON = Value -> Logout -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

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

-- |
-- Create a value of 'LogoutResponse' 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.
newLogoutResponse ::
  LogoutResponse
newLogoutResponse :: LogoutResponse
newLogoutResponse = LogoutResponse
LogoutResponse'

instance Prelude.NFData LogoutResponse