create method

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

Creates and returns a new ProductSet resource.

Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.

request - The metadata request object.

Request parameters:

parent - Required. The project in which the ProductSet should be created. Format is projects/PROJECT_ID/locations/LOC_ID. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+$.

productSetId - A user-supplied resource id for this ProductSet. 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 ProductSet.

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

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

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