Skip to content

Commit 28de5f8

Browse files
committed
feat: adds two partial templates for creating method signatures
1 parent dc54c99 commit 28de5f8

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
def {{ method.name }}(
2+
self,
3+
{{ method.request_id_args[-1] }}: Optional[str] = None,
4+
*,
5+
request: Optional[{{ '.'.join(method.request_class_full_name.split('.')[-2:]) }}] = None,
6+
retry: OptionalRetry = DEFAULT_RETRY,
7+
timeout: Union[float, object] = DEFAULT_TIMEOUT,
8+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = DEFAULT_METADATA,
9+
) -> "{{ method.return_type }}":
10+
"""
11+
TODO: Docstring is purposefully blank. microgenerator will add automatically.
12+
"""
13+
if request and {{ method.request_id_args[-1] }} is not None:
14+
raise ValueError("Cannot provide both request and {{ method.request_id_args[-1] }}.")
15+
16+
if request:
17+
final_request = request
18+
else:
19+
path_identifier = {{ method.request_id_args[-1] }}
20+
if path_identifier is None:
21+
if len({{ method.request_id_args }}) == 1:
22+
path_identifier = self.project
23+
else:
24+
raise ValueError("Either request or {{ method.request_id_args[-1] }} must be provided.")
25+
26+
if path_identifier is None:
27+
raise ValueError("Could not determine a path identifier.")
28+
29+
request_class = {{ '.'.join(method.request_class_full_name.split('.')[-2:]) }}
30+
31+
final_request = _helpers._create_request(
32+
request_class=request_class,
33+
path_identifier=path_identifier,
34+
expected_args={{ method.request_id_args }},
35+
default_project_id=self.project,
36+
)
37+
38+
return self.{{ class_to_instance_map[method.class_name] }}.{{ method.name }}(
39+
request=final_request,
40+
retry=retry,
41+
timeout=timeout,
42+
metadata=metadata,
43+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def {{ method.name }}(
2+
self,
3+
*,
4+
request: Optional[dict] = None,
5+
retry: OptionalRetry = DEFAULT_RETRY,
6+
timeout: Union[float, object] = DEFAULT_TIMEOUT,
7+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = DEFAULT_METADATA,
8+
) -> "{{ method.return_type }}":
9+
"""
10+
TODO: Docstring is purposefully blank. microgenerator will add automatically.
11+
"""
12+
13+
return self.{{ class_to_instance_map[method.class_name] }}.{{ method.name }}(
14+
request=request,
15+
retry=retry,
16+
timeout=timeout,
17+
metadata=metadata,
18+
)

0 commit comments

Comments
 (0)