Skip to content

Commit 27b4c10

Browse files
authored
Update docs for v2 storage (#1104)
* Update docs for v2 storage
1 parent 09b2889 commit 27b4c10

File tree

1 file changed

+162
-12
lines changed

1 file changed

+162
-12
lines changed

src/v2/providers/storage.ts

Lines changed: 162 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,107 +192,257 @@ export const metadataUpdatedEvent =
192192

193193
/** StorageOptions extend EventHandlerOptions with a bucket name */
194194
export interface StorageOptions extends options.EventHandlerOptions {
195+
/** The name of the bucket containing this object. */
195196
bucket?: string;
196197
}
197198

198-
/** Handle a storage object archived */
199+
/**
200+
* Event handler sent only when a bucket has enabled object versioning.
201+
* This event indicates that the live version of an object has become an
202+
* archived version, either because it was archived or because it was
203+
* overwritten by the upload of an object of the same name.
204+
*
205+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
206+
*/
199207
export function onObjectArchived(
200208
handler: (event: StorageEvent) => any | Promise<any>
201209
): CloudFunction<StorageEvent>;
202210

211+
/**
212+
* Event handler sent only when a bucket has enabled object versioning.
213+
* This event indicates that the live version of an object has become an
214+
* archived version, either because it was archived or because it was
215+
* overwritten by the upload of an object of the same name.
216+
*
217+
* @param bucket - The name of the bucket containing this object.
218+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
219+
*/
203220
export function onObjectArchived(
204221
bucket: string,
205222
handler: (event: StorageEvent) => any | Promise<any>
206223
): CloudFunction<StorageEvent>;
207224

225+
/**
226+
* Event handler sent only when a bucket has enabled object versioning.
227+
* This event indicates that the live version of an object has become an
228+
* archived version, either because it was archived or because it was
229+
* overwritten by the upload of an object of the same name.
230+
*
231+
* @param opts - Options that can be set on an individual event-handling function.
232+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
233+
*/
208234
export function onObjectArchived(
209235
opts: StorageOptions,
210236
handler: (event: StorageEvent) => any | Promise<any>
211237
): CloudFunction<StorageEvent>;
212238

239+
/**
240+
* Event handler sent only when a bucket has enabled object versioning.
241+
* This event indicates that the live version of an object has become an
242+
* archived version, either because it was archived or because it was
243+
* overwritten by the upload of an object of the same name.
244+
*
245+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
246+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
247+
*/
213248
export function onObjectArchived(
214-
buketOrOptsOrHandler:
249+
bucketOrOptsOrHandler:
215250
| string
216251
| StorageOptions
217252
| ((event: StorageEvent) => any | Promise<any>),
218253
handler?: (event: StorageEvent) => any | Promise<any>
219254
): CloudFunction<StorageEvent> {
220-
return onOperation(archivedEvent, buketOrOptsOrHandler, handler);
255+
return onOperation(archivedEvent, bucketOrOptsOrHandler, handler);
221256
}
222257

223-
/** Handle a storage object finalized */
258+
/**
259+
* Event handler which fires every time a Google Cloud Storage object
260+
* creation occurs.
261+
*
262+
* Sent when a new object (or a new generation of an existing object)
263+
* is successfully created in the bucket. This includes copying or rewriting
264+
* an existing object. A failed upload does not trigger this event.
265+
*
266+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
267+
*/
224268
export function onObjectFinalized(
225269
handler: (event: StorageEvent) => any | Promise<any>
226270
): CloudFunction<StorageEvent>;
227271

272+
/**
273+
* Event handler which fires every time a Google Cloud Storage object
274+
* creation occurs.
275+
*
276+
* Sent when a new object (or a new generation of an existing object)
277+
* is successfully created in the bucket. This includes copying or rewriting
278+
* an existing object. A failed upload does not trigger this event.
279+
*
280+
* @param bucket - The name of the bucket containing this object.
281+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
282+
*/
228283
export function onObjectFinalized(
229284
bucket: string,
230285
handler: (event: StorageEvent) => any | Promise<any>
231286
): CloudFunction<StorageEvent>;
232287

288+
/**
289+
* Event handler which fires every time a Google Cloud Storage object
290+
* creation occurs.
291+
*
292+
* Sent when a new object (or a new generation of an existing object)
293+
* is successfully created in the bucket. This includes copying or rewriting
294+
* an existing object. A failed upload does not trigger this event.
295+
*
296+
* @param opts - Options that can be set on an individual event-handling function.
297+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
298+
*/
233299
export function onObjectFinalized(
234300
opts: StorageOptions,
235301
handler: (event: StorageEvent) => any | Promise<any>
236302
): CloudFunction<StorageEvent>;
237303

304+
/**
305+
* Event handler which fires every time a Google Cloud Storage object
306+
* creation occurs.
307+
*
308+
* Sent when a new object (or a new generation of an existing object)
309+
* is successfully created in the bucket. This includes copying or rewriting
310+
* an existing object. A failed upload does not trigger this event.
311+
*
312+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
313+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
314+
*/
238315
export function onObjectFinalized(
239-
buketOrOptsOrHandler:
316+
bucketOrOptsOrHandler:
240317
| string
241318
| StorageOptions
242319
| ((event: StorageEvent) => any | Promise<any>),
243320
handler?: (event: StorageEvent) => any | Promise<any>
244321
): CloudFunction<StorageEvent> {
245-
return onOperation(finalizedEvent, buketOrOptsOrHandler, handler);
322+
return onOperation(finalizedEvent, bucketOrOptsOrHandler, handler);
246323
}
247324

248-
/** Handle a storage object deleted */
325+
/**
326+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
327+
*
328+
* Sent when an object has been permanently deleted. This includes objects
329+
* that are overwritten or are deleted as part of the bucket's lifecycle
330+
* configuration. For buckets with object versioning enabled, this is not
331+
* sent when an object is archived, even if archival occurs
332+
* via the `storage.objects.delete` method.
333+
*
334+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
335+
*/
249336
export function onObjectDeleted(
250337
handler: (event: StorageEvent) => any | Promise<any>
251338
): CloudFunction<StorageEvent>;
252339

340+
/**
341+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
342+
*
343+
* Sent when an object has been permanently deleted. This includes objects
344+
* that are overwritten or are deleted as part of the bucket's lifecycle
345+
* configuration. For buckets with object versioning enabled, this is not
346+
* sent when an object is archived, even if archival occurs
347+
* via the `storage.objects.delete` method.
348+
*
349+
* @param bucket - The name of the bucket containing this object.
350+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
351+
*/
253352
export function onObjectDeleted(
254353
bucket: string,
255354
handler: (event: StorageEvent) => any | Promise<any>
256355
): CloudFunction<StorageEvent>;
257356

357+
/**
358+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
359+
*
360+
* Sent when an object has been permanently deleted. This includes objects
361+
* that are overwritten or are deleted as part of the bucket's lifecycle
362+
* configuration. For buckets with object versioning enabled, this is not
363+
* sent when an object is archived, even if archival occurs
364+
* via the `storage.objects.delete` method.
365+
*
366+
* @param opts - Options that can be set on an individual event-handling function.
367+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
368+
*/
258369
export function onObjectDeleted(
259370
opts: StorageOptions,
260371
handler: (event: StorageEvent) => any | Promise<any>
261372
): CloudFunction<StorageEvent>;
262373

374+
/**
375+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
376+
*
377+
* Sent when an object has been permanently deleted. This includes objects
378+
* that are overwritten or are deleted as part of the bucket's lifecycle
379+
* configuration. For buckets with object versioning enabled, this is not
380+
* sent when an object is archived, even if archival occurs
381+
* via the `storage.objects.delete` method.
382+
*
383+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
384+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
385+
*/
263386
export function onObjectDeleted(
264-
buketOrOptsOrHandler:
387+
bucketOrOptsOrHandler:
265388
| string
266389
| StorageOptions
267390
| ((event: StorageEvent) => any | Promise<any>),
268391
handler?: (event: StorageEvent) => any | Promise<any>
269392
): CloudFunction<StorageEvent> {
270-
return onOperation(deletedEvent, buketOrOptsOrHandler, handler);
393+
return onOperation(deletedEvent, bucketOrOptsOrHandler, handler);
271394
}
272395

273-
/** Handle a storage object metadata updated */
396+
/**
397+
* Event handler which fires every time the metadata of an existing object
398+
* changes.
399+
*
400+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
401+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
402+
*/
274403
export function onObjectMetadataUpdated(
275404
handler: (event: StorageEvent) => any | Promise<any>
276405
): CloudFunction<StorageEvent>;
277406

407+
/**
408+
* Event handler which fires every time the metadata of an existing object
409+
* changes.
410+
*
411+
* @param bucket - The name of the bucket containing this object.
412+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
413+
*/
278414
export function onObjectMetadataUpdated(
279415
bucket: string,
280416
handler: (event: StorageEvent) => any | Promise<any>
281417
): CloudFunction<StorageEvent>;
282418

419+
/**
420+
* Event handler which fires every time the metadata of an existing object
421+
* changes.
422+
*
423+
* @param opts - Options that can be set on an individual event-handling function.
424+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
425+
*/
283426
export function onObjectMetadataUpdated(
284427
opts: StorageOptions,
285428
handler: (event: StorageEvent) => any | Promise<any>
286429
): CloudFunction<StorageEvent>;
287430

431+
/**
432+
* Event handler which fires every time the metadata of an existing object
433+
* changes.
434+
*
435+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
436+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
437+
*/
288438
export function onObjectMetadataUpdated(
289-
buketOrOptsOrHandler:
439+
bucketOrOptsOrHandler:
290440
| string
291441
| StorageOptions
292442
| ((event: StorageEvent) => any | Promise<any>),
293443
handler?: (event: StorageEvent) => any | Promise<any>
294444
): CloudFunction<StorageEvent> {
295-
return onOperation(metadataUpdatedEvent, buketOrOptsOrHandler, handler);
445+
return onOperation(metadataUpdatedEvent, bucketOrOptsOrHandler, handler);
296446
}
297447

298448
/** @internal */

0 commit comments

Comments
 (0)