Skip to content

Commit

Permalink
feat: [google-shopping-merchant-products] Add support for opt-in debu…
Browse files Browse the repository at this point in the history
…g logging (#13333)

BEGIN_COMMIT_OVERRIDE

feat: Add support for opt-in debug logging
fix: Fix typing issue with gRPC metadata when key ends in -bin
chore: Update gapic-generator-python to v1.21.0
fix!: Changed repeated flag of an existing field `gtin` in message
`.google.shopping.merchant.products.v1beta.Attributes`
fix!: An existing field `gtin` is moved out of oneof in message
`.google.shopping.merchant.products.v1beta.Attributes`
docs: A comment for message `ProductInput` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.ProductInput` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.DeleteProductInputRequest` is
changed
docs: A comment for message `Product` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.Product` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.GetProductRequest` is changed
docs: A comment for field `page_size` in message
`.google.shopping.merchant.products.v1beta.ListProductsRequest` is
changed
docs: A comment for field `gtin` in message
`.google.shopping.merchant.products.v1beta.Attributes` is changed
docs: A comment for field `tax_category` in message
`.google.shopping.merchant.products.v1beta.Attributes` is changed
docs: A comment for field `min_handling_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
docs: A comment for field `max_handling_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
docs: A comment for field `min_transit_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
docs: A comment for field `max_transit_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
feat: A new field `member_price_effective_date` is added to message
`.google.shopping.merchant.products.v1beta.LoyaltyProgram`
feat: A new field `shipping_label` is added to message
`.google.shopping.merchant.products.v1beta.LoyaltyProgram`

END_COMMIT_OVERRIDE

- [ ] Regenerate this pull request now.

fix: Fix typing issue with gRPC metadata when key ends in -bin
chore: Update gapic-generator-python to v1.21.0

PiperOrigin-RevId: 705285820

Source-Link:
googleapis/googleapis@f9b8b91

Source-Link:
googleapis/googleapis-gen@ca1e0a1
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLW1lcmNoYW50LXByb2R1Y3RzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0=

BEGIN_NESTED_COMMIT
fix!: [google-shopping-merchant-products] Changed repeated flag of an
existing field `gtin` in message
`.google.shopping.merchant.products.v1beta.Attributes`
fix!: An existing field `gtin` is moved out of oneof in message
`.google.shopping.merchant.products.v1beta.Attributes`
docs: A comment for message `ProductInput` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.ProductInput` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.DeleteProductInputRequest` is
changed
docs: A comment for message `Product` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.Product` is changed
docs: A comment for field `name` in message
`.google.shopping.merchant.products.v1beta.GetProductRequest` is changed
docs: A comment for field `page_size` in message
`.google.shopping.merchant.products.v1beta.ListProductsRequest` is
changed
docs: A comment for field `gtin` in message
`.google.shopping.merchant.products.v1beta.Attributes` is changed
docs: A comment for field `tax_category` in message
`.google.shopping.merchant.products.v1beta.Attributes` is changed
docs: A comment for field `min_handling_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
docs: A comment for field `max_handling_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
docs: A comment for field `min_transit_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
docs: A comment for field `max_transit_time` in message
`.google.shopping.merchant.products.v1beta.Shipping` is changed
feat: A new field `member_price_effective_date` is added to message
`.google.shopping.merchant.products.v1beta.LoyaltyProgram`
feat: A new field `shipping_label` is added to message
`.google.shopping.merchant.products.v1beta.LoyaltyProgram`

PiperOrigin-RevId: 704281512

Source-Link:
googleapis/googleapis@0f1beb9

Source-Link:
googleapis/googleapis-gen@5429d7d
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLW1lcmNoYW50LXByb2R1Y3RzLy5Pd2xCb3QueWFtbCIsImgiOiI1NDI5ZDdkNDBiMjQ4YWQwMzQ3ZTkxNmRlZmVlMTdiYTUxMTY0MDExIn0=
END_NESTED_COMMIT

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: ohmayr <omairnaveed@ymail.com>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent d406707 commit ce5c35a
Show file tree
Hide file tree
Showing 19 changed files with 925 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.4" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.4" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
from collections import OrderedDict
import logging as std_logging
import re
from typing import (
Callable,
Expand Down Expand Up @@ -53,6 +54,15 @@
from .transports.base import DEFAULT_CLIENT_INFO, ProductInputsServiceTransport
from .transports.grpc_asyncio import ProductInputsServiceGrpcAsyncIOTransport

try:
from google.api_core import client_logging # type: ignore

CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
except ImportError: # pragma: NO COVER
CLIENT_LOGGING_SUPPORTED = False

_LOGGER = std_logging.getLogger(__name__)


class ProductInputsServiceAsyncClient:
"""Service to use ProductInput resource.
Expand Down Expand Up @@ -268,13 +278,35 @@ def __init__(
client_info=client_info,
)

if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
std_logging.DEBUG
): # pragma: NO COVER
_LOGGER.debug(
"Created client `google.shopping.merchant.products_v1beta.ProductInputsServiceAsyncClient`.",
extra={
"serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService",
"universeDomain": getattr(
self._client._transport._credentials, "universe_domain", ""
),
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
"credentialsInfo": getattr(
self.transport._credentials, "get_cred_info", lambda: None
)(),
}
if hasattr(self._client._transport, "_credentials")
else {
"serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService",
"credentialsType": None,
},
)

async def insert_product_input(
self,
request: Optional[Union[productinputs.InsertProductInputRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> productinputs.ProductInput:
r"""Uploads a product input to your Merchant Center
account. If an input with the same contentLanguage,
Expand Down Expand Up @@ -326,8 +358,10 @@ async def sample_insert_product_input():
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, str]]): Strings which should be
sent along with the request as metadata.
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:
Expand All @@ -336,18 +370,18 @@ async def sample_insert_product_input():
Shopping ads, or across Google surfaces. Product
inputs, rules and supplemental data source data are
combined to create the processed
[product][google.shopping.content.bundles.Products.Product].
[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.content.bundles.Products.feed_label],
[contentLanguage][google.shopping.content.bundles.Products.content_language]
[feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label],
[contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language]
and
[offerId][google.shopping.content.bundles.Products.offer_id].
[offerId][google.shopping.merchant.products.v1beta.Product.offer_id].
After inserting, updating, or deleting a product
input, it may take several minutes before the
Expand Down Expand Up @@ -398,7 +432,7 @@ async def delete_product_input(
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> None:
r"""Deletes a product input from your Merchant Center
account.
Expand Down Expand Up @@ -435,18 +469,24 @@ async def sample_delete_product_input():
The request object. Request message for the
DeleteProductInput method.
name (:class:`str`):
Required. The name of the product
input resource to delete. Format:
accounts/{account}/productInputs/{product}
Required. The name of the product input resource to
delete. Format:
accounts/{account}/productInputs/{product} where the
last section ``product`` consists of 4 parts:
channel~content_language~feed_label~offer_id example for
product name is
"accounts/123/productInputs/online~en~US~sku123"
This corresponds to the ``name`` 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, str]]): Strings which should be
sent along with the request as metadata.
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`.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
from collections import OrderedDict
import logging as std_logging
import os
import re
from typing import (
Expand Down Expand Up @@ -48,6 +49,15 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object, None] # type: ignore

try:
from google.api_core import client_logging # type: ignore

CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
except ImportError: # pragma: NO COVER
CLIENT_LOGGING_SUPPORTED = False

_LOGGER = std_logging.getLogger(__name__)

from google.shopping.type.types import types

from google.shopping.merchant_products_v1beta.types import (
Expand Down Expand Up @@ -602,6 +612,10 @@ def __init__(
# Initialize the universe domain validation.
self._is_universe_domain_valid = False

if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
# Setup logging.
client_logging.initialize_logging()

api_key_value = getattr(self._client_options, "api_key", None)
if api_key_value and credentials:
raise ValueError(
Expand Down Expand Up @@ -668,13 +682,36 @@ def __init__(
api_audience=self._client_options.api_audience,
)

if "async" not in str(self._transport):
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
std_logging.DEBUG
): # pragma: NO COVER
_LOGGER.debug(
"Created client `google.shopping.merchant.products_v1beta.ProductInputsServiceClient`.",
extra={
"serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService",
"universeDomain": getattr(
self._transport._credentials, "universe_domain", ""
),
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
"credentialsInfo": getattr(
self.transport._credentials, "get_cred_info", lambda: None
)(),
}
if hasattr(self._transport, "_credentials")
else {
"serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService",
"credentialsType": None,
},
)

def insert_product_input(
self,
request: Optional[Union[productinputs.InsertProductInputRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> productinputs.ProductInput:
r"""Uploads a product input to your Merchant Center
account. If an input with the same contentLanguage,
Expand Down Expand Up @@ -726,8 +763,10 @@ def sample_insert_product_input():
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
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:
Expand All @@ -736,18 +775,18 @@ def sample_insert_product_input():
Shopping ads, or across Google surfaces. Product
inputs, rules and supplemental data source data are
combined to create the processed
[product][google.shopping.content.bundles.Products.Product].
[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.content.bundles.Products.feed_label],
[contentLanguage][google.shopping.content.bundles.Products.content_language]
[feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label],
[contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language]
and
[offerId][google.shopping.content.bundles.Products.offer_id].
[offerId][google.shopping.merchant.products.v1beta.Product.offer_id].
After inserting, updating, or deleting a product
input, it may take several minutes before the
Expand Down Expand Up @@ -796,7 +835,7 @@ def delete_product_input(
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> None:
r"""Deletes a product input from your Merchant Center
account.
Expand Down Expand Up @@ -833,18 +872,24 @@ def sample_delete_product_input():
The request object. Request message for the
DeleteProductInput method.
name (str):
Required. The name of the product
input resource to delete. Format:
accounts/{account}/productInputs/{product}
Required. The name of the product input resource to
delete. Format:
accounts/{account}/productInputs/{product} where the
last section ``product`` consists of 4 parts:
channel~content_language~feed_label~offer_id example for
product name is
"accounts/123/productInputs/online~en~US~sku123"
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
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`.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
Expand Down
Loading

0 comments on commit ce5c35a

Please sign in to comment.