-
Notifications
You must be signed in to change notification settings - Fork 87
feat: add preview MultipartUploadClient#listMultipartUploads #3396
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 20 commits
21fb8fe
fa539c0
f6b31d3
b900983
37bf4ec
194284b
de8dc78
6af874b
ac9387d
9273da0
9f75064
6b9562c
57a7abd
73b07fa
0701c6b
a33268c
5ac47b7
e14725e
310754d
d53c735
0ed2945
e229e73
002fd8b
2b2fe9a
1e162b9
e330520
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 |
|---|---|---|
|
|
@@ -36,6 +36,8 @@ | |
| import com.google.cloud.storage.multipartupload.model.CompleteMultipartUploadResponse; | ||
| import com.google.cloud.storage.multipartupload.model.CreateMultipartUploadRequest; | ||
| import com.google.cloud.storage.multipartupload.model.CreateMultipartUploadResponse; | ||
| import com.google.cloud.storage.multipartupload.model.ListMultipartUploadsRequest; | ||
| import com.google.cloud.storage.multipartupload.model.ListMultipartUploadsResponse; | ||
| import com.google.cloud.storage.multipartupload.model.ListPartsRequest; | ||
| import com.google.cloud.storage.multipartupload.model.ListPartsResponse; | ||
| import com.google.cloud.storage.multipartupload.model.UploadPartRequest; | ||
|
|
@@ -111,6 +113,42 @@ ListPartsResponse sendListPartsRequest(URI uri, ListPartsRequest request) throws | |
| return httpRequest.execute().parseAs(ListPartsResponse.class); | ||
| } | ||
|
|
||
| ListMultipartUploadsResponse sendListMultipartUploadsRequest( | ||
| URI uri, ListMultipartUploadsRequest request) throws IOException { | ||
|
|
||
| ImmutableMap.Builder<String, Object> params = | ||
| ImmutableMap.<String, Object>builder().put("bucket", request.bucket()); | ||
| if (request.delimiter() != null) { | ||
| params.put("delimiter", request.delimiter()); | ||
| } | ||
| if (request.encodingType() != null) { | ||
| params.put("encoding-type", request.encodingType()); | ||
| } | ||
| if (request.keyMarker() != null) { | ||
| params.put("key-marker", request.keyMarker()); | ||
| } | ||
| if (request.maxUploads() != null) { | ||
| params.put("max-uploads", request.maxUploads()); | ||
| } | ||
| if (request.prefix() != null) { | ||
| params.put("prefix", request.prefix()); | ||
| } | ||
| if (request.uploadIdMarker() != null) { | ||
| params.put("upload-id-marker", request.uploadIdMarker()); | ||
| } | ||
| String listUri = | ||
| UriTemplate.expand( | ||
| uri.toString() | ||
| + "{bucket}?uploads{&delimiter,encoding-type,key-marker,max-uploads,prefix,upload-id-marker}", | ||
| params.build(), | ||
| false); | ||
| HttpRequest httpRequest = requestFactory.buildGetRequest(new GenericUrl(listUri)); | ||
| httpRequest.getHeaders().putAll(headerProvider.getHeaders()); | ||
| httpRequest.setParser(objectParser); | ||
| httpRequest.setThrowExceptionOnExecuteError(true); | ||
| return httpRequest.execute().parseAs(ListMultipartUploadsResponse.class); | ||
| } | ||
|
|
||
| AbortMultipartUploadResponse sendAbortMultipartUploadRequest( | ||
| URI uri, AbortMultipartUploadRequest request) throws IOException { | ||
|
|
||
|
|
@@ -273,7 +311,7 @@ private static String urlEncode(String value) { | |
| */ | ||
| private static String formatName(String name) { | ||
| // Only lowercase letters, digits, and "-" are allowed | ||
| return name.toLowerCase().replaceAll("[^\\w\\d\\-]", "-"); | ||
| return name.toLowerCase().replaceAll("[^\\w-]", "-"); | ||
|
Collaborator
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. Why did we need to remove
Collaborator
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. Also, the comment wasn't updated when the regex was and is now inaccurate.
Contributor
Author
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. The second statement is used because the explicit inclusion of \d in the first statement's exclusion list is redundant, as digits are already covered by \w, making the second expression more concise while having the same effect. |
||
| } | ||
|
|
||
| private static String formatSemver(String version) { | ||
|
|
||
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.
We are okay breaking this classes API, it's annotated
@InternalExtensionOnly, and the constructor is package private preventing subclasses by anything outside our package.To get clirr to not fail for this we should add an ignore rule to https://github.com/googleapis/java-storage/blob/main/google-cloud-storage/clirr-ignored-differences.xml
And keep this method abstract