UNPKG

3.45 kBTypeScriptView Raw
1import { BaseMetadata, ServiceObject } from './nodejs-common/index.js';
2import { ResponseBody } from './nodejs-common/util.js';
3import { Bucket } from './bucket.js';
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 type GetNotificationMetadataResponse = [ResponseBody, unknown];
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?: unknown): void;
24}
25/**
26 * @typedef {array} GetNotificationResponse
27 * @property {Notification} 0 The {@link Notification}
28 * @property {object} 1 The full API response.
29 */
30export type GetNotificationResponse = [Notification, unknown];
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?: unknown): 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?: unknown): void;
57}
58export interface NotificationMetadata extends BaseMetadata {
59 custom_attributes?: {
60 [key: string]: string;
61 };
62 event_types?: string[];
63 object_name_prefix?: string;
64 payload_format?: 'JSON_API_V1' | 'NONE';
65 topic?: string;
66}
67/**
68 * The API-formatted resource description of the notification.
69 *
70 * Note: This is not guaranteed to be up-to-date when accessed. To get the
71 * latest record, call the `getMetadata()` method.
72 *
73 * @name Notification#metadata
74 * @type {object}
75 */
76/**
77 * A Notification object is created from your {@link Bucket} object using
78 * {@link Bucket#notification}. Use it to interact with Cloud Pub/Sub
79 * notifications.
80 *
81 * See {@link https://cloud.google.com/storage/docs/pubsub-notifications| Cloud Pub/Sub Notifications for Google Cloud Storage}
82 *
83 * @class
84 * @hideconstructor
85 *
86 * @param {Bucket} bucket The bucket instance this notification is attached to.
87 * @param {string} id The ID of the notification.
88 *
89 * @example
90 * ```
91 * const {Storage} = require('@google-cloud/storage');
92 * const storage = new Storage();
93 * const myBucket = storage.bucket('my-bucket');
94 *
95 * const notification = myBucket.notification('1');
96 * ```
97 */
98declare class Notification extends ServiceObject<Notification, NotificationMetadata> {
99 constructor(bucket: Bucket, id: string);
100}
101/**
102 * Reference to the {@link Notification} class.
103 * @name module:@google-cloud/storage.Notification
104 * @see Notification
105 */
106export { Notification };