{-# 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.GameProperty
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.GameProperty where

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

-- | Set of key-value pairs that contain information about a game session.
-- When included in a game session request, these properties communicate
-- details to be used when setting up the new game session. For example, a
-- game property might specify a game mode, level, or map. Game properties
-- are passed to the game server process when initiating a new game
-- session. For more information, see the
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-client-api.html#gamelift-sdk-client-api-create GameLift Developer Guide>.
--
-- /See:/ 'newGameProperty' smart constructor.
data GameProperty = GameProperty'
  { -- | The game property identifier.
    GameProperty -> Text
key :: Prelude.Text,
    -- | The game property value.
    GameProperty -> Text
value :: Prelude.Text
  }
  deriving (GameProperty -> GameProperty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GameProperty -> GameProperty -> Bool
$c/= :: GameProperty -> GameProperty -> Bool
== :: GameProperty -> GameProperty -> Bool
$c== :: GameProperty -> GameProperty -> Bool
Prelude.Eq, ReadPrec [GameProperty]
ReadPrec GameProperty
Int -> ReadS GameProperty
ReadS [GameProperty]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GameProperty]
$creadListPrec :: ReadPrec [GameProperty]
readPrec :: ReadPrec GameProperty
$creadPrec :: ReadPrec GameProperty
readList :: ReadS [GameProperty]
$creadList :: ReadS [GameProperty]
readsPrec :: Int -> ReadS GameProperty
$creadsPrec :: Int -> ReadS GameProperty
Prelude.Read, Int -> GameProperty -> ShowS
[GameProperty] -> ShowS
GameProperty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GameProperty] -> ShowS
$cshowList :: [GameProperty] -> ShowS
show :: GameProperty -> String
$cshow :: GameProperty -> String
showsPrec :: Int -> GameProperty -> ShowS
$cshowsPrec :: Int -> GameProperty -> ShowS
Prelude.Show, forall x. Rep GameProperty x -> GameProperty
forall x. GameProperty -> Rep GameProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GameProperty x -> GameProperty
$cfrom :: forall x. GameProperty -> Rep GameProperty x
Prelude.Generic)

-- |
-- Create a value of 'GameProperty' 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:
--
-- 'key', 'gameProperty_key' - The game property identifier.
--
-- 'value', 'gameProperty_value' - The game property value.
newGameProperty ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  GameProperty
newGameProperty :: Text -> Text -> GameProperty
newGameProperty Text
pKey_ Text
pValue_ =
  GameProperty' {$sel:key:GameProperty' :: Text
key = Text
pKey_, $sel:value:GameProperty' :: Text
value = Text
pValue_}

-- | The game property identifier.
gameProperty_key :: Lens.Lens' GameProperty Prelude.Text
gameProperty_key :: Lens' GameProperty Text
gameProperty_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameProperty' {Text
key :: Text
$sel:key:GameProperty' :: GameProperty -> Text
key} -> Text
key) (\s :: GameProperty
s@GameProperty' {} Text
a -> GameProperty
s {$sel:key:GameProperty' :: Text
key = Text
a} :: GameProperty)

-- | The game property value.
gameProperty_value :: Lens.Lens' GameProperty Prelude.Text
gameProperty_value :: Lens' GameProperty Text
gameProperty_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameProperty' {Text
value :: Text
$sel:value:GameProperty' :: GameProperty -> Text
value} -> Text
value) (\s :: GameProperty
s@GameProperty' {} Text
a -> GameProperty
s {$sel:value:GameProperty' :: Text
value = Text
a} :: GameProperty)

instance Data.FromJSON GameProperty where
  parseJSON :: Value -> Parser GameProperty
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GameProperty"
      ( \Object
x ->
          Text -> Text -> GameProperty
GameProperty'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
      )

instance Prelude.Hashable GameProperty where
  hashWithSalt :: Int -> GameProperty -> Int
hashWithSalt Int
_salt GameProperty' {Text
value :: Text
key :: Text
$sel:value:GameProperty' :: GameProperty -> Text
$sel:key:GameProperty' :: GameProperty -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData GameProperty where
  rnf :: GameProperty -> ()
rnf GameProperty' {Text
value :: Text
key :: Text
$sel:value:GameProperty' :: GameProperty -> Text
$sel:key:GameProperty' :: GameProperty -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON GameProperty where
  toJSON :: GameProperty -> Value
toJSON GameProperty' {Text
value :: Text
key :: Text
$sel:value:GameProperty' :: GameProperty -> Text
$sel:key:GameProperty' :: GameProperty -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )