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// Registers a player's acceptance or rejection of a proposed FlexMatch match. A
15// matchmaking configuration may require player acceptance; if so, then matches
16// built with that configuration cannot be completed unless all players accept the
17// proposed match within a specified time limit. When FlexMatch builds a match, all
18// the matchmaking tickets involved in the proposed match are placed into status
19// REQUIRES_ACCEPTANCE. This is a trigger for your game to get acceptance from all
20// players in the ticket. Acceptances are only valid for tickets when they are in
21// this status; all other acceptances result in an error. To register acceptance,
22// specify the ticket ID, a response, and one or more players. Once all players
23// have registered acceptance, the matchmaking tickets advance to status PLACING,
24// where a new game session is created for the match. If any player rejects the
25// match, or if acceptances are not received before a specified timeout, the
26// proposed match is dropped. The matchmaking tickets are then handled in one of
27// two ways: For tickets where one or more players rejected the match, the ticket
28// status is returned to SEARCHING to find a new match. For tickets where one or
29// more players failed to respond, the ticket status is set to CANCELLED, and
30// processing is terminated. A new matchmaking request for these players can be
31// submitted as needed. Learn more  Add FlexMatch to a Game Client
32// (https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-client.html)
33// FlexMatch Events Reference
34// (https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-events.html)
35// Related operations
36//
37// * StartMatchmaking
38//
39// * DescribeMatchmaking
40//
41// *
42// StopMatchmaking
43//
44// * AcceptMatch
45//
46// * StartMatchBackfill
47func (c *Client) AcceptMatch(ctx context.Context, params *AcceptMatchInput, optFns ...func(*Options)) (*AcceptMatchOutput, error) {
48	if params == nil {
49		params = &AcceptMatchInput{}
50	}
51
52	result, metadata, err := c.invokeOperation(ctx, "AcceptMatch", params, optFns, addOperationAcceptMatchMiddlewares)
53	if err != nil {
54		return nil, err
55	}
56
57	out := result.(*AcceptMatchOutput)
58	out.ResultMetadata = metadata
59	return out, nil
60}
61
62// Represents the input for a request operation.
63type AcceptMatchInput struct {
64
65	// Player response to the proposed match.
66	//
67	// This member is required.
68	AcceptanceType types.AcceptanceType
69
70	// A unique identifier for a player delivering the response. This parameter can
71	// include one or multiple player IDs.
72	//
73	// This member is required.
74	PlayerIds []string
75
76	// A unique identifier for a matchmaking ticket. The ticket must be in status
77	// REQUIRES_ACCEPTANCE; otherwise this request will fail.
78	//
79	// This member is required.
80	TicketId *string
81}
82
83type AcceptMatchOutput struct {
84	// Metadata pertaining to the operation's result.
85	ResultMetadata middleware.Metadata
86}
87
88func addOperationAcceptMatchMiddlewares(stack *middleware.Stack, options Options) (err error) {
89	err = stack.Serialize.Add(&awsAwsjson11_serializeOpAcceptMatch{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAcceptMatch{}, middleware.After)
94	if err != nil {
95		return err
96	}
97	if err = addSetLoggerMiddleware(stack, options); err != nil {
98		return err
99	}
100	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
104		return err
105	}
106	if err = addResolveEndpointMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
110		return err
111	}
112	if err = addRetryMiddlewares(stack, options); err != nil {
113		return err
114	}
115	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
122		return err
123	}
124	if err = addClientUserAgent(stack); err != nil {
125		return err
126	}
127	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
131		return err
132	}
133	if err = addOpAcceptMatchValidationMiddleware(stack); err != nil {
134		return err
135	}
136	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAcceptMatch(options.Region), middleware.Before); err != nil {
137		return err
138	}
139	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
140		return err
141	}
142	if err = addResponseErrorMiddleware(stack); err != nil {
143		return err
144	}
145	if err = addRequestResponseLogging(stack, options); err != nil {
146		return err
147	}
148	return nil
149}
150
151func newServiceMetadataMiddleware_opAcceptMatch(region string) *awsmiddleware.RegisterServiceMetadata {
152	return &awsmiddleware.RegisterServiceMetadata{
153		Region:        region,
154		ServiceID:     ServiceID,
155		SigningName:   "gamelift",
156		OperationName: "AcceptMatch",
157	}
158}
159