Skip to content

Commit 9210851

Browse files
chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (googleapis#77)
* 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: https://github.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab 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 19ac3a7 commit 9210851

6 files changed

Lines changed: 112 additions & 100 deletions

File tree

packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/client.py

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

packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/rest.py

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

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

6670
class BatchServiceRestInterceptor:
6771
"""Interceptor for BatchService.
@@ -474,9 +478,6 @@ class BatchServiceRestTransport(BatchServiceTransport):
474478
475479
It sends JSON representations of protocol buffers over HTTP/1.1
476480
477-
NOTE: This REST transport functionality is currently in a beta
478-
state (preview). We welcome your feedback via an issue in this
479-
library's source repository. Thank you!
480481
"""
481482

482483
def __init__(
@@ -496,39 +497,35 @@ def __init__(
496497
) -> None:
497498
"""Instantiate the transport.
498499
499-
NOTE: This REST transport functionality is currently in a beta
500-
state (preview). We welcome your feedback via a GitHub issue in
501-
this library's repository. Thank you!
502-
503-
Args:
504-
host (Optional[str]):
505-
The hostname to connect to.
506-
credentials (Optional[google.auth.credentials.Credentials]): The
507-
authorization credentials to attach to requests. These
508-
credentials identify the application to the service; if none
509-
are specified, the client will attempt to ascertain the
510-
credentials from the environment.
511-
512-
credentials_file (Optional[str]): A file with credentials that can
513-
be loaded with :func:`google.auth.load_credentials_from_file`.
514-
This argument is ignored if ``channel`` is provided.
515-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
516-
ignored if ``channel`` is provided.
517-
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
518-
certificate to configure mutual TLS HTTP channel. It is ignored
519-
if ``channel`` is provided.
520-
quota_project_id (Optional[str]): An optional project to use for billing
521-
and quota.
522-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
523-
The client info used to send a user-agent string along with
524-
API requests. If ``None``, then default info will be used.
525-
Generally, you only need to set this if you are developing
526-
your own client library.
527-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
528-
be used for service account credentials.
529-
url_scheme: the protocol scheme for the API endpoint. Normally
530-
"https", but for testing or local servers,
531-
"http" can be specified.
500+
Args:
501+
host (Optional[str]):
502+
The hostname to connect to.
503+
credentials (Optional[google.auth.credentials.Credentials]): The
504+
authorization credentials to attach to requests. These
505+
credentials identify the application to the service; if none
506+
are specified, the client will attempt to ascertain the
507+
credentials from the environment.
508+
509+
credentials_file (Optional[str]): A file with credentials that can
510+
be loaded with :func:`google.auth.load_credentials_from_file`.
511+
This argument is ignored if ``channel`` is provided.
512+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
513+
ignored if ``channel`` is provided.
514+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
515+
certificate to configure mutual TLS HTTP channel. It is ignored
516+
if ``channel`` is provided.
517+
quota_project_id (Optional[str]): An optional project to use for billing
518+
and quota.
519+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
520+
The client info used to send a user-agent string along with
521+
API requests. If ``None``, then default info will be used.
522+
Generally, you only need to set this if you are developing
523+
your own client library.
524+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
525+
be used for service account credentials.
526+
url_scheme: the protocol scheme for the API endpoint. Normally
527+
"https", but for testing or local servers,
528+
"http" can be specified.
532529
"""
533530
# Run the base constructor
534531
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
@@ -666,7 +663,7 @@ def __call__(
666663
body = json_format.MessageToJson(
667664
transcoded_request["body"],
668665
including_default_value_fields=False,
669-
use_integers_for_enums=False,
666+
use_integers_for_enums=True,
670667
)
671668
uri = transcoded_request["uri"]
672669
method = transcoded_request["method"]
@@ -676,11 +673,13 @@ def __call__(
676673
json_format.MessageToJson(
677674
transcoded_request["query_params"],
678675
including_default_value_fields=False,
679-
use_integers_for_enums=False,
676+
use_integers_for_enums=True,
680677
)
681678
)
682679
query_params.update(self._get_unset_required_fields(query_params))
683680

681+
query_params["$alt"] = "json;enum-encoding=int"
682+
684683
# Send the request
685684
headers = dict(metadata)
686685
headers["Content-Type"] = "application/json"
@@ -754,10 +753,12 @@ def __call__(
754753
json_format.MessageToJson(
755754
transcoded_request["query_params"],
756755
including_default_value_fields=False,
757-
use_integers_for_enums=False,
756+
use_integers_for_enums=True,
758757
)
759758
)
760759

760+
query_params["$alt"] = "json;enum-encoding=int"
761+
761762
# Send the request
762763
headers = dict(metadata)
763764
headers["Content-Type"] = "application/json"
@@ -835,11 +836,13 @@ def __call__(
835836
json_format.MessageToJson(
836837
transcoded_request["query_params"],
837838
including_default_value_fields=False,
838-
use_integers_for_enums=False,
839+
use_integers_for_enums=True,
839840
)
840841
)
841842
query_params.update(self._get_unset_required_fields(query_params))
842843

844+
query_params["$alt"] = "json;enum-encoding=int"
845+
843846
# Send the request
844847
headers = dict(metadata)
845848
headers["Content-Type"] = "application/json"
@@ -919,11 +922,13 @@ def __call__(
919922
json_format.MessageToJson(
920923
transcoded_request["query_params"],
921924
including_default_value_fields=False,
922-
use_integers_for_enums=False,
925+
use_integers_for_enums=True,
923926
)
924927
)
925928
query_params.update(self._get_unset_required_fields(query_params))
926929

930+
query_params["$alt"] = "json;enum-encoding=int"
931+
927932
# Send the request
928933
headers = dict(metadata)
929934
headers["Content-Type"] = "application/json"
@@ -993,10 +998,12 @@ def __call__(
993998
json_format.MessageToJson(
994999
transcoded_request["query_params"],
9951000
including_default_value_fields=False,
996-
use_integers_for_enums=False,
1001+
use_integers_for_enums=True,
9971002
)
9981003
)
9991004

1005+
query_params["$alt"] = "json;enum-encoding=int"
1006+
10001007
# Send the request
10011008
headers = dict(metadata)
10021009
headers["Content-Type"] = "application/json"
@@ -1076,11 +1083,13 @@ def __call__(
10761083
json_format.MessageToJson(
10771084
transcoded_request["query_params"],
10781085
including_default_value_fields=False,
1079-
use_integers_for_enums=False,
1086+
use_integers_for_enums=True,
10801087
)
10811088
)
10821089
query_params.update(self._get_unset_required_fields(query_params))
10831090

1091+
query_params["$alt"] = "json;enum-encoding=int"
1092+
10841093
# Send the request
10851094
headers = dict(metadata)
10861095
headers["Content-Type"] = "application/json"

packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/client.py

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

packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py

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

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

6670
class BatchServiceRestInterceptor:
6771
"""Interceptor for BatchService.
@@ -474,9 +478,6 @@ class BatchServiceRestTransport(BatchServiceTransport):
474478
475479
It sends JSON representations of protocol buffers over HTTP/1.1
476480
477-
NOTE: This REST transport functionality is currently in a beta
478-
state (preview). We welcome your feedback via an issue in this
479-
library's source repository. Thank you!
480481
"""
481482

482483
def __init__(
@@ -496,39 +497,35 @@ def __init__(
496497
) -> None:
497498
"""Instantiate the transport.
498499
499-
NOTE: This REST transport functionality is currently in a beta
500-
state (preview). We welcome your feedback via a GitHub issue in
501-
this library's repository. Thank you!
502-
503-
Args:
504-
host (Optional[str]):
505-
The hostname to connect to.
506-
credentials (Optional[google.auth.credentials.Credentials]): The
507-
authorization credentials to attach to requests. These
508-
credentials identify the application to the service; if none
509-
are specified, the client will attempt to ascertain the
510-
credentials from the environment.
511-
512-
credentials_file (Optional[str]): A file with credentials that can
513-
be loaded with :func:`google.auth.load_credentials_from_file`.
514-
This argument is ignored if ``channel`` is provided.
515-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
516-
ignored if ``channel`` is provided.
517-
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
518-
certificate to configure mutual TLS HTTP channel. It is ignored
519-
if ``channel`` is provided.
520-
quota_project_id (Optional[str]): An optional project to use for billing
521-
and quota.
522-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
523-
The client info used to send a user-agent string along with
524-
API requests. If ``None``, then default info will be used.
525-
Generally, you only need to set this if you are developing
526-
your own client library.
527-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
528-
be used for service account credentials.
529-
url_scheme: the protocol scheme for the API endpoint. Normally
530-
"https", but for testing or local servers,
531-
"http" can be specified.
500+
Args:
501+
host (Optional[str]):
502+
The hostname to connect to.
503+
credentials (Optional[google.auth.credentials.Credentials]): The
504+
authorization credentials to attach to requests. These
505+
credentials identify the application to the service; if none
506+
are specified, the client will attempt to ascertain the
507+
credentials from the environment.
508+
509+
credentials_file (Optional[str]): A file with credentials that can
510+
be loaded with :func:`google.auth.load_credentials_from_file`.
511+
This argument is ignored if ``channel`` is provided.
512+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
513+
ignored if ``channel`` is provided.
514+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
515+
certificate to configure mutual TLS HTTP channel. It is ignored
516+
if ``channel`` is provided.
517+
quota_project_id (Optional[str]): An optional project to use for billing
518+
and quota.
519+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
520+
The client info used to send a user-agent string along with
521+
API requests. If ``None``, then default info will be used.
522+
Generally, you only need to set this if you are developing
523+
your own client library.
524+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
525+
be used for service account credentials.
526+
url_scheme: the protocol scheme for the API endpoint. Normally
527+
"https", but for testing or local servers,
528+
"http" can be specified.
532529
"""
533530
# Run the base constructor
534531
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
@@ -666,7 +663,7 @@ def __call__(
666663
body = json_format.MessageToJson(
667664
transcoded_request["body"],
668665
including_default_value_fields=False,
669-
use_integers_for_enums=False,
666+
use_integers_for_enums=True,
670667
)
671668
uri = transcoded_request["uri"]
672669
method = transcoded_request["method"]
@@ -676,11 +673,13 @@ def __call__(
676673
json_format.MessageToJson(
677674
transcoded_request["query_params"],
678675
including_default_value_fields=False,
679-
use_integers_for_enums=False,
676+
use_integers_for_enums=True,
680677
)
681678
)
682679
query_params.update(self._get_unset_required_fields(query_params))
683680

681+
query_params["$alt"] = "json;enum-encoding=int"
682+
684683
# Send the request
685684
headers = dict(metadata)
686685
headers["Content-Type"] = "application/json"
@@ -754,10 +753,12 @@ def __call__(
754753
json_format.MessageToJson(
755754
transcoded_request["query_params"],
756755
including_default_value_fields=False,
757-
use_integers_for_enums=False,
756+
use_integers_for_enums=True,
758757
)
759758
)
760759

760+
query_params["$alt"] = "json;enum-encoding=int"
761+
761762
# Send the request
762763
headers = dict(metadata)
763764
headers["Content-Type"] = "application/json"
@@ -835,11 +836,13 @@ def __call__(
835836
json_format.MessageToJson(
836837
transcoded_request["query_params"],
837838
including_default_value_fields=False,
838-
use_integers_for_enums=False,
839+
use_integers_for_enums=True,
839840
)
840841
)
841842
query_params.update(self._get_unset_required_fields(query_params))
842843

844+
query_params["$alt"] = "json;enum-encoding=int"
845+
843846
# Send the request
844847
headers = dict(metadata)
845848
headers["Content-Type"] = "application/json"
@@ -919,11 +922,13 @@ def __call__(
919922
json_format.MessageToJson(
920923
transcoded_request["query_params"],
921924
including_default_value_fields=False,
922-
use_integers_for_enums=False,
925+
use_integers_for_enums=True,
923926
)
924927
)
925928
query_params.update(self._get_unset_required_fields(query_params))
926929

930+
query_params["$alt"] = "json;enum-encoding=int"
931+
927932
# Send the request
928933
headers = dict(metadata)
929934
headers["Content-Type"] = "application/json"
@@ -993,10 +998,12 @@ def __call__(
993998
json_format.MessageToJson(
994999
transcoded_request["query_params"],
9951000
including_default_value_fields=False,
996-
use_integers_for_enums=False,
1001+
use_integers_for_enums=True,
9971002
)
9981003
)
9991004

1005+
query_params["$alt"] = "json;enum-encoding=int"
1006+
10001007
# Send the request
10011008
headers = dict(metadata)
10021009
headers["Content-Type"] = "application/json"
@@ -1076,11 +1083,13 @@ def __call__(
10761083
json_format.MessageToJson(
10771084
transcoded_request["query_params"],
10781085
including_default_value_fields=False,
1079-
use_integers_for_enums=False,
1086+
use_integers_for_enums=True,
10801087
)
10811088
)
10821089
query_params.update(self._get_unset_required_fields(query_params))
10831090

1091+
query_params["$alt"] = "json;enum-encoding=int"
1092+
10841093
# Send the request
10851094
headers = dict(metadata)
10861095
headers["Content-Type"] = "application/json"

0 commit comments

Comments
 (0)