{-# 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 #-}
module Amazonka.GameLift.Types.Player where
import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.AttributeValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Player = Player'
{
Player -> Maybe (HashMap Text AttributeValue)
playerAttributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
Player -> Maybe Text
team :: Prelude.Maybe Prelude.Text,
Player -> Maybe Text
playerId :: Prelude.Maybe Prelude.Text,
Player -> Maybe (HashMap Text Natural)
latencyInMs :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Natural)
}
deriving (Player -> Player -> Bool
(Player -> Player -> Bool)
-> (Player -> Player -> Bool) -> Eq Player
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Player -> Player -> Bool
$c/= :: Player -> Player -> Bool
== :: Player -> Player -> Bool
$c== :: Player -> Player -> Bool
Prelude.Eq, ReadPrec [Player]
ReadPrec Player
Int -> ReadS Player
ReadS [Player]
(Int -> ReadS Player)
-> ReadS [Player]
-> ReadPrec Player
-> ReadPrec [Player]
-> Read Player
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Player]
$creadListPrec :: ReadPrec [Player]
readPrec :: ReadPrec Player
$creadPrec :: ReadPrec Player
readList :: ReadS [Player]
$creadList :: ReadS [Player]
readsPrec :: Int -> ReadS Player
$creadsPrec :: Int -> ReadS Player
Prelude.Read, Int -> Player -> ShowS
[Player] -> ShowS
Player -> String
(Int -> Player -> ShowS)
-> (Player -> String) -> ([Player] -> ShowS) -> Show Player
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Player] -> ShowS
$cshowList :: [Player] -> ShowS
show :: Player -> String
$cshow :: Player -> String
showsPrec :: Int -> Player -> ShowS
$cshowsPrec :: Int -> Player -> ShowS
Prelude.Show, (forall x. Player -> Rep Player x)
-> (forall x. Rep Player x -> Player) -> Generic Player
forall x. Rep Player x -> Player
forall x. Player -> Rep Player x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Player x -> Player
$cfrom :: forall x. Player -> Rep Player x
Prelude.Generic)
newPlayer ::
Player
newPlayer :: Player
newPlayer =
Player' :: Maybe (HashMap Text AttributeValue)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Natural)
-> Player
Player'
{ $sel:playerAttributes:Player' :: Maybe (HashMap Text AttributeValue)
playerAttributes = Maybe (HashMap Text AttributeValue)
forall a. Maybe a
Prelude.Nothing,
$sel:team:Player' :: Maybe Text
team = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:playerId:Player' :: Maybe Text
playerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:latencyInMs:Player' :: Maybe (HashMap Text Natural)
latencyInMs = Maybe (HashMap Text Natural)
forall a. Maybe a
Prelude.Nothing
}
player_playerAttributes :: Lens.Lens' Player (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
player_playerAttributes :: (Maybe (HashMap Text AttributeValue)
-> f (Maybe (HashMap Text AttributeValue)))
-> Player -> f Player
player_playerAttributes = (Player -> Maybe (HashMap Text AttributeValue))
-> (Player -> Maybe (HashMap Text AttributeValue) -> Player)
-> Lens
Player
Player
(Maybe (HashMap Text AttributeValue))
(Maybe (HashMap Text AttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Player' {Maybe (HashMap Text AttributeValue)
playerAttributes :: Maybe (HashMap Text AttributeValue)
$sel:playerAttributes:Player' :: Player -> Maybe (HashMap Text AttributeValue)
playerAttributes} -> Maybe (HashMap Text AttributeValue)
playerAttributes) (\s :: Player
s@Player' {} Maybe (HashMap Text AttributeValue)
a -> Player
s {$sel:playerAttributes:Player' :: Maybe (HashMap Text AttributeValue)
playerAttributes = Maybe (HashMap Text AttributeValue)
a} :: Player) ((Maybe (HashMap Text AttributeValue)
-> f (Maybe (HashMap Text AttributeValue)))
-> Player -> f Player)
-> ((Maybe (HashMap Text AttributeValue)
-> f (Maybe (HashMap Text AttributeValue)))
-> Maybe (HashMap Text AttributeValue)
-> f (Maybe (HashMap Text AttributeValue)))
-> (Maybe (HashMap Text AttributeValue)
-> f (Maybe (HashMap Text AttributeValue)))
-> Player
-> f Player
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
-> Iso
(Maybe (HashMap Text AttributeValue))
(Maybe (HashMap Text AttributeValue))
(Maybe (HashMap Text AttributeValue))
(Maybe (HashMap Text AttributeValue))
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
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
player_team :: Lens.Lens' Player (Prelude.Maybe Prelude.Text)
player_team :: (Maybe Text -> f (Maybe Text)) -> Player -> f Player
player_team = (Player -> Maybe Text)
-> (Player -> Maybe Text -> Player)
-> Lens Player Player (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Player' {Maybe Text
team :: Maybe Text
$sel:team:Player' :: Player -> Maybe Text
team} -> Maybe Text
team) (\s :: Player
s@Player' {} Maybe Text
a -> Player
s {$sel:team:Player' :: Maybe Text
team = Maybe Text
a} :: Player)
player_playerId :: Lens.Lens' Player (Prelude.Maybe Prelude.Text)
player_playerId :: (Maybe Text -> f (Maybe Text)) -> Player -> f Player
player_playerId = (Player -> Maybe Text)
-> (Player -> Maybe Text -> Player)
-> Lens Player Player (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Player' {Maybe Text
playerId :: Maybe Text
$sel:playerId:Player' :: Player -> Maybe Text
playerId} -> Maybe Text
playerId) (\s :: Player
s@Player' {} Maybe Text
a -> Player
s {$sel:playerId:Player' :: Maybe Text
playerId = Maybe Text
a} :: Player)
player_latencyInMs :: Lens.Lens' Player (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Natural))
player_latencyInMs :: (Maybe (HashMap Text Natural) -> f (Maybe (HashMap Text Natural)))
-> Player -> f Player
player_latencyInMs = (Player -> Maybe (HashMap Text Natural))
-> (Player -> Maybe (HashMap Text Natural) -> Player)
-> Lens
Player
Player
(Maybe (HashMap Text Natural))
(Maybe (HashMap Text Natural))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Player' {Maybe (HashMap Text Natural)
latencyInMs :: Maybe (HashMap Text Natural)
$sel:latencyInMs:Player' :: Player -> Maybe (HashMap Text Natural)
latencyInMs} -> Maybe (HashMap Text Natural)
latencyInMs) (\s :: Player
s@Player' {} Maybe (HashMap Text Natural)
a -> Player
s {$sel:latencyInMs:Player' :: Maybe (HashMap Text Natural)
latencyInMs = Maybe (HashMap Text Natural)
a} :: Player) ((Maybe (HashMap Text Natural) -> f (Maybe (HashMap Text Natural)))
-> Player -> f Player)
-> ((Maybe (HashMap Text Natural)
-> f (Maybe (HashMap Text Natural)))
-> Maybe (HashMap Text Natural)
-> f (Maybe (HashMap Text Natural)))
-> (Maybe (HashMap Text Natural)
-> f (Maybe (HashMap Text Natural)))
-> Player
-> f Player
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Natural)
(HashMap Text Natural)
(HashMap Text Natural)
(HashMap Text Natural)
-> Iso
(Maybe (HashMap Text Natural))
(Maybe (HashMap Text Natural))
(Maybe (HashMap Text Natural))
(Maybe (HashMap Text Natural))
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
(HashMap Text Natural)
(HashMap Text Natural)
(HashMap Text Natural)
(HashMap Text Natural)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON Player where
parseJSON :: Value -> Parser Player
parseJSON =
String -> (Object -> Parser Player) -> Value -> Parser Player
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Player"
( \Object
x ->
Maybe (HashMap Text AttributeValue)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Natural)
-> Player
Player'
(Maybe (HashMap Text AttributeValue)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Natural)
-> Player)
-> Parser (Maybe (HashMap Text AttributeValue))
-> Parser
(Maybe Text
-> Maybe Text -> Maybe (HashMap Text Natural) -> Player)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text AttributeValue)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PlayerAttributes"
Parser (Maybe (Maybe (HashMap Text AttributeValue)))
-> Maybe (HashMap Text AttributeValue)
-> Parser (Maybe (HashMap Text AttributeValue))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text AttributeValue)
forall a. Monoid a => a
Prelude.mempty
)
Parser
(Maybe Text
-> Maybe Text -> Maybe (HashMap Text Natural) -> Player)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe (HashMap Text Natural) -> Player)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Team")
Parser (Maybe Text -> Maybe (HashMap Text Natural) -> Player)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Natural) -> Player)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PlayerId")
Parser (Maybe (HashMap Text Natural) -> Player)
-> Parser (Maybe (HashMap Text Natural)) -> Parser Player
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Natural)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LatencyInMs" Parser (Maybe (Maybe (HashMap Text Natural)))
-> Maybe (HashMap Text Natural)
-> Parser (Maybe (HashMap Text Natural))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Natural)
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable Player
instance Prelude.NFData Player
instance Core.ToJSON Player where
toJSON :: Player -> Value
toJSON Player' {Maybe Text
Maybe (HashMap Text Natural)
Maybe (HashMap Text AttributeValue)
latencyInMs :: Maybe (HashMap Text Natural)
playerId :: Maybe Text
team :: Maybe Text
playerAttributes :: Maybe (HashMap Text AttributeValue)
$sel:latencyInMs:Player' :: Player -> Maybe (HashMap Text Natural)
$sel:playerId:Player' :: Player -> Maybe Text
$sel:team:Player' :: Player -> Maybe Text
$sel:playerAttributes:Player' :: Player -> Maybe (HashMap Text AttributeValue)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"PlayerAttributes" Text -> HashMap Text AttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(HashMap Text AttributeValue -> Pair)
-> Maybe (HashMap Text AttributeValue) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeValue)
playerAttributes,
(Text
"Team" 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
team,
(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,
(Text
"LatencyInMs" Text -> HashMap Text Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Natural -> Pair)
-> Maybe (HashMap Text Natural) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Natural)
latencyInMs
]
)