Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
chore: use gapic-generator-python 0.53.4 (#84)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Nov 1, 2021
1 parent 960ea61 commit eef4248
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 271 deletions.
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.servicecontrol_v1.types import metric_value
from google.cloud.servicecontrol_v1.types import quota_controller
from .transports.base import QuotaControllerTransport, DEFAULT_CLIENT_INFO
Expand Down Expand Up @@ -165,9 +167,9 @@ def __init__(

async def allocate_quota(
self,
request: quota_controller.AllocateQuotaRequest = None,
request: Union[quota_controller.AllocateQuotaRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> quota_controller.AllocateQuotaResponse:
Expand All @@ -185,7 +187,7 @@ async def allocate_quota(
functionality.
Args:
request (:class:`google.cloud.servicecontrol_v1.types.AllocateQuotaRequest`):
request (Union[google.cloud.servicecontrol_v1.types.AllocateQuotaRequest, dict]):
The request object. Request message for the
AllocateQuota method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand Down
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.servicecontrol_v1.types import metric_value
from google.cloud.servicecontrol_v1.types import quota_controller
from .transports.base import QuotaControllerTransport, DEFAULT_CLIENT_INFO
Expand Down Expand Up @@ -339,7 +341,7 @@ def allocate_quota(
self,
request: Union[quota_controller.AllocateQuotaRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> quota_controller.AllocateQuotaResponse:
Expand Down
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -37,15 +36,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class QuotaControllerTransport(abc.ABC):
"""Abstract transport class for QuotaController."""
Expand Down Expand Up @@ -98,7 +88,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -131,29 +121,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down
Expand Up @@ -20,7 +20,6 @@
from google.api_core import grpc_helpers_async # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.servicecontrol_v1.types import check_error
from google.cloud.servicecontrol_v1.types import service_controller
from .transports.base import ServiceControllerTransport, DEFAULT_CLIENT_INFO
Expand Down Expand Up @@ -165,9 +167,9 @@ def __init__(

async def check(
self,
request: service_controller.CheckRequest = None,
request: Union[service_controller.CheckRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> service_controller.CheckResponse:
Expand All @@ -192,7 +194,7 @@ async def check(
`Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`google.cloud.servicecontrol_v1.types.CheckRequest`):
request (Union[google.cloud.servicecontrol_v1.types.CheckRequest, dict]):
The request object. Request message for the Check
method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand Down Expand Up @@ -235,9 +237,9 @@ async def check(

async def report(
self,
request: service_controller.ReportRequest = None,
request: Union[service_controller.ReportRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> service_controller.ReportResponse:
Expand All @@ -261,7 +263,7 @@ async def report(
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`google.cloud.servicecontrol_v1.types.ReportRequest`):
request (Union[google.cloud.servicecontrol_v1.types.ReportRequest, dict]):
The request object. Request message for the Report
method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand Down
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.servicecontrol_v1.types import check_error
from google.cloud.servicecontrol_v1.types import service_controller
from .transports.base import ServiceControllerTransport, DEFAULT_CLIENT_INFO
Expand Down Expand Up @@ -341,7 +343,7 @@ def check(
self,
request: Union[service_controller.CheckRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> service_controller.CheckResponse:
Expand Down Expand Up @@ -403,7 +405,7 @@ def report(
self,
request: Union[service_controller.ReportRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> service_controller.ReportResponse:
Expand Down
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -37,15 +36,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class ServiceControllerTransport(abc.ABC):
"""Abstract transport class for ServiceController."""
Expand Down Expand Up @@ -98,7 +88,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -131,29 +121,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down
Expand Up @@ -20,7 +20,6 @@
from google.api_core import grpc_helpers_async # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down
10 changes: 10 additions & 0 deletions google/cloud/servicecontrol_v1/types/distribution.py
Expand Up @@ -34,6 +34,13 @@ class Distribution(proto.Message):
variance
- a histogram of the values of the sample points
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
count (int):
The total number of samples in the
Expand Down Expand Up @@ -68,10 +75,13 @@ class Distribution(proto.Message):
Any suffix of trailing zeros may be omitted.
linear_buckets (google.cloud.servicecontrol_v1.types.Distribution.LinearBuckets):
Buckets with constant width.
This field is a member of `oneof`_ ``bucket_option``.
exponential_buckets (google.cloud.servicecontrol_v1.types.Distribution.ExponentialBuckets):
Buckets with exponentially growing width.
This field is a member of `oneof`_ ``bucket_option``.
explicit_buckets (google.cloud.servicecontrol_v1.types.Distribution.ExplicitBuckets):
Buckets with arbitrary user-provided width.
This field is a member of `oneof`_ ``bucket_option``.
exemplars (Sequence[google.api.distribution_pb2.Exemplar]):
Example points. Must be in increasing order of ``value``
field.
Expand Down
10 changes: 10 additions & 0 deletions google/cloud/servicecontrol_v1/types/log_entry.py
Expand Up @@ -31,6 +31,13 @@
class LogEntry(proto.Message):
r"""An individual log entry.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
name (str):
Required. The log to which this log entry belongs. Examples:
Expand Down Expand Up @@ -63,12 +70,15 @@ class LogEntry(proto.Message):
The log entry payload, represented as a protocol buffer that
is expressed as a JSON object. The only accepted type
currently is [AuditLog][google.cloud.audit.AuditLog].
This field is a member of `oneof`_ ``payload``.
text_payload (str):
The log entry payload, represented as a
Unicode string (UTF-8).
This field is a member of `oneof`_ ``payload``.
struct_payload (google.protobuf.struct_pb2.Struct):
The log entry payload, represented as a
structure that is expressed as a JSON object.
This field is a member of `oneof`_ ``payload``.
operation (google.cloud.servicecontrol_v1.types.LogEntryOperation):
Optional. Information about an operation
associated with the log entry, if applicable.
Expand Down
12 changes: 12 additions & 0 deletions google/cloud/servicecontrol_v1/types/metric_value.py
Expand Up @@ -27,6 +27,13 @@
class MetricValue(proto.Message):
r"""Represents a single metric value.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
labels (Sequence[google.cloud.servicecontrol_v1.types.MetricValue.LabelsEntry]):
The labels describing the metric value. See comments on
Expand All @@ -48,14 +55,19 @@ class MetricValue(proto.Message):
will be used.
bool_value (bool):
A boolean value.
This field is a member of `oneof`_ ``value``.
int64_value (int):
A signed 64-bit integer value.
This field is a member of `oneof`_ ``value``.
double_value (float):
A double precision floating point value.
This field is a member of `oneof`_ ``value``.
string_value (str):
A text string value.
This field is a member of `oneof`_ ``value``.
distribution_value (google.cloud.servicecontrol_v1.types.Distribution):
A distribution value.
This field is a member of `oneof`_ ``value``.
"""

labels = proto.MapField(proto.STRING, proto.STRING, number=1,)
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -28,10 +28,9 @@
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
# Until this issue is closed
# https://github.com/googleapis/google-cloud-python/issues/10566
"google-api-core[grpc] >= 1.26.0, <3.0.0dev",
"google-api-core[grpc] >= 1.28.0, <3.0.0dev",
"libcst >= 0.2.5",
"proto-plus >= 1.15.0",
"packaging >= 14.3",
]

package_root = os.path.abspath(os.path.dirname(__file__))
Expand Down
4 changes: 1 addition & 3 deletions testing/constraints-3.6.txt
Expand Up @@ -5,8 +5,6 @@
#
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
google-api-core==1.26.0
google-api-core==1.28.0
libcst==0.2.5
proto-plus==1.15.0
packaging==14.3
google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is transitively required through google-auth

0 comments on commit eef4248

Please sign in to comment.