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

Skip to content

Commit 8beb1d2

Browse files
chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (#45)
* 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 c6e38aa commit 8beb1d2

File tree

3 files changed

+59
-52
lines changed

3 files changed

+59
-52
lines changed

packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/client.py

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

packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/rest.py

Lines changed: 53 additions & 44 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 AppConnectionsServiceRestInterceptor:
6468
"""Interceptor for AppConnectionsService.
@@ -512,9 +516,6 @@ class AppConnectionsServiceRestTransport(AppConnectionsServiceTransport):
512516
513517
It sends JSON representations of protocol buffers over HTTP/1.1
514518
515-
NOTE: This REST transport functionality is currently in a beta
516-
state (preview). We welcome your feedback via an issue in this
517-
library's source repository. Thank you!
518519
"""
519520

520521
def __init__(
@@ -534,39 +535,35 @@ def __init__(
534535
) -> None:
535536
"""Instantiate the transport.
536537
537-
NOTE: This REST transport functionality is currently in a beta
538-
state (preview). We welcome your feedback via a GitHub issue in
539-
this library's repository. Thank you!
540-
541-
Args:
542-
host (Optional[str]):
543-
The hostname to connect to.
544-
credentials (Optional[google.auth.credentials.Credentials]): The
545-
authorization credentials to attach to requests. These
546-
credentials identify the application to the service; if none
547-
are specified, the client will attempt to ascertain the
548-
credentials from the environment.
549-
550-
credentials_file (Optional[str]): A file with credentials that can
551-
be loaded with :func:`google.auth.load_credentials_from_file`.
552-
This argument is ignored if ``channel`` is provided.
553-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
554-
ignored if ``channel`` is provided.
555-
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
556-
certificate to configure mutual TLS HTTP channel. It is ignored
557-
if ``channel`` is provided.
558-
quota_project_id (Optional[str]): An optional project to use for billing
559-
and quota.
560-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
561-
The client info used to send a user-agent string along with
562-
API requests. If ``None``, then default info will be used.
563-
Generally, you only need to set this if you are developing
564-
your own client library.
565-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
566-
be used for service account credentials.
567-
url_scheme: the protocol scheme for the API endpoint. Normally
568-
"https", but for testing or local servers,
569-
"http" can be specified.
538+
Args:
539+
host (Optional[str]):
540+
The hostname to connect to.
541+
credentials (Optional[google.auth.credentials.Credentials]): The
542+
authorization credentials to attach to requests. These
543+
credentials identify the application to the service; if none
544+
are specified, the client will attempt to ascertain the
545+
credentials from the environment.
546+
547+
credentials_file (Optional[str]): A file with credentials that can
548+
be loaded with :func:`google.auth.load_credentials_from_file`.
549+
This argument is ignored if ``channel`` is provided.
550+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
551+
ignored if ``channel`` is provided.
552+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
553+
certificate to configure mutual TLS HTTP channel. It is ignored
554+
if ``channel`` is provided.
555+
quota_project_id (Optional[str]): An optional project to use f 77FB or billing
556+
and quota.
557+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
558+
The client info used to send a user-agent string along with
559+
API requests. If ``None``, then default info will be used.
560+
Generally, you only need to set this if you are developing
561+
your own client library.
562+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
563+
be used for service account credentials.
564+
url_scheme: the protocol scheme for the API endpoint. Normally
565+
"https", but for testing or local servers,
566+
"http" can be specified.
570567
"""
571568
# Run the base constructor
572569
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
@@ -711,7 +708,7 @@ def __call__(
711708
body = json_format.MessageToJson(
712709
transcoded_request["body"],
713710
including_default_value_fields=False,
714-
use_integers_for_enums=False,
711+
use_integers_for_enums=True,
715712
)
716713
uri = transcoded_request["uri"]
717714
method = transcoded_request["method"]
@@ -721,11 +718,13 @@ def __call__(
721718
json_format.MessageToJson(
722719
transcoded_request["query_params"],
723720
including_default_value_fields=False,
724-
use_integers_for_enums=False,
721+
use_integers_for_enums=True,
725722
)
726723
)
727724
query_params.update(self._get_unset_required_fields(query_params))
728725

726+
query_params["$alt"] = "json;enum-encoding=int"
727+
729728
# Send the request
730729
headers = dict(metadata)
731730
headers["Content-Type"] = "application/json"
@@ -811,11 +810,13 @@ def __call__(
811810
json_format.MessageToJson(
812811
transcoded_request["query_params"],
813812
including_default_value_fields=False,
814-
use_integers_for_enums=False,
813+
use_integers_for_enums=True,
815814
)
816815
)
817816
F438 query_params.update(self._get_unset_required_fields(query_params))
818817

818+
query_params["$alt"] = "json;enum-encoding=int"
819+
819820
# Send the request
820821
headers = dict(metadata)
821822
headers["Content-Type"] = "application/json"
@@ -905,11 +906,13 @@ def __call__(
905906
json_format.MessageToJson(
906907
transcoded_request["query_params"],
907908
including_default_value_fields=False,
908-
use_integers_for_enums=False,
909+
use_integers_for_enums=True,
909910
)
910911
)
911912
query_params.update(self._get_unset_required_fields(query_params))
912913

914+
query_params["$alt"] = "json;enum-encoding=int"
915+
913916
# Send the request
914917
headers = dict(metadata)
915918
headers["Content-Type"] = "application/json"
@@ -995,11 +998,13 @@ def __call__(
995998
json_format.MessageToJson(
996999
transcoded_request["query_params"],
9971000
including_default_value_fields=False,
998-
use_integers_for_enums=False,
1001+
use_integers_for_enums=True,
9991002
)
10001003
)
10011004
query_params.update(self._get_unset_required_fields(query_params))
10021005

1006+
query_params["$alt"] = "json;enum-encoding=int"
1007+
10031008
# Send the request
10041009
headers = dict(metadata)
10051010
headers["Content-Type"] = "application/json"
@@ -1089,11 +1094,13 @@ def __call__(
10891094
json_format.MessageToJson(
10901095
transcoded_request["query_params"],
10911096
including_default_value_fields=False,
1092-
use_integers_for_enums=False,
1097+
use_integers_for_enums=True,
10931098
)
10941099
)
10951100
query_params.update(self._get_unset_required_fields(query_params))
10961101

1102+
query_params["$alt"] = "json;enum-encoding=int"
1103+
10971104
# Send the request
10981105
headers = dict(metadata)
10991106
headers["Content-Type"] = "application/json"
@@ -1180,7 +1187,7 @@ def __call__(
11801187
body = json_format.MessageToJson(
11811188
transcoded_request["body"],
11821189
including_default_value_fields=False,
1183-
use_integers_for_enums=False,
1190+
use_integers_for_enums=True,
11841191
)
11851192
uri = transcoded_request["uri"]
11861193
method = transcoded_request["method"]
@@ -1190,11 +1197,13 @@ def __call__(
11901197
json_format.MessageToJson(
11911198
transcoded_request["query_params"],
11921199
including_default_value_fields=False,
1193-
use_integers_for_enums=False,
1200+
use_integers_for_enums=True,
11941201
)
11951202
)
11961203
query_params.update(self._get_unset_required_fields(query_params))
11971204

1205+
query_params["$alt"] = "json;enum-encoding=int"
1206+
11981207
# Send the request
11991208
headers = dict(metadata)
12001209
headers["Content-Type"] = "application/json"

packages/google-cloud-beyondcorp-appconnections/tests/unit/gapic/beyondcorp_appconnections_v1/test_app_connections_service.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ def test_list_app_connections_rest_required_fields(
28212821

28222822
response = client.list_app_connections(request)
28232823

2824-
expected_params = []
2824+
expected_params = [("$alt", "json;enum-encoding=int")]
28252825
actual_params = req.call_args.kwargs["params"]
28262826
assert expected_params == actual_params
28272827

@@ -3174,7 +3174,7 @@ def test_get_app_connection_rest_required_fields(
31743174

31753175
response = client.get_app_connection(request)
31763176

3177-
expected_params = []
3177+
expected_params = [("$alt", "json;enum-encoding=int")]
31783178
actual_params = req.call_args.kwargs["params"]
31793179
assert expected_params == actual_params
31803180

@@ -3466,7 +3466,7 @@ def test_create_app_connection_rest_required_fields(
34663466

34673467
response = client.create_app_connection(request)
34683468

3469-
expected_params = []
3469+
expected_params = [("$alt", "json;enum-encoding=int")]
34703470
actual_params = req.call_args.kwargs["params"]
34713471
assert expected_params == actual_params
34723472

@@ -3793,7 +3793,7 @@ def test_update_app_connection_rest_required_fields(
37933793

37943794
response = client.update_app_connection(request)
37953795

3796-
expected_params = []
3796+
expected_params = [("$alt", "json;enum-encoding=int")]
37973797
actual_params = req.call_args.kwargs["params"]
37983798
assert expected_params == actual_params
37993799

@@ -4107,7 +4107,7 @@ def test_delete_app_connection_rest_required_fields(
41074107

41084108
response = client.delete_app_connection(request)
41094109

4110-
expected_params = []
4110+
expected_params = [("$alt", "json;enum-encoding=int")]
41114111
actual_params = req.call_args.kwargs["params"]
41124112
assert expected_params == actual_params
41134113

@@ -4413,6 +4413,7 @@ def test_resolve_app_connections_rest_required_fields(
44134413
"appConnectorId",
44144414
"",
44154415
),
4416+
("$alt", "json;enum-encoding=int"),
44164417
]
44174418
actual_params = req.call_args.kwargs["params"]
44184419
assert expected_params == actual_params

0 commit comments

Comments
 (0)
0