-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(gapic-generator): add support for resumable uploads #18354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
97d7d24
27f4f31
ecf086f
d6e5718
56bd6d8
1c1e284
d20a47c
ac5fe37
9385108
08d5522
cabbe7e
326db48
ebcb83a
660d32d
e23fe10
db6d375
93c7e38
9922795
705209d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1345,7 +1345,8 @@ def _load_children( | |
| wrapped = loader( | ||
| child, address=address, path=path + (i,), resources=resources | ||
| ) | ||
| answer[wrapped.name] = wrapped | ||
| if wrapped is not None: | ||
| answer[wrapped.name] = wrapped | ||
| return answer | ||
|
|
||
| def _get_oneofs( | ||
|
|
@@ -1633,6 +1634,9 @@ def _get_methods( | |
| # Iterate over the methods and collect them into a dictionary. | ||
| answer: Dict[str, wrappers.Method] = collections.OrderedDict() | ||
| for i, meth_pb in enumerate(methods): | ||
| if self._is_media_upload_proto(meth_pb) and not self.opts.resumable_upload_prefix: | ||
| continue | ||
|
Comment on lines
+1637
to
+1638
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skipping the generation of media upload methods entirely when References
|
||
|
|
||
| retry, timeout = self._get_retry_and_timeout(service_address, meth_pb) | ||
|
|
||
| # Create the method wrapper object. | ||
|
|
@@ -1651,11 +1655,37 @@ def _get_methods( | |
| output=self.api_messages[meth_pb.output_type.lstrip(".")], | ||
| retry=retry, | ||
| timeout=timeout, | ||
| resumable_upload_prefix=self.opts.resumable_upload_prefix, | ||
| ) | ||
|
|
||
| # Done; return the answer. | ||
| return answer | ||
|
|
||
| def _is_media_upload_proto( | ||
| self, meth_pb: descriptor_pb2.MethodDescriptorProto | ||
| ) -> bool: | ||
| try: | ||
| if meth_pb.options: | ||
| http = meth_pb.options.Extensions[annotations_pb2.http] | ||
| if getattr(http, "media_upload", None) and getattr( | ||
| http.media_upload, "enabled", False | ||
| ): | ||
| return True | ||
| for binding in getattr(http, "additional_bindings", ()): | ||
| if getattr(binding, "media_upload", None) and getattr( | ||
| binding.media_upload, "enabled", False | ||
| ): | ||
| return True | ||
| except Exception: | ||
| pass | ||
|
|
||
| # TODO(cl/964122389): TEMPORARY - Remove this hardcoded fallback once | ||
| # the media_upload annotation is published in cl/964122389 and added to gapic-showcase proto. | ||
| if meth_pb.name == "UploadMedia": | ||
| return True | ||
|
|
||
| return False | ||
|
|
||
| def _load_message( | ||
| self, | ||
| message_pb: descriptor_pb2.DescriptorProto, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert this change once #18352 is merged to main and released