8000 chore: Enable requesting numeric enums in "transport=rest" responses … · googleapis/google-cloud-python@d030d30 · GitHub
[go: up one dir, main page]

Skip to content

Commit d030d30

Browse files
chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (#38)
* 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 4370c79 commit d030d30

File tree

3 files changed

+50
-48
lines changed

3 files changed

+50
-48
lines changed

packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/client.py

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

packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/rest.py

Lines changed: 46 additions & 41 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 AppGatewaysServiceRestInterceptor:
6468
"""Interceptor for AppGatewaysService.
@@ -440,9 +444,6 @@ class AppGatewaysServiceRestTransport(AppGatewaysServiceTransport):
440444
441445
It sends JSON representations of protocol buffers over HTTP/1.1
442446
443-
NOTE: This REST transport functionality is currently in a beta
444-
state (preview). We welcome your feedback via an issue in this
445-
library's source repository. Thank you!
446447
"""
447448

448449
def __init__(
@@ -462,39 +463,35 @@ def __init__(
462463
) -> None:
463464
"""Instantiate the transport.
464465
465-
NOTE: This REST transport functionality is currently in a beta
466-
state (preview). We welcome your feedback via a GitHub issue in
467-
this library's repository. Thank you!
468-
469-
Args:
470-
host (Optional[str]):
471-
The hostname to connect to.
472-
credentials (Optional[google.auth.credentials.Credentials]): The
473-
authorization credentials to attach to requests. These
474-
credentials identify the application to the service; if none
475-
are specified, the client will attempt to ascertain the
476-
credentials from the environment.
477-
478-
credentials_file (Optional[str]): A file with credentials that can
479-
be loaded with :func:`google.auth.load_credentials_from_file`.
480-
This argument is ignored if ``channel`` is provided.
481-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
482-
ignored if ``channel`` is provided.
483-
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
484-
certificate to configure mutual TLS HTTP channel. It is ignored
485-
if ``channel`` is provided.
486-
quota_project_id (Optional[str]): An optional project to use for billing
487-
and quota.
488-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
489-
The client info used to send a user-agent string along with
490-
API requests. If ``None``, then default info will be used.
491-
Generally, you only need to set this if you are developing
492-
your own client library.
493-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
494-
be used for service account credentials.
495-
url_scheme: the protocol scheme for the API endpoint. Normally
496-
"https", but for testing or local servers,
497-
"http" can be specified.
466+
Args:
467+
host (Optional[str]):
468+
The hostname to connect to.
469+
credentials (Optional[google.auth.credentials.Credentials]): The
470+
authorization credentials to attach to requests. These
471+
credentials identify the application to the service; if none
472+
are specified, the client will attempt to ascertain the
473+
credentials from the environment.
474+
475+
credentials_file (Optional[str]): A file with credentials that can
476+
be loaded with :func:`google.auth.load_credentials_from_file`.
477+
This argument is ignored if ``channel`` is provided.
478+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
479+
ignored if ``channel`` is provided.
480+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
481+
certificate to configure mutual TLS HTTP channel. It is ignored
482+
if ``channel`` is provided.
483+
quota_project_id (Optional[str]): An optional project to use for billing
484+
and quota.
485+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
486+
The client info used to send a user-agent string along with
487+
API requests. If ``None``, then default info will be used.
488+
Generally, you only need to set this if you are developing
489+
your own client library.
490+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
491+
be used for service account credentials.
492+
url_scheme: the protocol scheme for the API endpoint. Normally
493+
"https", but for testing or local servers,
494+
"http" can be specified.
498495
"""
499496
# Run the base constructor
500497
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
@@ -639,7 +636,7 @@ def __call__(
639636
body = json_format.MessageToJson(
640637
transcoded_request["body"],
641638
including_default_value_fields=False,
642-
use_integers_for_enums=False,
639+
use_integers_for_enums=True,
643640
)
644641
uri = transcoded_request["uri"]
645642
method = transcoded_request["method"]
@@ -649,11 +646,13 @@ def __call__(
649646
json_format.MessageToJson(
650647
transcoded_request["query_params"],
651648
including_default_value_fields=False,
652-
use_integers_for_enums=False,
649+
use_integers_for_enums=True,
653650
)
654651
)
655652
query_params.update(self._get_unset_required_fields(query_params))
656653

654+
query_params["$alt"] = "json;enum-encoding=int"
655+
657656
# Send the request
658657
headers = dict(metadata)
659658
headers["Content-Type"] = "application/json"
@@ -739,11 +738,13 @@ def __call__(
739738
json_format.MessageToJson(
740739
transcoded_request["query_params"],
741740
including_default_value_fields=False,
742-
use_integers_for_enums=False,
741+
use_integers_for_enums=True,
743742
)
744743
)
745744
query_params.update(self._get_unset_required_fields(query_params))
746745

746+
query_params["$alt"] = "json;enum-encoding=int"
747+
747748
# Send the request
748749
headers = dict(metadata)
749750
headers["Content-Type"] = "application/json"
@@ -831,11 +832,13 @@ def __call__(
831832
json_format.MessageToJson(
832833
transcoded_request["query_params"],
833834
including_default_value_fields=False,
834-
use_integers_for_enums=False,
835+
use_integers_for_enums=True,
835836
)
836837
)
837838
query_params.update(self._get_unset_required_fields(query_params))
838839

840+
query_params["$alt"] = "json;enum-encoding=int"
841+
839842
# Send the request
840843
headers = dict(metadata)
841844
headers["Content-Type"] = "application/json"
@@ -921,11 +924,13 @@ def __call__(
921924
json_format.MessageToJson(
922925
transcoded_request["query_params"],
923926
including_default_value_fields=False,
924-
use_integers_for_enums=False,
927+
use_integers_for_enums=True,
925928
)
926929
)
927930
query_params.update(self._get_unset_required_fields(query_params))
928931

932+
query_params["$alt"] = "json;enum-encoding=int"
933+
929934
# Send the request
930935
headers = dict(metadata)
931936
headers["Content-Type"] = "application/json"

packages/google-cloud-beyondcorp-appgateways/tests/unit/gapic/beyondcorp_appgateways_v1/test_app_gateways_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ def test_list_app_gateways_rest_required_fields(
20822082

20832083
response = client.list_app_gateways(request)
20842084

2085-
expected_params = []
2085+
expected_params = [("$alt", "json;enum-encoding=int")]
20862086
actual_params = req.call_args.kwargs["params"]
20872087
assert expected_params == actual_params
20882088

@@ -2433,7 +2433,7 @@ def test_get_app_gateway_rest_required_fields(
24332433

24342434
response = client.get_app_gateway(request)
24352435

2436-
expected_params = []
2436+
expected_params = [("$alt", "json;enum-encoding=int")]
24372437
actual_params = req.call_args.kwargs["params"]
24382438
assert expected_params == actual_params
24392439

@@ -2719,7 +2719,7 @@ def test_create_app_gateway_rest_required_fields(
27192719

27202720
response = client.create_app_gateway(request)
27212721

2722-
expected_params = []
2722+
expected_params = [("$alt", "json;enum-encoding=int")]
27232723
actual_params = req.call_args.kwargs["params"]
27242724
assert expected_params == actual_params
27252725

@@ -3020,7 +3020,7 @@ def test_delete_app_gateway_rest_required_fields(
30203020

30213021
response = client.delete_app_gateway(request)
30223022

3023-
expected_params = []
3023+
expected_params = [("$alt", "json;enum-encoding=int")]
30243024
actual_params = req.call_args.kwargs["params"]
30253025
assert expected_params == actual_params
30263026

0 commit comments

Comments
 (0)
0