UNPKG

3.85 kBTypeScriptView Raw
1import { Metadata, MetadataCallback, ServiceObject } from './nodejs-common';
2import { ResponseBody } from './nodejs-common/util';
3import { Bucket } from './bucket';
4export interface DeleteNotificationOptions {
5 userProject?: string;
6}
7export interface GetNotificationMetadataOptions {
8 userProject?: string;
9}
10/**
11 * @typedef {array} GetNotificationMetadataResponse
12 * @property {object} 0 The notification metadata.
13 * @property {object} 1 The full API response.
14 */
15export declare type GetNotificationMetadataResponse = [ResponseBody, Metadata];
16/**
17 * @callback GetNotificationMetadataCallback
18 * @param {?Error} err Request error, if any.
19 * @param {object} files The notification metadata.
20 * @param {object} apiResponse The full API response.
21 */
22export interface GetNotificationMetadataCallback {
23 (err: Error | null, metadata?: ResponseBody, apiResponse?: Metadata): void;
24}
25/**
26 * @typedef {array} GetNotificationResponse
27 * @property {Notification} 0 The {@link Notification}
28 * @property {object} 1 The full API response.
29 */
30export declare type GetNotificationResponse = [Notification, Metadata];
31export interface GetNotificationOptions {
32 /**
33 * Automatically create the object if it does not exist. Default: `false`.
34 */
35 autoCreate?: boolean;
36 /**
37 * The ID of the project which will be billed for the request.
38 */
39 userProject?: string;
40}
41/**
42 * @callback GetNotificationCallback
43 * @param {?Error} err Request error, if any.
44 * @param {Notification} notification The {@link Notification}.
45 * @param {object} apiResponse The full API response.
46 */
47export interface GetNotificationCallback {
48 (err: Error | null, notification?: Notification | null, apiResponse?: Metadata): void;
49}
50/**
51 * @callback DeleteNotificationCallback
52 * @param {?Error} err Request error, if any.
53 * @param {object} apiResponse The full API response.
54 */
55export interface DeleteNotificationCallback {
56 (err: Error | null, apiResponse?: Metadata): void;
57}
58/**
59 * The API-formatted resource description of the notification.
60 *
61 * Note: This is not guaranteed to be up-to-date when accessed. To get the
62 * latest record, call the `getMetadata()` method.
63 *
64 * @name Notification#metadata
65 * @type {object}
66 */
67/**
68 * A Notification object is created from your {@link Bucket} object using
69 * {@link Bucket#notification}. Use it to interact with Cloud Pub/Sub
70 * notifications.
71 *
72 * See {@link https://cloud.google.com/storage/docs/pubsub-notifications| Cloud Pub/Sub Notifications for Google Cloud Storage}
73 *
74 * @class
75 * @hideconstructor
76 *
77 * @param {Bucket} bucket The bucket instance this notification is attached to.
78 * @param {string} id The ID of the notification.
79 *
80 * @example
81 * ```
82 * const {Storage} = require('@google-cloud/storage');
83 * const storage = new Storage();
84 * const myBucket = storage.bucket('my-bucket');
85 *
86 * const notification = myBucket.notification('1');
87 * ```
88 */
89declare class Notification extends ServiceObject {
90 constructor(bucket: Bucket, id: string);
91 delete(options?: DeleteNotificationOptions): Promise<[Metadata]>;
92 delete(options: DeleteNotificationOptions, callback: DeleteNotificationCallback): void;
93 delete(callback: DeleteNotificationCallback): void;
94 get(options?: GetNotificationOptions): Promise<GetNotificationResponse>;
95 get(options: GetNotificationOptions, callback: GetNotificationCallback): void;
96 get(callback: GetNotificationCallback): void;
97 getMetadata(options?: GetNotificationMetadataOptions): Promise<GetNotificationMetadataResponse>;
98 getMetadata(options: GetNotificationMetadataOptions, callback: MetadataCallback): void;
99 getMetadata(callback: MetadataCallback): void;
100}
101/**
102 * Reference to the {@link Notification} class.
103 * @name module:@google-cloud/storage.Notification
104 * @see Notification
105 */
106export { Notification };