{-# 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 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
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
(CreatePlayerSession -> CreatePlayerSession -> Bool)
-> (CreatePlayerSession -> CreatePlayerSession -> Bool)
-> Eq CreatePlayerSession
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]
(Int -> ReadS CreatePlayerSession)
-> ReadS [CreatePlayerSession]
-> ReadPrec CreatePlayerSession
-> ReadPrec [CreatePlayerSession]
-> Read 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
(Int -> CreatePlayerSession -> ShowS)
-> (CreatePlayerSession -> String)
-> ([CreatePlayerSession] -> ShowS)
-> Show CreatePlayerSession
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. CreatePlayerSession -> Rep CreatePlayerSession x)
-> (forall x. Rep CreatePlayerSession x -> CreatePlayerSession)
-> Generic CreatePlayerSession
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' :: Maybe Text -> Text -> Text -> CreatePlayerSession
CreatePlayerSession'
{ $sel:playerData:CreatePlayerSession' :: Maybe Text
playerData = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> CreatePlayerSession -> f CreatePlayerSession
createPlayerSession_playerData = (CreatePlayerSession -> Maybe Text)
-> (CreatePlayerSession -> Maybe Text -> CreatePlayerSession)
-> Lens
CreatePlayerSession CreatePlayerSession (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> CreatePlayerSession -> f CreatePlayerSession
createPlayerSession_gameSessionId = (CreatePlayerSession -> Text)
-> (CreatePlayerSession -> Text -> CreatePlayerSession)
-> Lens CreatePlayerSession CreatePlayerSession Text Text
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 :: (Text -> f Text) -> CreatePlayerSession -> f CreatePlayerSession
createPlayerSession_playerId = (CreatePlayerSession -> Text)
-> (CreatePlayerSession -> Text -> CreatePlayerSession)
-> Lens CreatePlayerSession CreatePlayerSession Text Text
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 :: CreatePlayerSession -> Request CreatePlayerSession
request = Service -> CreatePlayerSession -> Request CreatePlayerSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreatePlayerSession
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePlayerSession)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreatePlayerSession))
-> Logger
-> Service
-> Proxy CreatePlayerSession
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePlayerSession)))
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 PlayerSession -> Int -> CreatePlayerSessionResponse
CreatePlayerSessionResponse'
(Maybe PlayerSession -> Int -> CreatePlayerSessionResponse)
-> Either String (Maybe PlayerSession)
-> Either String (Int -> CreatePlayerSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe PlayerSession)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PlayerSession")
Either String (Int -> CreatePlayerSessionResponse)
-> Either String Int -> Either String CreatePlayerSessionResponse
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 CreatePlayerSession
instance Prelude.NFData CreatePlayerSession
instance Core.ToHeaders CreatePlayerSession where
toHeaders :: CreatePlayerSession -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreatePlayerSession -> 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.CreatePlayerSession" ::
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 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
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,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GameSessionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gameSessionId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PlayerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
playerId)
]
)
instance Core.ToPath CreatePlayerSession where
toPath :: CreatePlayerSession -> ByteString
toPath = ByteString -> CreatePlayerSession -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreatePlayerSession where
toQuery :: CreatePlayerSession -> QueryString
toQuery = QueryString -> CreatePlayerSession -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(CreatePlayerSessionResponse
-> CreatePlayerSessionResponse -> Bool)
-> (CreatePlayerSessionResponse
-> CreatePlayerSessionResponse -> Bool)
-> Eq CreatePlayerSessionResponse
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]
(Int -> ReadS CreatePlayerSessionResponse)
-> ReadS [CreatePlayerSessionResponse]
-> ReadPrec CreatePlayerSessionResponse
-> ReadPrec [CreatePlayerSessionResponse]
-> Read 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
(Int -> CreatePlayerSessionResponse -> ShowS)
-> (CreatePlayerSessionResponse -> String)
-> ([CreatePlayerSessionResponse] -> ShowS)
-> Show CreatePlayerSessionResponse
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.
CreatePlayerSessionResponse -> Rep CreatePlayerSessionResponse x)
-> (forall x.
Rep CreatePlayerSessionResponse x -> CreatePlayerSessionResponse)
-> Generic CreatePlayerSessionResponse
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' :: Maybe PlayerSession -> Int -> CreatePlayerSessionResponse
CreatePlayerSessionResponse'
{ $sel:playerSession:CreatePlayerSessionResponse' :: Maybe PlayerSession
playerSession =
Maybe PlayerSession
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreatePlayerSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createPlayerSessionResponse_playerSession :: Lens.Lens' CreatePlayerSessionResponse (Prelude.Maybe PlayerSession)
createPlayerSessionResponse_playerSession :: (Maybe PlayerSession -> f (Maybe PlayerSession))
-> CreatePlayerSessionResponse -> f CreatePlayerSessionResponse
createPlayerSessionResponse_playerSession = (CreatePlayerSessionResponse -> Maybe PlayerSession)
-> (CreatePlayerSessionResponse
-> Maybe PlayerSession -> CreatePlayerSessionResponse)
-> Lens
CreatePlayerSessionResponse
CreatePlayerSessionResponse
(Maybe PlayerSession)
(Maybe 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 :: (Int -> f Int)
-> CreatePlayerSessionResponse -> f CreatePlayerSessionResponse
createPlayerSessionResponse_httpStatus = (CreatePlayerSessionResponse -> Int)
-> (CreatePlayerSessionResponse
-> Int -> CreatePlayerSessionResponse)
-> Lens
CreatePlayerSessionResponse CreatePlayerSessionResponse Int Int
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