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
34 lines (27 loc) · 1.29 KB
/
sample.py.j2
File metadata and controls
34 lines (27 loc) · 1.29 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
{% 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 }}]
{# python code is responsible for all transformations: all we do here is render #}
{% for import_statement in imports %}
{{ import_statement }}
{% endfor %}
from {{ api.naming.module_namespace|join(".") }} import {{ api.naming.versioned_module_name }}
{# also need calling form #}
def sample_{{ frags.render_method_name(sample.rpc)|trim -}}({{ frags.print_input_params(sample.request)|trim -}}):
"""{{ sample.description }}"""
# Create client
client = {{ api.naming.versioned_module_name }}.{{ service.client_name }}()
{# TODO: Enable detailed request setup #}
{# {{ frags.render_request_setup(sample.request)|indent }} #}
{% with method_call = frags.render_method_call(sample, calling_form, calling_form_enum) %}
# Make the request
{{ frags.render_calling_form(method_call, calling_form, calling_form_enum, 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.rpc, sample.request) }} #}
{%- endblock %}