1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package gamelift
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/gamelift/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Reserves open slots in a game session for a group of players. New player
15// sessions can be created in any game session with an open slot that is in ACTIVE
16// status and has a player creation policy of ACCEPT_ALL. To add a single player to
17// a game session, use CreatePlayerSession. To create player sessions, specify a
18// game session ID and a list of player IDs. Optionally, provide a set of player
19// data for each player ID. If successful, a slot is reserved in the game session
20// for each player, and new PlayerSession objects are returned with player session
21// IDs. Each player references their player session ID when sending a connection
22// request to the game session, and the game server can use it to validate the
23// player reservation with the GameLift service. Player sessions cannot be updated.
24// Available in Amazon GameLift Local. Related actions CreatePlayerSession |
25// CreatePlayerSessions | DescribePlayerSessions | StartGameSessionPlacement |
26// DescribeGameSessionPlacement | All APIs by task
27// (https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets)
28func (c *Client) CreatePlayerSessions(ctx context.Context, params *CreatePlayerSessionsInput, optFns ...func(*Options)) (*CreatePlayerSessionsOutput, error) {
29	if params == nil {
30		params = &CreatePlayerSessionsInput{}
31	}
32
33	result, metadata, err := c.invokeOperation(ctx, "CreatePlayerSessions", params, optFns, addOperationCreatePlayerSessionsMiddlewares)
34	if err != nil {
35		return nil, err
36	}
37
38	out := result.(*CreatePlayerSessionsOutput)
39	out.ResultMetadata = metadata
40	return out, nil
41}
42
43// Represents the input for a request operation.
44type CreatePlayerSessionsInput struct {
45
46	// A unique identifier for the game session to add players to.
47	//
48	// This member is required.
49	GameSessionId *string
50
51	// List of unique identifiers for the players to be added.
52	//
53	// This member is required.
54	PlayerIds []string
55
56	// Map of string pairs, each specifying a player ID and a set of developer-defined
57	// information related to the player. Amazon GameLift does not use this data, so it
58	// can be formatted as needed for use in the game. Any player data strings for
59	// player IDs that are not included in the PlayerIds parameter are ignored.
60	PlayerDataMap map[string]string
61}
62
63// Represents the returned data in response to a request operation.
64type CreatePlayerSessionsOutput struct {
65
66	// A collection of player session objects created for the added players.
67	PlayerSessions []types.PlayerSession
68
69	// Metadata pertaining to the operation's result.
70	ResultMetadata middleware.Metadata
71}
72
73func addOperationCreatePlayerSessionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
74	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreatePlayerSessions{}, middleware.After)
75	if err != nil {
76		return err
77	}
78	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreatePlayerSessions{}, middleware.After)
79	if err != nil {
80		return err
81	}
82	if err = addSetLoggerMiddleware(stack, options); err != nil {
83		return err
84	}
85	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
86		return err
87	}
88	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
89		return err
90	}
91	if err = addResolveEndpointMiddleware(stack, options); err != nil {
92		return err
93	}
94	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
95		return err
96	}
97	if err = addRetryMiddlewares(stack, options); err != nil {
98		return err
99	}
100	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
101		return err
102	}
103	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
104		return err
105	}
106	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
107		return err
108	}
109	if err = addClientUserAgent(stack); err != nil {
110		return err
111	}
112	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
113		return err
114	}
115	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addOpCreatePlayerSessionsValidationMiddleware(stack); err != nil {
119		return err
120	}
121	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreatePlayerSessions(options.Region), middleware.Before); err != nil {
122		return err
123	}
124	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addResponseErrorMiddleware(stack); err != nil {
128		return err
129	}
130	if err = addRequestResponseLogging(stack, options); err != nil {
131		return err
132	}
133	return nil
134}
135
136func newServiceMetadataMiddleware_opCreatePlayerSessions(region string) *awsmiddleware.RegisterServiceMetadata {
137	return &awsmiddleware.RegisterServiceMetadata{
138		Region:        region,
139		ServiceID:     ServiceID,
140		SigningName:   "gamelift",
141		OperationName: "CreatePlayerSessions",
142	}
143}
144