-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for reading ClientLibrarySettings from service conf…
…iguration YAML
- Loading branch information
Showing
40 changed files
with
6,662 additions
and
3,390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/README.rst.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
transport inheritance structure | ||
_______________________________ | ||
|
||
`{{ service.name }}Transport` is the ABC for all transports. | ||
- public child `{{ service.name }}GrpcTransport` for sync gRPC transport (defined in `grpc.py`). | ||
- public child `{{ service.name }}GrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). | ||
- private child `_Base{{ service.name }}RestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). | ||
- public child `{{ service.name }}RestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). | ||
{# Since the service mixins have a similar structure, we factor out shared code into `_shared_macros.j2` to avoid duplication. #} |
18 changes: 18 additions & 0 deletions
18
gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/_mixins.py.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...lates/%namespace/%name_%version/%sub/services/%service/transports/_rest_mixins_base.py.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{# | ||
# Copyright (C) 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#} | ||
|
||
{% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %} | ||
|
||
{% if "rest" in opts.transport %} | ||
|
||
{% for name, sig in api.mixin_api_signatures.items() %} | ||
class _Base{{ name }}: | ||
|
||
{{ shared_macros.http_options_method(api.mixin_http_options["{}".format(name)])|indent(8)}} | ||
|
||
@staticmethod | ||
def _get_transcoded_request(http_options, request): | ||
request_kwargs = json_format.MessageToDict(request) | ||
transcoded_request = path_template.transcode( | ||
http_options, **request_kwargs) | ||
return transcoded_request | ||
|
||
{% set body_spec = api.mixin_http_options["{}".format(name)][0].body %} | ||
{%- if body_spec %} | ||
|
||
@staticmethod | ||
def _get_request_body_json(transcoded_request): | ||
body = json.dumps(transcoded_request['body']) | ||
return body | ||
|
||
{%- endif %} {# body_spec #} | ||
|
||
@staticmethod | ||
def _get_query_params_json(transcoded_request): | ||
query_params = json.loads(json.dumps(transcoded_request['query_params'])) | ||
return query_params | ||
|
||
{% endfor %} | ||
{% endif %} {# rest in opts.transport #} |
Oops, something went wrong.