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

feat: Added the gRPC service config for the Service Controller v1 API #38

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -34,8 +34,7 @@


class QuotaControllerAsyncClient:
"""`Google Quota Control
API <https://cloud.google.com/service-control/overview>`__
"""`Google Quota Control API </service-control/overview>`__

Allows clients to allocate and release quota against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down
Expand Up @@ -71,8 +71,7 @@ def get_transport_class(cls, label: str = None,) -> Type[QuotaControllerTranspor


class QuotaControllerClient(metaclass=QuotaControllerClientMeta):
"""`Google Quota Control
API <https://cloud.google.com/service-control/overview>`__
"""`Google Quota Control API </service-control/overview>`__

Allows clients to allocate and release quota against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down
Expand Up @@ -31,8 +31,7 @@
class QuotaControllerGrpcTransport(QuotaControllerTransport):
"""gRPC backend transport for QuotaController.

`Google Quota Control
API <https://cloud.google.com/service-control/overview>`__
`Google Quota Control API </service-control/overview>`__

Allows clients to allocate and release quota against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down
Expand Up @@ -33,8 +33,7 @@
class QuotaControllerGrpcAsyncIOTransport(QuotaControllerTransport):
"""gRPC AsyncIO backend transport for QuotaController.

`Google Quota Control
API <https://cloud.google.com/service-control/overview>`__
`Google Quota Control API </service-control/overview>`__

Allows clients to allocate and release quota against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down
Expand Up @@ -34,8 +34,7 @@


class ServiceControllerAsyncClient:
"""`Google Service Control
API <https://cloud.google.com/service-control/overview>`__
"""`Google Service Control API </service-control/overview>`__

Lets clients check and report operations against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down Expand Up @@ -186,7 +185,7 @@ async def check(

NOTE: the
[CheckRequest][google.api.servicecontrol.v1.CheckRequest] has
the size limit of 64KB.
the size limit (wire-format byte size) of 1MB.

This method requires the ``servicemanagement.services.check``
permission on the specified service. For more information, see
Expand Down Expand Up @@ -215,7 +214,16 @@ async def check(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.check,
default_timeout=None,
default_retry=retries.Retry(
initial=1.0,
maximum=10.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
),
deadline=5.0,
),
default_timeout=5.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down Expand Up @@ -275,7 +283,7 @@ async def report(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.report,
default_timeout=None,
default_timeout=16.0,
client_info=DEFAULT_CLIENT_INFO,
)

Expand Down
Expand Up @@ -73,8 +73,7 @@ def get_transport_class(


class ServiceControllerClient(metaclass=ServiceControllerClientMeta):
"""`Google Service Control
API <https://cloud.google.com/service-control/overview>`__
"""`Google Service Control API </service-control/overview>`__

Lets clients check and report operations against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down Expand Up @@ -359,7 +358,7 @@ def check(

NOTE: the
[CheckRequest][google.api.servicecontrol.v1.CheckRequest] has
the size limit of 64KB.
the size limit (wire-format byte size) of 1MB.

This method requires the ``servicemanagement.services.check``
permission on the specified service. For more information, see
Expand Down
Expand Up @@ -158,10 +158,21 @@ def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
self.check: gapic_v1.method.wrap_method(
self.check, default_timeout=None, client_info=client_info,
self.check,
default_retry=retries.Retry(
initial=1.0,
maximum=10.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
),
deadline=5.0,
),
default_timeout=5.0,
client_info=client_info,
),
self.report: gapic_v1.method.wrap_method(
self.report, default_timeout=None, client_info=client_info,
self.report, default_timeout=16.0, client_info=client_info,
),
}

Expand Down
Expand Up @@ -31,8 +31,7 @@
class ServiceControllerGrpcTransport(ServiceControllerTransport):
"""gRPC backend transport for ServiceController.

`Google Service Control
API <https://cloud.google.com/service-control/overview>`__
`Google Service Control API </service-control/overview>`__

Lets clients check and report operations against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down Expand Up @@ -246,7 +245,7 @@ def check(

NOTE: the
[CheckRequest][google.api.servicecontrol.v1.CheckRequest] has
the size limit of 64KB.
the size limit (wire-format byte size) of 1MB.

This method requires the ``servicemanagement.services.check``
permission on the specified service. For more information, see
Expand Down
Expand Up @@ -33,8 +33,7 @@
class ServiceControllerGrpcAsyncIOTransport(ServiceControllerTransport):
"""gRPC AsyncIO backend transport for ServiceController.

`Google Service Control
API <https://cloud.google.com/service-control/overview>`__
`Google Service Control API </service-control/overview>`__

Lets clients check and report operations against a `managed
service <https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService>`__.
Expand Down Expand Up @@ -251,7 +250,7 @@ def check(

NOTE: the
[CheckRequest][google.api.servicecontrol.v1.CheckRequest] has
the size limit of 64KB.
the size limit (wire-format byte size) of 1MB.

This method requires the ``servicemanagement.services.check``
permission on the specified service. For more information, see
Expand Down
8 changes: 8 additions & 0 deletions google/cloud/servicecontrol_v1/types/distribution.py
Expand Up @@ -15,6 +15,8 @@
#
import proto # type: ignore

from google.api import distribution_pb2 # type: ignore


__protobuf__ = proto.module(
package="google.api.servicecontrol.v1", manifest={"Distribution",},
Expand Down Expand Up @@ -70,6 +72,9 @@ class Distribution(proto.Message):
Buckets with exponentially growing width.
explicit_buckets (google.cloud.servicecontrol_v1.types.Distribution.ExplicitBuckets):
Buckets with arbitrary user-provided width.
exemplars (Sequence[google.api.distribution_pb2.Exemplar]):
Example points. Must be in increasing order of ``value``
field.
"""

class LinearBuckets(proto.Message):
Expand Down Expand Up @@ -155,6 +160,9 @@ class ExplicitBuckets(proto.Message):
explicit_buckets = proto.Field(
proto.MESSAGE, number=9, oneof="bucket_option", message=ExplicitBuckets,
)
exemplars = proto.RepeatedField(
proto.MESSAGE, number=10, message=distribution_pb2.Distribution.Exemplar,
)


__all__ = tuple(sorted(__protobuf__.manifest))
23 changes: 13 additions & 10 deletions google/cloud/servicecontrol_v1/types/metric_value.py
Expand Up @@ -15,7 +15,7 @@
#
import proto # type: ignore

from google.cloud.servicecontrol_v1.types import distribution
from google.cloud.servicecontrol_v1.types import distribution as gas_distribution
from google.protobuf import timestamp_pb2 # type: ignore


Expand All @@ -33,15 +33,18 @@ class MetricValue(proto.Message):
for the overriding relationship. Note that this map must not
contain monitored resource labels.
start_time (google.protobuf.timestamp_pb2.Timestamp):
The start of the time period over which this
metric value's measurement applies. The time
period has different semantics for different
metric types (cumulative, delta, and gauge). See
the metric definition documentation in the
service configuration for details.
The start of the time period over which this metric value's
measurement applies. The time period has different semantics
for different metric types (cumulative, delta, and gauge).
See the metric definition documentation in the service
configuration for details. If not specified,
[google.api.servicecontrol.v1.Operation.start_time][google.api.servicecontrol.v1.Operation.start_time]
will be used.
end_time (google.protobuf.timestamp_pb2.Timestamp):
The end of the time period over which this
metric value's measurement applies.
The end of the time period over which this metric value's
measurement applies. If not specified,
[google.api.servicecontrol.v1.Operation.end_time][google.api.servicecontrol.v1.Operation.end_time]
will be used.
bool_value (bool):
A boolean value.
int64_value (int):
Expand All @@ -62,7 +65,7 @@ class MetricValue(proto.Message):
double_value = proto.Field(proto.DOUBLE, number=6, oneof="value",)
string_value = proto.Field(proto.STRING, number=7, oneof="value",)
distribution_value = proto.Field(
proto.MESSAGE, number=8, oneof="value", message=distribution.Distribution,
proto.MESSAGE, number=8, oneof="value", message=gas_distribution.Distribution,
)


Expand Down
5 changes: 5 additions & 0 deletions google/cloud/servicecontrol_v1/types/quota_controller.py
Expand Up @@ -16,6 +16,7 @@
import proto # type: ignore

from google.cloud.servicecontrol_v1.types import metric_value
from google.rpc import status_pb2 # type: ignore


__protobuf__ = proto.module(
Expand Down Expand Up @@ -176,6 +177,9 @@ class QuotaError(proto.Message):
description (str):
Free-form text that provides details on the
cause of the error.
status (google.rpc.status_pb2.Status):
Contains additional information about the quota error. If
available, ``status.code`` will be non zero.
"""

class Code(proto.Enum):
Expand All @@ -196,6 +200,7 @@ class Code(proto.Enum):
code = proto.Field(proto.ENUM, number=1, enum=Code,)
subject = proto.Field(proto.STRING, number=2,)
description = proto.Field(proto.STRING, number=3,)
status = proto.Field(proto.MESSAGE, number=4, message=status_pb2.Status,)


__all__ = tuple(sorted(__protobuf__.manifest))
4 changes: 3 additions & 1 deletion tests/unit/gapic/servicecontrol_v1/test_quota_controller.py
Expand Up @@ -24,6 +24,7 @@
from proto.marshal.rules.dates import DurationRule, TimestampRule


from google.api import distribution_pb2 # type: ignore
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
Expand All @@ -41,10 +42,11 @@
from google.cloud.servicecontrol_v1.services.quota_controller.transports.base import (
_GOOGLE_AUTH_VERSION,
)
from google.cloud.servicecontrol_v1.types import distribution
from google.cloud.servicecontrol_v1.types import distribution as gas_distribution
from google.cloud.servicecontrol_v1.types import metric_value
from google.cloud.servicecontrol_v1.types import quota_controller
from google.oauth2 import service_account
from google.protobuf import any_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
import google.auth

Expand Down
Expand Up @@ -24,6 +24,7 @@
from proto.marshal.rules.dates import DurationRule, TimestampRule


from google.api import distribution_pb2 # type: ignore
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
Expand All @@ -42,7 +43,7 @@
_GOOGLE_AUTH_VERSION,
)
from google.cloud.servicecontrol_v1.types import check_error
from google.cloud.servicecontrol_v1.types import distribution
from google.cloud.servicecontrol_v1.types import distribution as gas_distribution
from google.cloud.servicecontrol_v1.types import http_request
from google.cloud.servicecontrol_v1.types import log_entry
from google.cloud.servicecontrol_v1.types import metric_value
Expand Down