Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
DeleteProductInputRequest,
InsertProductInputRequest,
ProductInput,
UpdateProductInputRequest,
)
from google.shopping.merchant_products_v1beta.types.products import (
GetProductRequest,
Expand All @@ -54,6 +55,7 @@
ProductStatus,
ProductStructuredDescription,
ProductStructuredTitle,
ProductSustainabilityIncentive,
ProductWeight,
Shipping,
ShippingDimension,
Expand All @@ -73,6 +75,7 @@
"DeleteProductInputRequest",
"InsertProductInputRequest",
"ProductInput",
"UpdateProductInputRequest",
"GetProductRequest",
"ListProductsRequest",
"ListProductsResponse",
Expand All @@ -89,6 +92,7 @@
"ProductStatus",
"ProductStructuredDescription",
"ProductStructuredTitle",
"ProductSustainabilityIncentive",
"ProductWeight",
"Shipping",
"ShippingDimension",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
DeleteProductInputRequest,
InsertProductInputRequest,
ProductInput,
UpdateProductInputRequest,
)
from .types.products import (
GetProductRequest,
Expand All @@ -47,6 +48,7 @@
ProductStatus,
ProductStructuredDescription,
ProductStructuredTitle,
ProductSustainabilityIncentive,
ProductWeight,
Shipping,
ShippingDimension,
Expand Down Expand Up @@ -81,6 +83,7 @@
"ProductStatus",
"ProductStructuredDescription",
"ProductStructuredTitle",
"ProductSustainabilityIncentive",
"ProductWeight",
"ProductsServiceClient",
"Shipping",
Expand All @@ -91,4 +94,5 @@
"Tax",
"UnitPricingBaseMeasure",
"UnitPricingMeasure",
"UpdateProductInputRequest",
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"methods": [
"insert_product_input"
]
},
"UpdateProductInput": {
"methods": [
"update_product_input"
]
}
}
},
Expand All @@ -34,6 +39,11 @@
"methods": [
"insert_product_input"
]
},
"UpdateProductInput": {
"methods": [
"update_product_input"
]
}
}
},
Expand All @@ -49,6 +59,11 @@
"methods": [
"insert_product_input"
]
},
"UpdateProductInput": {
"methods": [
"update_product_input"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore

from google.protobuf import field_mask_pb2 # type: ignore
from google.shopping.type.types import types

from google.shopping.merchant_products_v1beta.types import (
Expand Down Expand Up @@ -334,7 +335,6 @@ async def sample_insert_product_input():

# Initialize request argument(s)
product_input = merchant_products_v1beta.ProductInput()
product_input.channel = "LOCAL"
product_input.offer_id = "offer_id_value"
product_input.content_language = "content_language_value"
product_input.feed_label = "feed_label_value"
Expand Down Expand Up @@ -425,6 +425,185 @@ async def sample_insert_product_input():
# Done; return the response.
return response

async def update_product_input(
self,
request: Optional[Union[productinputs.UpdateProductInputRequest, dict]] = None,
*,
product_input: Optional[productinputs.ProductInput] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> productinputs.ProductInput:
r"""Updates the existing product input in your Merchant
Center account.
After inserting, updating, or deleting a product input,
it may take several minutes before the processed product
can be retrieved.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.shopping import merchant_products_v1beta

async def sample_update_product_input():
# Create a client
client = merchant_products_v1beta.ProductInputsServiceAsyncClient()

# Initialize request argument(s)
product_input = merchant_products_v1beta.ProductInput()
product_input.offer_id = "offer_id_value"
product_input.content_language = "content_language_value"
product_input.feed_label = "feed_label_value"

request = merchant_products_v1beta.UpdateProductInputRequest(
product_input=product_input,
data_source="data_source_value",
)

# Make the request
response = await client.update_product_input(request=request)

# Handle the response
print(response)

Args:
request (Optional[Union[google.shopping.merchant_products_v1beta.types.UpdateProductInputRequest, dict]]):
The request object. Request message for the
UpdateProductInput method. The product
(primary input) must exist for the
update to succeed. If the update is for
a primary product input, the existing
primary product input must be from the
same data source.
product_input (:class:`google.shopping.merchant_products_v1beta.types.ProductInput`):
Required. The product input resource
to update. Information you submit will
be applied to the processed product as
well.

This corresponds to the ``product_input`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Optional. The list of product attributes to be updated.

If the update mask is omitted, then it is treated as
implied field mask equivalent to all fields that are
populated (have a non-empty value).

Attributes specified in the update mask without a value
specified in the body will be deleted from the product.

Update mask can only be specified for top level fields
in attributes and custom attributes.

To specify the update mask for custom attributes you
need to add the ``custom_attribute.`` prefix.

Providing special "*" value for full product replacement
is not supported.

This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.

Returns:
google.shopping.merchant_products_v1beta.types.ProductInput:
This resource represents input data you submit for a product, not the
processed product that you see in Merchant Center, in
Shopping ads, or across Google surfaces. Product
inputs, rules and supplemental data source data are
combined to create the processed
[Product][google.shopping.merchant.products.v1beta.Product].

Required product input attributes to pass data
validation checks are primarily defined in the
[Products Data
Specification](\ https://support.google.com/merchants/answer/188494).

The following attributes are required:
[feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label],
[contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language]
and
[offerId][google.shopping.merchant.products.v1beta.Product.offer_id].

After inserting, updating, or deleting a product
input, it may take several minutes before the
processed product can be retrieved.

All fields in the product input and its sub-messages
match the English name of their corresponding
attribute in the vertical spec with [some
exceptions](\ https://support.google.com/merchants/answer/7052112).

"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
flattened_params = [product_input, update_mask]
has_flattened_params = (
len([param for param in flattened_params if param is not None]) > 0
)
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, productinputs.UpdateProductInputRequest):
request = productinputs.UpdateProductInputRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if product_input is not None:
request.product_input = product_input
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.update_product_input
]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("product_input.name", request.product_input.name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def delete_product_input(
self,
request: Optional[Union[productinputs.DeleteProductInputRequest, dict]] = None,
Expand Down
Loading