Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
@@ -0,0 +1,33 @@
{
"schema": "1.0",
Comment thread
software-dov marked this conversation as resolved.
Outdated
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
"language": "python",
"protoPackage": "{{ api.naming.proto_package }}",
"libraryPackage": "{{ '.'.join(api.naming.module_namespace+(api.naming.versioned_module_name,)) }}",
"services": {
{% for service in api.services.values()|sort(attribute='name') -%}
"{{ service.name }}":{
{% if 'grpc' in opts.transport -%}
"grpc": {
"libraryClient": "{{ service.client_name }}",
"rpcs": {
{% for method in service.methods.values() -%}
"{{ method.name }}": ["{{ method.name|snake_case }}"]{{ "," if not loop.last else "" }}
{% endfor -%}{# method -#}
}
}{{ "," if 'rest' in opts.transport else "" -}}
{% endif -%}
{% if 'rest' in opts.transport -%}
"rest": {
"libraryClient": "{{ service.client_name }}",
"rpcs": {
{% for method in service.methods.values() -%}
"{{ method.name }}": ["{{ method.name|snake_case }}"]{{ "," if not loop.last else "" }}
{% endfor -%}{# method -#}
}
}
{% endif -%}{# opts.transport #}
}{{ "," if not loop.last else "" }}
{% endfor -%}{# service -#}
}
}
9 changes: 5 additions & 4 deletions gapic/cli/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ def generate(
# This generator uses a slightly different mechanism for determining
# which files to generate; it tracks at package level rather than file
# level.
package = os.path.commonprefix([i.package for i in filter(
lambda p: p.name in req.file_to_generate,
req.proto_file,
)]).rstrip('.')
package = os.path.commonprefix([
p.package
for p in req.proto_file
if p.name in req.file_to_generate
]).rstrip('.')

# Build the API model object.
# This object is a frozen representation of the whole API, and is sent
Expand Down
41 changes: 41 additions & 0 deletions gapic/templates/%namespace/%name_%version/gapic_metadata.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"schema": "1.0",
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
"language": "python",
"protoPackage": "{{ api.naming.proto_package }}",
"libraryPackage": "{{ '.'.join(api.naming.module_namespace+(api.naming.versioned_module_name,)) }}",
"services": {
{% for service in api.services.values()|sort(attribute='name') -%}
"{{ service.name }}":{
{% if 'grpc' in opts.transport -%}
"grpc": {
"libraryClient": "{{ service.client_name }}",
"rpcs": {
{% for method in service.methods.values() -%}
"{{ method.name }}": ["{{ method.name|snake_case }}"]{{ "," if not loop.last else "" }}
{% endfor -%}{# method -#}
}
},
"grpcAsync": {
"libraryClient": "{{ service.async_client_name }}",
"rpcs": {
{% for method in service.methods.values() -%}
"{{ method.name }}": ["{{ method.name|snake_case }}"]{{ "," if not loop.last else "" }}
{% endfor -%}{# method -#}
}
}{{ "," if 'rest' in opts.transport else "" -}}
{% endif -%}
{% if 'rest' in opts.transport -%}
"rest": {
"libraryClient": "{{ service.client_name }}",
"rpcs": {
{% for method in service.methods.values() -%}
"{{ method.name }}": ["{{ method.name|snake_case }}"]{{ "," if not loop.last else "" }}
{% endfor -%}{# method -#}
}
}
{% endif -%}{# opts.transport #}
}{{ "," if not loop.last else "" }}
{% endfor -%}{# service -#}
}
}