Skip to content

Commit

Permalink
feat: Add BUILD rule parameter to allow setting numeric enums (#1411)
Browse files Browse the repository at this point in the history
This allows generator users to set the numeric-enum-response parameter at generation time via the BUILD rule. The default is `False` for backward compatibility.
  • Loading branch information
vchudnov-g committed Aug 17, 2022
1 parent a80d861 commit 5c578ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/getting-started/bazel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ your ``BUILD.bazel`` file. You can use the Python section of the Document AI
":documentai_py_gapic",
],
)
Some of the ``py_gapic_library`` rule that may be of interest:
* ``transport``: the desired transport(s) to generate, delimited by ``+`` e.g. ``grpc+rest``.
- Acceptable values are ``grpc`` and ``rest``.
- Defaults to ``grpc``.

* ``rest_numeric_enums``: if ``True``, enables generation of system parameter requesting response enums be encoded as numbers.
- Default is ``False``.
- Only effective when ``rest`` is included as a ``transport`` to be generated.

.. _BUILD.bazel: https://github.com/googleapis/googleapis/blob/master/google/cloud/documentai/v1beta2/BUILD.bazel

Compiling an API
Expand Down
4 changes: 4 additions & 0 deletions rules_python_gapic/py_gapic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def py_gapic_library(
metadata = True,
service_yaml = None,
transport = None,
rest_numeric_enums = False,
deps = [],
**kwargs):
srcjar_target_name = "%s_srcjar" % name
Expand All @@ -63,6 +64,9 @@ def py_gapic_library(
if transport:
opt_args = opt_args + ["transport=%s" % transport]

if rest_numeric_enums:
opt_args = opt_args + ["rest-numeric-enums"]

proto_custom_library(
name = srcjar_target_name,
deps = srcs,
Expand Down

0 comments on commit 5c578ed

Please sign in to comment.