Skip to content

Commit 8f4ecfb

Browse files
chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (#55)
* chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java) PiperOrigin-RevId: 493113566 Source-Link: googleapis/googleapis@758f0d1 Source-Link: googleapis/googleapis-gen@78bd8f0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzhiZDhmMDVlMTI3NjM2M2ViMTRlYWU3MGU5MWZlNGJjMjA3MDNhYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent f13c953 commit 8f4ecfb

File tree

7 files changed

+234
-164
lines changed

7 files changed

+234
-164
lines changed

packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,6 @@ def __init__(
369369
transport (Union[str, ProvisioningTransport]): The
370370
transport to use. If set to None, a transport is chosen
371371
automatically.
372-
NOTE: "rest" transport functionality is currently in a
373-
beta state (preview). We welcome your feedback via an
374-
issue in this library's source repository.
375372
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
376373
client. It won't take effect if a ``transport`` instance is provided.
377374
(1) The ``api_endpoint`` property can be used to override the

packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/rest.py

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
rest_version=requests_version,
6060
)
6161

62+
# TODO (numeric enums): This file was generated with the option to
63+
# request that the server respond with enums JSON-encoded as
64+
# numbers. The code below does not implement that functionality yet.
65+
6266

6367
class ProvisioningRestInterceptor:
6468
"""Interceptor for Provisioning.
@@ -398,9 +402,6 @@ class ProvisioningRestTransport(ProvisioningTransport):
398402
399403
It sends JSON representations of protocol buffers over HTTP/1.1
400404
401-
NOTE: This REST transport functionality is currently in a beta
402-
state (preview). We welcome your feedback via an issue in this
403-
library's source repository. Thank you!
404405
"""
405406

406407
def __init__(
@@ -420,39 +421,35 @@ def __init__(
420421
) -> None:
421422
"""Instantiate the transport.
422423
423-
NOTE: This REST transport functionality is currently in a beta
424-
state (preview). We welcome your feedback via a GitHub issue in
425-
this library's repository. Thank you!
426-
427-
Args:
428-
host (Optional[str]):
429-
The hostname to connect to.
430-
credentials (Optional[google.auth.credentials.Credentials]): The
431-
authorization credentials to attach to requests. These
432-
credentials identify the application to the service; if none
433-
are specified, the client will attempt to ascertain the
434-
credentials from the environment.
435-
436-
credentials_file (Optional[str]): A file with credentials that can
437-
be loaded with :func:`google.auth.load_credentials_from_file`.
438-
This argument is ignored if ``channel`` is provided.
439-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
440-
ignored if ``channel`` is provided.
441-
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
442-
certificate to configure mutual TLS HTTP channel. It is ignored
443-
if ``channel`` is provided.
444-
quota_project_id (Optional[str]): An optional project to use for billing
445-
and quota.
446-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
447-
The client info used to send a user-agent string along with
448-
API requests. If ``None``, then default info will be used.
449-
Generally, you only need to set this if you are developing
450-
your own client library.
451-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
452-
be used for service account credentials.
453-
url_scheme: the protocol scheme for the API endpoint. Normally
454-
"https", but for testing or local servers,
455-
"http" can be specified.
424+
Args:
425+
host (Optional[str]):
426+
The hostname to connect to.
427+
credentials (Optional[google.auth.credentials.Credentials]): The
428+
authorization credentials to attach to requests. These
429+
credentials identify the application to the service; if none
430+
are specified, the client will attempt to ascertain the
431+
credentials from the environment.
432+
433+
credentials_file (Optional[str]): A file with credentials that can
434+
be loaded with :func:`google.auth.load_credentials_from_file`.
435+
This argument is ignored if ``channel`` is provided.
436+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
437+
ignored if ``channel`` is provided.
438+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
439+
certificate to configure mutual TLS HTTP channel. It is ignored
440+
if ``channel`` is provided.
441+
quota_project_id (Optional[str]): An optional project to use for billing
442+
and quota.
443+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
444+
The client info used to send a user-agent string along with
445+
API requests. If ``None``, then default info will be used.
446+
Generally, you only need to set this if you are developing
447+
your own client library.
448+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
449+
be used for service account credentials.
450+
url_scheme: the protocol scheme for the API endpoint. Normally
451+
"https", but for testing or local servers,
452+
"http" can be specified.
456453
"""
457454
# Run the base constructor
458455
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
@@ -595,7 +592,7 @@ def __call__(
595592
body = json_format.MessageToJson(
596593
transcoded_request["body"],
597594
including_default_value_fields=False,
598-
use_integers_for_enums=False,
595+
use_integers_for_enums=True,
599596
)
600597
uri = transcoded_request["uri"]
601598
method = transcoded_request["method"]
@@ -605,11 +602,13 @@ def __call__(
605602
json_format.MessageToJson(
606603
transcoded_request["query_params"],
607604
including_default_value_fields=False,
608-
use_integers_for_enums=False,
605+
use_integers_for_enums=True,
609606
)
610607
)
611608
query_params.update(self._get_unset_required_fields(query_params))
612609

610+
query_params["$alt"] = "json;enum-encoding=int"
611+
613612
# Send the request
614613
headers = dict(metadata)
615614
headers["Content-Type"] = "application/json"
@@ -691,11 +690,13 @@ def __call__(
691690
json_format.MessageToJson(
692691
transcoded_request["query_params"],
693692
including_default_value_fields=False,
694-
use_integers_for_enums=False,
693+
use_integers_for_enums=True,
695694
)
696695
)
697696
query_params.update(self._get_unset_required_fields(query_params))
698697

698+
query_params["$alt"] = "json;enum-encoding=int"
699+
699700
# Send the request
700701
headers = dict(metadata)
701702
headers["Content-Type"] = "application/json"
@@ -777,11 +778,13 @@ def __call__(
777778
json_format.MessageToJson(
778779
transcoded_request["query_params"],
779780
including_default_value_fields=False,
780-
use_integers_for_enums=False,
781+
use_integers_for_enums=True,
781782
)
782783
)
783784
query_params.update(self._get_unset_required_fields(query_params))
784785

786+
query_params["$alt"] = "json;enum-encoding=int"
787+
785788
# Send the request
786789
headers = dict(metadata)
787790
headers["Content-Type"] = "application/json"

packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,6 @@ def __init__(
466466
transport (Union[str, RegistryTransport]): The
467467
transport to use. If set to None, a transport is chosen
468468
automatically.
469-
NOTE: "rest" transport functionality is currently in a
470-
beta state (preview). We welcome your feedback via an
471-
issue in this library's source repository.
472469
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
473470
client. It won't take effect if a ``transport`` instance is provided.
474471
(1) The ``api_endpoint`` property can be used to override the

0 commit comments

Comments
 (0)