{-# 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.StartGameSessionPlacement
-- 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)
--
-- Places a request for a new game session in a queue (see
-- CreateGameSessionQueue). When processing a placement request, Amazon
-- GameLift searches for available resources on the queue\'s destinations,
-- scanning each until it finds resources or the placement request times
-- out.
--
-- A game session placement request can also request player sessions. When
-- a new game session is successfully created, Amazon GameLift creates a
-- player session for each player included in the request.
--
-- When placing a game session, by default Amazon GameLift tries each fleet
-- in the order they are listed in the queue configuration. Ideally, a
-- queue\'s destinations are listed in preference order.
--
-- Alternatively, when requesting a game session with players, you can also
-- provide latency data for each player in relevant Regions. Latency data
-- indicates the performance lag a player experiences when connected to a
-- fleet in the Region. Amazon GameLift uses latency data to reorder the
-- list of destinations to place the game session in a Region with minimal
-- lag. If latency data is provided for multiple players, Amazon GameLift
-- calculates each Region\'s average lag for all players and reorders to
-- get the best game play across all players.
--
-- To place a new game session request, specify the following:
--
-- -   The queue name and a set of game session properties and settings
--
-- -   A unique ID (such as a UUID) for the placement. You use this ID to
--     track the status of the placement request
--
-- -   (Optional) A set of player data and a unique player ID for each
--     player that you are joining to the new game session (player data is
--     optional, but if you include it, you must also provide a unique ID
--     for each player)
--
-- -   Latency data for all players (if you want to optimize game play for
--     the players)
--
-- If successful, a new game session placement is created.
--
-- To track the status of a placement request, call
-- DescribeGameSessionPlacement and check the request\'s status. If the
-- status is @FULFILLED@, a new game session has been created and a game
-- session ARN and Region are referenced. If the placement request times
-- out, you can resubmit the request or retry it with a different queue.
--
-- __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.StartGameSessionPlacement
  ( -- * Creating a Request
    StartGameSessionPlacement (..),
    newStartGameSessionPlacement,

    -- * Request Lenses
    startGameSessionPlacement_gameProperties,
    startGameSessionPlacement_gameSessionName,
    startGameSessionPlacement_playerLatencies,
    startGameSessionPlacement_gameSessionData,
    startGameSessionPlacement_desiredPlayerSessions,
    startGameSessionPlacement_placementId,
    startGameSessionPlacement_gameSessionQueueName,
    startGameSessionPlacement_maximumPlayerSessionCount,

    -- * Destructuring the Response
    StartGameSessionPlacementResponse (..),
    newStartGameSessionPlacementResponse,

    -- * Response Lenses
    startGameSessionPlacementResponse_gameSessionPlacement,
    startGameSessionPlacementResponse_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:/ 'newStartGameSessionPlacement' smart constructor.
data StartGameSessionPlacement = StartGameSessionPlacement'
  { -- | A set of custom properties for a game session, formatted as key:value
    -- pairs. These properties are passed to a game server process in the
    -- GameSession object with a request to start a new game session (see
    -- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a Game Session>).
    StartGameSessionPlacement -> Maybe [GameProperty]
gameProperties :: Prelude.Maybe [GameProperty],
    -- | A descriptive label that is associated with a game session. Session
    -- names do not need to be unique.
    StartGameSessionPlacement -> Maybe Text
gameSessionName :: Prelude.Maybe Prelude.Text,
    -- | A set of values, expressed in milliseconds, that indicates the amount of
    -- latency that a player experiences when connected to AWS Regions. This
    -- information is used to try to place the new game session where it can
    -- offer the best possible gameplay experience for the players.
    StartGameSessionPlacement -> Maybe [PlayerLatency]
playerLatencies :: Prelude.Maybe [PlayerLatency],
    -- | A set of custom game session properties, formatted as a single string
    -- value. This data is passed to a game server process in the GameSession
    -- object with a request to start a new game session (see
    -- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a Game Session>).
    StartGameSessionPlacement -> Maybe Text
gameSessionData :: Prelude.Maybe Prelude.Text,
    -- | Set of information on each player to create a player session for.
    StartGameSessionPlacement -> Maybe [DesiredPlayerSession]
desiredPlayerSessions :: Prelude.Maybe [DesiredPlayerSession],
    -- | A unique identifier to assign to the new game session placement. This
    -- value is developer-defined. The value must be unique across all Regions
    -- and cannot be reused unless you are resubmitting a canceled or timed-out
    -- placement request.
    StartGameSessionPlacement -> Text
placementId :: Prelude.Text,
    -- | Name of the queue to use to place the new game session. You can use
    -- either the queue name or ARN value.
    StartGameSessionPlacement -> Text
gameSessionQueueName :: Prelude.Text,
    -- | The maximum number of players that can be connected simultaneously to
    -- the game session.
    StartGameSessionPlacement -> Natural
maximumPlayerSessionCount :: Prelude.Natural
  }
  deriving (StartGameSessionPlacement -> StartGameSessionPlacement -> Bool
(StartGameSessionPlacement -> StartGameSessionPlacement -> Bool)
-> (StartGameSessionPlacement -> StartGameSessionPlacement -> Bool)
-> Eq StartGameSessionPlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartGameSessionPlacement -> StartGameSessionPlacement -> Bool
$c/= :: StartGameSessionPlacement -> StartGameSessionPlacement -> Bool
== :: StartGameSessionPlacement -> StartGameSessionPlacement -> Bool
$c== :: StartGameSessionPlacement -> StartGameSessionPlacement -> Bool
Prelude.Eq, ReadPrec [StartGameSessionPlacement]
ReadPrec StartGameSessionPlacement
Int -> ReadS StartGameSessionPlacement
ReadS [StartGameSessionPlacement]
(Int -> ReadS StartGameSessionPlacement)
-> ReadS [StartGameSessionPlacement]
-> ReadPrec StartGameSessionPlacement
-> ReadPrec [StartGameSessionPlacement]
-> Read StartGameSessionPlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartGameSessionPlacement]
$creadListPrec :: ReadPrec [StartGameSessionPlacement]
readPrec :: ReadPrec StartGameSessionPlacement
$creadPrec :: ReadPrec StartGameSessionPlacement
readList :: ReadS [StartGameSessionPlacement]
$creadList :: ReadS [StartGameSessionPlacement]
readsPrec :: Int -> ReadS StartGameSessionPlacement
$creadsPrec :: Int -> ReadS StartGameSessionPlacement
Prelude.Read, Int -> StartGameSessionPlacement -> ShowS
[StartGameSessionPlacement] -> ShowS
StartGameSessionPlacement -> String
(Int -> StartGameSessionPlacement -> ShowS)
-> (StartGameSessionPlacement -> String)
-> ([StartGameSessionPlacement] -> ShowS)
-> Show StartGameSessionPlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartGameSessionPlacement] -> ShowS
$cshowList :: [StartGameSessionPlacement] -> ShowS
show :: StartGameSessionPlacement -> String
$cshow :: StartGameSessionPlacement -> String
showsPrec :: Int -> StartGameSessionPlacement -> ShowS
$cshowsPrec :: Int -> StartGameSessionPlacement -> ShowS
Prelude.Show, (forall x.
 StartGameSessionPlacement -> Rep StartGameSessionPlacement x)
-> (forall x.
    Rep StartGameSessionPlacement x -> StartGameSessionPlacement)
-> Generic StartGameSessionPlacement
forall x.
Rep StartGameSessionPlacement x -> StartGameSessionPlacement
forall x.
StartGameSessionPlacement -> Rep StartGameSessionPlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartGameSessionPlacement x -> StartGameSessionPlacement
$cfrom :: forall x.
StartGameSessionPlacement -> Rep StartGameSessionPlacement x
Prelude.Generic)

-- |
-- Create a value of 'StartGameSessionPlacement' 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:
--
-- 'gameProperties', 'startGameSessionPlacement_gameProperties' - A set of custom properties for a game session, formatted as key:value
-- pairs. These properties are passed to a game server process in the
-- GameSession object with a request to start a new game session (see
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a Game Session>).
--
-- 'gameSessionName', 'startGameSessionPlacement_gameSessionName' - A descriptive label that is associated with a game session. Session
-- names do not need to be unique.
--
-- 'playerLatencies', 'startGameSessionPlacement_playerLatencies' - A set of values, expressed in milliseconds, that indicates the amount of
-- latency that a player experiences when connected to AWS Regions. This
-- information is used to try to place the new game session where it can
-- offer the best possible gameplay experience for the players.
--
-- 'gameSessionData', 'startGameSessionPlacement_gameSessionData' - A set of custom game session properties, formatted as a single string
-- value. This data is passed to a game server process in the GameSession
-- object with a request to start a new game session (see
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a Game Session>).
--
-- 'desiredPlayerSessions', 'startGameSessionPlacement_desiredPlayerSessions' - Set of information on each player to create a player session for.
--
-- 'placementId', 'startGameSessionPlacement_placementId' - A unique identifier to assign to the new game session placement. This
-- value is developer-defined. The value must be unique across all Regions
-- and cannot be reused unless you are resubmitting a canceled or timed-out
-- placement request.
--
-- 'gameSessionQueueName', 'startGameSessionPlacement_gameSessionQueueName' - Name of the queue to use to place the new game session. You can use
-- either the queue name or ARN value.
--
-- 'maximumPlayerSessionCount', 'startGameSessionPlacement_maximumPlayerSessionCount' - The maximum number of players that can be connected simultaneously to
-- the game session.
newStartGameSessionPlacement ::
  -- | 'placementId'
  Prelude.Text ->
  -- | 'gameSessionQueueName'
  Prelude.Text ->
  -- | 'maximumPlayerSessionCount'
  Prelude.Natural ->
  StartGameSessionPlacement
newStartGameSessionPlacement :: Text -> Text -> Natural -> StartGameSessionPlacement
newStartGameSessionPlacement
  Text
pPlacementId_
  Text
pGameSessionQueueName_
  Natural
pMaximumPlayerSessionCount_ =
    StartGameSessionPlacement' :: Maybe [GameProperty]
-> Maybe Text
-> Maybe [PlayerLatency]
-> Maybe Text
-> Maybe [DesiredPlayerSession]
-> Text
-> Text
-> Natural
-> StartGameSessionPlacement
StartGameSessionPlacement'
      { $sel:gameProperties:StartGameSessionPlacement' :: Maybe [GameProperty]
gameProperties =
          Maybe [GameProperty]
forall a. Maybe a
Prelude.Nothing,
        $sel:gameSessionName:StartGameSessionPlacement' :: Maybe Text
gameSessionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:playerLatencies:StartGameSessionPlacement' :: Maybe [PlayerLatency]
playerLatencies = Maybe [PlayerLatency]
forall a. Maybe a
Prelude.Nothing,
        $sel:gameSessionData:StartGameSessionPlacement' :: Maybe Text
gameSessionData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:desiredPlayerSessions:StartGameSessionPlacement' :: Maybe [DesiredPlayerSession]
desiredPlayerSessions = Maybe [DesiredPlayerSession]
forall a. Maybe a
Prelude.Nothing,
        $sel:placementId:StartGameSessionPlacement' :: Text
placementId = Text
pPlacementId_,
        $sel:gameSessionQueueName:StartGameSessionPlacement' :: Text
gameSessionQueueName = Text
pGameSessionQueueName_,
        $sel:maximumPlayerSessionCount:StartGameSessionPlacement' :: Natural
maximumPlayerSessionCount =
          Natural
pMaximumPlayerSessionCount_
      }

-- | A set of custom properties for a game session, formatted as key:value
-- pairs. These properties are passed to a game server process in the
-- GameSession object with a request to start a new game session (see
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a Game Session>).
startGameSessionPlacement_gameProperties :: Lens.Lens' StartGameSessionPlacement (Prelude.Maybe [GameProperty])
startGameSessionPlacement_gameProperties :: (Maybe [GameProperty] -> f (Maybe [GameProperty]))
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_gameProperties = (StartGameSessionPlacement -> Maybe [GameProperty])
-> (StartGameSessionPlacement
    -> Maybe [GameProperty] -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement
     StartGameSessionPlacement
     (Maybe [GameProperty])
     (Maybe [GameProperty])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Maybe [GameProperty]
gameProperties :: Maybe [GameProperty]
$sel:gameProperties:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe [GameProperty]
gameProperties} -> Maybe [GameProperty]
gameProperties) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Maybe [GameProperty]
a -> StartGameSessionPlacement
s {$sel:gameProperties:StartGameSessionPlacement' :: Maybe [GameProperty]
gameProperties = Maybe [GameProperty]
a} :: StartGameSessionPlacement) ((Maybe [GameProperty] -> f (Maybe [GameProperty]))
 -> StartGameSessionPlacement -> f StartGameSessionPlacement)
-> ((Maybe [GameProperty] -> f (Maybe [GameProperty]))
    -> Maybe [GameProperty] -> f (Maybe [GameProperty]))
-> (Maybe [GameProperty] -> f (Maybe [GameProperty]))
-> StartGameSessionPlacement
-> f StartGameSessionPlacement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [GameProperty] [GameProperty] [GameProperty] [GameProperty]
-> Iso
     (Maybe [GameProperty])
     (Maybe [GameProperty])
     (Maybe [GameProperty])
     (Maybe [GameProperty])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [GameProperty] [GameProperty] [GameProperty] [GameProperty]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A descriptive label that is associated with a game session. Session
-- names do not need to be unique.
startGameSessionPlacement_gameSessionName :: Lens.Lens' StartGameSessionPlacement (Prelude.Maybe Prelude.Text)
startGameSessionPlacement_gameSessionName :: (Maybe Text -> f (Maybe Text))
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_gameSessionName = (StartGameSessionPlacement -> Maybe Text)
-> (StartGameSessionPlacement
    -> Maybe Text -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement
     StartGameSessionPlacement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Maybe Text
gameSessionName :: Maybe Text
$sel:gameSessionName:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe Text
gameSessionName} -> Maybe Text
gameSessionName) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Maybe Text
a -> StartGameSessionPlacement
s {$sel:gameSessionName:StartGameSessionPlacement' :: Maybe Text
gameSessionName = Maybe Text
a} :: StartGameSessionPlacement)

-- | A set of values, expressed in milliseconds, that indicates the amount of
-- latency that a player experiences when connected to AWS Regions. This
-- information is used to try to place the new game session where it can
-- offer the best possible gameplay experience for the players.
startGameSessionPlacement_playerLatencies :: Lens.Lens' StartGameSessionPlacement (Prelude.Maybe [PlayerLatency])
startGameSessionPlacement_playerLatencies :: (Maybe [PlayerLatency] -> f (Maybe [PlayerLatency]))
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_playerLatencies = (StartGameSessionPlacement -> Maybe [PlayerLatency])
-> (StartGameSessionPlacement
    -> Maybe [PlayerLatency] -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement
     StartGameSessionPlacement
     (Maybe [PlayerLatency])
     (Maybe [PlayerLatency])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Maybe [PlayerLatency]
playerLatencies :: Maybe [PlayerLatency]
$sel:playerLatencies:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe [PlayerLatency]
playerLatencies} -> Maybe [PlayerLatency]
playerLatencies) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Maybe [PlayerLatency]
a -> StartGameSessionPlacement
s {$sel:playerLatencies:StartGameSessionPlacement' :: Maybe [PlayerLatency]
playerLatencies = Maybe [PlayerLatency]
a} :: StartGameSessionPlacement) ((Maybe [PlayerLatency] -> f (Maybe [PlayerLatency]))
 -> StartGameSessionPlacement -> f StartGameSessionPlacement)
-> ((Maybe [PlayerLatency] -> f (Maybe [PlayerLatency]))
    -> Maybe [PlayerLatency] -> f (Maybe [PlayerLatency]))
-> (Maybe [PlayerLatency] -> f (Maybe [PlayerLatency]))
-> StartGameSessionPlacement
-> f StartGameSessionPlacement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PlayerLatency] [PlayerLatency] [PlayerLatency] [PlayerLatency]
-> Iso
     (Maybe [PlayerLatency])
     (Maybe [PlayerLatency])
     (Maybe [PlayerLatency])
     (Maybe [PlayerLatency])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [PlayerLatency] [PlayerLatency] [PlayerLatency] [PlayerLatency]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A set of custom game session properties, formatted as a single string
-- value. This data is passed to a game server process in the GameSession
-- object with a request to start a new game session (see
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a Game Session>).
startGameSessionPlacement_gameSessionData :: Lens.Lens' StartGameSessionPlacement (Prelude.Maybe Prelude.Text)
startGameSessionPlacement_gameSessionData :: (Maybe Text -> f (Maybe Text))
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_gameSessionData = (StartGameSessionPlacement -> Maybe Text)
-> (StartGameSessionPlacement
    -> Maybe Text -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement
     StartGameSessionPlacement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Maybe Text
gameSessionData :: Maybe Text
$sel:gameSessionData:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe Text
gameSessionData} -> Maybe Text
gameSessionData) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Maybe Text
a -> StartGameSessionPlacement
s {$sel:gameSessionData:StartGameSessionPlacement' :: Maybe Text
gameSessionData = Maybe Text
a} :: StartGameSessionPlacement)

-- | Set of information on each player to create a player session for.
startGameSessionPlacement_desiredPlayerSessions :: Lens.Lens' StartGameSessionPlacement (Prelude.Maybe [DesiredPlayerSession])
startGameSessionPlacement_desiredPlayerSessions :: (Maybe [DesiredPlayerSession] -> f (Maybe [DesiredPlayerSession]))
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_desiredPlayerSessions = (StartGameSessionPlacement -> Maybe [DesiredPlayerSession])
-> (StartGameSessionPlacement
    -> Maybe [DesiredPlayerSession] -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement
     StartGameSessionPlacement
     (Maybe [DesiredPlayerSession])
     (Maybe [DesiredPlayerSession])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Maybe [DesiredPlayerSession]
desiredPlayerSessions :: Maybe [DesiredPlayerSession]
$sel:desiredPlayerSessions:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe [DesiredPlayerSession]
desiredPlayerSessions} -> Maybe [DesiredPlayerSession]
desiredPlayerSessions) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Maybe [DesiredPlayerSession]
a -> StartGameSessionPlacement
s {$sel:desiredPlayerSessions:StartGameSessionPlacement' :: Maybe [DesiredPlayerSession]
desiredPlayerSessions = Maybe [DesiredPlayerSession]
a} :: StartGameSessionPlacement) ((Maybe [DesiredPlayerSession] -> f (Maybe [DesiredPlayerSession]))
 -> StartGameSessionPlacement -> f StartGameSessionPlacement)
-> ((Maybe [DesiredPlayerSession]
     -> f (Maybe [DesiredPlayerSession]))
    -> Maybe [DesiredPlayerSession]
    -> f (Maybe [DesiredPlayerSession]))
-> (Maybe [DesiredPlayerSession]
    -> f (Maybe [DesiredPlayerSession]))
-> StartGameSessionPlacement
-> f StartGameSessionPlacement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DesiredPlayerSession]
  [DesiredPlayerSession]
  [DesiredPlayerSession]
  [DesiredPlayerSession]
-> Iso
     (Maybe [DesiredPlayerSession])
     (Maybe [DesiredPlayerSession])
     (Maybe [DesiredPlayerSession])
     (Maybe [DesiredPlayerSession])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [DesiredPlayerSession]
  [DesiredPlayerSession]
  [DesiredPlayerSession]
  [DesiredPlayerSession]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique identifier to assign to the new game session placement. This
-- value is developer-defined. The value must be unique across all Regions
-- and cannot be reused unless you are resubmitting a canceled or timed-out
-- placement request.
startGameSessionPlacement_placementId :: Lens.Lens' StartGameSessionPlacement Prelude.Text
startGameSessionPlacement_placementId :: (Text -> f Text)
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_placementId = (StartGameSessionPlacement -> Text)
-> (StartGameSessionPlacement -> Text -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement StartGameSessionPlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:StartGameSessionPlacement' :: StartGameSessionPlacement -> Text
placementId} -> Text
placementId) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Text
a -> StartGameSessionPlacement
s {$sel:placementId:StartGameSessionPlacement' :: Text
placementId = Text
a} :: StartGameSessionPlacement)

-- | Name of the queue to use to place the new game session. You can use
-- either the queue name or ARN value.
startGameSessionPlacement_gameSessionQueueName :: Lens.Lens' StartGameSessionPlacement Prelude.Text
startGameSessionPlacement_gameSessionQueueName :: (Text -> f Text)
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_gameSessionQueueName = (StartGameSessionPlacement -> Text)
-> (StartGameSessionPlacement -> Text -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement StartGameSessionPlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Text
gameSessionQueueName :: Text
$sel:gameSessionQueueName:StartGameSessionPlacement' :: StartGameSessionPlacement -> Text
gameSessionQueueName} -> Text
gameSessionQueueName) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Text
a -> StartGameSessionPlacement
s {$sel:gameSessionQueueName:StartGameSessionPlacement' :: Text
gameSessionQueueName = Text
a} :: StartGameSessionPlacement)

-- | The maximum number of players that can be connected simultaneously to
-- the game session.
startGameSessionPlacement_maximumPlayerSessionCount :: Lens.Lens' StartGameSessionPlacement Prelude.Natural
startGameSessionPlacement_maximumPlayerSessionCount :: (Natural -> f Natural)
-> StartGameSessionPlacement -> f StartGameSessionPlacement
startGameSessionPlacement_maximumPlayerSessionCount = (StartGameSessionPlacement -> Natural)
-> (StartGameSessionPlacement
    -> Natural -> StartGameSessionPlacement)
-> Lens
     StartGameSessionPlacement StartGameSessionPlacement Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacement' {Natural
maximumPlayerSessionCount :: Natural
$sel:maximumPlayerSessionCount:StartGameSessionPlacement' :: StartGameSessionPlacement -> Natural
maximumPlayerSessionCount} -> Natural
maximumPlayerSessionCount) (\s :: StartGameSessionPlacement
s@StartGameSessionPlacement' {} Natural
a -> StartGameSessionPlacement
s {$sel:maximumPlayerSessionCount:StartGameSessionPlacement' :: Natural
maximumPlayerSessionCount = Natural
a} :: StartGameSessionPlacement)

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

instance Prelude.NFData StartGameSessionPlacement

instance Core.ToHeaders StartGameSessionPlacement where
  toHeaders :: StartGameSessionPlacement -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartGameSessionPlacement -> 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.StartGameSessionPlacement" ::
                          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 StartGameSessionPlacement where
  toJSON :: StartGameSessionPlacement -> Value
toJSON StartGameSessionPlacement' {Natural
Maybe [DesiredPlayerSession]
Maybe [GameProperty]
Maybe [PlayerLatency]
Maybe Text
Text
maximumPlayerSessionCount :: Natural
gameSessionQueueName :: Text
placementId :: Text
desiredPlayerSessions :: Maybe [DesiredPlayerSession]
gameSessionData :: Maybe Text
playerLatencies :: Maybe [PlayerLatency]
gameSessionName :: Maybe Text
gameProperties :: Maybe [GameProperty]
$sel:maximumPlayerSessionCount:StartGameSessionPlacement' :: StartGameSessionPlacement -> Natural
$sel:gameSessionQueueName:StartGameSessionPlacement' :: StartGameSessionPlacement -> Text
$sel:placementId:StartGameSessionPlacement' :: StartGameSessionPlacement -> Text
$sel:desiredPlayerSessions:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe [DesiredPlayerSession]
$sel:gameSessionData:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe Text
$sel:playerLatencies:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe [PlayerLatency]
$sel:gameSessionName:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe Text
$sel:gameProperties:StartGameSessionPlacement' :: StartGameSessionPlacement -> Maybe [GameProperty]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"GameProperties" Text -> [GameProperty] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([GameProperty] -> Pair) -> Maybe [GameProperty] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GameProperty]
gameProperties,
            (Text
"GameSessionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
gameSessionName,
            (Text
"PlayerLatencies" Text -> [PlayerLatency] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([PlayerLatency] -> Pair) -> Maybe [PlayerLatency] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PlayerLatency]
playerLatencies,
            (Text
"GameSessionData" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
gameSessionData,
            (Text
"DesiredPlayerSessions" Text -> [DesiredPlayerSession] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([DesiredPlayerSession] -> Pair)
-> Maybe [DesiredPlayerSession] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DesiredPlayerSession]
desiredPlayerSessions,
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"GameSessionQueueName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gameSessionQueueName
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MaximumPlayerSessionCount"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maximumPlayerSessionCount
              )
          ]
      )

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

instance Core.ToQuery StartGameSessionPlacement where
  toQuery :: StartGameSessionPlacement -> QueryString
toQuery = QueryString -> StartGameSessionPlacement -> 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:/ 'newStartGameSessionPlacementResponse' smart constructor.
data StartGameSessionPlacementResponse = StartGameSessionPlacementResponse'
  { -- | Object that describes the newly created game session placement. This
    -- object includes all the information provided in the request, as well as
    -- start\/end time stamps and placement status.
    StartGameSessionPlacementResponse -> Maybe GameSessionPlacement
gameSessionPlacement :: Prelude.Maybe GameSessionPlacement,
    -- | The response's http status code.
    StartGameSessionPlacementResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartGameSessionPlacementResponse
-> StartGameSessionPlacementResponse -> Bool
(StartGameSessionPlacementResponse
 -> StartGameSessionPlacementResponse -> Bool)
-> (StartGameSessionPlacementResponse
    -> StartGameSessionPlacementResponse -> Bool)
-> Eq StartGameSessionPlacementResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartGameSessionPlacementResponse
-> StartGameSessionPlacementResponse -> Bool
$c/= :: StartGameSessionPlacementResponse
-> StartGameSessionPlacementResponse -> Bool
== :: StartGameSessionPlacementResponse
-> StartGameSessionPlacementResponse -> Bool
$c== :: StartGameSessionPlacementResponse
-> StartGameSessionPlacementResponse -> Bool
Prelude.Eq, ReadPrec [StartGameSessionPlacementResponse]
ReadPrec StartGameSessionPlacementResponse
Int -> ReadS StartGameSessionPlacementResponse
ReadS [StartGameSessionPlacementResponse]
(Int -> ReadS StartGameSessionPlacementResponse)
-> ReadS [StartGameSessionPlacementResponse]
-> ReadPrec StartGameSessionPlacementResponse
-> ReadPrec [StartGameSessionPlacementResponse]
-> Read StartGameSessionPlacementResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartGameSessionPlacementResponse]
$creadListPrec :: ReadPrec [StartGameSessionPlacementResponse]
readPrec :: ReadPrec StartGameSessionPlacementResponse
$creadPrec :: ReadPrec StartGameSessionPlacementResponse
readList :: ReadS [StartGameSessionPlacementResponse]
$creadList :: ReadS [StartGameSessionPlacementResponse]
readsPrec :: Int -> ReadS StartGameSessionPlacementResponse
$creadsPrec :: Int -> ReadS StartGameSessionPlacementResponse
Prelude.Read, Int -> StartGameSessionPlacementResponse -> ShowS
[StartGameSessionPlacementResponse] -> ShowS
StartGameSessionPlacementResponse -> String
(Int -> StartGameSessionPlacementResponse -> ShowS)
-> (StartGameSessionPlacementResponse -> String)
-> ([StartGameSessionPlacementResponse] -> ShowS)
-> Show StartGameSessionPlacementResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartGameSessionPlacementResponse] -> ShowS
$cshowList :: [StartGameSessionPlacementResponse] -> ShowS
show :: StartGameSessionPlacementResponse -> String
$cshow :: StartGameSessionPlacementResponse -> String
showsPrec :: Int -> StartGameSessionPlacementResponse -> ShowS
$cshowsPrec :: Int -> StartGameSessionPlacementResponse -> ShowS
Prelude.Show, (forall x.
 StartGameSessionPlacementResponse
 -> Rep StartGameSessionPlacementResponse x)
-> (forall x.
    Rep StartGameSessionPlacementResponse x
    -> StartGameSessionPlacementResponse)
-> Generic StartGameSessionPlacementResponse
forall x.
Rep StartGameSessionPlacementResponse x
-> StartGameSessionPlacementResponse
forall x.
StartGameSessionPlacementResponse
-> Rep StartGameSessionPlacementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartGameSessionPlacementResponse x
-> StartGameSessionPlacementResponse
$cfrom :: forall x.
StartGameSessionPlacementResponse
-> Rep StartGameSessionPlacementResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartGameSessionPlacementResponse' 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', 'startGameSessionPlacementResponse_gameSessionPlacement' - Object that describes the newly created game session placement. This
-- object includes all the information provided in the request, as well as
-- start\/end time stamps and placement status.
--
-- 'httpStatus', 'startGameSessionPlacementResponse_httpStatus' - The response's http status code.
newStartGameSessionPlacementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartGameSessionPlacementResponse
newStartGameSessionPlacementResponse :: Int -> StartGameSessionPlacementResponse
newStartGameSessionPlacementResponse Int
pHttpStatus_ =
  StartGameSessionPlacementResponse' :: Maybe GameSessionPlacement
-> Int -> StartGameSessionPlacementResponse
StartGameSessionPlacementResponse'
    { $sel:gameSessionPlacement:StartGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement =
        Maybe GameSessionPlacement
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartGameSessionPlacementResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Object that describes the newly created game session placement. This
-- object includes all the information provided in the request, as well as
-- start\/end time stamps and placement status.
startGameSessionPlacementResponse_gameSessionPlacement :: Lens.Lens' StartGameSessionPlacementResponse (Prelude.Maybe GameSessionPlacement)
startGameSessionPlacementResponse_gameSessionPlacement :: (Maybe GameSessionPlacement -> f (Maybe GameSessionPlacement))
-> StartGameSessionPlacementResponse
-> f StartGameSessionPlacementResponse
startGameSessionPlacementResponse_gameSessionPlacement = (StartGameSessionPlacementResponse -> Maybe GameSessionPlacement)
-> (StartGameSessionPlacementResponse
    -> Maybe GameSessionPlacement -> StartGameSessionPlacementResponse)
-> Lens
     StartGameSessionPlacementResponse
     StartGameSessionPlacementResponse
     (Maybe GameSessionPlacement)
     (Maybe GameSessionPlacement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartGameSessionPlacementResponse' {Maybe GameSessionPlacement
gameSessionPlacement :: Maybe GameSessionPlacement
$sel:gameSessionPlacement:StartGameSessionPlacementResponse' :: StartGameSessionPlacementResponse -> Maybe GameSessionPlacement
gameSessionPlacement} -> Maybe GameSessionPlacement
gameSessionPlacement) (\s :: StartGameSessionPlacementResponse
s@StartGameSessionPlacementResponse' {} Maybe GameSessionPlacement
a -> StartGameSessionPlacementResponse
s {$sel:gameSessionPlacement:StartGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement = Maybe GameSessionPlacement
a} :: StartGameSessionPlacementResponse)

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

instance
  Prelude.NFData
    StartGameSessionPlacementResponse