You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
samples: Add Soft Delete policy and object management samples (#2676)
* samples: Add Soft Delete policy and object management samples
Adds complete code samples demonstrating the following operations:
- storage_disable_soft_delete
- storage_get_soft_delete_policy
- storage_set_soft_delete_policy
- storage_list_soft_deleted_objects
- storage_list_soft_deleted_object_versions
- storage_restore_object
* remove conflict
* bug fix
* refactor: Use literal for retention duration and improve test assertion
- Removed the SOFT_DELETE_RETENTION_SECONDS constant, replacing it with
the literal value (604800) and adding a comment.
- Updated the listSoftDeletedObjectVersions test to assert on the object
generation number, improving test coverage and reflecting the logging
change.
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
---------
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tre
129
129
| Storage Disable Bucket Versioning. |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/disableBucketVersioning.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableBucketVersioning.js,samples/README.md)|
130
130
| Disable Default Event Based Hold |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/disableDefaultEventBasedHold.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableDefaultEventBasedHold.js,samples/README.md)|
131
131
| Disable Requester Pays |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/disableRequesterPays.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableRequesterPays.js,samples/README.md)|
132
+
| Disable Soft Delete |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/disableSoftDelete.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableSoftDelete.js,samples/README.md)|
| Download Byte Range |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/downloadByteRange.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/downloadByteRange.js,samples/README.md)|
134
135
| Download Encrypted File |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/downloadEncryptedFile.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/downloadEncryptedFile.js,samples/README.md)|
@@ -161,6 +162,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tre
161
162
| Get Requester Pays Status |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getRequesterPaysStatus.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getRequesterPaysStatus.js,samples/README.md)|
162
163
| Get Retention Policy |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getRetentionPolicy.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getRetentionPolicy.js,samples/README.md)|
163
164
| Storage Get Service Account. |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getServiceAccount.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getServiceAccount.js,samples/README.md)|
165
+
| Get Soft Delete Policy |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getSoftDeletePolicy.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getSoftDeletePolicy.js,samples/README.md)|
164
166
| Get Soft Deleted Bucket |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getSoftDeletedBucket.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getSoftDeletedBucket.js,samples/README.md)|
165
167
| Get Uniform Bucket Level Access |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getUniformBucketLevelAccess.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getUniformBucketLevelAccess.js,samples/README.md)|
166
168
| Activate HMAC SA Key. |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/hmacKeyActivate.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/hmacKeyActivate.js,samples/README.md)|
@@ -176,6 +178,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tre
176
178
| List Files with Old Versions. |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listFilesWithOldVersions.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listFilesWithOldVersions.js,samples/README.md)|
177
179
| List Notifications |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listNotifications.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listNotifications.js,samples/README.md)|
178
180
| List Soft Deleted Bucket |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listSoftDeletedBucket.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listSoftDeletedBucket.js,samples/README.md)|
181
+
| List Soft Deleted Object Versions |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listSoftDeletedObjectVersions.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listSoftDeletedObjectVersions.js,samples/README.md)|
182
+
| List Soft Deleted Objects |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listSoftDeletedObjects.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listSoftDeletedObjects.js,samples/README.md)|
179
183
| Lock Retention Policy |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/lockRetentionPolicy.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/lockRetentionPolicy.js,samples/README.md)|
180
184
| Storage Make Bucket Public. |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/makeBucketPublic.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/makeBucketPublic.js,samples/README.md)|
181
185
| Make Public |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/makePublic.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/makePublic.js,samples/README.md)|
@@ -199,6 +203,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tre
199
203
| Remove Retention Policy |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/removeRetentionPolicy.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/removeRetentionPolicy.js,samples/README.md)|
200
204
| Rename File |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/renameFile.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/renameFile.js,samples/README.md)|
201
205
| Restore Soft Deleted Bucket |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/restoreSoftDeletedBucket.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/restoreSoftDeletedBucket.js,samples/README.md)|
206
+
| Restore Soft Deleted Object |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/restoreSoftDeletedObject.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/restoreSoftDeletedObject.js,samples/README.md)|
202
207
| Rotate Encryption Key |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/rotateEncryptionKey.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/rotateEncryptionKey.js,samples/README.md)|
203
208
| Set Autoclass |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setAutoclass.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setAutoclass.js,samples/README.md)|
204
209
| Set Client Endpoint |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setClientEndpoint.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setClientEndpoint.js,samples/README.md)|
@@ -209,6 +214,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tre
209
214
| Set RPO Async Turbo |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setRPOAsyncTurbo.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setRPOAsyncTurbo.js,samples/README.md)|
210
215
| Set RPO Default |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setRPODefault.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setRPODefault.js,samples/README.md)|
211
216
| Set Retention Policy |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setRetentionPolicy.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setRetentionPolicy.js,samples/README.md)|
217
+
| Set Soft Delete Policy |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setSoftDeletePolicy.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setSoftDeletePolicy.js,samples/README.md)|
212
218
| Set Temporary Hold |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setTemporaryHold.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setTemporaryHold.js,samples/README.md)|
213
219
| Stream File Download |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/streamFileDownload.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/streamFileDownload.js,samples/README.md)|
214
220
| Stream File Upload |[source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/streamFileUpload.js)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/streamFileUpload.js,samples/README.md)|
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/disableSoftDelete.js).
708
+
709
+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableSoftDelete.js,samples/README.md)
710
+
711
+
__Usage:__
712
+
713
+
714
+
`node samples/disableSoftDelete.js`
715
+
716
+
717
+
-----
718
+
719
+
720
+
721
+
699
722
### Disable Uniform Bucket Level Access
700
723
701
724
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/disableUniformBucketLevelAccess.js).
@@ -1256,6 +1279,23 @@ __Usage:__
1256
1279
1257
1280
1258
1281
1282
+
### Get Soft Delete Policy
1283
+
1284
+
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getSoftDeletePolicy.js).
1285
+
1286
+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/getSoftDeletePolicy.js,samples/README.md)
1287
+
1288
+
__Usage:__
1289
+
1290
+
1291
+
`node samples/getSoftDeletePolicy.js`
1292
+
1293
+
1294
+
-----
1295
+
1296
+
1297
+
1298
+
1259
1299
### Get Soft Deleted Bucket
1260
1300
1261
1301
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/getSoftDeletedBucket.js).
@@ -1525,6 +1565,40 @@ __Usage:__
1525
1565
1526
1566
1527
1567
1568
+
### List Soft Deleted Object Versions
1569
+
1570
+
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listSoftDeletedObjectVersions.js).
1571
+
1572
+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listSoftDeletedObjectVersions.js,samples/README.md)
1573
+
1574
+
__Usage:__
1575
+
1576
+
1577
+
`node samples/listSoftDeletedObjectVersions.js`
1578
+
1579
+
1580
+
-----
1581
+
1582
+
1583
+
1584
+
1585
+
### List Soft Deleted Objects
1586
+
1587
+
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/listSoftDeletedObjects.js).
1588
+
1589
+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/listSoftDeletedObjects.js,samples/README.md)
1590
+
1591
+
__Usage:__
1592
+
1593
+
1594
+
`node samples/listSoftDeletedObjects.js`
1595
+
1596
+
1597
+
-----
1598
+
1599
+
1600
+
1601
+
1528
1602
### Lock Retention Policy
1529
1603
1530
1604
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/lockRetentionPolicy.js).
@@ -1924,6 +1998,23 @@ __Usage:__
1924
1998
1925
1999
1926
2000
2001
+
### Restore Soft Deleted Object
2002
+
2003
+
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/restoreSoftDeletedObject.js).
2004
+
2005
+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/restoreSoftDeletedObject.js,samples/README.md)
2006
+
2007
+
__Usage:__
2008
+
2009
+
2010
+
`node samples/restoreSoftDeletedObject.js`
2011
+
2012
+
2013
+
-----
2014
+
2015
+
2016
+
2017
+
1927
2018
### Rotate Encryption Key
1928
2019
1929
2020
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/rotateEncryptionKey.js).
@@ -2096,6 +2187,23 @@ __Usage:__
2096
2187
2097
2188
2098
2189
2190
+
### Set Soft Delete Policy
2191
+
2192
+
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setSoftDeletePolicy.js).
2193
+
2194
+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/setSoftDeletePolicy.js,samples/README.md)
2195
+
2196
+
__Usage:__
2197
+
2198
+
2199
+
`node samples/setSoftDeletePolicy.js`
2200
+
2201
+
2202
+
-----
2203
+
2204
+
2205
+
2206
+
2099
2207
### Set Temporary Hold
2100
2208
2101
2209
View the [source code](https://github.com/googleapis/nodejs-storage/blob/main/samples/setTemporaryHold.js).
0 commit comments