{-# 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 #-}
module Amazonka.GameLift.CreatePlayerSession
(
CreatePlayerSession (..),
newCreatePlayerSession,
createPlayerSession_playerData,
createPlayerSession_gameSessionId,
createPlayerSession_playerId,
CreatePlayerSessionResponse (..),
newCreatePlayerSessionResponse,
createPlayerSessionResponse_playerSession,
createPlayerSessionResponse_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
data CreatePlayerSession = CreatePlayerSession'
{
CreatePlayerSession -> Maybe Text
playerData :: Prelude.Maybe Prelude.Text,
CreatePlayerSession -> Text
gameSessionId :: Prelude.Text,
CreatePlayerSession -> Text
playerId :: Prelude.Text
}
deriving (CreatePlayerSession -> CreatePlayerSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePlayerSession -> CreatePlayerSession -> Bool
$c/= :: CreatePlayerSession -> CreatePlayerSession -> Bool
== :: CreatePlayerSession -> CreatePlayerSession -> Bool
$c== :: CreatePlayerSession -> CreatePlayerSession -> Bool
Prelude.Eq, ReadPrec [CreatePlayerSession]
ReadPrec CreatePlayerSession
Int -> ReadS CreatePlayerSession
ReadS [CreatePlayerSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePlayerSession]
$creadListPrec :: ReadPrec [CreatePlayerSession]
readPrec :: ReadPrec CreatePlayerSession
$creadPrec :: ReadPrec CreatePlayerSession
readList :: ReadS [CreatePlayerSession]
$creadList :: ReadS [CreatePlayerSession]
readsPrec :: Int -> ReadS CreatePlayerSession
$creadsPrec :: Int -> ReadS CreatePlayerSession
Prelude.Read, Int -> CreatePlayerSession -> ShowS
[CreatePlayerSession] -> ShowS
CreatePlayerSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePlayerSession] -> ShowS
$cshowList :: [CreatePlayerSession] -> ShowS
show :: CreatePlayerSession -> String
$cshow :: CreatePlayerSession -> String
showsPrec :: Int -> CreatePlayerSession -> ShowS
$cshowsPrec :: Int -> CreatePlayerSession -> ShowS
Prelude.Show, forall x. Rep CreatePlayerSession x -> CreatePlayerSession
forall x. CreatePlayerSession -> Rep CreatePlayerSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePlayerSession x -> CreatePlayerSession
$cfrom :: forall x. CreatePlayerSession -> Rep CreatePlayerSession x
Prelude.Generic)
newCreatePlayerSession ::
Prelude.Text ->
Prelude.Text ->
CreatePlayerSession
newCreatePlayerSession :: Text -> Text -> CreatePlayerSession
newCreatePlayerSession Text
pGameSessionId_ Text
pPlayerId_ =
CreatePlayerSession'
{ $sel:playerData:CreatePlayerSession' :: Maybe Text
playerData = forall a. Maybe a
Prelude.Nothing,
$sel:gameSessionId:CreatePlayerSession' :: Text
gameSessionId = Text
pGameSessionId_,
$sel:playerId:CreatePlayerSession' :: Text
playerId = Text
pPlayerId_
}
createPlayerSession_playerData :: Lens.Lens' CreatePlayerSession (Prelude.Maybe Prelude.Text)
createPlayerSession_playerData :: Lens' CreatePlayerSession (Maybe Text)
createPlayerSession_playerData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePlayerSession' {Maybe Text
playerData :: Maybe Text
$sel:playerData:CreatePlayerSession' :: CreatePlayerSession -> Maybe Text
playerData} -> Maybe Text
playerData) (\s :: CreatePlayerSession
s@CreatePlayerSession' {} Maybe Text
a -> CreatePlayerSession
s {$sel:playerData:CreatePlayerSession' :: Maybe Text
playerData = Maybe Text
a} :: CreatePlayerSession)
createPlayerSession_gameSessionId :: Lens.Lens' CreatePlayerSession Prelude.Text
createPlayerSession_gameSessionId :: Lens' CreatePlayerSession Text
createPlayerSession_gameSessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePlayerSession' {Text
gameSessionId :: Text
$sel:gameSessionId:CreatePlayerSession' :: CreatePlayerSession -> Text
gameSessionId} -> Text
gameSessionId) (\s :: CreatePlayerSession
s@CreatePlayerSession' {} Text
a -> CreatePlayerSession
s {$sel:gameSessionId:CreatePlayerSession' :: Text
gameSessionId = Text
a} :: CreatePlayerSession)
createPlayerSession_playerId :: Lens.Lens' CreatePlayerSession Prelude.Text
createPlayerSession_playerId :: Lens' CreatePlayerSession Text
createPlayerSession_playerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePlayerSession' {Text
playerId :: Text
$sel:playerId:CreatePlayerSession' :: CreatePlayerSession -> Text
playerId} -> Text
playerId) (\s :: CreatePlayerSession
s@CreatePlayerSession' {} Text
a -> CreatePlayerSession
s {$sel:playerId:CreatePlayerSession' :: Text
playerId = Text
a} :: CreatePlayerSession)
instance Core.AWSRequest CreatePlayerSession where
type
AWSResponse CreatePlayerSession =
CreatePlayerSessionResponse
request :: (Service -> Service)
-> CreatePlayerSession -> Request CreatePlayerSession
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 CreatePlayerSession
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePlayerSession)))
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 PlayerSession -> Int -> CreatePlayerSessionResponse
CreatePlayerSessionResponse'
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
"PlayerSession")
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 CreatePlayerSession where
hashWithSalt :: Int -> CreatePlayerSession -> Int
hashWithSalt Int
_salt CreatePlayerSession' {Maybe Text
Text
playerId :: Text
gameSessionId :: Text
playerData :: Maybe Text
$sel:playerId:CreatePlayerSession' :: CreatePlayerSession -> Text
$sel:gameSessionId:CreatePlayerSession' :: CreatePlayerSession -> Text
$sel:playerData:CreatePlayerSession' :: CreatePlayerSession -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
playerData
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameSessionId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
playerId
instance Prelude.NFData CreatePlayerSession where
rnf :: CreatePlayerSession -> ()
rnf CreatePlayerSession' {Maybe Text
Text
playerId :: Text
gameSessionId :: Text
playerData :: Maybe Text
$sel:playerId:CreatePlayerSession' :: CreatePlayerSession -> Text
$sel:gameSessionId:CreatePlayerSession' :: CreatePlayerSession -> Text
$sel:playerData:CreatePlayerSession' :: CreatePlayerSession -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
playerData
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
gameSessionId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
playerId
instance Data.ToHeaders CreatePlayerSession where
toHeaders :: CreatePlayerSession -> 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.CreatePlayerSession" ::
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 CreatePlayerSession where
toJSON :: CreatePlayerSession -> Value
toJSON CreatePlayerSession' {Maybe Text
Text
playerId :: Text
gameSessionId :: Text
playerData :: Maybe Text
$sel:playerId:CreatePlayerSession' :: CreatePlayerSession -> Text
$sel:gameSessionId:CreatePlayerSession' :: CreatePlayerSession -> Text
$sel:playerData:CreatePlayerSession' :: CreatePlayerSession -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"PlayerData" 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
playerData,
forall a. a -> Maybe a
Prelude.Just (Key
"GameSessionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
gameSessionId),
forall a. a -> Maybe a
Prelude.Just (Key
"PlayerId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
playerId)
]
)
instance Data.ToPath CreatePlayerSession where
toPath :: CreatePlayerSession -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery CreatePlayerSession where
toQuery :: CreatePlayerSession -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data CreatePlayerSessionResponse = CreatePlayerSessionResponse'
{
CreatePlayerSessionResponse -> Maybe PlayerSession
playerSession :: Prelude.Maybe PlayerSession,
CreatePlayerSessionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreatePlayerSessionResponse -> CreatePlayerSessionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePlayerSessionResponse -> CreatePlayerSessionResponse -> Bool
$c/= :: CreatePlayerSessionResponse -> CreatePlayerSessionResponse -> Bool
== :: CreatePlayerSessionResponse -> CreatePlayerSessionResponse -> Bool
$c== :: CreatePlayerSessionResponse -> CreatePlayerSessionResponse -> Bool
Prelude.Eq, ReadPrec [CreatePlayerSessionResponse]
ReadPrec CreatePlayerSessionResponse
Int -> ReadS CreatePlayerSessionResponse
ReadS [CreatePlayerSessionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePlayerSessionResponse]
$creadListPrec :: ReadPrec [CreatePlayerSessionResponse]
readPrec :: ReadPrec CreatePlayerSessionResponse
$creadPrec :: ReadPrec CreatePlayerSessionResponse
readList :: ReadS [CreatePlayerSessionResponse]
$creadList :: ReadS [CreatePlayerSessionResponse]
readsPrec :: Int -> ReadS CreatePlayerSessionResponse
$creadsPrec :: Int -> ReadS CreatePlayerSessionResponse
Prelude.Read, Int -> CreatePlayerSessionResponse -> ShowS
[CreatePlayerSessionResponse] -> ShowS
CreatePlayerSessionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePlayerSessionResponse] -> ShowS
$cshowList :: [CreatePlayerSessionResponse] -> ShowS
show :: CreatePlayerSessionResponse -> String
$cshow :: CreatePlayerSessionResponse -> String
showsPrec :: Int -> CreatePlayerSessionResponse -> ShowS
$cshowsPrec :: Int -> CreatePlayerSessionResponse -> ShowS
Prelude.Show, forall x.
Rep CreatePlayerSessionResponse x -> CreatePlayerSessionResponse
forall x.
CreatePlayerSessionResponse -> Rep CreatePlayerSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePlayerSessionResponse x -> CreatePlayerSessionResponse
$cfrom :: forall x.
CreatePlayerSessionResponse -> Rep CreatePlayerSessionResponse x
Prelude.Generic)
newCreatePlayerSessionResponse ::
Prelude.Int ->
CreatePlayerSessionResponse
newCreatePlayerSessionResponse :: Int -> CreatePlayerSessionResponse
newCreatePlayerSessionResponse Int
pHttpStatus_ =
CreatePlayerSessionResponse'
{ $sel:playerSession:CreatePlayerSessionResponse' :: Maybe PlayerSession
playerSession =
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreatePlayerSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createPlayerSessionResponse_playerSession :: Lens.Lens' CreatePlayerSessionResponse (Prelude.Maybe PlayerSession)
createPlayerSessionResponse_playerSession :: Lens' CreatePlayerSessionResponse (Maybe PlayerSession)
createPlayerSessionResponse_playerSession = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePlayerSessionResponse' {Maybe PlayerSession
playerSession :: Maybe PlayerSession
$sel:playerSession:CreatePlayerSessionResponse' :: CreatePlayerSessionResponse -> Maybe PlayerSession
playerSession} -> Maybe PlayerSession
playerSession) (\s :: CreatePlayerSessionResponse
s@CreatePlayerSessionResponse' {} Maybe PlayerSession
a -> CreatePlayerSessionResponse
s {$sel:playerSession:CreatePlayerSessionResponse' :: Maybe PlayerSession
playerSession = Maybe PlayerSession
a} :: CreatePlayerSessionResponse)
createPlayerSessionResponse_httpStatus :: Lens.Lens' CreatePlayerSessionResponse Prelude.Int
createPlayerSessionResponse_httpStatus :: Lens' CreatePlayerSessionResponse Int
createPlayerSessionResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePlayerSessionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreatePlayerSessionResponse' :: CreatePlayerSessionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreatePlayerSessionResponse
s@CreatePlayerSessionResponse' {} Int
a -> CreatePlayerSessionResponse
s {$sel:httpStatus:CreatePlayerSessionResponse' :: Int
httpStatus = Int
a} :: CreatePlayerSessionResponse)
instance Prelude.NFData CreatePlayerSessionResponse where
rnf :: CreatePlayerSessionResponse -> ()
rnf CreatePlayerSessionResponse' {Int
Maybe PlayerSession
httpStatus :: Int
playerSession :: Maybe PlayerSession
$sel:httpStatus:CreatePlayerSessionResponse' :: CreatePlayerSessionResponse -> Int
$sel:playerSession:CreatePlayerSessionResponse' :: CreatePlayerSessionResponse -> Maybe PlayerSession
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe PlayerSession
playerSession
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus