Skip to content

Commit 31c1b18

Browse files
feat: add {Compose,Rewrite,StartResumableWrite}Request.object_checksums and Bucket.RetentionPolicy.retention_duration (#1790)
* ComposeObjectRequest.object_checksums * provide checksum validation values for ComposeObject operations * RewriteObjectRequest.object_checksums * provide checksum validation values for RewriteObject operations * StartResumableWriteRequest.object_checksums * provide checksum validation values when starting a ResumableWrite session * Bucket.RetentionPolicy.retention_duration * Add new retention_duration field that is explicitly a Duration superseding retention_period which is an int64 of seconds. docs: Clarified the object can be deleted via DeleteObject docs: Clarified relative resource names in gRPC IAM RPCs feat: Added object_checksums for compose/rewrite/startResumableWrite request docs: Updated the document link for `Naming Guidelines` fix: Removed WriteObject routing annotations feat: Added a new retention_duration field of Duration type PiperOrigin-RevId: 492231039 Source-Link: googleapis/googleapis@82a7568 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ecf909ca662ba304842ce6d041e92920be1e9b8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmVjZjkwOWNhNjYyYmEzMDQ4NDJjZTZkMDQxZTkyOTIwYmUxZTliOCJ9 Co-authored-by: BenWhitehead <[email protected]>
1 parent deb89e5 commit 31c1b18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3060
-1545
lines changed

gapic-google-cloud-storage-v2/src/main/java/com/google/storage/v2/StorageClient.java

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,9 @@ public final Bucket lockBucketRetentionPolicy(LockBucketRetentionPolicyRequest r
829829

830830
// AUTO-GENERATED DOCUMENTATION AND METHOD.
831831
/**
832-
* Gets the IAM policy for a specified bucket or object.
832+
* Gets the IAM policy for a specified bucket or object. The `resource` field in the request
833+
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
834+
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
833835
*
834836
* <p>Sample code:
835837
*
@@ -860,7 +862,9 @@ public final Policy getIamPolicy(ResourceName resource) {
860862

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

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

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

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

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

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

10511065
// AUTO-GENERATED DOCUMENTATION AND METHOD.
10521066
/**
1053-
* Updates an IAM policy for the specified bucket or object.
1067+
* Updates an IAM policy for the specified bucket or object. The `resource` field in the request
1068+
* should be projects/_/buckets/&lt;bucket_name&gt; for a bucket or
1069+
* projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an object.
10541070
*
10551071
* <p>Sample code:
10561072
*
@@ -1082,7 +1098,9 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
10821098
// AUTO-GENERATED DOCUMENTATION AND METHOD.
10831099
/**
10841100
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
1085-
* caller.
1101+
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
1102+
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
1103+
* object.
10861104
*
10871105
* <p>Sample code:
10881106
*
@@ -1120,7 +1138,9 @@ public final TestIamPermissionsResponse testIamPermissions(
11201138
// AUTO-GENERATED DOCUMENTATION AND METHOD.
11211139
/**
11221140
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
1123-
* caller.
1141+
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
1142+
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
1143+
* object.
11241144
*
11251145
* <p>Sample code:
11261146
*
@@ -1158,7 +1178,9 @@ public final TestIamPermissionsResponse testIamPermissions(
11581178
// AUTO-GENERATED DOCUMENTATION AND METHOD.
11591179
/**
11601180
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
1161-
* caller.
1181+
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
1182+
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
1183+
* object.
11621184
*
11631185
* <p>Sample code:
11641186
*
@@ -1190,7 +1212,9 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
11901212
// AUTO-GENERATED DOCUMENTATION AND METHOD.
11911213
/**
11921214
* Tests a set of permissions on the given bucket or object to see which, if any, are held by the
1193-
* caller.
1215+
* caller. The `resource` field in the request should be projects/_/buckets/&lt;bucket_name&gt;
1216+
* for a bucket or projects/_/buckets/&lt;bucket_name&gt;/objects/&lt;object_name&gt; for an
1217+
* object.
11941218
*
11951219
* <p>Sample code:
11961220
*
@@ -1861,6 +1885,7 @@ public final ListNotificationsPagedResponse listNotifications(ListNotificationsR
18611885
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
18621886
* .toString())
18631887
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
1888+
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
18641889
* .build();
18651890
* Object response = storageClient.composeObject(request);
18661891
* }
@@ -1897,6 +1922,7 @@ public final Object composeObject(ComposeObjectRequest request) {
18971922
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
18981923
* .toString())
18991924
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
1925+
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
19001926
* .build();
19011927
* ApiFuture<Object> future = storageClient.composeObjectCallable().futureCall(request);
19021928
* // Do something.
@@ -1929,7 +1955,8 @@ public final UnaryCallable<ComposeObjectRequest, Object> composeObjectCallable()
19291955
* }</pre>
19301956
*
19311957
* @param bucket Required. Name of the bucket in which the object resides.
1932-
* @param object Required. The name of the object to delete (when not using a resumable write).
1958+
* @param object Required. The name of the finalized object to delete. Note: If you want to delete
1959+
* an unfinalized resumable upload please use `CancelResumableWrite`.
19331960
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
19341961
*/
19351962
public final void deleteObject(String bucket, String object) {
@@ -1960,7 +1987,8 @@ public final void deleteObject(String bucket, String object) {
19601987
* }</pre>
19611988
*
19621989
* @param bucket Required. Name of the bucket in which the object resides.
1963-
* @param object Required. The name of the object to delete (when not using a resumable write).
1990+
* @param object Required. The name of the finalized object to delete. Note: If you want to delete
1991+
* an unfinalized resumable upload please use `CancelResumableWrite`.
19641992
* @param generation If present, permanently deletes a specific revision of this object (as
19651993
* opposed to the latest version, the default).
19661994
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -2717,6 +2745,7 @@ public final UnaryCallable<ListObjectsRequest, ListObjectsResponse> listObjectsC
27172745
* .setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
27182746
* .setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
27192747
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2748+
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
27202749
* .build();
27212750
* RewriteResponse response = storageClient.rewriteObject(request);
27222751
* }
@@ -2768,6 +2797,7 @@ public final RewriteResponse rewriteObject(RewriteObjectRequest request) {
27682797
* .setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
27692798
* .setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
27702799
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2800+
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
27712801
* .build();
27722802
* ApiFuture<RewriteResponse> future = storageClient.rewriteObjectCallable().futureCall(request);
27732803
* // Do something.
@@ -2797,6 +2827,7 @@ public final UnaryCallable<RewriteObjectRequest, RewriteResponse> rewriteObjectC
27972827
* StartResumableWriteRequest.newBuilder()
27982828
* .setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
27992829
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2830+
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
28002831
* .build();
28012832
* StartResumableWriteResponse response = storageClient.startResumableWrite(request);
28022833
* }
@@ -2827,6 +2858,7 @@ public final StartResumableWriteResponse startResumableWrite(StartResumableWrite
28272858
* StartResumableWriteRequest.newBuilder()
28282859
* .setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
28292860
* .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2861+
* .setObjectChecksums(ObjectChecksums.newBuilder().build())
28302862
* .build();
28312863
* ApiFuture<StartResumableWriteResponse> future =
28322864
* storageClient.startResumableWriteCallable().futureCall(request);

gapic-google-cloud-storage-v2/src/main/java/com/google/storage/v2/stub/GrpcStorageStub.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,6 @@ public class GrpcStorageStub extends StorageStub {
471471
PathTemplate.create("{bucket=**}");
472472
private static final PathTemplate UPDATE_OBJECT_0_PATH_TEMPLATE =
473473
PathTemplate.create("{bucket=**}");
474-
private static final PathTemplate WRITE_OBJECT_0_PATH_TEMPLATE =
475-
PathTemplate.create("{bucket=**}");
476-
private static final PathTemplate WRITE_OBJECT_1_PATH_TEMPLATE =
477-
PathTemplate.create("{bucket=projects/*/buckets/*}/**");
478474
private static final PathTemplate LIST_OBJECTS_0_PATH_TEMPLATE =
479475
PathTemplate.create("{bucket=**}");
480476
private static final PathTemplate REWRITE_OBJECT_0_PATH_TEMPLATE =
@@ -751,19 +747,6 @@ protected GrpcStorageStub(
751747
GrpcCallSettings<WriteObjectRequest, WriteObjectResponse> writeObjectTransportSettings =
752748
GrpcCallSettings.<WriteObjectRequest, WriteObjectResponse>newBuilder()
753749
.setMethodDescriptor(writeObjectMethodDescriptor)
754-
.setParamsExtractor(
755-
request -> {
756-
RequestParamsBuilder builder = RequestParamsBuilder.create();
757-
if (request.getWriteObjectSpec() != null
758-
&& request.getWriteObjectSpec().getResource() != null) {
759-
builder.add(
760-
request.getWriteObjectSpec().getResource().getBucket(),
761-
"bucket",
762-
WRITE_OBJECT_0_PATH_TEMPLATE);
763-
}
764-
builder.add(request.getUploadId(), "bucket", WRITE_OBJECT_1_PATH_TEMPLATE);
765-
return builder.build();
766-
})
767750
.build();
768751
GrpcCallSettings<ListObjectsRequest, ListObjectsResponse> listObjectsTransportSettings =
769752
GrpcCallSettings.<ListObjectsRequest, ListObjectsResponse>newBuilder()

gapic-google-cloud-storage-v2/src/test/java/com/google/storage/v2/StorageClientTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ public void composeObjectTest() throws Exception {
13681368
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
13691369
.toString())
13701370
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
1371+
.setObjectChecksums(ObjectChecksums.newBuilder().build())
13711372
.build();
13721373

13731374
Object actualResponse = client.composeObject(request);
@@ -1387,6 +1388,7 @@ public void composeObjectTest() throws Exception {
13871388
Assert.assertEquals(request.getKmsKey(), actualRequest.getKmsKey());
13881389
Assert.assertEquals(
13891390
request.getCommonObjectRequestParams(), actualRequest.getCommonObjectRequestParams());
1391+
Assert.assertEquals(request.getObjectChecksums(), actualRequest.getObjectChecksums());
13901392
Assert.assertTrue(
13911393
channelProvider.isHeaderSent(
13921394
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -1410,6 +1412,7 @@ public void composeObjectExceptionTest() throws Exception {
14101412
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
14111413
.toString())
14121414
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
1415+
.setObjectChecksums(ObjectChecksums.newBuilder().build())
14131416
.build();
14141417
client.composeObject(request);
14151418
Assert.fail("No exception raised");
@@ -1997,6 +2000,7 @@ public void rewriteObjectTest() throws Exception {
19972000
.setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
19982001
.setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
19992002
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2003+
.setObjectChecksums(ObjectChecksums.newBuilder().build())
20002004
.build();
20012005

20022006
RewriteResponse actualResponse = client.rewriteObject(request);
@@ -2043,6 +2047,7 @@ public void rewriteObjectTest() throws Exception {
20432047
actualRequest.getCopySourceEncryptionKeySha256Bytes());
20442048
Assert.assertEquals(
20452049
request.getCommonObjectRequestParams(), actualRequest.getCommonObjectRequestParams());
2050+
Assert.assertEquals(request.getObjectChecksums(), actualRequest.getObjectChecksums());
20462051
Assert.assertTrue(
20472052
channelProvider.isHeaderSent(
20482053
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -2081,6 +2086,7 @@ public void rewriteObjectExceptionTest() throws Exception {
20812086
.setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
20822087
.setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
20832088
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2089+
.setObjectChecksums(ObjectChecksums.newBuilder().build())
20842090
.build();
20852091
client.rewriteObject(request);
20862092
Assert.fail("No exception raised");
@@ -2099,6 +2105,7 @@ public void startResumableWriteTest() throws Exception {
20992105
StartResumableWriteRequest.newBuilder()
21002106
.setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
21012107
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2108+
.setObjectChecksums(ObjectChecksums.newBuilder().build())
21022109
.build();
21032110

21042111
StartResumableWriteResponse actualResponse = client.startResumableWrite(request);
@@ -2111,6 +2118,7 @@ public void startResumableWriteTest() throws Exception {
21112118
Assert.assertEquals(request.getWriteObjectSpec(), actualRequest.getWriteObjectSpec());
21122119
Assert.assertEquals(
21132120
request.getCommonObjectRequestParams(), actualRequest.getCommonObjectRequestParams());
2121+
Assert.assertEquals(request.getObjectChecksums(), actualRequest.getObjectChecksums());
21142122
Assert.assertTrue(
21152123
channelProvider.isHeaderSent(
21162124
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -2127,6 +2135,7 @@ public void startResumableWriteExceptionTest() throws Exception {
21272135
StartResumableWriteRequest.newBuilder()
21282136
.setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
21292137
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
2138+
.setObjectChecksums(ObjectChecksums.newBuilder().build())
21302139
.build();
21312140
client.startResumableWrite(request);
21322141
Assert.fail("No exception raised");

0 commit comments

Comments
 (0)