-
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 7 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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,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; | ||||||||||||
|
|
@@ -100,6 +102,18 @@ public abstract CompleteMultipartUploadResponse completeMultipartUpload( | |||||||||||
| @BetaApi | ||||||||||||
| public abstract UploadPartResponse uploadPart(UploadPartRequest request, RequestBody requestBody); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Lists all multipart uploads in a bucket. | ||||||||||||
| * | ||||||||||||
| * @param request The request object containing the details for listing the multipart uploads. | ||||||||||||
| * @return A {@link ListMultipartUploadsResponse} object containing the list of multipart uploads. | ||||||||||||
| * @since 2.61.0 This new api is in preview and is subject to breaking changes. | ||||||||||||
| */ | ||||||||||||
| @BetaApi | ||||||||||||
| public ListMultipartUploadsResponse listMultipartUploads(ListMultipartUploadsRequest request) { | ||||||||||||
| throw new UnsupportedOperationException("This operation is not yet implemented."); | ||||||||||||
| } | ||||||||||||
|
||||||||||||
| public ListMultipartUploadsResponse listMultipartUploads(ListMultipartUploadsRequest request) { | |
| throw new UnsupportedOperationException("This operation is not yet implemented."); | |
| } | |
| public abstract ListMultipartUploadsResponse listMultipartUploads( | |
| ListMultipartUploadsRequest request); |
| 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,43 @@ 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); | ||
| System.out.println(listUri); | ||
| 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 { | ||
|
|
||
|
|
@@ -248,7 +287,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.
Is this needed for listing the in progress uploads? If not, can this fix be moved to it's own PR?
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.
When moved to it's own PR, please also add tests covering the logic change in https://github.com/googleapis/java-storage/blob/main/google-cloud-storage/src/test/java/com/google/cloud/storage/ChecksumResponseParserTest.java
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.
Done, Those changes are moved to another PR and reverted from this PR.