Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ To get help, follow the instructions in the [shared Troubleshooting document][tr

{% if metadata['repo']['transport'] == 'grpc' -%}
{{metadata['repo']['name_pretty']}} uses gRPC for the transport layer.
{% elif metadata['repo']['transport'] == 'http' -%}
{% elif metadata['repo']['transport'] == 'http' or metadata['repo']['transport'] == 'rest' -%}
{{metadata['repo']['name_pretty']}} uses HTTP/JSON for the transport layer.
{% elif metadata['repo']['transport'] == 'both' -%}
{% elif metadata['repo']['transport'] == 'both' or metadata['repo']['transport'] == 'grpc+rest' -%}
{{metadata['repo']['name_pretty']}} uses both gRPC and HTTP/JSON for the transport layer.
Comment on lines +160 to 163

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the in operator with a list of values is more concise and idiomatic in Jinja templates than multiple or conditions. This also makes it easier to maintain if more transport types are added in the future.

Suggested change
{% elif metadata['repo']['transport'] == 'http' or metadata['repo']['transport'] == 'rest' -%}
{{metadata['repo']['name_pretty']}} uses HTTP/JSON for the transport layer.
{% elif metadata['repo']['transport'] == 'both' -%}
{% elif metadata['repo']['transport'] == 'both' or metadata['repo']['transport'] == 'grpc+rest' -%}
{{metadata['repo']['name_pretty']}} uses both gRPC and HTTP/JSON for the transport layer.
{% elif metadata['repo']['transport'] in ['http', 'rest'] -%}
{{metadata['repo']['name_pretty']}} uses HTTP/JSON for the transport layer.
{% elif metadata['repo']['transport'] in ['both', 'grpc+rest'] -%}
{{metadata['repo']['name_pretty']}} uses both gRPC and HTTP/JSON for the transport layer.

{% endif %}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"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",
"transport": "rest",
"language": "java",
"repo": "googleapis/google-cloud-java",
"repo_short": "java-secretmanager",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,14 @@ def generate_postprocessing_prerequisite_files(
else f"https://cloud.google.com/{language}/docs/reference/{artifact_id}/latest/overview"
)

# The mapping is needed because transport in .repo-metadata.json
# is one of grpc, http and both,
if transport == "grpc":
converted_transport = "grpc"
elif transport == "rest":
converted_transport = "http"
else:
converted_transport = "both"

repo_metadata = {
"api_shortname": library.api_shortname,
"name_pretty": library.name_pretty,
"product_documentation": library.product_documentation,
"api_description": library.api_description,
"client_documentation": client_documentation,
"release_level": library.release_level,
"transport": converted_transport,
"transport": transport,
"language": language,
"repo": repo,
"repo_short": f"{language}-{library_name}",
Expand Down
Loading