{-# 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.StopGameSessionPlacement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels a game session placement that is in @PENDING@ status. To stop a
-- placement, provide the placement ID values. If successful, the placement
-- is moved to @CANCELLED@ status.
module Amazonka.GameLift.StopGameSessionPlacement
  ( -- * Creating a Request
    StopGameSessionPlacement (..),
    newStopGameSessionPlacement,

    -- * Request Lenses
    stopGameSessionPlacement_placementId,

    -- * Destructuring the Response
    StopGameSessionPlacementResponse (..),
    newStopGameSessionPlacementResponse,

    -- * Response Lenses
    stopGameSessionPlacementResponse_gameSessionPlacement,
    stopGameSessionPlacementResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GameLift.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStopGameSessionPlacement' smart constructor.
data StopGameSessionPlacement = StopGameSessionPlacement'
  { -- | A unique identifier for a game session placement to stop.
    StopGameSessionPlacement -> Text
placementId :: Prelude.Text
  }
  deriving (StopGameSessionPlacement -> StopGameSessionPlacement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopGameSessionPlacement -> StopGameSessionPlacement -> Bool
$c/= :: StopGameSessionPlacement -> StopGameSessionPlacement -> Bool
== :: StopGameSessionPlacement -> StopGameSessionPlacement -> Bool
$c== :: StopGameSessionPlacement -> StopGameSessionPlacement -> Bool
Prelude.Eq, ReadPrec [StopGameSessionPlacement]
ReadPrec StopGameSessionPlacement
Int -> ReadS StopGameSessionPlacement
ReadS [StopGameSessionPlacement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopGameSessionPlacement]
$creadListPrec :: ReadPrec [StopGameSessionPlacement]
readPrec :: ReadPrec StopGameSessionPlacement
$creadPrec :: ReadPrec StopGameSessionPlacement
readList :: ReadS [StopGameSessionPlacement]
$creadList :: ReadS [StopGameSessionPlacement]
readsPrec :: Int -> ReadS StopGameSessionPlacement
$creadsPrec :: Int -> ReadS StopGameSessionPlacement
Prelude.Read, Int -> StopGameSessionPlacement -> ShowS
[StopGameSessionPlacement] -> ShowS
StopGameSessionPlacement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopGameSessionPlacement] -> ShowS
$cshowList :: [StopGameSessionPlacement] -> ShowS
show :: StopGameSessionPlacement -> String
$cshow :: StopGameSessionPlacement -> String
showsPrec :: Int -> StopGameSessionPlacement -> ShowS
$cshowsPrec :: Int -> StopGameSessionPlacement -> ShowS
Prelude.Show, forall x.
Rep StopGameSessionPlacement x -> StopGameSessionPlacement
forall x.
StopGameSessionPlacement -> Rep StopGameSessionPlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopGameSessionPlacement x -> StopGameSessionPlacement
$cfrom :: forall x.
StopGameSessionPlacement -> Rep StopGameSessionPlacement x
Prelude.Generic)

-- |
-- Create a value of 'StopGameSessionPlacement' 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:
--
-- 'placementId', 'stopGameSessionPlacement_placementId' - A unique identifier for a game session placement to stop.
newStopGameSessionPlacement ::
  -- | 'placementId'
  Prelude.Text ->
  StopGameSessionPlacement
newStopGameSessionPlacement :: Text -> StopGameSessionPlacement
newStopGameSessionPlacement Text
pPlacementId_ =
  StopGameSessionPlacement'
    { $sel:placementId:StopGameSessionPlacement' :: Text
placementId =
        Text
pPlacementId_
    }

-- | A unique identifier for a game session placement to stop.
stopGameSessionPlacement_placementId :: Lens.Lens' StopGameSessionPlacement Prelude.Text
stopGameSessionPlacement_placementId :: Lens' StopGameSessionPlacement Text
stopGameSessionPlacement_placementId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:StopGameSessionPlacement' :: StopGameSessionPlacement -> Text
placementId} -> Text
placementId) (\s :: StopGameSessionPlacement
s@StopGameSessionPlacement' {} Text
a -> StopGameSessionPlacement
s {$sel:placementId:StopGameSessionPlacement' :: Text
placementId = Text
a} :: StopGameSessionPlacement)

instance Core.AWSRequest StopGameSessionPlacement where
  type
    AWSResponse StopGameSessionPlacement =
      StopGameSessionPlacementResponse
  request :: (Service -> Service)
-> StopGameSessionPlacement -> Request StopGameSessionPlacement
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 StopGameSessionPlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopGameSessionPlacement)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe GameSessionPlacement
-> Int -> StopGameSessionPlacementResponse
StopGameSessionPlacementResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"GameSessionPlacement")
            forall (f :: * -> *) a b. Applicative f => 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 StopGameSessionPlacement where
  hashWithSalt :: Int -> StopGameSessionPlacement -> Int
hashWithSalt Int
_salt StopGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:StopGameSessionPlacement' :: StopGameSessionPlacement -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
placementId

instance Prelude.NFData StopGameSessionPlacement where
  rnf :: StopGameSessionPlacement -> ()
rnf StopGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:StopGameSessionPlacement' :: StopGameSessionPlacement -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
placementId

instance Data.ToHeaders StopGameSessionPlacement where
  toHeaders :: StopGameSessionPlacement -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"GameLift.StopGameSessionPlacement" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StopGameSessionPlacement where
  toJSON :: StopGameSessionPlacement -> Value
toJSON StopGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:StopGameSessionPlacement' :: StopGameSessionPlacement -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"PlacementId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
placementId)]
      )

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

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

-- | /See:/ 'newStopGameSessionPlacementResponse' smart constructor.
data StopGameSessionPlacementResponse = StopGameSessionPlacementResponse'
  { -- | Object that describes the canceled game session placement, with
    -- @CANCELLED@ status and an end time stamp.
    StopGameSessionPlacementResponse -> Maybe GameSessionPlacement
gameSessionPlacement :: Prelude.Maybe GameSessionPlacement,
    -- | The response's http status code.
    StopGameSessionPlacementResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopGameSessionPlacementResponse
-> StopGameSessionPlacementResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopGameSessionPlacementResponse
-> StopGameSessionPlacementResponse -> Bool
$c/= :: StopGameSessionPlacementResponse
-> StopGameSessionPlacementResponse -> Bool
== :: StopGameSessionPlacementResponse
-> StopGameSessionPlacementResponse -> Bool
$c== :: StopGameSessionPlacementResponse
-> StopGameSessionPlacementResponse -> Bool
Prelude.Eq, ReadPrec [StopGameSessionPlacementResponse]
ReadPrec StopGameSessionPlacementResponse
Int -> ReadS StopGameSessionPlacementResponse
ReadS [StopGameSessionPlacementResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopGameSessionPlacementResponse]
$creadListPrec :: ReadPrec [StopGameSessionPlacementResponse]
readPrec :: ReadPrec StopGameSessionPlacementResponse
$creadPrec :: ReadPrec StopGameSessionPlacementResponse
readList :: ReadS [StopGameSessionPlacementResponse]
$creadList :: ReadS [StopGameSessionPlacementResponse]
readsPrec :: Int -> ReadS StopGameSessionPlacementResponse
$creadsPrec :: Int -> ReadS StopGameSessionPlacementResponse
Prelude.Read, Int -> StopGameSessionPlacementResponse -> ShowS
[StopGameSessionPlacementResponse] -> ShowS
StopGameSessionPlacementResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopGameSessionPlacementResponse] -> ShowS
$cshowList :: [StopGameSessionPlacementResponse] -> ShowS
show :: StopGameSessionPlacementResponse -> String
$cshow :: StopGameSessionPlacementResponse -> String
showsPrec :: Int -> StopGameSessionPlacementResponse -> ShowS
$cshowsPrec :: Int -> StopGameSessionPlacementResponse -> ShowS
Prelude.Show, forall x.
Rep StopGameSessionPlacementResponse x
-> StopGameSessionPlacementResponse
forall x.
StopGameSessionPlacementResponse
-> Rep StopGameSessionPlacementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopGameSessionPlacementResponse x
-> StopGameSessionPlacementResponse
$cfrom :: forall x.
StopGameSessionPlacementResponse
-> Rep StopGameSessionPlacementResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopGameSessionPlacementResponse' 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:
--
-- 'gameSessionPlacement', 'stopGameSessionPlacementResponse_gameSessionPlacement' - Object that describes the canceled game session placement, with
-- @CANCELLED@ status and an end time stamp.
--
-- 'httpStatus', 'stopGameSessionPlacementResponse_httpStatus' - The response's http status code.
newStopGameSessionPlacementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopGameSessionPlacementResponse
newStopGameSessionPlacementResponse :: Int -> StopGameSessionPlacementResponse
newStopGameSessionPlacementResponse Int
pHttpStatus_ =
  StopGameSessionPlacementResponse'
    { $sel:gameSessionPlacement:StopGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopGameSessionPlacementResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Object that describes the canceled game session placement, with
-- @CANCELLED@ status and an end time stamp.
stopGameSessionPlacementResponse_gameSessionPlacement :: Lens.Lens' StopGameSessionPlacementResponse (Prelude.Maybe GameSessionPlacement)
stopGameSessionPlacementResponse_gameSessionPlacement :: Lens' StopGameSessionPlacementResponse (Maybe GameSessionPlacement)
stopGameSessionPlacementResponse_gameSessionPlacement = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopGameSessionPlacementResponse' {Maybe GameSessionPlacement
gameSessionPlacement :: Maybe GameSessionPlacement
$sel:gameSessionPlacement:StopGameSessionPlacementResponse' :: StopGameSessionPlacementResponse -> Maybe GameSessionPlacement
gameSessionPlacement} -> Maybe GameSessionPlacement
gameSessionPlacement) (\s :: StopGameSessionPlacementResponse
s@StopGameSessionPlacementResponse' {} Maybe GameSessionPlacement
a -> StopGameSessionPlacementResponse
s {$sel:gameSessionPlacement:StopGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement = Maybe GameSessionPlacement
a} :: StopGameSessionPlacementResponse)

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

instance
  Prelude.NFData
    StopGameSessionPlacementResponse
  where
  rnf :: StopGameSessionPlacementResponse -> ()
rnf StopGameSessionPlacementResponse' {Int
Maybe GameSessionPlacement
httpStatus :: Int
gameSessionPlacement :: Maybe GameSessionPlacement
$sel:httpStatus:StopGameSessionPlacementResponse' :: StopGameSessionPlacementResponse -> Int
$sel:gameSessionPlacement:StopGameSessionPlacementResponse' :: StopGameSessionPlacementResponse -> Maybe GameSessionPlacement
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe GameSessionPlacement
gameSessionPlacement
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus