1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package gamelift 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/gamelift/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Retrieves the details for FlexMatch matchmaking rule sets. You can request all 16// existing rule sets for the Region, or provide a list of one or more rule set 17// names. When requesting multiple items, use the pagination parameters to retrieve 18// results as a set of sequential pages. If successful, a rule set is returned for 19// each requested name. Learn more 20// 21// * Build a Rule Set 22// (https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-rulesets.html) 23// 24// Related 25// operations 26// 27// * CreateMatchmakingConfiguration 28// 29// * 30// DescribeMatchmakingConfigurations 31// 32// * UpdateMatchmakingConfiguration 33// 34// * 35// DeleteMatchmakingConfiguration 36// 37// * CreateMatchmakingRuleSet 38// 39// * 40// DescribeMatchmakingRuleSets 41// 42// * ValidateMatchmakingRuleSet 43// 44// * 45// DeleteMatchmakingRuleSet 46func (c *Client) DescribeMatchmakingRuleSets(ctx context.Context, params *DescribeMatchmakingRuleSetsInput, optFns ...func(*Options)) (*DescribeMatchmakingRuleSetsOutput, error) { 47 if params == nil { 48 params = &DescribeMatchmakingRuleSetsInput{} 49 } 50 51 result, metadata, err := c.invokeOperation(ctx, "DescribeMatchmakingRuleSets", params, optFns, addOperationDescribeMatchmakingRuleSetsMiddlewares) 52 if err != nil { 53 return nil, err 54 } 55 56 out := result.(*DescribeMatchmakingRuleSetsOutput) 57 out.ResultMetadata = metadata 58 return out, nil 59} 60 61// Represents the input for a request operation. 62type DescribeMatchmakingRuleSetsInput struct { 63 64 // The maximum number of results to return. Use this parameter with NextToken to 65 // get results as a set of sequential pages. 66 Limit *int32 67 68 // A list of one or more matchmaking rule set names to retrieve details for. (Note: 69 // The rule set name is different from the optional "name" field in the rule set 70 // body.) You can use either the rule set name or ARN value. 71 Names []string 72 73 // A token that indicates the start of the next sequential page of results. Use the 74 // token that is returned with a previous call to this operation. To start at the 75 // beginning of the result set, do not specify a value. 76 NextToken *string 77} 78 79// Represents the returned data in response to a request operation. 80type DescribeMatchmakingRuleSetsOutput struct { 81 82 // A collection of requested matchmaking rule set objects. 83 // 84 // This member is required. 85 RuleSets []types.MatchmakingRuleSet 86 87 // A token that indicates where to resume retrieving results on the next call to 88 // this operation. If no token is returned, these results represent the end of the 89 // list. 90 NextToken *string 91 92 // Metadata pertaining to the operation's result. 93 ResultMetadata middleware.Metadata 94} 95 96func addOperationDescribeMatchmakingRuleSetsMiddlewares(stack *middleware.Stack, options Options) (err error) { 97 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeMatchmakingRuleSets{}, middleware.After) 98 if err != nil { 99 return err 100 } 101 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeMatchmakingRuleSets{}, middleware.After) 102 if err != nil { 103 return err 104 } 105 if err = addSetLoggerMiddleware(stack, options); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 112 return err 113 } 114 if err = addResolveEndpointMiddleware(stack, options); err != nil { 115 return err 116 } 117 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 118 return err 119 } 120 if err = addRetryMiddlewares(stack, options); err != nil { 121 return err 122 } 123 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 124 return err 125 } 126 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 127 return err 128 } 129 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 130 return err 131 } 132 if err = addClientUserAgent(stack); err != nil { 133 return err 134 } 135 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 136 return err 137 } 138 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 139 return err 140 } 141 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeMatchmakingRuleSets(options.Region), middleware.Before); err != nil { 142 return err 143 } 144 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 145 return err 146 } 147 if err = addResponseErrorMiddleware(stack); err != nil { 148 return err 149 } 150 if err = addRequestResponseLogging(stack, options); err != nil { 151 return err 152 } 153 return nil 154} 155 156// DescribeMatchmakingRuleSetsAPIClient is a client that implements the 157// DescribeMatchmakingRuleSets operation. 158type DescribeMatchmakingRuleSetsAPIClient interface { 159 DescribeMatchmakingRuleSets(context.Context, *DescribeMatchmakingRuleSetsInput, ...func(*Options)) (*DescribeMatchmakingRuleSetsOutput, error) 160} 161 162var _ DescribeMatchmakingRuleSetsAPIClient = (*Client)(nil) 163 164// DescribeMatchmakingRuleSetsPaginatorOptions is the paginator options for 165// DescribeMatchmakingRuleSets 166type DescribeMatchmakingRuleSetsPaginatorOptions struct { 167 // The maximum number of results to return. Use this parameter with NextToken to 168 // get results as a set of sequential pages. 169 Limit int32 170 171 // Set to true if pagination should stop if the service returns a pagination token 172 // that matches the most recent token provided to the service. 173 StopOnDuplicateToken bool 174} 175 176// DescribeMatchmakingRuleSetsPaginator is a paginator for 177// DescribeMatchmakingRuleSets 178type DescribeMatchmakingRuleSetsPaginator struct { 179 options DescribeMatchmakingRuleSetsPaginatorOptions 180 client DescribeMatchmakingRuleSetsAPIClient 181 params *DescribeMatchmakingRuleSetsInput 182 nextToken *string 183 firstPage bool 184} 185 186// NewDescribeMatchmakingRuleSetsPaginator returns a new 187// DescribeMatchmakingRuleSetsPaginator 188func NewDescribeMatchmakingRuleSetsPaginator(client DescribeMatchmakingRuleSetsAPIClient, params *DescribeMatchmakingRuleSetsInput, optFns ...func(*DescribeMatchmakingRuleSetsPaginatorOptions)) *DescribeMatchmakingRuleSetsPaginator { 189 options := DescribeMatchmakingRuleSetsPaginatorOptions{} 190 if params.Limit != nil { 191 options.Limit = *params.Limit 192 } 193 194 for _, fn := range optFns { 195 fn(&options) 196 } 197 198 if params == nil { 199 params = &DescribeMatchmakingRuleSetsInput{} 200 } 201 202 return &DescribeMatchmakingRuleSetsPaginator{ 203 options: options, 204 client: client, 205 params: params, 206 firstPage: true, 207 } 208} 209 210// HasMorePages returns a boolean indicating whether more pages are available 211func (p *DescribeMatchmakingRuleSetsPaginator) HasMorePages() bool { 212 return p.firstPage || p.nextToken != nil 213} 214 215// NextPage retrieves the next DescribeMatchmakingRuleSets page. 216func (p *DescribeMatchmakingRuleSetsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeMatchmakingRuleSetsOutput, error) { 217 if !p.HasMorePages() { 218 return nil, fmt.Errorf("no more pages available") 219 } 220 221 params := *p.params 222 params.NextToken = p.nextToken 223 224 var limit *int32 225 if p.options.Limit > 0 { 226 limit = &p.options.Limit 227 } 228 params.Limit = limit 229 230 result, err := p.client.DescribeMatchmakingRuleSets(ctx, ¶ms, optFns...) 231 if err != nil { 232 return nil, err 233 } 234 p.firstPage = false 235 236 prevToken := p.nextToken 237 p.nextToken = result.NextToken 238 239 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 240 p.nextToken = nil 241 } 242 243 return result, nil 244} 245 246func newServiceMetadataMiddleware_opDescribeMatchmakingRuleSets(region string) *awsmiddleware.RegisterServiceMetadata { 247 return &awsmiddleware.RegisterServiceMetadata{ 248 Region: region, 249 ServiceID: ServiceID, 250 SigningName: "gamelift", 251 OperationName: "DescribeMatchmakingRuleSets", 252 } 253} 254