module Network.AWS.GameLift.CreateGameSession
(
createGameSession
, CreateGameSession
, cgsGameProperties
, cgsAliasId
, cgsName
, cgsFleetId
, cgsMaximumPlayerSessionCount
, createGameSessionResponse
, CreateGameSessionResponse
, cgsrsGameSession
, cgsrsResponseStatus
) where
import Network.AWS.GameLift.Types
import Network.AWS.GameLift.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateGameSession = CreateGameSession'
{ _cgsGameProperties :: !(Maybe [GameProperty])
, _cgsAliasId :: !(Maybe Text)
, _cgsName :: !(Maybe Text)
, _cgsFleetId :: !(Maybe Text)
, _cgsMaximumPlayerSessionCount :: !Nat
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createGameSession
:: Natural
-> CreateGameSession
createGameSession pMaximumPlayerSessionCount_ =
CreateGameSession'
{ _cgsGameProperties = Nothing
, _cgsAliasId = Nothing
, _cgsName = Nothing
, _cgsFleetId = Nothing
, _cgsMaximumPlayerSessionCount = _Nat # pMaximumPlayerSessionCount_
}
cgsGameProperties :: Lens' CreateGameSession [GameProperty]
cgsGameProperties = lens _cgsGameProperties (\ s a -> s{_cgsGameProperties = a}) . _Default . _Coerce;
cgsAliasId :: Lens' CreateGameSession (Maybe Text)
cgsAliasId = lens _cgsAliasId (\ s a -> s{_cgsAliasId = a});
cgsName :: Lens' CreateGameSession (Maybe Text)
cgsName = lens _cgsName (\ s a -> s{_cgsName = a});
cgsFleetId :: Lens' CreateGameSession (Maybe Text)
cgsFleetId = lens _cgsFleetId (\ s a -> s{_cgsFleetId = a});
cgsMaximumPlayerSessionCount :: Lens' CreateGameSession Natural
cgsMaximumPlayerSessionCount = lens _cgsMaximumPlayerSessionCount (\ s a -> s{_cgsMaximumPlayerSessionCount = a}) . _Nat;
instance AWSRequest CreateGameSession where
type Rs CreateGameSession = CreateGameSessionResponse
request = postJSON gameLift
response
= receiveJSON
(\ s h x ->
CreateGameSessionResponse' <$>
(x .?> "GameSession") <*> (pure (fromEnum s)))
instance Hashable CreateGameSession
instance NFData CreateGameSession
instance ToHeaders CreateGameSession where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("GameLift.CreateGameSession" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateGameSession where
toJSON CreateGameSession'{..}
= object
(catMaybes
[("GameProperties" .=) <$> _cgsGameProperties,
("AliasId" .=) <$> _cgsAliasId,
("Name" .=) <$> _cgsName,
("FleetId" .=) <$> _cgsFleetId,
Just
("MaximumPlayerSessionCount" .=
_cgsMaximumPlayerSessionCount)])
instance ToPath CreateGameSession where
toPath = const "/"
instance ToQuery CreateGameSession where
toQuery = const mempty
data CreateGameSessionResponse = CreateGameSessionResponse'
{ _cgsrsGameSession :: !(Maybe GameSession)
, _cgsrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createGameSessionResponse
:: Int
-> CreateGameSessionResponse
createGameSessionResponse pResponseStatus_ =
CreateGameSessionResponse'
{ _cgsrsGameSession = Nothing
, _cgsrsResponseStatus = pResponseStatus_
}
cgsrsGameSession :: Lens' CreateGameSessionResponse (Maybe GameSession)
cgsrsGameSession = lens _cgsrsGameSession (\ s a -> s{_cgsrsGameSession = a});
cgsrsResponseStatus :: Lens' CreateGameSessionResponse Int
cgsrsResponseStatus = lens _cgsrsResponseStatus (\ s a -> s{_cgsrsResponseStatus = a});
instance NFData CreateGameSessionResponse