createEndpoint method

Future<CreateEndpointResponse> createEndpoint({
  1. required int desiredInferenceUnits,
  2. required String endpointName,
  3. required String modelArn,
  4. String? clientRequestToken,
  5. List<Tag>? tags,
})

Creates a model-specific endpoint for synchronous inference for a previously trained custom model

May throw InvalidRequestException. May throw ResourceInUseException. May throw ResourceLimitExceededException. May throw ResourceNotFoundException. May throw ResourceUnavailableException. May throw TooManyRequestsException. May throw TooManyTagsException. May throw InternalServerException.

Parameter desiredInferenceUnits : The desired number of inference units to be used by the model using this endpoint. Each inference unit represents of a throughput of 100 characters per second.

Parameter endpointName : This is the descriptive suffix that becomes part of the EndpointArn used for all subsequent requests to this resource.

Parameter modelArn : The Amazon Resource Number (ARN) of the model to which the endpoint will be attached.

Parameter clientRequestToken : An idempotency token provided by the customer. If this token matches a previous endpoint creation request, Amazon Comprehend will not return a ResourceInUseException.

Parameter tags : Tags associated with the endpoint being created. A tag is a key-value pair that adds metadata to the endpoint. For example, a tag with "Sales" as the key might be added to an endpoint to indicate its use by the sales department.

Implementation

Future<CreateEndpointResponse> createEndpoint({
  required int desiredInferenceUnits,
  required String endpointName,
  required String modelArn,
  String? clientRequestToken,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(desiredInferenceUnits, 'desiredInferenceUnits');
  _s.validateNumRange(
    'desiredInferenceUnits',
    desiredInferenceUnits,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(endpointName, 'endpointName');
  _s.validateStringLength(
    'endpointName',
    endpointName,
    0,
    40,
    isRequired: true,
  );
  ArgumentError.checkNotNull(modelArn, 'modelArn');
  _s.validateStringLength(
    'modelArn',
    modelArn,
    0,
    256,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    64,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Comprehend_20171127.CreateEndpoint'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DesiredInferenceUnits': desiredInferenceUnits,
      'EndpointName': endpointName,
      'ModelArn': modelArn,
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateEndpointResponse.fromJson(jsonResponse.body);
}