createMatchmakingRuleSet method

Future<CreateMatchmakingRuleSetOutput> createMatchmakingRuleSet({
  1. required String name,
  2. required String ruleSetBody,
  3. List<Tag>? tags,
})

This API works with the following fleet types: EC2, Anywhere, Container

Creates a new rule set for FlexMatch matchmaking. A rule set describes the type of match to create, such as the number and size of teams. It also sets the parameters for acceptable player matches, such as minimum skill level or character type.

To create a matchmaking rule set, provide unique rule set name and the rule set body in JSON format. Rule sets must be defined in the same Region as the matchmaking configuration they are used with.

Since matchmaking rule sets cannot be edited, it is a good idea to check the rule set syntax using ValidateMatchmakingRuleSet before creating a new rule set.

Learn more

May throw InternalServiceException. May throw InvalidRequestException. May throw LimitExceededException. May throw TaggingFailedException. May throw UnsupportedRegionException.

Parameter name : A unique identifier for the matchmaking rule set. A matchmaking configuration identifies the rule set it uses by this name value. Note that the rule set name is different from the optional name field in the rule set body.

Parameter ruleSetBody : A collection of matchmaking rules, formatted as a JSON string. Comments are not allowed in JSON, but most elements support a description field.

Parameter tags : A list of labels to assign to the new matchmaking rule set resource. Tags are developer-defined key-value pairs. Tagging Amazon Web Services resources are useful for resource management, access management and cost allocation. For more information, see Tagging Amazon Web Services Resources in the Amazon Web Services General Reference.

Implementation

Future<CreateMatchmakingRuleSetOutput> createMatchmakingRuleSet({
  required String name,
  required String ruleSetBody,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.CreateMatchmakingRuleSet'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'RuleSetBody': ruleSetBody,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateMatchmakingRuleSetOutput.fromJson(jsonResponse.body);
}