{-# 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.CreateGameSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a multiplayer game session for players in a specific fleet
-- location. This operation prompts an available server process to start a
-- game session and retrieves connection information for the new game
-- session. As an alternative, consider using the GameLift game session
-- placement feature with
-- <https://docs.aws.amazon.com/gamelift/latest/apireference/API_StartGameSessionPlacement.html StartGameSessionPlacement>
-- , which uses FleetIQ algorithms and queues to optimize the placement
-- process.
--
-- When creating a game session, you specify exactly where you want to
-- place it and provide a set of game session configuration settings. The
-- fleet must be in @ACTIVE@ status before a game session can be created in
-- it.
--
-- This operation can be used in the following ways:
--
-- -   To create a game session on an instance in a fleet\'s home Region,
--     provide a fleet or alias ID along with your game session
--     configuration.
--
-- -   To create a game session on an instance in a fleet\'s remote
--     location, provide a fleet or alias ID and a location name, along
--     with your game session configuration.
--
-- If successful, a workflow is initiated to start a new game session. A
-- @GameSession@ object is returned containing the game session
-- configuration and status. When the status is @ACTIVE@, game session
-- connection information is provided and player sessions can be created
-- for the game session. By default, newly created game sessions are open
-- to new players. You can restrict new player access by using
-- <https://docs.aws.amazon.com/gamelift/latest/apireference/API_UpdateGameSession.html UpdateGameSession>
-- to change the game session\'s player session creation policy.
--
-- Game session logs are retained for all active game sessions for 14 days.
-- To access the logs, call
-- <https://docs.aws.amazon.com/gamelift/latest/apireference/API_GetGameSessionLogUrl.html GetGameSessionLogUrl>
-- to download the log files.
--
-- /Available in Amazon GameLift Local./
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession Start a game session>
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.CreateGameSession
  ( -- * Creating a Request
    CreateGameSession (..),
    newCreateGameSession,

    -- * Request Lenses
    createGameSession_aliasId,
    createGameSession_creatorId,
    createGameSession_fleetId,
    createGameSession_gameProperties,
    createGameSession_gameSessionData,
    createGameSession_gameSessionId,
    createGameSession_idempotencyToken,
    createGameSession_location,
    createGameSession_name,
    createGameSession_maximumPlayerSessionCount,

    -- * Destructuring the Response
    CreateGameSessionResponse (..),
    newCreateGameSessionResponse,

    -- * Response Lenses
    createGameSessionResponse_gameSession,
    createGameSessionResponse_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:/ 'newCreateGameSession' smart constructor.
data CreateGameSession = CreateGameSession'
  { -- | A unique identifier for the alias associated with the fleet to create a
    -- game session in. You can use either the alias ID or ARN value. Each
    -- request must reference either a fleet ID or alias ID, but not both.
    CreateGameSession -> Maybe Text
aliasId :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for a player or entity creating the game session.
    -- This parameter is required when requesting a new game session on a fleet
    -- with a resource creation limit policy. This type of policy limits the
    -- number of concurrent active game sessions that one player can create
    -- within a certain time span. GameLift uses the CreatorId to evaluate the
    -- new request against the policy.
    CreateGameSession -> Maybe Text
creatorId :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the fleet to create a game session in. You can
    -- use either the fleet ID or ARN value. Each request must reference either
    -- a fleet ID or alias ID, but not both.
    CreateGameSession -> Maybe Text
fleetId :: Prelude.Maybe Prelude.Text,
    -- | A set of custom properties for a game session, formatted as key:value
    -- pairs. These properties are passed to a game server process 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>).
    CreateGameSession -> Maybe [GameProperty]
gameProperties :: Prelude.Maybe [GameProperty],
    -- | A set of custom game session properties, formatted as a single string
    -- value. This data is passed to a game server process 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>).
    CreateGameSession -> Maybe Text
gameSessionData :: Prelude.Maybe Prelude.Text,
    -- | /This parameter is deprecated. Use @IdempotencyToken@ instead./
    --
    -- Custom string that uniquely identifies a request for a new game session.
    -- Maximum token length is 48 characters. If provided, this string is
    -- included in the new game session\'s ID.
    CreateGameSession -> Maybe Text
gameSessionId :: Prelude.Maybe Prelude.Text,
    -- | Custom string that uniquely identifies the new game session request.
    -- This is useful for ensuring that game session requests with the same
    -- idempotency token are processed only once. Subsequent requests with the
    -- same string return the original @GameSession@ object, with an updated
    -- status. Maximum token length is 48 characters. If provided, this string
    -- is included in the new game session\'s ID. A game session ARN has the
    -- following format:
    -- @arn:aws:gamelift:\<region>::gamesession\/\<fleet ID>\/\<custom ID string or idempotency token>@.
    -- Idempotency tokens remain in use for 30 days after a game session has
    -- ended; game session objects are retained for this time period and then
    -- deleted.
    CreateGameSession -> Maybe Text
idempotencyToken :: Prelude.Maybe Prelude.Text,
    -- | A fleet\'s remote location to place the new game session in. If this
    -- parameter is not set, the new game session is placed in the fleet\'s
    -- home Region. Specify a remote location with an Amazon Web Services
    -- Region code such as @us-west-2@.
    CreateGameSession -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | A descriptive label that is associated with a game session. Session
    -- names do not need to be unique.
    CreateGameSession -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of players that can be connected simultaneously to
    -- the game session.
    CreateGameSession -> Natural
maximumPlayerSessionCount :: Prelude.Natural
  }
  deriving (CreateGameSession -> CreateGameSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGameSession -> CreateGameSession -> Bool
$c/= :: CreateGameSession -> CreateGameSession -> Bool
== :: CreateGameSession -> CreateGameSession -> Bool
$c== :: CreateGameSession -> CreateGameSession -> Bool
Prelude.Eq, ReadPrec [CreateGameSession]
ReadPrec CreateGameSession
Int -> ReadS CreateGameSession
ReadS [CreateGameSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGameSession]
$creadListPrec :: ReadPrec [CreateGameSession]
readPrec :: ReadPrec CreateGameSession
$creadPrec :: ReadPrec CreateGameSession
readList :: ReadS [CreateGameSession]
$creadList :: ReadS [CreateGameSession]
readsPrec :: Int -> ReadS CreateGameSession
$creadsPrec :: Int -> ReadS CreateGameSession
Prelude.Read, Int -> CreateGameSession -> ShowS
[CreateGameSession] -> ShowS
CreateGameSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGameSession] -> ShowS
$cshowList :: [CreateGameSession] -> ShowS
show :: CreateGameSession -> String
$cshow :: CreateGameSession -> String
showsPrec :: Int -> CreateGameSession -> ShowS
$cshowsPrec :: Int -> CreateGameSession -> ShowS
Prelude.Show, forall x. Rep CreateGameSession x -> CreateGameSession
forall x. CreateGameSession -> Rep CreateGameSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGameSession x -> CreateGameSession
$cfrom :: forall x. CreateGameSession -> Rep CreateGameSession x
Prelude.Generic)

-- |
-- Create a value of 'CreateGameSession' 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:
--
-- 'aliasId', 'createGameSession_aliasId' - A unique identifier for the alias associated with the fleet to create a
-- game session in. You can use either the alias ID or ARN value. Each
-- request must reference either a fleet ID or alias ID, but not both.
--
-- 'creatorId', 'createGameSession_creatorId' - A unique identifier for a player or entity creating the game session.
-- This parameter is required when requesting a new game session on a fleet
-- with a resource creation limit policy. This type of policy limits the
-- number of concurrent active game sessions that one player can create
-- within a certain time span. GameLift uses the CreatorId to evaluate the
-- new request against the policy.
--
-- 'fleetId', 'createGameSession_fleetId' - A unique identifier for the fleet to create a game session in. You can
-- use either the fleet ID or ARN value. Each request must reference either
-- a fleet ID or alias ID, but not both.
--
-- 'gameProperties', 'createGameSession_gameProperties' - A set of custom properties for a game session, formatted as key:value
-- pairs. These properties are passed to a game server process 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>).
--
-- 'gameSessionData', 'createGameSession_gameSessionData' - A set of custom game session properties, formatted as a single string
-- value. This data is passed to a game server process 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>).
--
-- 'gameSessionId', 'createGameSession_gameSessionId' - /This parameter is deprecated. Use @IdempotencyToken@ instead./
--
-- Custom string that uniquely identifies a request for a new game session.
-- Maximum token length is 48 characters. If provided, this string is
-- included in the new game session\'s ID.
--
-- 'idempotencyToken', 'createGameSession_idempotencyToken' - Custom string that uniquely identifies the new game session request.
-- This is useful for ensuring that game session requests with the same
-- idempotency token are processed only once. Subsequent requests with the
-- same string return the original @GameSession@ object, with an updated
-- status. Maximum token length is 48 characters. If provided, this string
-- is included in the new game session\'s ID. A game session ARN has the
-- following format:
-- @arn:aws:gamelift:\<region>::gamesession\/\<fleet ID>\/\<custom ID string or idempotency token>@.
-- Idempotency tokens remain in use for 30 days after a game session has
-- ended; game session objects are retained for this time period and then
-- deleted.
--
-- 'location', 'createGameSession_location' - A fleet\'s remote location to place the new game session in. If this
-- parameter is not set, the new game session is placed in the fleet\'s
-- home Region. Specify a remote location with an Amazon Web Services
-- Region code such as @us-west-2@.
--
-- 'name', 'createGameSession_name' - A descriptive label that is associated with a game session. Session
-- names do not need to be unique.
--
-- 'maximumPlayerSessionCount', 'createGameSession_maximumPlayerSessionCount' - The maximum number of players that can be connected simultaneously to
-- the game session.
newCreateGameSession ::
  -- | 'maximumPlayerSessionCount'
  Prelude.Natural ->
  CreateGameSession
newCreateGameSession :: Natural -> CreateGameSession
newCreateGameSession Natural
pMaximumPlayerSessionCount_ =
  CreateGameSession'
    { $sel:aliasId:CreateGameSession' :: Maybe Text
aliasId = forall a. Maybe a
Prelude.Nothing,
      $sel:creatorId:CreateGameSession' :: Maybe Text
creatorId = forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:CreateGameSession' :: Maybe Text
fleetId = forall a. Maybe a
Prelude.Nothing,
      $sel:gameProperties:CreateGameSession' :: Maybe [GameProperty]
gameProperties = forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionData:CreateGameSession' :: Maybe Text
gameSessionData = forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionId:CreateGameSession' :: Maybe Text
gameSessionId = forall a. Maybe a
Prelude.Nothing,
      $sel:idempotencyToken:CreateGameSession' :: Maybe Text
idempotencyToken = forall a. Maybe a
Prelude.Nothing,
      $sel:location:CreateGameSession' :: Maybe Text
location = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateGameSession' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPlayerSessionCount:CreateGameSession' :: Natural
maximumPlayerSessionCount =
        Natural
pMaximumPlayerSessionCount_
    }

-- | A unique identifier for the alias associated with the fleet to create a
-- game session in. You can use either the alias ID or ARN value. Each
-- request must reference either a fleet ID or alias ID, but not both.
createGameSession_aliasId :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_aliasId :: Lens' CreateGameSession (Maybe Text)
createGameSession_aliasId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
aliasId :: Maybe Text
$sel:aliasId:CreateGameSession' :: CreateGameSession -> Maybe Text
aliasId} -> Maybe Text
aliasId) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:aliasId:CreateGameSession' :: Maybe Text
aliasId = Maybe Text
a} :: CreateGameSession)

-- | A unique identifier for a player or entity creating the game session.
-- This parameter is required when requesting a new game session on a fleet
-- with a resource creation limit policy. This type of policy limits the
-- number of concurrent active game sessions that one player can create
-- within a certain time span. GameLift uses the CreatorId to evaluate the
-- new request against the policy.
createGameSession_creatorId :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_creatorId :: Lens' CreateGameSession (Maybe Text)
createGameSession_creatorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
creatorId :: Maybe Text
$sel:creatorId:CreateGameSession' :: CreateGameSession -> Maybe Text
creatorId} -> Maybe Text
creatorId) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:creatorId:CreateGameSession' :: Maybe Text
creatorId = Maybe Text
a} :: CreateGameSession)

-- | A unique identifier for the fleet to create a game session in. You can
-- use either the fleet ID or ARN value. Each request must reference either
-- a fleet ID or alias ID, but not both.
createGameSession_fleetId :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_fleetId :: Lens' CreateGameSession (Maybe Text)
createGameSession_fleetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
fleetId :: Maybe Text
$sel:fleetId:CreateGameSession' :: CreateGameSession -> Maybe Text
fleetId} -> Maybe Text
fleetId) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:fleetId:CreateGameSession' :: Maybe Text
fleetId = Maybe Text
a} :: CreateGameSession)

-- | A set of custom properties for a game session, formatted as key:value
-- pairs. These properties are passed to a game server process 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>).
createGameSession_gameProperties :: Lens.Lens' CreateGameSession (Prelude.Maybe [GameProperty])
createGameSession_gameProperties :: Lens' CreateGameSession (Maybe [GameProperty])
createGameSession_gameProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe [GameProperty]
gameProperties :: Maybe [GameProperty]
$sel:gameProperties:CreateGameSession' :: CreateGameSession -> Maybe [GameProperty]
gameProperties} -> Maybe [GameProperty]
gameProperties) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe [GameProperty]
a -> CreateGameSession
s {$sel:gameProperties:CreateGameSession' :: Maybe [GameProperty]
gameProperties = Maybe [GameProperty]
a} :: CreateGameSession) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 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>).
createGameSession_gameSessionData :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_gameSessionData :: Lens' CreateGameSession (Maybe Text)
createGameSession_gameSessionData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
gameSessionData :: Maybe Text
$sel:gameSessionData:CreateGameSession' :: CreateGameSession -> Maybe Text
gameSessionData} -> Maybe Text
gameSessionData) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:gameSessionData:CreateGameSession' :: Maybe Text
gameSessionData = Maybe Text
a} :: CreateGameSession)

-- | /This parameter is deprecated. Use @IdempotencyToken@ instead./
--
-- Custom string that uniquely identifies a request for a new game session.
-- Maximum token length is 48 characters. If provided, this string is
-- included in the new game session\'s ID.
createGameSession_gameSessionId :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_gameSessionId :: Lens' CreateGameSession (Maybe Text)
createGameSession_gameSessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
gameSessionId :: Maybe Text
$sel:gameSessionId:CreateGameSession' :: CreateGameSession -> Maybe Text
gameSessionId} -> Maybe Text
gameSessionId) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:gameSessionId:CreateGameSession' :: Maybe Text
gameSessionId = Maybe Text
a} :: CreateGameSession)

-- | Custom string that uniquely identifies the new game session request.
-- This is useful for ensuring that game session requests with the same
-- idempotency token are processed only once. Subsequent requests with the
-- same string return the original @GameSession@ object, with an updated
-- status. Maximum token length is 48 characters. If provided, this string
-- is included in the new game session\'s ID. A game session ARN has the
-- following format:
-- @arn:aws:gamelift:\<region>::gamesession\/\<fleet ID>\/\<custom ID string or idempotency token>@.
-- Idempotency tokens remain in use for 30 days after a game session has
-- ended; game session objects are retained for this time period and then
-- deleted.
createGameSession_idempotencyToken :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_idempotencyToken :: Lens' CreateGameSession (Maybe Text)
createGameSession_idempotencyToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
idempotencyToken :: Maybe Text
$sel:idempotencyToken:CreateGameSession' :: CreateGameSession -> Maybe Text
idempotencyToken} -> Maybe Text
idempotencyToken) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:idempotencyToken:CreateGameSession' :: Maybe Text
idempotencyToken = Maybe Text
a} :: CreateGameSession)

-- | A fleet\'s remote location to place the new game session in. If this
-- parameter is not set, the new game session is placed in the fleet\'s
-- home Region. Specify a remote location with an Amazon Web Services
-- Region code such as @us-west-2@.
createGameSession_location :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_location :: Lens' CreateGameSession (Maybe Text)
createGameSession_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSession' {Maybe Text
location :: Maybe Text
$sel:location:CreateGameSession' :: CreateGameSession -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateGameSession
s@CreateGameSession' {} Maybe Text
a -> CreateGameSession
s {$sel:location:CreateGameSession' :: Maybe Text
location = Maybe Text
a} :: CreateGameSession)

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

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

instance Core.AWSRequest CreateGameSession where
  type
    AWSResponse CreateGameSession =
      CreateGameSessionResponse
  request :: (Service -> Service)
-> CreateGameSession -> Request CreateGameSession
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 CreateGameSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGameSession)))
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 GameSession -> Int -> CreateGameSessionResponse
CreateGameSessionResponse'
            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
"GameSession")
            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 CreateGameSession where
  hashWithSalt :: Int -> CreateGameSession -> Int
hashWithSalt Int
_salt CreateGameSession' {Natural
Maybe [GameProperty]
Maybe Text
maximumPlayerSessionCount :: Natural
name :: Maybe Text
location :: Maybe Text
idempotencyToken :: Maybe Text
gameSessionId :: Maybe Text
gameSessionData :: Maybe Text
gameProperties :: Maybe [GameProperty]
fleetId :: Maybe Text
creatorId :: Maybe Text
aliasId :: Maybe Text
$sel:maximumPlayerSessionCount:CreateGameSession' :: CreateGameSession -> Natural
$sel:name:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:location:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:idempotencyToken:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionData:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameProperties:CreateGameSession' :: CreateGameSession -> Maybe [GameProperty]
$sel:fleetId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:creatorId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:aliasId:CreateGameSession' :: CreateGameSession -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
aliasId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
creatorId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fleetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GameProperty]
gameProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gameSessionData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gameSessionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
idempotencyToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maximumPlayerSessionCount

instance Prelude.NFData CreateGameSession where
  rnf :: CreateGameSession -> ()
rnf CreateGameSession' {Natural
Maybe [GameProperty]
Maybe Text
maximumPlayerSessionCount :: Natural
name :: Maybe Text
location :: Maybe Text
idempotencyToken :: Maybe Text
gameSessionId :: Maybe Text
gameSessionData :: Maybe Text
gameProperties :: Maybe [GameProperty]
fleetId :: Maybe Text
creatorId :: Maybe Text
aliasId :: Maybe Text
$sel:maximumPlayerSessionCount:CreateGameSession' :: CreateGameSession -> Natural
$sel:name:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:location:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:idempotencyToken:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionData:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameProperties:CreateGameSession' :: CreateGameSession -> Maybe [GameProperty]
$sel:fleetId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:creatorId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:aliasId:CreateGameSession' :: CreateGameSession -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
aliasId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
creatorId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fleetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [GameProperty]
gameProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gameSessionData
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gameSessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
idempotencyToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
maximumPlayerSessionCount

instance Data.ToHeaders CreateGameSession where
  toHeaders :: CreateGameSession -> 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.CreateGameSession" :: 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 CreateGameSession where
  toJSON :: CreateGameSession -> Value
toJSON CreateGameSession' {Natural
Maybe [GameProperty]
Maybe Text
maximumPlayerSessionCount :: Natural
name :: Maybe Text
location :: Maybe Text
idempotencyToken :: Maybe Text
gameSessionId :: Maybe Text
gameSessionData :: Maybe Text
gameProperties :: Maybe [GameProperty]
fleetId :: Maybe Text
creatorId :: Maybe Text
aliasId :: Maybe Text
$sel:maximumPlayerSessionCount:CreateGameSession' :: CreateGameSession -> Natural
$sel:name:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:location:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:idempotencyToken:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionData:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameProperties:CreateGameSession' :: CreateGameSession -> Maybe [GameProperty]
$sel:fleetId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:creatorId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:aliasId:CreateGameSession' :: CreateGameSession -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AliasId" 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
aliasId,
            (Key
"CreatorId" 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
creatorId,
            (Key
"FleetId" 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
fleetId,
            (Key
"GameProperties" 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 [GameProperty]
gameProperties,
            (Key
"GameSessionData" 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
gameSessionData,
            (Key
"GameSessionId" 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
gameSessionId,
            (Key
"IdempotencyToken" 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
idempotencyToken,
            (Key
"Location" 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
location,
            (Key
"Name" 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
name,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"MaximumPlayerSessionCount"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maximumPlayerSessionCount
              )
          ]
      )

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

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

-- | /See:/ 'newCreateGameSessionResponse' smart constructor.
data CreateGameSessionResponse = CreateGameSessionResponse'
  { -- | Object that describes the newly created game session record.
    CreateGameSessionResponse -> Maybe GameSession
gameSession :: Prelude.Maybe GameSession,
    -- | The response's http status code.
    CreateGameSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateGameSessionResponse -> CreateGameSessionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGameSessionResponse -> CreateGameSessionResponse -> Bool
$c/= :: CreateGameSessionResponse -> CreateGameSessionResponse -> Bool
== :: CreateGameSessionResponse -> CreateGameSessionResponse -> Bool
$c== :: CreateGameSessionResponse -> CreateGameSessionResponse -> Bool
Prelude.Eq, ReadPrec [CreateGameSessionResponse]
ReadPrec CreateGameSessionResponse
Int -> ReadS CreateGameSessionResponse
ReadS [CreateGameSessionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGameSessionResponse]
$creadListPrec :: ReadPrec [CreateGameSessionResponse]
readPrec :: ReadPrec CreateGameSessionResponse
$creadPrec :: ReadPrec CreateGameSessionResponse
readList :: ReadS [CreateGameSessionResponse]
$creadList :: ReadS [CreateGameSessionResponse]
readsPrec :: Int -> ReadS CreateGameSessionResponse
$creadsPrec :: Int -> ReadS CreateGameSessionResponse
Prelude.Read, Int -> CreateGameSessionResponse -> ShowS
[CreateGameSessionResponse] -> ShowS
CreateGameSessionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGameSessionResponse] -> ShowS
$cshowList :: [CreateGameSessionResponse] -> ShowS
show :: CreateGameSessionResponse -> String
$cshow :: CreateGameSessionResponse -> String
showsPrec :: Int -> CreateGameSessionResponse -> ShowS
$cshowsPrec :: Int -> CreateGameSessionResponse -> ShowS
Prelude.Show, forall x.
Rep CreateGameSessionResponse x -> CreateGameSessionResponse
forall x.
CreateGameSessionResponse -> Rep CreateGameSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateGameSessionResponse x -> CreateGameSessionResponse
$cfrom :: forall x.
CreateGameSessionResponse -> Rep CreateGameSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateGameSessionResponse' 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:
--
-- 'gameSession', 'createGameSessionResponse_gameSession' - Object that describes the newly created game session record.
--
-- 'httpStatus', 'createGameSessionResponse_httpStatus' - The response's http status code.
newCreateGameSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateGameSessionResponse
newCreateGameSessionResponse :: Int -> CreateGameSessionResponse
newCreateGameSessionResponse Int
pHttpStatus_ =
  CreateGameSessionResponse'
    { $sel:gameSession:CreateGameSessionResponse' :: Maybe GameSession
gameSession =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateGameSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Object that describes the newly created game session record.
createGameSessionResponse_gameSession :: Lens.Lens' CreateGameSessionResponse (Prelude.Maybe GameSession)
createGameSessionResponse_gameSession :: Lens' CreateGameSessionResponse (Maybe GameSession)
createGameSessionResponse_gameSession = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGameSessionResponse' {Maybe GameSession
gameSession :: Maybe GameSession
$sel:gameSession:CreateGameSessionResponse' :: CreateGameSessionResponse -> Maybe GameSession
gameSession} -> Maybe GameSession
gameSession) (\s :: CreateGameSessionResponse
s@CreateGameSessionResponse' {} Maybe GameSession
a -> CreateGameSessionResponse
s {$sel:gameSession:CreateGameSessionResponse' :: Maybe GameSession
gameSession = Maybe GameSession
a} :: CreateGameSessionResponse)

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

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