create method

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

Creates a Product.

request - The metadata request object.

Request parameters:

parent - Required. The parent catalog resource name, such as `projects /

  • /locations/global/catalogs/default_catalog/branches/default_branch. Value must have pattern ^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/branches/[^/]+$`.

productId - Required. The ID to use for the Product, which will become the final component of the Product.name. If the caller does not have permission to create the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. This field must be unique among all Products with the same parent. Otherwise, an ALREADY_EXISTS error is returned. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.

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

Completes with a GoogleCloudRetailV2Product.

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<GoogleCloudRetailV2Product> create(
  GoogleCloudRetailV2Product request,
  core.String parent, {
  core.String? productId,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (productId != null) 'productId': [productId],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$parent') + '/products';

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