setInventory method
- GoogleCloudRetailV2SetInventoryRequest request,
- String name, {
- String? $fields,
Updates inventory information for a Product while respecting the last update timestamps of each inventory field.
This process is asynchronous and does not require the Product to exist
before updating fulfillment information. If the request is valid, the
update is enqueued and processed downstream. As a consequence, when a
response is returned, updates are not immediately manifested in the
Product queried by ProductService.GetProduct or
ProductService.ListProducts. When inventory is updated with
ProductService.CreateProduct and ProductService.UpdateProduct, the
specified inventory field value(s) overwrite any existing value(s) while
ignoring the last update time for this field. Furthermore, the last update
times for the specified inventory fields are overwritten by the times of
the ProductService.CreateProduct or ProductService.UpdateProduct request.
If no inventory fields are set in CreateProductRequest.product, then any
pre-existing inventory information for this product is used. If no
inventory fields are set in SetInventoryRequest.set_mask, then any
existing inventory information is preserved. Pre-existing inventory
information can only be updated with ProductService.SetInventory,
ProductService.AddFulfillmentPlaces, and
ProductService.RemoveFulfillmentPlaces. The returned Operations is
obsolete after one day, and the GetOperation API returns NOT_FOUND
afterwards. If conflicting updates are issued, the Operations associated
with the stale updates are not marked as done until they are obsolete.
request
- The metadata request object.
Request parameters:
name
- Immutable. Full resource name of the product, such as projects / * /locations/global/catalogs/default_catalog/branches/default_branch/products/product_id
.
Value must have pattern
^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+/branches/\[^/\]+/products/.*$
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a GoogleLongrunningOperation.
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<GoogleLongrunningOperation> setInventory(
GoogleCloudRetailV2SetInventoryRequest request,
core.String name, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v2/' + core.Uri.encodeFull('$name') + ':setInventory';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return GoogleLongrunningOperation.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}