|
43 | 43 | except AttributeError: # pragma: NO COVER
|
44 | 44 | OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
45 | 45 |
|
| 46 | +from google.protobuf import field_mask_pb2 # type: ignore |
46 | 47 | from google.shopping.type.types import types
|
47 | 48 |
|
48 | 49 | from google.shopping.merchant_products_v1beta.types import (
|
@@ -334,7 +335,6 @@ async def sample_insert_product_input():
|
334 | 335 |
|
335 | 336 | # Initialize request argument(s)
|
336 | 337 | product_input = merchant_products_v1beta.ProductInput()
|
337 |
| - product_input.channel = "LOCAL" |
338 | 338 | product_input.offer_id = "offer_id_value"
|
339 | 339 | product_input.content_language = "content_language_value"
|
340 | 340 | product_input.feed_label = "feed_label_value"
|
@@ -425,6 +425,185 @@ async def sample_insert_product_input():
|
425 | 425 | # Done; return the response.
|
426 | 426 | return response
|
427 | 427 |
|
| 428 | + async def update_product_input( |
| 429 | + self, |
| 430 | + request: Optional[Union[productinputs.UpdateProductInputRequest, dict]] = None, |
| 431 | + *, |
| 432 | + product_input: Optional[productinputs.ProductInput] = None, |
| 433 | + update_mask: Optional[field_mask_pb2.FieldMask] = None, |
| 434 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 435 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
| 436 | + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), |
| 437 | + ) -> productinputs.ProductInput: |
| 438 | + r"""Updates the existing product input in your Merchant |
| 439 | + Center account. |
| 440 | + After inserting, updating, or deleting a product input, |
| 441 | + it may take several minutes before the processed product |
| 442 | + can be retrieved. |
| 443 | +
|
| 444 | + .. code-block:: python |
| 445 | +
|
| 446 | + # This snippet has been automatically generated and should be regarded as a |
| 447 | + # code template only. |
| 448 | + # It will require modifications to work: |
| 449 | + # - It may require correct/in-range values for request initialization. |
| 450 | + # - It may require specifying regional endpoints when creating the service |
| 451 | + # client as shown in: |
| 452 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html |
| 453 | + from google.shopping import merchant_products_v1beta |
| 454 | +
|
| 455 | + async def sample_update_product_input(): |
| 456 | + # Create a client |
| 457 | + client = merchant_products_v1beta.ProductInputsServiceAsyncClient() |
| 458 | +
|
| 459 | + # Initialize request argument(s) |
| 460 | + product_input = merchant_products_v1beta.ProductInput() |
| 461 | + product_input.offer_id = "offer_id_value" |
| 462 | + product_input.content_language = "content_language_value" |
| 463 | + product_input.feed_label = "feed_label_value" |
| 464 | +
|
| 465 | + request = merchant_products_v1beta.UpdateProductInputRequest( |
| 466 | + product_input=product_input, |
| 467 | + data_source="data_source_value", |
| 468 | + ) |
| 469 | +
|
| 470 | + # Make the request |
| 471 | + response = await client.update_product_input(request=request) |
| 472 | +
|
| 473 | + # Handle the response |
| 474 | + print(response) |
| 475 | +
|
| 476 | + Args: |
| 477 | + request (Optional[Union[google.shopping.merchant_products_v1beta.types.UpdateProductInputRequest, dict]]): |
| 478 | + The request object. Request message for the |
| 479 | + UpdateProductInput method. The product |
| 480 | + (primary input) must exist for the |
| 481 | + update to succeed. If the update is for |
| 482 | + a primary product input, the existing |
| 483 | + primary product input must be from the |
| 484 | + same data source. |
| 485 | + product_input (:class:`google.shopping.merchant_products_v1beta.types.ProductInput`): |
| 486 | + Required. The product input resource |
| 487 | + to update. Information you submit will |
| 488 | + be applied to the processed product as |
| 489 | + well. |
| 490 | +
|
| 491 | + This corresponds to the ``product_input`` field |
| 492 | + on the ``request`` instance; if ``request`` is provided, this |
| 493 | + should not be set. |
| 494 | + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): |
| 495 | + Optional. The list of product attributes to be updated. |
| 496 | +
|
| 497 | + If the update mask is omitted, then it is treated as |
| 498 | + implied field mask equivalent to all fields that are |
| 499 | + populated (have a non-empty value). |
| 500 | +
|
| 501 | + Attributes specified in the update mask without a value |
| 502 | + specified in the body will be deleted from the product. |
| 503 | +
|
| 504 | + Update mask can only be specified for top level fields |
| 505 | + in attributes and custom attributes. |
| 506 | +
|
| 507 | + To specify the update mask for custom attributes you |
| 508 | + need to add the ``custom_attribute.`` prefix. |
| 509 | +
|
| 510 | + Providing special "*" value for full product replacement |
| 511 | + is not supported. |
| 512 | +
|
| 513 | + This corresponds to the ``update_mask`` field |
| 514 | + on the ``request`` instance; if ``request`` is provided, this |
| 515 | + should not be set. |
| 516 | + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, |
| 517 | + should be retried. |
| 518 | + timeout (float): The timeout for this request. |
| 519 | + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be |
| 520 | + sent along with the request as metadata. Normally, each value must be of type `str`, |
| 521 | + but for metadata keys ending with the suffix `-bin`, the corresponding values must |
| 522 | + be of type `bytes`. |
| 523 | +
|
| 524 | + Returns: |
| 525 | + google.shopping.merchant_products_v1beta.types.ProductInput: |
| 526 | + This resource represents input data you submit for a product, not the |
| 527 | + processed product that you see in Merchant Center, in |
| 528 | + Shopping ads, or across Google surfaces. Product |
| 529 | + inputs, rules and supplemental data source data are |
| 530 | + combined to create the processed |
| 531 | + [Product][google.shopping.merchant.products.v1beta.Product]. |
| 532 | +
|
| 533 | + Required product input attributes to pass data |
| 534 | + validation checks are primarily defined in the |
| 535 | + [Products Data |
| 536 | + Specification](\ https://support.google.com/merchants/answer/188494). |
| 537 | +
|
| 538 | + The following attributes are required: |
| 539 | + [feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label], |
| 540 | + [contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language] |
| 541 | + and |
| 542 | + [offerId][google.shopping.merchant.products.v1beta.Product.offer_id]. |
| 543 | +
|
| 544 | + After inserting, updating, or deleting a product |
| 545 | + input, it may take several minutes before the |
| 546 | + processed product can be retrieved. |
| 547 | +
|
| 548 | + All fields in the product input and its sub-messages |
| 549 | + match the English name of their corresponding |
| 550 | + attribute in the vertical spec with [some |
| 551 | + exceptions](\ https://support.google.com/merchants/answer/7052112). |
| 552 | +
|
| 553 | + """ |
| 554 | + # Create or coerce a protobuf request object. |
| 555 | + # - Quick check: If we got a request object, we should *not* have |
| 556 | + # gotten any keyword arguments that map to the request. |
| 557 | + flattened_params = [product_input, update_mask] |
| 558 | + has_flattened_params = ( |
| 559 | + len([param for param in flattened_params if param is not None]) > 0 |
| 560 | + ) |
| 561 | + if request is not None and has_flattened_params: |
| 562 | + raise ValueError( |
| 563 | + "If the `request` argument is set, then none of " |
| 564 | + "the individual field arguments should be set." |
| 565 | + ) |
| 566 | + |
| 567 | + # - Use the request object if provided (there's no risk of modifying the input as |
| 568 | + # there are no flattened fields), or create one. |
| 569 | + if not isinstance(request, productinputs.UpdateProductInputRequest): |
| 570 | + request = productinputs.UpdateProductInputRequest(request) |
| 571 | + |
| 572 | + # If we have keyword arguments corresponding to fields on the |
| 573 | + # request, apply these. |
| 574 | + if product_input is not None: |
| 575 | + request.product_input = product_input |
| 576 | + if update_mask is not None: |
| 577 | + request.update_mask = update_mask |
| 578 | + |
| 579 | + # Wrap the RPC method; this adds retry and timeout information, |
| 580 | + # and friendly error handling. |
| 581 | + rpc = self._client._transport._wrapped_methods[ |
| 582 | + self._client._transport.update_product_input |
| 583 | + ] |
| 584 | + |
| 585 | + # Certain fields should be provided within the metadata header; |
| 586 | + # add these here. |
| 587 | + metadata = tuple(metadata) + ( |
| 588 | + gapic_v1.routing_header.to_grpc_metadata( |
| 589 | + (("product_input.name", request.product_input.name),) |
| 590 | + ), |
| 591 | + ) |
| 592 | + |
| 593 | + # Validate the universe domain. |
| 594 | + self._client._validate_universe_domain() |
| 595 | + |
| 596 | + # Send the request. |
| 597 | + response = await rpc( |
| 598 | + request, |
| 599 | + retry=retry, |
| 600 | + timeout=timeout, |
| 601 | + metadata=metadata, |
| 602 | + ) |
| 603 | + |
| 604 | + # Done; return the response. |
| 605 | + return response |
| 606 | + |
428 | 607 | async def delete_product_input(
|
429 | 608 | self,
|
430 | 609 | request: Optional[Union[productinputs.DeleteProductInputRequest, dict]] = None,
|
|
0 commit comments