{-# 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.GameLift.StopMatchmaking
-- 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)
--
-- Cancels a matchmaking ticket or match backfill ticket that is currently
-- being processed. To stop the matchmaking operation, specify the ticket
-- ID. If successful, work on the ticket is stopped, and the ticket status
-- is changed to @CANCELLED@.
--
-- This call is also used to turn off automatic backfill for an individual
-- game session. This is for game sessions that are created with a
-- matchmaking configuration that has automatic backfill enabled. The
-- ticket ID is included in the @MatchmakerData@ of an updated game session
-- object, which is provided to the game server.
--
-- If the operation is successful, the service sends back an empty JSON
-- struct with the HTTP 200 response (not an empty HTTP body).
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-client.html Add FlexMatch to a game client>
--
-- __Related actions__
--
-- StartMatchmaking | DescribeMatchmaking | StopMatchmaking | AcceptMatch |
-- StartMatchBackfill |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.StopMatchmaking
  ( -- * Creating a Request
    StopMatchmaking (..),
    newStopMatchmaking,

    -- * Request Lenses
    stopMatchmaking_ticketId,

    -- * Destructuring the Response
    StopMatchmakingResponse (..),
    newStopMatchmakingResponse,

    -- * Response Lenses
    stopMatchmakingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types
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 input for a request operation.
--
-- /See:/ 'newStopMatchmaking' smart constructor.
data StopMatchmaking = StopMatchmaking'
  { -- | A unique identifier for a matchmaking ticket.
    StopMatchmaking -> Text
ticketId :: Prelude.Text
  }
  deriving (StopMatchmaking -> StopMatchmaking -> Bool
(StopMatchmaking -> StopMatchmaking -> Bool)
-> (StopMatchmaking -> StopMatchmaking -> Bool)
-> Eq StopMatchmaking
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopMatchmaking -> StopMatchmaking -> Bool
$c/= :: StopMatchmaking -> StopMatchmaking -> Bool
== :: StopMatchmaking -> StopMatchmaking -> Bool
$c== :: StopMatchmaking -> StopMatchmaking -> Bool
Prelude.Eq, ReadPrec [StopMatchmaking]
ReadPrec StopMatchmaking
Int -> ReadS StopMatchmaking
ReadS [StopMatchmaking]
(Int -> ReadS StopMatchmaking)
-> ReadS [StopMatchmaking]
-> ReadPrec StopMatchmaking
-> ReadPrec [StopMatchmaking]
-> Read StopMatchmaking
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopMatchmaking]
$creadListPrec :: ReadPrec [StopMatchmaking]
readPrec :: ReadPrec StopMatchmaking
$creadPrec :: ReadPrec StopMatchmaking
readList :: ReadS [StopMatchmaking]
$creadList :: ReadS [StopMatchmaking]
readsPrec :: Int -> ReadS StopMatchmaking
$creadsPrec :: Int -> ReadS StopMatchmaking
Prelude.Read, Int -> StopMatchmaking -> ShowS
[StopMatchmaking] -> ShowS
StopMatchmaking -> String
(Int -> StopMatchmaking -> ShowS)
-> (StopMatchmaking -> String)
-> ([StopMatchmaking] -> ShowS)
-> Show StopMatchmaking
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopMatchmaking] -> ShowS
$cshowList :: [StopMatchmaking] -> ShowS
show :: StopMatchmaking -> String
$cshow :: StopMatchmaking -> String
showsPrec :: Int -> StopMatchmaking -> ShowS
$cshowsPrec :: Int -> StopMatchmaking -> ShowS
Prelude.Show, (forall x. StopMatchmaking -> Rep StopMatchmaking x)
-> (forall x. Rep StopMatchmaking x -> StopMatchmaking)
-> Generic StopMatchmaking
forall x. Rep StopMatchmaking x -> StopMatchmaking
forall x. StopMatchmaking -> Rep StopMatchmaking x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopMatchmaking x -> StopMatchmaking
$cfrom :: forall x. StopMatchmaking -> Rep StopMatchmaking x
Prelude.Generic)

-- |
-- Create a value of 'StopMatchmaking' 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:
--
-- 'ticketId', 'stopMatchmaking_ticketId' - A unique identifier for a matchmaking ticket.
newStopMatchmaking ::
  -- | 'ticketId'
  Prelude.Text ->
  StopMatchmaking
newStopMatchmaking :: Text -> StopMatchmaking
newStopMatchmaking Text
pTicketId_ =
  StopMatchmaking' :: Text -> StopMatchmaking
StopMatchmaking' {$sel:ticketId:StopMatchmaking' :: Text
ticketId = Text
pTicketId_}

-- | A unique identifier for a matchmaking ticket.
stopMatchmaking_ticketId :: Lens.Lens' StopMatchmaking Prelude.Text
stopMatchmaking_ticketId :: (Text -> f Text) -> StopMatchmaking -> f StopMatchmaking
stopMatchmaking_ticketId = (StopMatchmaking -> Text)
-> (StopMatchmaking -> Text -> StopMatchmaking)
-> Lens StopMatchmaking StopMatchmaking Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopMatchmaking' {Text
ticketId :: Text
$sel:ticketId:StopMatchmaking' :: StopMatchmaking -> Text
ticketId} -> Text
ticketId) (\s :: StopMatchmaking
s@StopMatchmaking' {} Text
a -> StopMatchmaking
s {$sel:ticketId:StopMatchmaking' :: Text
ticketId = Text
a} :: StopMatchmaking)

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

instance Prelude.NFData StopMatchmaking

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

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

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

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

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

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

instance Prelude.NFData StopMatchmakingResponse