amazonka-gamelift-1.4.3: gen/Network/AWS/GameLift/CreatePlayerSessions.hs
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.GameLift.CreatePlayerSessions
-- Copyright : (c) 2013-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds a group of players to a game session. Similar to < CreatePlayerSession>, this action allows you to add multiple players in a single call, which is useful for games that provide party and\/or matchmaking features. A game session must be in an ACTIVE state, have a creation policy of ALLOW_ALL, and have an open player slot before players can be added to the session.
--
-- To create player sessions, specify a game session ID and a list of player IDs. If successful, the players are added to the game session and a set of new < PlayerSession> objects is returned.
module Network.AWS.GameLift.CreatePlayerSessions
(
-- * Creating a Request
createPlayerSessions
, CreatePlayerSessions
-- * Request Lenses
, cpsGameSessionId
, cpsPlayerIds
-- * Destructuring the Response
, createPlayerSessionsResponse
, CreatePlayerSessionsResponse
-- * Response Lenses
, crsPlayerSessions
, crsResponseStatus
) 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
-- | Represents the input for a request action.
--
-- /See:/ 'createPlayerSessions' smart constructor.
data CreatePlayerSessions = CreatePlayerSessions'
{ _cpsGameSessionId :: !Text
, _cpsPlayerIds :: !(List1 Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'CreatePlayerSessions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'cpsGameSessionId'
--
-- * 'cpsPlayerIds'
createPlayerSessions
:: Text -- ^ 'cpsGameSessionId'
-> NonEmpty Text -- ^ 'cpsPlayerIds'
-> CreatePlayerSessions
createPlayerSessions pGameSessionId_ pPlayerIds_ =
CreatePlayerSessions'
{ _cpsGameSessionId = pGameSessionId_
, _cpsPlayerIds = _List1 # pPlayerIds_
}
-- | Unique identifier for a game session.
cpsGameSessionId :: Lens' CreatePlayerSessions Text
cpsGameSessionId = lens _cpsGameSessionId (\ s a -> s{_cpsGameSessionId = a});
-- | List of unique identifiers for the players to be added.
cpsPlayerIds :: Lens' CreatePlayerSessions (NonEmpty Text)
cpsPlayerIds = lens _cpsPlayerIds (\ s a -> s{_cpsPlayerIds = a}) . _List1;
instance AWSRequest CreatePlayerSessions where
type Rs CreatePlayerSessions =
CreatePlayerSessionsResponse
request = postJSON gameLift
response
= receiveJSON
(\ s h x ->
CreatePlayerSessionsResponse' <$>
(x .?> "PlayerSessions" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable CreatePlayerSessions
instance NFData CreatePlayerSessions
instance ToHeaders CreatePlayerSessions where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("GameLift.CreatePlayerSessions" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreatePlayerSessions where
toJSON CreatePlayerSessions'{..}
= object
(catMaybes
[Just ("GameSessionId" .= _cpsGameSessionId),
Just ("PlayerIds" .= _cpsPlayerIds)])
instance ToPath CreatePlayerSessions where
toPath = const "/"
instance ToQuery CreatePlayerSessions where
toQuery = const mempty
-- | Represents the returned data in response to a request action.
--
-- /See:/ 'createPlayerSessionsResponse' smart constructor.
data CreatePlayerSessionsResponse = CreatePlayerSessionsResponse'
{ _crsPlayerSessions :: !(Maybe [PlayerSession])
, _crsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'CreatePlayerSessionsResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'crsPlayerSessions'
--
-- * 'crsResponseStatus'
createPlayerSessionsResponse
:: Int -- ^ 'crsResponseStatus'
-> CreatePlayerSessionsResponse
createPlayerSessionsResponse pResponseStatus_ =
CreatePlayerSessionsResponse'
{ _crsPlayerSessions = Nothing
, _crsResponseStatus = pResponseStatus_
}
-- | Collection of player session objects created for the added players.
crsPlayerSessions :: Lens' CreatePlayerSessionsResponse [PlayerSession]
crsPlayerSessions = lens _crsPlayerSessions (\ s a -> s{_crsPlayerSessions = a}) . _Default . _Coerce;
-- | The response status code.
crsResponseStatus :: Lens' CreatePlayerSessionsResponse Int
crsResponseStatus = lens _crsResponseStatus (\ s a -> s{_crsResponseStatus = a});
instance NFData CreatePlayerSessionsResponse