@@ -72,6 +72,8 @@ import {
7272 BaseMetadata ,
7373 DeleteCallback ,
7474 DeleteOptions ,
75+ GetResponse ,
76+ InstanceResponseCallback ,
7577 RequestResponse ,
7678 SetMetadataOptions ,
7779} from './nodejs-common/service-object.js' ;
@@ -172,6 +174,8 @@ export interface GetFileMetadataCallback {
172174
173175export interface GetFileOptions extends GetConfig {
174176 userProject ?: string ;
177+ generation ?: number ;
178+ softDeleted ?: boolean ;
175179}
176180
177181export type GetFileResponse = [ File , unknown ] ;
@@ -418,6 +422,11 @@ export interface SetStorageClassCallback {
418422 ( err ?: Error | null , apiResponse ?: unknown ) : void ;
419423}
420424
425+ export interface RestoreOptions extends PreconditionOptions {
426+ generation : number ;
427+ projection ?: 'full' | 'noAcl' ;
428+ }
429+
421430export interface FileMetadata extends BaseMetadata {
422431 acl ?: AclMetadata [ ] | null ;
423432 bucket ?: string ;
@@ -436,6 +445,7 @@ export interface FileMetadata extends BaseMetadata {
436445 eventBasedHold ?: boolean | null ;
437446 readonly eventBasedHoldReleaseTime ?: string ;
438447 generation ?: string | number ;
448+ hardDeleteTime ?: string ;
439449 kmsKeyName ?: string ;
440450 md5Hash ?: string ;
441451 mediaLink ?: string ;
@@ -454,6 +464,7 @@ export interface FileMetadata extends BaseMetadata {
454464 } | null ;
455465 retentionExpirationTime ?: string ;
456466 size ?: string | number ;
467+ softDeleteTime ?: string ;
457468 storageClass ?: string ;
458469 temporaryHold ?: boolean | null ;
459470 timeCreated ?: string ;
@@ -803,6 +814,9 @@ class File extends ServiceObject<File, FileMetadata> {
803814 * @param {options } [options] Configuration options.
804815 * @param {string } [options.userProject] The ID of the project which will be
805816 * billed for the request.
817+ * @param {number } [options.generation] The generation number to get
818+ * @param {boolean } [options.softDeleted] If true, returns the soft-deleted object.
819+ Object `generation` is required if `softDeleted` is set to True.
806820 * @param {GetFileCallback } [callback] Callback function.
807821 * @returns {Promise<GetFileResponse> }
808822 *
@@ -2344,6 +2358,27 @@ class File extends ServiceObject<File, FileMetadata> {
23442358 return this ;
23452359 }
23462360
2361+ get ( options ?: GetFileOptions ) : Promise < GetResponse < File > > ;
2362+ get ( callback : InstanceResponseCallback < File > ) : void ;
2363+ get ( options : GetFileOptions , callback : InstanceResponseCallback < File > ) : void ;
2364+ get (
2365+ optionsOrCallback ?: GetFileOptions | InstanceResponseCallback < File > ,
2366+ cb ?: InstanceResponseCallback < File >
2367+ ) : Promise < GetResponse < File > > | void {
2368+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2369+ const options : any =
2370+ typeof optionsOrCallback === 'object' ? optionsOrCallback : { } ;
2371+ cb =
2372+ typeof optionsOrCallback === 'function'
2373+ ? ( optionsOrCallback as InstanceResponseCallback < File > )
2374+ : cb ;
2375+
2376+ super
2377+ . get ( options )
2378+ . then ( resp => cb ! ( null , ...resp ) )
2379+ . catch ( cb ! ) ;
2380+ }
2381+
23472382 getExpirationDate ( ) : Promise < GetExpirationDateResponse > ;
23482383 getExpirationDate ( callback : GetExpirationDateCallback ) : void ;
23492384 /**
@@ -3597,6 +3632,39 @@ class File extends ServiceObject<File, FileMetadata> {
35973632 this . move ( destinationFile , options , callback ) ;
35983633 }
35993634
3635+ /**
3636+ * @typedef {object } RestoreOptions Options for File#restore(). See an
3637+ * {@link https://cloud.google.com/storage/docs/json_api/v1/objects#resource| Object resource}.
3638+ * @param {string } [userProject] The ID of the project which will be
3639+ * billed for the request.
3640+ * @param {number } [generation] If present, selects a specific revision of this object.
3641+ * @param {string } [projection] Specifies the set of properties to return. If used, must be 'full' or 'noAcl'.
3642+ * @param {string | number } [ifGenerationMatch] Request proceeds if the generation of the target resource
3643+ * matches the value used in the precondition.
3644+ * If the values don't match, the request fails with a 412 Precondition Failed response.
3645+ * @param {string | number } [ifGenerationNotMatch] Request proceeds if the generation of the target resource does
3646+ * not match the value used in the precondition. If the values match, the request fails with a 304 Not Modified response.
3647+ * @param {string | number } [ifMetagenerationMatch] Request proceeds if the meta-generation of the target resource
3648+ * matches the value used in the precondition.
3649+ * If the values don't match, the request fails with a 412 Precondition Failed response.
3650+ * @param {string | number } [ifMetagenerationNotMatch] Request proceeds if the meta-generation of the target resource does
3651+ * not match the value used in the precondition. If the values match, the request fails with a 304 Not Modified response.
3652+ */
3653+ /**
3654+ * Restores a soft-deleted file
3655+ * @param {RestoreOptions } options Restore options.
3656+ * @returns {Promise<File> }
3657+ */
3658+ async restore ( options : RestoreOptions ) : Promise < File > {
3659+ const [ file ] = await this . request ( {
3660+ method : 'POST' ,
3661+ uri : '/restore' ,
3662+ qs : options ,
3663+ } ) ;
3664+
3665+ return file as File ;
3666+ }
3667+
36003668 request ( reqOpts : DecorateRequestOptions ) : Promise < RequestResponse > ;
36013669 request (
36023670 reqOpts : DecorateRequestOptions ,
@@ -4240,6 +4308,7 @@ promisifyAll(File, {
42404308 'setEncryptionKey' ,
42414309 'shouldRetryBasedOnPreconditionAndIdempotencyStrat' ,
42424310 'getBufferFromReadable' ,
4311+ 'restore' ,
42434312 ] ,
42444313} ) ;
42454314
0 commit comments