{-# 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.ConnectParticipant.DisconnectParticipant
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disconnects a participant.
--
-- @ConnectionToken@ is used for invoking this API instead of
-- @ParticipantToken@.
--
-- The Amazon Connect Participant Service APIs do not use
-- <https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html Signature Version 4 authentication>.
module Amazonka.ConnectParticipant.DisconnectParticipant
  ( -- * Creating a Request
    DisconnectParticipant (..),
    newDisconnectParticipant,

    -- * Request Lenses
    disconnectParticipant_clientToken,
    disconnectParticipant_connectionToken,

    -- * Destructuring the Response
    DisconnectParticipantResponse (..),
    newDisconnectParticipantResponse,

    -- * Response Lenses
    disconnectParticipantResponse_httpStatus,
  )
where

import Amazonka.ConnectParticipant.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:/ 'newDisconnectParticipant' smart constructor.
data DisconnectParticipant = DisconnectParticipant'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. If not provided, the Amazon Web Services SDK
    -- populates this field. For more information about idempotency, see
    -- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
    DisconnectParticipant -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The authentication token associated with the participant\'s connection.
    DisconnectParticipant -> Text
connectionToken :: Prelude.Text
  }
  deriving (DisconnectParticipant -> DisconnectParticipant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisconnectParticipant -> DisconnectParticipant -> Bool
$c/= :: DisconnectParticipant -> DisconnectParticipant -> Bool
== :: DisconnectParticipant -> DisconnectParticipant -> Bool
$c== :: DisconnectParticipant -> DisconnectParticipant -> Bool
Prelude.Eq, ReadPrec [DisconnectParticipant]
ReadPrec DisconnectParticipant
Int -> ReadS DisconnectParticipant
ReadS [DisconnectParticipant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisconnectParticipant]
$creadListPrec :: ReadPrec [DisconnectParticipant]
readPrec :: ReadPrec DisconnectParticipant
$creadPrec :: ReadPrec DisconnectParticipant
readList :: ReadS [DisconnectParticipant]
$creadList :: ReadS [DisconnectParticipant]
readsPrec :: Int -> ReadS DisconnectParticipant
$creadsPrec :: Int -> ReadS DisconnectParticipant
Prelude.Read, Int -> DisconnectParticipant -> ShowS
[DisconnectParticipant] -> ShowS
DisconnectParticipant -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisconnectParticipant] -> ShowS
$cshowList :: [DisconnectParticipant] -> ShowS
show :: DisconnectParticipant -> String
$cshow :: DisconnectParticipant -> String
showsPrec :: Int -> DisconnectParticipant -> ShowS
$cshowsPrec :: Int -> DisconnectParticipant -> ShowS
Prelude.Show, forall x. Rep DisconnectParticipant x -> DisconnectParticipant
forall x. DisconnectParticipant -> Rep DisconnectParticipant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisconnectParticipant x -> DisconnectParticipant
$cfrom :: forall x. DisconnectParticipant -> Rep DisconnectParticipant x
Prelude.Generic)

-- |
-- Create a value of 'DisconnectParticipant' 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:
--
-- 'clientToken', 'disconnectParticipant_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If not provided, the Amazon Web Services SDK
-- populates this field. For more information about idempotency, see
-- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
--
-- 'connectionToken', 'disconnectParticipant_connectionToken' - The authentication token associated with the participant\'s connection.
newDisconnectParticipant ::
  -- | 'connectionToken'
  Prelude.Text ->
  DisconnectParticipant
newDisconnectParticipant :: Text -> DisconnectParticipant
newDisconnectParticipant Text
pConnectionToken_ =
  DisconnectParticipant'
    { $sel:clientToken:DisconnectParticipant' :: Maybe Text
clientToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:connectionToken:DisconnectParticipant' :: Text
connectionToken = Text
pConnectionToken_
    }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If not provided, the Amazon Web Services SDK
-- populates this field. For more information about idempotency, see
-- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
disconnectParticipant_clientToken :: Lens.Lens' DisconnectParticipant (Prelude.Maybe Prelude.Text)
disconnectParticipant_clientToken :: Lens' DisconnectParticipant (Maybe Text)
disconnectParticipant_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisconnectParticipant' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DisconnectParticipant' :: DisconnectParticipant -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DisconnectParticipant
s@DisconnectParticipant' {} Maybe Text
a -> DisconnectParticipant
s {$sel:clientToken:DisconnectParticipant' :: Maybe Text
clientToken = Maybe Text
a} :: DisconnectParticipant)

-- | The authentication token associated with the participant\'s connection.
disconnectParticipant_connectionToken :: Lens.Lens' DisconnectParticipant Prelude.Text
disconnectParticipant_connectionToken :: Lens' DisconnectParticipant Text
disconnectParticipant_connectionToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisconnectParticipant' {Text
connectionToken :: Text
$sel:connectionToken:DisconnectParticipant' :: DisconnectParticipant -> Text
connectionToken} -> Text
connectionToken) (\s :: DisconnectParticipant
s@DisconnectParticipant' {} Text
a -> DisconnectParticipant
s {$sel:connectionToken:DisconnectParticipant' :: Text
connectionToken = Text
a} :: DisconnectParticipant)

instance Core.AWSRequest DisconnectParticipant where
  type
    AWSResponse DisconnectParticipant =
      DisconnectParticipantResponse
  request :: (Service -> Service)
-> DisconnectParticipant -> Request DisconnectParticipant
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 DisconnectParticipant
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisconnectParticipant)))
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 -> DisconnectParticipantResponse
DisconnectParticipantResponse'
            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 DisconnectParticipant where
  hashWithSalt :: Int -> DisconnectParticipant -> Int
hashWithSalt Int
_salt DisconnectParticipant' {Maybe Text
Text
connectionToken :: Text
clientToken :: Maybe Text
$sel:connectionToken:DisconnectParticipant' :: DisconnectParticipant -> Text
$sel:clientToken:DisconnectParticipant' :: DisconnectParticipant -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionToken

instance Prelude.NFData DisconnectParticipant where
  rnf :: DisconnectParticipant -> ()
rnf DisconnectParticipant' {Maybe Text
Text
connectionToken :: Text
clientToken :: Maybe Text
$sel:connectionToken:DisconnectParticipant' :: DisconnectParticipant -> Text
$sel:clientToken:DisconnectParticipant' :: DisconnectParticipant -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionToken

instance Data.ToHeaders DisconnectParticipant where
  toHeaders :: DisconnectParticipant -> ResponseHeaders
toHeaders DisconnectParticipant' {Maybe Text
Text
connectionToken :: Text
clientToken :: Maybe Text
$sel:connectionToken:DisconnectParticipant' :: DisconnectParticipant -> Text
$sel:clientToken:DisconnectParticipant' :: DisconnectParticipant -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amz-Bearer" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
connectionToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToJSON DisconnectParticipant where
  toJSON :: DisconnectParticipant -> Value
toJSON DisconnectParticipant' {Maybe Text
Text
connectionToken :: Text
clientToken :: Maybe Text
$sel:connectionToken:DisconnectParticipant' :: DisconnectParticipant -> Text
$sel:clientToken:DisconnectParticipant' :: DisconnectParticipant -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"ClientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken]
      )

instance Data.ToPath DisconnectParticipant where
  toPath :: DisconnectParticipant -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/participant/disconnect"

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

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

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

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

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