{-# 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-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 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.
--
-- __Related actions__
--
-- CreateGameSession | DescribeGameSessions | DescribeGameSessionDetails |
-- SearchGameSessions | UpdateGameSession | GetGameSessionLogUrl |
-- StartGameSessionPlacement | DescribeGameSessionPlacement |
-- StopGameSessionPlacement |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
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 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:/ 'newStopGameSessionPlacement' smart constructor.
data StopGameSessionPlacement = StopGameSessionPlacement'
  { -- | A unique identifier for a game session placement to cancel.
    StopGameSessionPlacement -> Text
placementId :: Prelude.Text
  }
  deriving (StopGameSessionPlacement -> StopGameSessionPlacement -> Bool
(StopGameSessionPlacement -> StopGameSessionPlacement -> Bool)
-> (StopGameSessionPlacement -> StopGameSessionPlacement -> Bool)
-> Eq StopGameSessionPlacement
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]
(Int -> ReadS StopGameSessionPlacement)
-> ReadS [StopGameSessionPlacement]
-> ReadPrec StopGameSessionPlacement
-> ReadPrec [StopGameSessionPlacement]
-> Read 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
(Int -> StopGameSessionPlacement -> ShowS)
-> (StopGameSessionPlacement -> String)
-> ([StopGameSessionPlacement] -> ShowS)
-> Show StopGameSessionPlacement
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.
 StopGameSessionPlacement -> Rep StopGameSessionPlacement x)
-> (forall x.
    Rep StopGameSessionPlacement x -> StopGameSessionPlacement)
-> Generic StopGameSessionPlacement
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 cancel.
newStopGameSessionPlacement ::
  -- | 'placementId'
  Prelude.Text ->
  StopGameSessionPlacement
newStopGameSessionPlacement :: Text -> StopGameSessionPlacement
newStopGameSessionPlacement Text
pPlacementId_ =
  StopGameSessionPlacement' :: Text -> StopGameSessionPlacement
StopGameSessionPlacement'
    { $sel:placementId:StopGameSessionPlacement' :: Text
placementId =
        Text
pPlacementId_
    }

-- | A unique identifier for a game session placement to cancel.
stopGameSessionPlacement_placementId :: Lens.Lens' StopGameSessionPlacement Prelude.Text
stopGameSessionPlacement_placementId :: (Text -> f Text)
-> StopGameSessionPlacement -> f StopGameSessionPlacement
stopGameSessionPlacement_placementId = (StopGameSessionPlacement -> Text)
-> (StopGameSessionPlacement -> Text -> StopGameSessionPlacement)
-> Lens StopGameSessionPlacement StopGameSessionPlacement Text Text
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 :: StopGameSessionPlacement -> Request StopGameSessionPlacement
request = Service
-> StopGameSessionPlacement -> Request StopGameSessionPlacement
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopGameSessionPlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopGameSessionPlacement)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopGameSessionPlacement))
-> Logger
-> Service
-> Proxy StopGameSessionPlacement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopGameSessionPlacement)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe GameSessionPlacement
-> Int -> StopGameSessionPlacementResponse
StopGameSessionPlacementResponse'
            (Maybe GameSessionPlacement
 -> Int -> StopGameSessionPlacementResponse)
-> Either String (Maybe GameSessionPlacement)
-> Either String (Int -> StopGameSessionPlacementResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GameSessionPlacement)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GameSessionPlacement")
            Either String (Int -> StopGameSessionPlacementResponse)
-> Either String Int
-> Either String StopGameSessionPlacementResponse
forall (f :: * -> *) a b. Applicative f => 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 StopGameSessionPlacement

instance Prelude.NFData StopGameSessionPlacement

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

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

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

-- | Represents the returned data in response to a request operation.
--
-- /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
(StopGameSessionPlacementResponse
 -> StopGameSessionPlacementResponse -> Bool)
-> (StopGameSessionPlacementResponse
    -> StopGameSessionPlacementResponse -> Bool)
-> Eq StopGameSessionPlacementResponse
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]
(Int -> ReadS StopGameSessionPlacementResponse)
-> ReadS [StopGameSessionPlacementResponse]
-> ReadPrec StopGameSessionPlacementResponse
-> ReadPrec [StopGameSessionPlacementResponse]
-> Read 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
(Int -> StopGameSessionPlacementResponse -> ShowS)
-> (StopGameSessionPlacementResponse -> String)
-> ([StopGameSessionPlacementResponse] -> ShowS)
-> Show StopGameSessionPlacementResponse
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.
 StopGameSessionPlacementResponse
 -> Rep StopGameSessionPlacementResponse x)
-> (forall x.
    Rep StopGameSessionPlacementResponse x
    -> StopGameSessionPlacementResponse)
-> Generic StopGameSessionPlacementResponse
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' :: Maybe GameSessionPlacement
-> Int -> StopGameSessionPlacementResponse
StopGameSessionPlacementResponse'
    { $sel:gameSessionPlacement:StopGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement =
        Maybe 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 :: (Maybe GameSessionPlacement -> f (Maybe GameSessionPlacement))
-> StopGameSessionPlacementResponse
-> f StopGameSessionPlacementResponse
stopGameSessionPlacementResponse_gameSessionPlacement = (StopGameSessionPlacementResponse -> Maybe GameSessionPlacement)
-> (StopGameSessionPlacementResponse
    -> Maybe GameSessionPlacement -> StopGameSessionPlacementResponse)
-> Lens
     StopGameSessionPlacementResponse
     StopGameSessionPlacementResponse
     (Maybe GameSessionPlacement)
     (Maybe 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 :: (Int -> f Int)
-> StopGameSessionPlacementResponse
-> f StopGameSessionPlacementResponse
stopGameSessionPlacementResponse_httpStatus = (StopGameSessionPlacementResponse -> Int)
-> (StopGameSessionPlacementResponse
    -> Int -> StopGameSessionPlacementResponse)
-> Lens
     StopGameSessionPlacementResponse
     StopGameSessionPlacementResponse
     Int
     Int
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