{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.DesiredPlayerSession
-- 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)
module Amazonka.GameLift.Types.DesiredPlayerSession where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Player information for use when creating player sessions using a game
-- session placement request with StartGameSessionPlacement.
--
-- /See:/ 'newDesiredPlayerSession' smart constructor.
data DesiredPlayerSession = DesiredPlayerSession'
  { -- | Developer-defined information related to a player. GameLift does not use
    -- this data, so it can be formatted as needed for use in the game.
    DesiredPlayerSession -> Maybe Text
playerData :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for a player to associate with the player session.
    DesiredPlayerSession -> Maybe Text
playerId :: Prelude.Maybe Prelude.Text
  }
  deriving (DesiredPlayerSession -> DesiredPlayerSession -> Bool
(DesiredPlayerSession -> DesiredPlayerSession -> Bool)
-> (DesiredPlayerSession -> DesiredPlayerSession -> Bool)
-> Eq DesiredPlayerSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DesiredPlayerSession -> DesiredPlayerSession -> Bool
$c/= :: DesiredPlayerSession -> DesiredPlayerSession -> Bool
== :: DesiredPlayerSession -> DesiredPlayerSession -> Bool
$c== :: DesiredPlayerSession -> DesiredPlayerSession -> Bool
Prelude.Eq, ReadPrec [DesiredPlayerSession]
ReadPrec DesiredPlayerSession
Int -> ReadS DesiredPlayerSession
ReadS [DesiredPlayerSession]
(Int -> ReadS DesiredPlayerSession)
-> ReadS [DesiredPlayerSession]
-> ReadPrec DesiredPlayerSession
-> ReadPrec [DesiredPlayerSession]
-> Read DesiredPlayerSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DesiredPlayerSession]
$creadListPrec :: ReadPrec [DesiredPlayerSession]
readPrec :: ReadPrec DesiredPlayerSession
$creadPrec :: ReadPrec DesiredPlayerSession
readList :: ReadS [DesiredPlayerSession]
$creadList :: ReadS [DesiredPlayerSession]
readsPrec :: Int -> ReadS DesiredPlayerSession
$creadsPrec :: Int -> ReadS DesiredPlayerSession
Prelude.Read, Int -> DesiredPlayerSession -> ShowS
[DesiredPlayerSession] -> ShowS
DesiredPlayerSession -> String
(Int -> DesiredPlayerSession -> ShowS)
-> (DesiredPlayerSession -> String)
-> ([DesiredPlayerSession] -> ShowS)
-> Show DesiredPlayerSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DesiredPlayerSession] -> ShowS
$cshowList :: [DesiredPlayerSession] -> ShowS
show :: DesiredPlayerSession -> String
$cshow :: DesiredPlayerSession -> String
showsPrec :: Int -> DesiredPlayerSession -> ShowS
$cshowsPrec :: Int -> DesiredPlayerSession -> ShowS
Prelude.Show, (forall x. DesiredPlayerSession -> Rep DesiredPlayerSession x)
-> (forall x. Rep DesiredPlayerSession x -> DesiredPlayerSession)
-> Generic DesiredPlayerSession
forall x. Rep DesiredPlayerSession x -> DesiredPlayerSession
forall x. DesiredPlayerSession -> Rep DesiredPlayerSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DesiredPlayerSession x -> DesiredPlayerSession
$cfrom :: forall x. DesiredPlayerSession -> Rep DesiredPlayerSession x
Prelude.Generic)

-- |
-- Create a value of 'DesiredPlayerSession' 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:
--
-- 'playerData', 'desiredPlayerSession_playerData' - Developer-defined information related to a player. GameLift does not use
-- this data, so it can be formatted as needed for use in the game.
--
-- 'playerId', 'desiredPlayerSession_playerId' - A unique identifier for a player to associate with the player session.
newDesiredPlayerSession ::
  DesiredPlayerSession
newDesiredPlayerSession :: DesiredPlayerSession
newDesiredPlayerSession =
  DesiredPlayerSession' :: Maybe Text -> Maybe Text -> DesiredPlayerSession
DesiredPlayerSession'
    { $sel:playerData:DesiredPlayerSession' :: Maybe Text
playerData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:playerId:DesiredPlayerSession' :: Maybe Text
playerId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Developer-defined information related to a player. GameLift does not use
-- this data, so it can be formatted as needed for use in the game.
desiredPlayerSession_playerData :: Lens.Lens' DesiredPlayerSession (Prelude.Maybe Prelude.Text)
desiredPlayerSession_playerData :: (Maybe Text -> f (Maybe Text))
-> DesiredPlayerSession -> f DesiredPlayerSession
desiredPlayerSession_playerData = (DesiredPlayerSession -> Maybe Text)
-> (DesiredPlayerSession -> Maybe Text -> DesiredPlayerSession)
-> Lens
     DesiredPlayerSession DesiredPlayerSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DesiredPlayerSession' {Maybe Text
playerData :: Maybe Text
$sel:playerData:DesiredPlayerSession' :: DesiredPlayerSession -> Maybe Text
playerData} -> Maybe Text
playerData) (\s :: DesiredPlayerSession
s@DesiredPlayerSession' {} Maybe Text
a -> DesiredPlayerSession
s {$sel:playerData:DesiredPlayerSession' :: Maybe Text
playerData = Maybe Text
a} :: DesiredPlayerSession)

-- | A unique identifier for a player to associate with the player session.
desiredPlayerSession_playerId :: Lens.Lens' DesiredPlayerSession (Prelude.Maybe Prelude.Text)
desiredPlayerSession_playerId :: (Maybe Text -> f (Maybe Text))
-> DesiredPlayerSession -> f DesiredPlayerSession
desiredPlayerSession_playerId = (DesiredPlayerSession -> Maybe Text)
-> (DesiredPlayerSession -> Maybe Text -> DesiredPlayerSession)
-> Lens
     DesiredPlayerSession DesiredPlayerSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DesiredPlayerSession' {Maybe Text
playerId :: Maybe Text
$sel:playerId:DesiredPlayerSession' :: DesiredPlayerSession -> Maybe Text
playerId} -> Maybe Text
playerId) (\s :: DesiredPlayerSession
s@DesiredPlayerSession' {} Maybe Text
a -> DesiredPlayerSession
s {$sel:playerId:DesiredPlayerSession' :: Maybe Text
playerId = Maybe Text
a} :: DesiredPlayerSession)

instance Prelude.Hashable DesiredPlayerSession

instance Prelude.NFData DesiredPlayerSession

instance Core.ToJSON DesiredPlayerSession where
  toJSON :: DesiredPlayerSession -> Value
toJSON DesiredPlayerSession' {Maybe Text
playerId :: Maybe Text
playerData :: Maybe Text
$sel:playerId:DesiredPlayerSession' :: DesiredPlayerSession -> Maybe Text
$sel:playerData:DesiredPlayerSession' :: DesiredPlayerSession -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PlayerData" 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
playerData,
            (Text
"PlayerId" 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
playerId
          ]
      )