22
33{% block content %}
44from collections import OrderedDict
5- from typing import Dict, Sequence, Tuple, Type, Union
5+ from typing import Dict, Iterable, Iterator, Sequence, Tuple, Type, Union
66import pkg_resources
77
88import google.api_core.client_options as ClientOptions # type: ignore
@@ -11,7 +11,7 @@ from google.api_core import gapic_v1 # type: ignore
1111from google.api_core import retry as retries # type: ignore
1212from google.auth import credentials # type: ignore
1313from google.oauth2 import service_account # type: ignore
14-
14+
1515{% filter sort_lines -%}
1616{% for method in service .methods .values () -%}
1717{% for ref_type in method .ref_types_legacy -%}
@@ -126,18 +126,28 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
126126
127127 {% for method in service .methods .values () -%}
128128 def {{ method.name|snake_case }}(self,
129+ {% - if not method .client_streaming %}
129130 request: {{ method.input.ident }} = None,
130131 *,
131132 {% for field in method .flattened_fields .values () -%}
132133 {{ field.name }}: {{ field.ident }} = None,
133134 {% endfor -%}
135+ {% - else %}
136+ requests: Iterator[{{ method.input.ident }}] = None,
137+ *,
138+ {% endif -%}
134139 retry: retries.Retry = gapic_v1.method.DEFAULT,
135140 timeout: float = None,
136141 metadata: Sequence[Tuple[str, str]] = (),
142+ {% - if not method .server_streaming %}
137143 ) -> {{ method.client_output.ident }}:
144+ {% - else %}
145+ ) -> Iterable[{{ method.client_output.ident }}]:
146+ {% - endif %}
138147 r"""{{ method.meta.doc|rst(width=72, indent=8) }}
139148
140149 Args:
150+ {% - if not method .client_streaming %}
141151 request (:class:`{{ method.input.ident.sphinx }}`):
142152 The request object.{{ ' ' -}}
143153 {{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
@@ -148,6 +158,11 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
148158 on the ``request`` instance; if ``request`` is provided, this
149159 should not be set.
150160 {% endfor -%}
161+ {% - else %}
162+ requests (Iterator[`{{ method.input.ident.sphinx }}`]):
163+ The request object iterator.{{ ' ' -}}
164+ {{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
165+ {% - endif %}
151166 retry (google.api_core.retry.Retry): Designation of what errors, if any,
152167 should be retried.
153168 timeout (float): The timeout for this request.
@@ -156,10 +171,15 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
156171 {% - if not method .void %}
157172
158173 Returns:
174+ {% - if not method .server_streaming %}
159175 {{ method.client_output.ident.sphinx }}:
176+ {% - else %}
177+ Iterable[{{ method.client_output.ident.sphinx }}]:
178+ {% - endif %}
160179 {{ method.client_output.meta.doc|rst(width=72, indent=16) }}
161180 {% - endif %}
162181 """
182+ {% - if not method .client_streaming %}
163183 # Create or coerce a protobuf request object.
164184 {% if method .flattened_fields -%}
165185 # Sanity check: If we got a request object, we should *not* have
@@ -176,6 +196,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
176196 if {{ field.name }} is not None:
177197 request.{{ key }} = {{ field.name }}
178198 {% - endfor %}
199+ {% - endif %}
179200
180201 # Wrap the RPC method; this adds retry and timeout information,
181202 # and friendly error handling.
@@ -213,7 +234,11 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
213234
214235 # Send the request.
215236 {% if not method .void %} response = {% endif %} rpc(
237+ {% - if not method .client_streaming %}
216238 request,
239+ {% - else %}
240+ requests,
241+ {% - endif %}
217242 retry=retry,
218243 timeout=timeout,
219244 metadata=metadata,
0 commit comments