createLimit method

Future<CreateLimitResponse> createLimit({
  1. required String amountRequirementName,
  2. required String displayName,
  3. required String farmId,
  4. required int maxCount,
  5. String? clientToken,
  6. String? description,
})

Creates a limit that manages the distribution of shared resources, such as floating licenses. A limit can throttle work assignments, help manage workloads, and track current usage. Before you use a limit, you must associate the limit with one or more queues.

You must add the amountRequirementName to a step in a job template to declare the limit requirement.

May throw AccessDeniedException. May throw InternalServerErrorException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter amountRequirementName : The value that you specify as the name in the amounts field of the hostRequirements in a step of a job template to declare the limit requirement.

Parameter displayName : The display name of the limit.

Parameter farmId : The farm ID of the farm that contains the limit.

Parameter maxCount : The maximum number of resources constrained by this limit. When all of the resources are in use, steps that require the limit won't be scheduled until the resource is available.

The maxCount must not be 0. If the value is -1, there is no restriction on the number of resources that can be acquired for this limit.

Parameter clientToken : The unique token which the server uses to recognize retries of the same request.

Parameter description : A description of the limit. A description helps you identify the purpose of the limit.

Implementation

Future<CreateLimitResponse> createLimit({
  required String amountRequirementName,
  required String displayName,
  required String farmId,
  required int maxCount,
  String? clientToken,
  String? description,
}) async {
  _s.validateNumRange(
    'maxCount',
    maxCount,
    -1,
    2147483647,
    isRequired: true,
  );
  final headers = <String, String>{
    if (clientToken != null) 'X-Amz-Client-Token': clientToken.toString(),
  };
  final $payload = <String, dynamic>{
    'amountRequirementName': amountRequirementName,
    'displayName': displayName,
    'maxCount': maxCount,
    if (description != null) 'description': description,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/2023-10-12/farms/${Uri.encodeComponent(farmId)}/limits',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreateLimitResponse.fromJson(response);
}