Skip to content

Commit

Permalink
chore: Enable requesting numeric enums in "transport=rest" responses …
Browse files Browse the repository at this point in the history
…for services supporting this (#159)

* 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Dec 6, 2022
1 parent 8741a7a commit e232c62
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ def __init__(
transport (Union[str, FlexTemplatesServiceTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
NOTE: "rest" transport functionality is currently in a
beta state (preview). We welcome your feedback via an
issue in this library's source repository.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
rest_version=requests_version,
)

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


class FlexTemplatesServiceRestInterceptor:
"""Interceptor for FlexTemplatesService.
Expand Down Expand Up @@ -119,9 +123,6 @@ class FlexTemplatesServiceRestTransport(FlexTemplatesServiceTransport):
It sends JSON representations of protocol buffers over HTTP/1.1
NOTE: This REST transport functionality is currently in a beta
state (preview). We welcome your feedback via an issue in this
library's source repository. Thank you!
"""

def __init__(
Expand All @@ -141,39 +142,35 @@ def __init__(
) -> None:
"""Instantiate the transport.
NOTE: This REST transport functionality is currently in a beta
state (preview). We welcome your feedback via a GitHub issue in
this library's repository. Thank you!
Args:
host (Optional[str]):
The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you are developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
url_scheme: the protocol scheme for the API endpoint. Normally
"https", but for testing or local servers,
"http" can be specified.
Args:
host (Optional[str]):
The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you are developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
url_scheme: the protocol scheme for the API endpoint. Normally
"https", but for testing or local servers,
"http" can be specified.
"""
# Run the base constructor
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
Expand Down Expand Up @@ -254,7 +251,7 @@ def __call__(
body = json_format.MessageToJson(
transcoded_request["body"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
Expand All @@ -264,10 +261,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,6 @@ def __init__(
transport (Union[str, JobsV1Beta3Transport]): The
transport to use. If set to None, a transport is chosen
automatically.
NOTE: "rest" transport functionality is currently in a
beta state (preview). We welcome your feedback via an
issue in this library's source repository.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
rest_version=requests_version,
)

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


class JobsV1Beta3RestInterceptor:
"""Interceptor for JobsV1Beta3.
Expand Down Expand Up @@ -255,9 +259,6 @@ class JobsV1Beta3RestTransport(JobsV1Beta3Transport):
It sends JSON representations of protocol buffers over HTTP/1.1
NOTE: This REST transport functionality is currently in a beta
state (preview). We welcome your feedback via an issue in this
library's source repository. Thank you!
"""

def __init__(
Expand All @@ -277,39 +278,35 @@ def __init__(
) -> None:
"""Instantiate the transport.
NOTE: This REST transport functionality is currently in a beta
state (preview). We welcome your feedback via a GitHub issue in
this library's repository. Thank you!
Args:
host (Optional[str]):
The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you are developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
url_scheme: the protocol scheme for the API endpoint. Normally
"https", but for testing or local servers,
"http" can be specified.
Args:
host (Optional[str]):
The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you are developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
url_scheme: the protocol scheme for the API endpoint. Normally
"https", but for testing or local servers,
"http" can be specified.
"""
# Run the base constructor
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
Expand Down Expand Up @@ -396,10 +393,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down Expand Up @@ -492,7 +491,7 @@ def __call__(
body = json_format.MessageToJson(
transcoded_request["body"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
Expand All @@ -502,10 +501,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down Expand Up @@ -584,10 +585,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down Expand Up @@ -669,10 +672,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down Expand Up @@ -747,7 +752,7 @@ def __call__(
body = json_format.MessageToJson(
transcoded_request["body"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
Expand All @@ -757,10 +762,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down Expand Up @@ -838,7 +845,7 @@ def __call__(
body = json_format.MessageToJson(
transcoded_request["body"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
Expand All @@ -848,10 +855,12 @@ def __call__(
json_format.MessageToJson(
transcoded_request["query_params"],
including_default_value_fields=False,
use_integers_for_enums=False,
use_integers_for_enums=True,
)
)

query_params["$alt"] = "json;enum-encoding=int"

# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ def __init__(
transport (Union[str, MessagesV1Beta3Transport]): The
transport to use. If set to None, a transport is chosen
automatically.
NOTE: "rest" transport functionality is currently in a
beta state (preview). We welcome your feedback via an
issue in this library's source repository.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
Expand Down
Loading

0 comments on commit e232c62

Please sign in to comment.