Skip to content

Commit 5cde00f

Browse files
feat: [google-shopping-merchant-products] add an update method (#13667)
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Add an update method docs: A comment for message `ProductInput` is changed docs: A comment for field `channel` in message `.google.shopping.merchant.products.v1beta.ProductInput` is changed docs: A comment for field `data_source` in message `.google.shopping.merchant.products.v1beta.InsertProductInputRequest` is changed END_COMMIT_OVERRIDE PiperOrigin-RevId: 737402434 Source-Link: googleapis/googleapis@bc7f715 Source-Link: googleapis/googleapis-gen@020db0d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLW1lcmNoYW50LXByb2R1Y3RzLy5Pd2xCb3QueWFtbCIsImgiOiIwMjBkYjBkZGJjYzdhMzc4ZGNhZmU4NzY2YTAzYzAyNDNjYjE4MDZjIn0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 9b5ba99 commit 5cde00f

21 files changed

+2705
-396
lines changed

packages/google-shopping-merchant-products/google/shopping/merchant_products/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
DeleteProductInputRequest,
3535
InsertProductInputRequest,
3636
ProductInput,
37+
UpdateProductInputRequest,
3738
)
3839
from google.shopping.merchant_products_v1beta.types.products import (
3940
GetProductRequest,
@@ -54,6 +55,7 @@
5455
ProductStatus,
5556
ProductStructuredDescription,
5657
ProductStructuredTitle,
58+
ProductSustainabilityIncentive,
5759
ProductWeight,
5860
Shipping,
5961
ShippingDimension,
@@ -73,6 +75,7 @@
7375
"DeleteProductInputRequest",
7476
"InsertProductInputRequest",
7577
"ProductInput",
78+
"UpdateProductInputRequest",
7679
"GetProductRequest",
7780
"ListProductsRequest",
7881
"ListProductsResponse",
@@ -89,6 +92,7 @@
8992
"ProductStatus",
9093
"ProductStructuredDescription",
9194
"ProductStructuredTitle",
95+
"ProductSustainabilityIncentive",
9296
"ProductWeight",
9397
"Shipping",
9498
"ShippingDimension",

packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
DeleteProductInputRequest,
2828
InsertProductInputRequest,
2929
ProductInput,
30+
UpdateProductInputRequest,
3031
)
3132
from .types.products import (
3233
GetProductRequest,
@@ -47,6 +48,7 @@
4748
ProductStatus,
4849
ProductStructuredDescription,
4950
ProductStructuredTitle,
51+
ProductSustainabilityIncentive,
5052
ProductWeight,
5153
Shipping,
5254
ShippingDimension,
@@ -81,6 +83,7 @@
8183
"ProductStatus",
8284
"ProductStructuredDescription",
8385
"ProductStructuredTitle",
86+
"ProductSustainabilityIncentive",
8487
"ProductWeight",
8588
"ProductsServiceClient",
8689
"Shipping",
@@ -91,4 +94,5 @@
9194
"Tax",
9295
"UnitPricingBaseMeasure",
9396
"UnitPricingMeasure",
97+
"UpdateProductInputRequest",
9498
)

packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"methods": [
2020
"insert_product_input"
2121
]
22+
},
23+
"UpdateProductInput": {
24+
"methods": [
25+
"update_product_input"
26+
]
2227
}
2328
}
2429
},
@@ -34,6 +39,11 @@
3439
"methods": [
3540
"insert_product_input"
3641
]
42+
},
43+
"UpdateProductInput": {
44+
"methods": [
45+
"update_product_input"
46+
]
3747
}
3848
}
3949
},
@@ -49,6 +59,11 @@
4959
"methods": [
5060
"insert_product_input"
5161
]
62+
},
63+
"UpdateProductInput": {
64+
"methods": [
65+
"update_product_input"
66+
]
5267
}
5368
}
5469
}

packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/async_client.py

Lines changed: 180 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
except AttributeError: # pragma: NO COVER
4444
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
4545

46+
from google.protobuf import field_mask_pb2 # type: ignore
4647
from google.shopping.type.types import types
4748

4849
from google.shopping.merchant_products_v1beta.types import (
@@ -334,7 +335,6 @@ async def sample_insert_product_input():
334335
335336
# Initialize request argument(s)
336337
product_input = merchant_products_v1beta.ProductInput()
337-
product_input.channel = "LOCAL"
338338
product_input.offer_id = "offer_id_value"
339339
product_input.content_language = "content_language_value"
340340
product_input.feed_label = "feed_label_value"
@@ -425,6 +425,185 @@ async def sample_insert_product_input():
425425
# Done; return the response.
426426
return response
427427

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+
428607
async def delete_product_input(
429608
self,
430609
request: Optional[Union[productinputs.DeleteProductInputRequest, dict]] = None,

0 commit comments

Comments
 (0)