-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add transport
option to generation_config.yaml
#3052
Changes from 3 commits
42648dc
6e2686c
faf5830
be42912
1700842
3bc9425
f7ef615
715667a
53681e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,13 +72,16 @@ def generate_composed_library( | |
gapic_inputs = parse_build_file(build_file_folder, gapic.proto_path) | ||
# generate postprocessing prerequisite files (.repo-metadata.json, .OwlBot-hermetic.yaml, | ||
# owlbot.py) here because transport is parsed from BUILD.bazel, | ||
# which lives in a versioned proto_path. | ||
# which lives in a versioned proto_path. The value of transport will be | ||
# overriden by the config object if specified. Note that this override | ||
# does not affect library generation but instead used only for | ||
# generating postprocessing files such as README. | ||
util.generate_postprocessing_prerequisite_files( | ||
config=config, | ||
library=library, | ||
proto_path=util.remove_version_from(gapic.proto_path), | ||
transport=gapic_inputs.transport, | ||
library_path=library_path, | ||
gapic_inputs=gapic_inputs, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from @blakeli0: let's encapsulate this logic in a function of |
||
) | ||
temp_destination_path = f"java-{gapic.proto_path.replace('/','-')}" | ||
effective_arguments = __construct_effective_arg( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"api_shortname": "secretmanager", | ||
"name_pretty": "Secret Management", | ||
"product_documentation": "https://cloud.google.com/solutions/secrets-management/", | ||
"api_description": "allows you to encrypt, store, manage, and audit infrastructure and application-level secrets.", | ||
"client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-secretmanager/latest/overview", | ||
"release_level": "preview", | ||
"transport": "http", | ||
"language": "java", | ||
"repo": "googleapis/google-cloud-java", | ||
"repo_short": "java-secretmanager", | ||
"distribution_name": "com.google.cloud:google-cloud-secretmanager", | ||
"api_id": "secretmanager.googleapis.com", | ||
"library_type": "GAPIC_AUTO", | ||
"requires_billing": true | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ | |||||||||||||||||
import shutil | ||||||||||||||||||
from pathlib import Path | ||||||||||||||||||
from library_generation.model.generation_config import GenerationConfig | ||||||||||||||||||
from library_generation.model.gapic_inputs import GapicInputs | ||||||||||||||||||
from library_generation.model.library_config import LibraryConfig | ||||||||||||||||||
from typing import List | ||||||||||||||||||
from library_generation.model.repo_config import RepoConfig | ||||||||||||||||||
|
@@ -186,7 +187,7 @@ def generate_postprocessing_prerequisite_files( | |||||||||||||||||
config: GenerationConfig, | ||||||||||||||||||
library: LibraryConfig, | ||||||||||||||||||
proto_path: str, | ||||||||||||||||||
transport: str, | ||||||||||||||||||
gapic_inputs: GapicInputs, | ||||||||||||||||||
library_path: str, | ||||||||||||||||||
language: str = "java", | ||||||||||||||||||
) -> None: | ||||||||||||||||||
|
@@ -198,11 +199,14 @@ def generate_postprocessing_prerequisite_files( | |||||||||||||||||
:param library: the library configuration | ||||||||||||||||||
:param proto_path: the path from the root of googleapis to the location of the service | ||||||||||||||||||
protos. If the path contains a version, it will be removed | ||||||||||||||||||
:param transport: transport supported by the library | ||||||||||||||||||
:param gapic_inputs: gapic_inputs obtained from the library's BUILD.bazel | ||||||||||||||||||
:param library_path: the path to which the generated file goes | ||||||||||||||||||
:param language: programming language of the library | ||||||||||||||||||
:return: None | ||||||||||||||||||
""" | ||||||||||||||||||
transport = ( | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this logic to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially did it that way, but then I found that it would be better for testing if we leave the This test helper passes a hard-coded value: sdk-platform-java/library_generation/test/utilities_unit_tests.py Lines 279 to 286 in e46648f
And we don't have unit tests for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolution from discussion with @blakeli0: let's move the logic to the model class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||||||
gapic_inputs.transport if library.transport is None else library.transport | ||||||||||||||||||
) | ||||||||||||||||||
library_name = library.get_library_name() | ||||||||||||||||||
artifact_id = library.get_artifact_id() | ||||||||||||||||||
if config.contains_common_protos(): | ||||||||||||||||||
|
@@ -224,7 +228,10 @@ def generate_postprocessing_prerequisite_files( | |||||||||||||||||
# is one of grpc, http and both, | ||||||||||||||||||
if transport == "grpc": | ||||||||||||||||||
converted_transport = "grpc" | ||||||||||||||||||
elif transport == "rest": | ||||||||||||||||||
elif transport in [ | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this is because we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||||||||||||||||
"rest", | ||||||||||||||||||
"http", | ||||||||||||||||||
]: # http can also be specified via generation_config.yaml | ||||||||||||||||||
converted_transport = "http" | ||||||||||||||||||
else: | ||||||||||||||||||
converted_transport = "both" | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we use
transport
from BUILD.bazel to determine if we should generate a grpc module or not, can you please confirm that? If yes, we should update the description to something likeThis value would only be used for generating .repo-metadata.json and relevant sections in README
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done