Skip to content

Commit 21f847b

Browse files
chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (#41)
* 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 5ef835b commit 21f847b

3 files changed

Lines changed: 55 additions & 51 deletions

File tree

packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/client.py

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

packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/rest.py

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
rest_version=requests_version,
6262
)
6363

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

6569
class ClientConnectorServicesServiceRestInterceptor:
6670
"""Interceptor for ClientConnectorServicesService.
@@ -487,9 +491,6 @@ class ClientConnectorServicesServiceRestTransport(
487491
488492
It sends JSON representations of protocol buffers over HTTP/1.1
489493
490-
NOTE: This REST transport functionality is currently in a beta
491-
state (preview). We welcome your feedback via an issue in this
492-
library's source repository. Thank you!
493494
"""
494495

495496
def __init__(
@@ -509,39 +510,35 @@ def __init__(
509510
) -> None:
510511
"""Instantiate the transport.
511512
512-
NOTE: This REST transport functionality is currently in a beta
513-
state (preview). We welcome your feedback via a GitHub issue in
514-
this library's repository. Thank you!
515-
516-
Args:
517-
host (Optional[str]):
518-
The hostname to connect to.
519-
credentials (Optional[google.auth.credentials.Credentials]): The
520-
authorization credentials to attach to requests. These
521-
credentials identify the application to the service; if none
522-
are specified, the client will attempt to ascertain the
523-
credentials from the environment.
524-
525-
credentials_file (Optional[str]): A file with credentials that can
526-
be loaded with :func:`google.auth.load_credentials_from_file`.
527-
This argument is ignored if ``channel`` is provided.
528-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
529-
ignored if ``channel`` is provided.
530-
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
531-
certificate to configure mutual TLS HTTP channel. It is ignored
532-
if ``channel`` is provided.
533-
quota_project_id (Optional[str]): An optional project to use for billing
534-
and quota.
535-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
536-
The client info used to send a user-agent string along with
537-
API requests. If ``None``, then default info will be used.
538-
Generally, you only need to set this if you are developing
539-
your own client library.
540-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
541-
be used for service account credentials.
542-
url_scheme: the protocol scheme for the API endpoint. Normally
543-
"https", but for testing or local servers,
544-
"http" can be specified.
513+
Args:
514+
host (Optional[str]):
515+
The hostname to connect to.
516+
credentials (Optional[google.auth.credentials.Credentials]): The
517+
authorization credentials to attach to requests. These
518+
credentials identify the application to the service; if none
519+
are specified, the client will attempt to ascertain the
520+
credentials from the environment.
521+
522+
credentials_file (Optional[str]): A file with credentials that can
523+
be loaded with :func:`google.auth.load_credentials_from_file`.
524+
This argument is ignored if ``channel`` is provided.
525+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
526+
ignored if ``channel`` is provided.
527+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
528+
certificate to configure mutual TLS HTTP channel. It is ignored
529+
if ``channel`` is provided.
530+
quota_project_id (Optional[str]): An optional project to use for billing
531+
and quota.
532+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
533+
The client info used to send a user-agent string along with
534+
API requests. If ``None``, then default info will be used.
535+
Generally, you only need to set this if you are developing
536+
your own client library.
537+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
538+
be used for service account credentials.
539+
url_scheme: the protocol scheme for the API endpoint. Normally
540+
"https", but for testing or local servers,
541+
"http" can be specified.
545542
"""
546543
# Run the base constructor
547544
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
@@ -691,7 +688,7 @@ def __call__(
691688
body = json_format.MessageToJson(
692689
transcoded_request["body"],
693690
including_default_value_fields=False,
694-
use_integers_for_enums=False,
691+
use_integers_for_enums=True,
695692
)
696693
uri = transcoded_request["uri"]
697694
method = transcoded_request["method"]
@@ -701,11 +698,13 @@ def __call__(
701698
json_format.MessageToJson(
702699
transcoded_request["query_params"],
703700
including_default_value_fields=False,
704-
use_integers_for_enums=False,
701+
use_integers_for_enums=True,
705702
)
706703
)
707704
query_params.update(self._get_unset_required_fields(query_params))
708705

706+
query_params["$alt"] = "json;enum-encoding=int"
707+
709708
# Send the request
710709
headers = dict(metadata)
711710
headers["Content-Type"] = "application/json"
@@ -794,11 +793,13 @@ def __call__(
794793
json_format.MessageToJson(
795794
transcoded_request["query_params"],
796795
including_default_value_fields=False,
797-
use_integers_for_enums=False,
796+
use_integers_for_enums=True,
798797
)
799798
)
800799
query_params.update(self._get_unset_required_fields(query_params))
801800

801+
query_params["$alt"] = "json;enum-encoding=int"
802+
802803
# Send the request
803804
headers = dict(metadata)
804805
headers["Content-Type"] = "application/json"
@@ -887,11 +888,13 @@ def __call__(
887888
json_format.MessageToJson(
888889
transcoded_request["query_params"],
889890
including_default_value_fields=False,
890-
use_integers_for_enums=False,
891+
use_integers_for_enums=True,
891892
)
892893
)
893894
query_params.update(self._get_unset_required_fields(query_params))
894895

896+
query_params["$alt"] = "json;enum-encoding=int"
897+
895898
# Send the request
896899
headers = dict(metadata)
897900
headers["Content-Type"] = "application/json"
@@ -982,11 +985,13 @@ def __call__(
982985
json_format.MessageToJson(
983986
transcoded_request["query_params"],
984987
including_default_value_fields=False,
985-
use_integers_for_enums=False,
988+
use_integers_for_enums=True,
986989
)
987990
)
988991
query_params.update(self._get_unset_required_fields(query_params))
989992

993+
query_params["$alt"] = "json;enum-encoding=int"
994+
990995
# Send the request
991996
headers = dict(metadata)
992997
headers["Content-Type"] = "application/json"
@@ -1080,7 +1085,7 @@ def __call__(
10801085
body = json_format.MessageToJson(
10811086
transcoded_request["body"],
10821087
including_default_value_fields=False,
1083-
use_integers_for_enums=False,
1088+
use_integers_for_enums=True,
10841089
)
10851090
uri = transcoded_request["uri"]
10861091
method = transcoded_request["method"]
@@ -1090,11 +1095,13 @@ def __call__(
10901095
json_format.MessageToJson(
10911096
transcoded_request["query_params"],
10921097
including_default_value_fields=False,
1093-
use_integers_for_enums=False,
1098+
use_integers_for_enums=True,
10941099
)
10951100
)
10961101
query_params.update(self._get_unset_required_fields(query_params))
10971102

1103+
query_params["$alt"] = "json;enum-encoding=int"
1104+
10981105
# Send the request
10991106
headers = dict(metadata)
11001107
headers["Content-Type"] = "application/json"

packages/google-cloud-beyondcorp-clientconnectorservices/tests/unit/gapic/beyondcorp_clientconnectorservices_v1/test_client_connector_services_service.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ def test_list_client_connector_services_rest_required_fields(
24602460

24612461
response = client.list_client_connector_services(request)
24622462

2463-
expected_params = []
2463+
expected_params = [("$alt", "json;enum-encoding=int")]
24642464
actual_params = req.call_args.kwargs["params"]
24652465
assert expected_params == actual_params
24662466

@@ -2835,7 +2835,7 @@ def test_get_client_connector_service_rest_required_fields(
28352835

28362836
response = client.get_client_connector_service(request)
28372837

2838-
expected_params = []
2838+
expected_params = [("$alt", "json;enum-encoding=int")]
28392839
actual_params = req.call_args.kwargs["params"]
28402840
assert expected_params == actual_params
28412841

@@ -3135,7 +3135,7 @@ def test_create_client_connector_service_rest_required_fields(
31353135

31363136
response = client.create_client_connector_service(request)
31373137

3138-
expected_params = []
3138+
expected_params = [("$alt", "json;enum-encoding=int")]
31393139
actual_params = req.call_args.kwargs["params"]
31403140
assert expected_params == actual_params
31413141

@@ -3470,7 +3470,7 @@ def test_update_client_connector_service_rest_required_fields(
34703470

34713471
response = client.update_client_connector_service(request)
34723472

3473-
expected_params = []
3473+
expected_params = [("$alt", "json;enum-encoding=int")]
34743474
actual_params = req.call_args.kwargs["params"]
34753475
assert expected_params == actual_params
34763476

@@ -3796,7 +3796,7 @@ def test_delete_client_connector_service_rest_required_fields(
37963796

37973797
response = client.delete_client_connector_service(request)
37983798

3799-
expected_params = []
3799+
expected_params = [("$alt", "json;enum-encoding=int")]
38003800
actual_params = req.call_args.kwargs["params"]
38013801
assert expected_params == actual_params
38023802

0 commit comments

Comments
 (0)