|
1 | 1 | from logging import getLogger |
| 2 | +from typing import Any, cast |
2 | 3 |
|
3 | 4 | from nebius.api.nebius import ( |
4 | 5 | FieldBehavior, |
5 | 6 | enum_value_deprecation_details, |
6 | 7 | field_deprecation_details, |
7 | 8 | message_deprecation_details, |
8 | 9 | method_deprecation_details, |
| 10 | + send_reset_mask, |
9 | 11 | service_deprecation_details, |
10 | 12 | ) |
11 | 13 |
|
@@ -755,6 +757,24 @@ def is_operation_output(method: Method) -> bool: |
755 | 757 | ) |
756 | 758 |
|
757 | 759 |
|
| 760 | +def _send_reset_mask_setting(method: Method) -> bool | None: |
| 761 | + """ |
| 762 | + Returns True/False when annotation is set, otherwise None. |
| 763 | + """ |
| 764 | + ext = cast(Any, send_reset_mask) |
| 765 | + options = method.descriptor.options |
| 766 | + if not options.HasExtension(ext): |
| 767 | + return None |
| 768 | + return bool(options.Extensions[ext]) |
| 769 | + |
| 770 | + |
| 771 | +def _should_add_reset_mask(method: Method) -> bool: |
| 772 | + setting = _send_reset_mask_setting(method) |
| 773 | + if setting is None: |
| 774 | + return method.name == "Update" |
| 775 | + return setting |
| 776 | + |
| 777 | + |
758 | 778 | def generate_service(srv: Service, g: PyGenFile) -> None: |
759 | 779 | operation_type = None |
760 | 780 | operation_source_method = None |
@@ -882,7 +902,7 @@ def generate_service(srv: Service, g: PyGenFile) -> None: |
882 | 902 | g.p(", stack_info=True, stacklevel=2)") |
883 | 903 | g.p() |
884 | 904 |
|
885 | | - if method.name == "Update" and is_operation_output(method): |
| 905 | + if _should_add_reset_mask(method): |
886 | 906 | g.p( |
887 | 907 | "kwargs['metadata'] = ", |
888 | 908 | ImportedSymbol( |
|
0 commit comments