Skip to content
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

feat: add {Compose,Rewrite,StartResumableWrite}Request.object_checksums and Bucket.RetentionPolicy.retention_duration #1790

Merged
merged 3 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,9 @@ public final Bucket lockBucketRetentionPolicy(LockBucketRetentionPolicyRequest r

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the IAM policy for a specified bucket or object.
* Gets the IAM policy for a specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/<bucket_name> for a bucket or
* projects/_/buckets/<bucket_name>/objects/<object_name> for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -860,7 +862,9 @@ public final Policy getIamPolicy(ResourceName resource) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the IAM policy for a specified bucket or object.
* Gets the IAM policy for a specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -888,7 +892,9 @@ public final Policy getIamPolicy(String resource) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the IAM policy for a specified bucket or object.
* Gets the IAM policy for a specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -919,7 +925,9 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the IAM policy for a specified bucket or object.
* Gets the IAM policy for a specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -949,7 +957,9 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates an IAM policy for the specified bucket or object.
* Updates an IAM policy for the specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -985,7 +995,9 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates an IAM policy for the specified bucket or object.
* Updates an IAM policy for the specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1018,7 +1030,9 @@ public final Policy setIamPolicy(String resource, Policy policy) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates an IAM policy for the specified bucket or object.
* Updates an IAM policy for the specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1050,7 +1064,9 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates an IAM policy for the specified bucket or object.
* Updates an IAM policy for the specified bucket or object. The `resource` field in the request
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1082,7 +1098,9 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
* caller.
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
* object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1120,7 +1138,9 @@ public final TestIamPermissionsResponse testIamPermissions(
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
* caller.
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
* object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1158,7 +1178,9 @@ public final TestIamPermissionsResponse testIamPermissions(
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
* caller.
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
* object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1190,7 +1212,9 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
* caller.
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
* object.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -1861,6 +1885,7 @@ public final ListNotificationsPagedResponse listNotifications(ListNotificationsR
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
* .build();
* Object response = storageClient.composeObject(request);
* }
Expand Down Expand Up @@ -1897,6 +1922,7 @@ public final Object composeObject(ComposeObjectRequest request) {
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
* .build();
* ApiFuture<Object> future = storageClient.composeObjectCallable().futureCall(request);
* // Do something.
Expand Down Expand Up @@ -1929,7 +1955,8 @@ public final UnaryCallable<ComposeObjectRequest, Object> composeObjectCallable()
* }</pre>
*
* @param bucket Required. Name of the bucket in which the object resides.
* @param object Required. The name of the object to delete (when not using a resumable write).
* @param object Required. The name of the finalized object to delete. Note: If you want to delete
* an unfinalized resumable upload please use `CancelResumableWrite`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteObject(String bucket, String object) {
Expand Down Expand Up @@ -1960,7 +1987,8 @@ public final void deleteObject(String bucket, String object) {
* }</pre>
*
* @param bucket Required. Name of the bucket in which the object resides.
* @param object Required. The name of the object to delete (when not using a resumable write).
* @param object Required. The name of the finalized object to delete. Note: If you want to delete
* an unfinalized resumable upload please use `CancelResumableWrite`.
* @param generation If present, permanently deletes a specific revision of this object (as
* opposed to the latest version, the default).
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand Down Expand Up @@ -2717,6 +2745,7 @@ public final UnaryCallable<ListObjectsRequest, ListObjectsResponse> listObjectsC
* .setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
* .setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
* .build();
* RewriteResponse response = storageClient.rewriteObject(request);
* }
Expand Down Expand Up @@ -2768,6 +2797,7 @@ public final RewriteResponse rewriteObject(RewriteObjectRequest request) {
* .setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
* .setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
* .build();
* ApiFuture<RewriteResponse> future = storageClient.rewriteObjectCallable().futureCall(request);
* // Do something.
Expand Down Expand Up @@ -2797,6 +2827,7 @@ public final UnaryCallable<RewriteObjectRequest, RewriteResponse> rewriteObjectC
* StartResumableWriteRequest.newBuilder()
* .setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
* .build();
* StartResumableWriteResponse response = storageClient.startResumableWrite(request);
* }
Expand Down Expand Up @@ -2827,6 +2858,7 @@ public final StartResumableWriteResponse startResumableWrite(StartResumableWrite
* StartResumableWriteRequest.newBuilder()
* .setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
* .build();
* ApiFuture<StartResumableWriteResponse> future =
* storageClient.startResumableWriteCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,6 @@ public class GrpcStorageStub extends StorageStub {
PathTemplate.create("{bucket=**}");
private static final PathTemplate UPDATE_OBJECT_0_PATH_TEMPLATE =
PathTemplate.create("{bucket=**}");
private static final PathTemplate WRITE_OBJECT_0_PATH_TEMPLATE =
PathTemplate.create("{bucket=**}");
private static final PathTemplate WRITE_OBJECT_1_PATH_TEMPLATE =
PathTemplate.create("{bucket=projects/*/buckets/*}/**");
private static final PathTemplate LIST_OBJECTS_0_PATH_TEMPLATE =
PathTemplate.create("{bucket=**}");
private static final PathTemplate REWRITE_OBJECT_0_PATH_TEMPLATE =
Expand Down Expand Up @@ -751,19 +747,6 @@ protected GrpcStorageStub(
GrpcCallSettings<WriteObjectRequest, WriteObjectResponse> writeObjectTransportSettings =
GrpcCallSettings.<WriteObjectRequest, WriteObjectResponse>newBuilder()
.setMethodDescriptor(writeObjectMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
if (request.getWriteObjectSpec() != null
&& request.getWriteObjectSpec().getResource() != null) {
builder.add(
request.getWriteObjectSpec().getResource().getBucket(),
"bucket",
WRITE_OBJECT_0_PATH_TEMPLATE);
}
builder.add(request.getUploadId(), "bucket", WRITE_OBJECT_1_PATH_TEMPLATE);
return builder.build();
})
.build();
GrpcCallSettings<ListObjectsRequest, ListObjectsResponse> listObjectsTransportSettings =
GrpcCallSettings.<ListObjectsRequest, ListObjectsResponse>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ public void composeObjectTest() throws Exception {
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setObjectChecksums(ObjectChecksums.newBuilder().build())
.build();

Object actualResponse = client.composeObject(request);
Expand All @@ -1387,6 +1388,7 @@ public void composeObjectTest() throws Exception {
Assert.assertEquals(request.getKmsKey(), actualRequest.getKmsKey());
Assert.assertEquals(
request.getCommonObjectRequestParams(), actualRequest.getCommonObjectRequestParams());
Assert.assertEquals(request.getObjectChecksums(), actualRequest.getObjectChecksums());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -1410,6 +1412,7 @@ public void composeObjectExceptionTest() throws Exception {
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setObjectChecksums(ObjectChecksums.newBuilder().build())
.build();
client.composeObject(request);
Assert.fail("No exception raised");
Expand Down Expand Up @@ -1997,6 +2000,7 @@ public void rewriteObjectTest() throws Exception {
.setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
.setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setObjectChecksums(ObjectChecksums.newBuilder().build())
.build();

RewriteResponse actualResponse = client.rewriteObject(request);
Expand Down Expand Up @@ -2043,6 +2047,7 @@ public void rewriteObjectTest() throws Exception {
actualRequest.getCopySourceEncryptionKeySha256Bytes());
Assert.assertEquals(
request.getCommonObjectRequestParams(), actualRequest.getCommonObjectRequestParams());
Assert.assertEquals(request.getObjectChecksums(), actualRequest.getObjectChecksums());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand Down Expand Up @@ -2081,6 +2086,7 @@ public void rewriteObjectExceptionTest() throws Exception {
.setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
.setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setObjectChecksums(ObjectChecksums.newBuilder().build())
.build();
client.rewriteObject(request);
Assert.fail("No exception raised");
Expand All @@ -2099,6 +2105,7 @@ public void startResumableWriteTest() throws Exception {
StartResumableWriteRequest.newBuilder()
.setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setObjectChecksums(ObjectChecksums.newBuilder().build())
.build();

StartResumableWriteResponse actualResponse = client.startResumableWrite(request);
Expand All @@ -2111,6 +2118,7 @@ public void startResumableWriteTest() throws Exception {
Assert.assertEquals(request.getWriteObjectSpec(), actualRequest.getWriteObjectSpec());
Assert.assertEquals(
request.getCommonObjectRequestParams(), actualRequest.getCommonObjectRequestParams());
Assert.assertEquals(request.getObjectChecksums(), actualRequest.getObjectChecksums());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -2127,6 +2135,7 @@ public void startResumableWriteExceptionTest() throws Exception {
StartResumableWriteRequest.newBuilder()
.setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setObjectChecksums(ObjectChecksums.newBuilder().build())
.build();
client.startResumableWrite(request);
Assert.fail("No exception raised");
Expand Down