This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathsample.py.j2
More file actions
46 lines (38 loc) · 1.86 KB
/
sample.py.j2
File metadata and controls
46 lines (38 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{#
# Copyright (C) 2019 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.
#}
{% extends "_base.py.j2" %}
{% block content %}
{# Input parameters: sample #}
{# callingForm #}
{% import "examples/feature_fragments.j2" as frags %}
{{ frags.sample_header(sample, calling_form) }}
# [START {{ sample.id }}]
{% include "examples/_generated_sample_comment.j2" %}
{# python code is responsible for all transformations: all we do here is render #}
{% for import_statement in imports %}
{{ import_statement }}
{% endfor %}
{# also need calling form #}
{% if sample.transport == "grpc-async" %}async {% endif %}def sample_{{ sample.rpc|snake_case|trim }}({{ frags.print_input_params(sample.request)|trim }}):
{{ frags.render_client_setup(sample.module_name, sample.client_name)|indent }}
{{ frags.render_request_setup(sample.request, sample.request_module_name, sample.request_type, calling_form, calling_form_enum)|indent }}
{% with method_call = frags.render_method_call(sample, calling_form, calling_form_enum, sample.transport) %}
{{ frags.render_calling_form(method_call, calling_form, calling_form_enum, sample.transport, sample.response)|indent -}}
{% endwith %}
# [END {{ sample.id }}]
{# TODO: Enable main block (or decide to remove main block from python sample) #}
{# {{ frags.render_main_block(sample, sample.request) }} #}
{% endblock %}