{-# 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-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)
--
-- 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
--
-- with 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
-- 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 GetGameSessionLogUrl to download the log files.
--
-- /Available in 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>
--
-- __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.CreateGameSession
  ( -- * Creating a Request
    CreateGameSession (..),
    newCreateGameSession,

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

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

    -- * Response Lenses
    createGameSessionResponse_gameSession,
    createGameSessionResponse_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:/ 'newCreateGameSession' smart constructor.
data CreateGameSession = 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 -> Maybe Text
idempotencyToken :: 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 in the
    -- GameSession object with a request to start a new game session.
    CreateGameSession -> Maybe [GameProperty]
gameProperties :: Prelude.Maybe [GameProperty],
    -- | 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 AWS Region code such as
    -- @us-west-2@.
    CreateGameSession -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | /This parameter is no longer preferred. Please 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,
    -- | 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 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,
    -- | 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.
    CreateGameSession -> Maybe Text
gameSessionData :: 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 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,
    -- | The maximum number of players that can be connected simultaneously to
    -- the game session.
    CreateGameSession -> Natural
maximumPlayerSessionCount :: Prelude.Natural
  }
  deriving (CreateGameSession -> CreateGameSession -> Bool
(CreateGameSession -> CreateGameSession -> Bool)
-> (CreateGameSession -> CreateGameSession -> Bool)
-> Eq CreateGameSession
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]
(Int -> ReadS CreateGameSession)
-> ReadS [CreateGameSession]
-> ReadPrec CreateGameSession
-> ReadPrec [CreateGameSession]
-> Read 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
(Int -> CreateGameSession -> ShowS)
-> (CreateGameSession -> String)
-> ([CreateGameSession] -> ShowS)
-> Show CreateGameSession
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. CreateGameSession -> Rep CreateGameSession x)
-> (forall x. Rep CreateGameSession x -> CreateGameSession)
-> Generic CreateGameSession
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:
--
-- '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.
--
-- '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 in the
-- GameSession object with a request to start a new game session.
--
-- '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 AWS Region code such as
-- @us-west-2@.
--
-- 'gameSessionId', 'createGameSession_gameSessionId' - /This parameter is no longer preferred. Please 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.
--
-- '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.
--
-- 'name', 'createGameSession_name' - A descriptive label that is associated with a game session. Session
-- names do not need to be unique.
--
-- '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 in the GameSession
-- object with a request to start a new game session.
--
-- '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.
--
-- '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.
--
-- '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' :: Maybe Text
-> Maybe [GameProperty]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Natural
-> CreateGameSession
CreateGameSession'
    { $sel:idempotencyToken:CreateGameSession' :: Maybe Text
idempotencyToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gameProperties:CreateGameSession' :: Maybe [GameProperty]
gameProperties = Maybe [GameProperty]
forall a. Maybe a
Prelude.Nothing,
      $sel:location:CreateGameSession' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionId:CreateGameSession' :: Maybe Text
gameSessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aliasId:CreateGameSession' :: Maybe Text
aliasId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateGameSession' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionData:CreateGameSession' :: Maybe Text
gameSessionData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:CreateGameSession' :: Maybe Text
fleetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creatorId:CreateGameSession' :: Maybe Text
creatorId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPlayerSessionCount:CreateGameSession' :: Natural
maximumPlayerSessionCount =
        Natural
pMaximumPlayerSessionCount_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_idempotencyToken = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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 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.
createGameSession_gameProperties :: Lens.Lens' CreateGameSession (Prelude.Maybe [GameProperty])
createGameSession_gameProperties :: (Maybe [GameProperty] -> f (Maybe [GameProperty]))
-> CreateGameSession -> f CreateGameSession
createGameSession_gameProperties = (CreateGameSession -> Maybe [GameProperty])
-> (CreateGameSession -> Maybe [GameProperty] -> CreateGameSession)
-> Lens
     CreateGameSession
     CreateGameSession
     (Maybe [GameProperty])
     (Maybe [GameProperty])
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) ((Maybe [GameProperty] -> f (Maybe [GameProperty]))
 -> CreateGameSession -> f CreateGameSession)
-> ((Maybe [GameProperty] -> f (Maybe [GameProperty]))
    -> Maybe [GameProperty] -> f (Maybe [GameProperty]))
-> (Maybe [GameProperty] -> f (Maybe [GameProperty]))
-> CreateGameSession
-> f CreateGameSession
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 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 AWS Region code such as
-- @us-west-2@.
createGameSession_location :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_location :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_location = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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)

-- | /This parameter is no longer preferred. Please 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 :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_gameSessionId = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_aliasId = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_name = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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)

-- | 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.
createGameSession_gameSessionData :: Lens.Lens' CreateGameSession (Prelude.Maybe Prelude.Text)
createGameSession_gameSessionData :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_gameSessionData = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_fleetId = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> CreateGameSession -> f CreateGameSession
createGameSession_creatorId = (CreateGameSession -> Maybe Text)
-> (CreateGameSession -> Maybe Text -> CreateGameSession)
-> Lens
     CreateGameSession CreateGameSession (Maybe Text) (Maybe Text)
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)

-- | The maximum number of players that can be connected simultaneously to
-- the game session.
createGameSession_maximumPlayerSessionCount :: Lens.Lens' CreateGameSession Prelude.Natural
createGameSession_maximumPlayerSessionCount :: (Natural -> f Natural) -> CreateGameSession -> f CreateGameSession
createGameSession_maximumPlayerSessionCount = (CreateGameSession -> Natural)
-> (CreateGameSession -> Natural -> CreateGameSession)
-> Lens CreateGameSession CreateGameSession Natural Natural
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 :: CreateGameSession -> Request CreateGameSession
request = Service -> CreateGameSession -> Request CreateGameSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateGameSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGameSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateGameSession))
-> Logger
-> Service
-> Proxy CreateGameSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGameSession)))
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 GameSession -> Int -> CreateGameSessionResponse
CreateGameSessionResponse'
            (Maybe GameSession -> Int -> CreateGameSessionResponse)
-> Either String (Maybe GameSession)
-> Either String (Int -> CreateGameSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GameSession)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GameSession")
            Either String (Int -> CreateGameSessionResponse)
-> Either String Int -> Either String CreateGameSessionResponse
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 CreateGameSession

instance Prelude.NFData CreateGameSession

instance Core.ToHeaders CreateGameSession where
  toHeaders :: CreateGameSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateGameSession -> 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.CreateGameSession" :: 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 CreateGameSession where
  toJSON :: CreateGameSession -> Value
toJSON CreateGameSession' {Natural
Maybe [GameProperty]
Maybe Text
maximumPlayerSessionCount :: Natural
creatorId :: Maybe Text
fleetId :: Maybe Text
gameSessionData :: Maybe Text
name :: Maybe Text
aliasId :: Maybe Text
gameSessionId :: Maybe Text
location :: Maybe Text
gameProperties :: Maybe [GameProperty]
idempotencyToken :: Maybe Text
$sel:maximumPlayerSessionCount:CreateGameSession' :: CreateGameSession -> Natural
$sel:creatorId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:fleetId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionData:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:name:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:aliasId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameSessionId:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:location:CreateGameSession' :: CreateGameSession -> Maybe Text
$sel:gameProperties:CreateGameSession' :: CreateGameSession -> Maybe [GameProperty]
$sel:idempotencyToken:CreateGameSession' :: CreateGameSession -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IdempotencyToken" 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
idempotencyToken,
            (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
"Location" 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
location,
            (Text
"GameSessionId" 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
gameSessionId,
            (Text
"AliasId" 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
aliasId,
            (Text
"Name" 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
name,
            (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
"FleetId" 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
fleetId,
            (Text
"CreatorId" 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
creatorId,
            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 CreateGameSession where
  toPath :: CreateGameSession -> ByteString
toPath = ByteString -> CreateGameSession -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateGameSession where
  toQuery :: CreateGameSession -> QueryString
toQuery = QueryString -> CreateGameSession -> 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:/ '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
(CreateGameSessionResponse -> CreateGameSessionResponse -> Bool)
-> (CreateGameSessionResponse -> CreateGameSessionResponse -> Bool)
-> Eq CreateGameSessionResponse
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]
(Int -> ReadS CreateGameSessionResponse)
-> ReadS [CreateGameSessionResponse]
-> ReadPrec CreateGameSessionResponse
-> ReadPrec [CreateGameSessionResponse]
-> Read 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
(Int -> CreateGameSessionResponse -> ShowS)
-> (CreateGameSessionResponse -> String)
-> ([CreateGameSessionResponse] -> ShowS)
-> Show CreateGameSessionResponse
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.
 CreateGameSessionResponse -> Rep CreateGameSessionResponse x)
-> (forall x.
    Rep CreateGameSessionResponse x -> CreateGameSessionResponse)
-> Generic CreateGameSessionResponse
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' :: Maybe GameSession -> Int -> CreateGameSessionResponse
CreateGameSessionResponse'
    { $sel:gameSession:CreateGameSessionResponse' :: Maybe GameSession
gameSession =
        Maybe 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 :: (Maybe GameSession -> f (Maybe GameSession))
-> CreateGameSessionResponse -> f CreateGameSessionResponse
createGameSessionResponse_gameSession = (CreateGameSessionResponse -> Maybe GameSession)
-> (CreateGameSessionResponse
    -> Maybe GameSession -> CreateGameSessionResponse)
-> Lens
     CreateGameSessionResponse
     CreateGameSessionResponse
     (Maybe GameSession)
     (Maybe 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 :: (Int -> f Int)
-> CreateGameSessionResponse -> f CreateGameSessionResponse
createGameSessionResponse_httpStatus = (CreateGameSessionResponse -> Int)
-> (CreateGameSessionResponse -> Int -> CreateGameSessionResponse)
-> Lens CreateGameSessionResponse CreateGameSessionResponse Int Int
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