create method

Future<ReferenceImage> create(
  1. ReferenceImage request,
  2. String parent, {
  3. String? referenceImageId,
  4. String? $fields,
})

Creates and returns a new ReferenceImage resource.

The bounding_poly field is optional. If bounding_poly is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected.

  • Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.

request - The metadata request object.

Request parameters:

parent - Required. Resource name of the product in which to create the reference image. Format is projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/products/\[^/\]+$.

referenceImageId - A user-supplied resource id for the ReferenceImage to be added. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character /.

$fields - Selector specifying which fields to include in a partial response.

Completes with a ReferenceImage.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<ReferenceImage> create(
  ReferenceImage request,
  core.String parent, {
  core.String? referenceImageId,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (referenceImageId != null) 'referenceImageId': [referenceImageId],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/referenceImages';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return ReferenceImage.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}