1 |
|
2 | import { ApiError, BodyResponseCallback, DecorateRequestOptions, DeleteCallback, ExistsCallback, GetConfig, Metadata, ResponseBody, ServiceObject } from './nodejs-common';
|
3 | import * as http from 'http';
|
4 | import { Acl } from './acl';
|
5 | import { Channel } from './channel';
|
6 | import { File, FileOptions, CreateResumableUploadOptions, CreateWriteStreamOptions } from './file';
|
7 | import { Iam } from './iam';
|
8 | import { Notification } from './notification';
|
9 | import { Storage, Cors, PreconditionOptions, BucketOptions } from './storage';
|
10 | import { GetSignedUrlResponse, GetSignedUrlCallback, URLSigner, Query } from './signer';
|
11 | import { Readable } from 'stream';
|
12 | export declare type GetFilesResponse = [File[], {}, Metadata];
|
13 | export interface GetFilesCallback {
|
14 | (err: Error | null, files?: File[], nextQuery?: {}, apiResponse?: Metadata): void;
|
15 | }
|
16 | interface WatchAllOptions {
|
17 | delimiter?: string;
|
18 | maxResults?: number;
|
19 | pageToken?: string;
|
20 | prefix?: string;
|
21 | projection?: string;
|
22 | userProject?: string;
|
23 | versions?: boolean;
|
24 | }
|
25 | export interface AddLifecycleRuleOptions {
|
26 | append?: boolean;
|
27 | }
|
28 | export interface LifecycleRule {
|
29 | action: {
|
30 | type: string;
|
31 | storageClass?: string;
|
32 | } | string;
|
33 | condition: {
|
34 | [key: string]: boolean | Date | number | string;
|
35 | };
|
36 | storageClass?: string;
|
37 | }
|
38 | export interface EnableLoggingOptions {
|
39 | bucket?: string | Bucket;
|
40 | prefix: string;
|
41 | }
|
42 | export interface GetFilesOptions {
|
43 | autoPaginate?: boolean;
|
44 | delimiter?: string;
|
45 | |
46 |
|
47 |
|
48 |
|
49 | directory?: string;
|
50 | endOffset?: string;
|
51 | includeTrailingDelimiter?: boolean;
|
52 | prefix?: string;
|
53 | maxApiCalls?: number;
|
54 | maxResults?: number;
|
55 | pageToken?: string;
|
56 | startOffset?: string;
|
57 | userProject?: string;
|
58 | versions?: boolean;
|
59 | }
|
60 | export interface CombineOptions extends PreconditionOptions {
|
61 | kmsKeyName?: string;
|
62 | userProject?: string;
|
63 | }
|
64 | export interface CombineCallback {
|
65 | (err: Error | null, newFile: File | null, apiResponse: Metadata): void;
|
66 | }
|
67 | export declare type CombineResponse = [File, Metadata];
|
68 | export interface CreateChannelConfig extends WatchAllOptions {
|
69 | address: string;
|
70 | }
|
71 | export interface CreateChannelOptions {
|
72 | userProject?: string;
|
73 | }
|
74 | export declare type CreateChannelResponse = [Channel, Metadata];
|
75 | export interface CreateChannelCallback {
|
76 | (err: Error | null, channel: Channel | null, apiResponse: Metadata): void;
|
77 | }
|
78 | export interface CreateNotificationOptions {
|
79 | customAttributes?: {
|
80 | [key: string]: string;
|
81 | };
|
82 | eventTypes?: string[];
|
83 | objectNamePrefix?: string;
|
84 | payloadFormat?: string;
|
85 | userProject?: string;
|
86 | }
|
87 | export interface CreateNotificationCallback {
|
88 | (err: Error | null, notification: Notification | null, apiResponse: Metadata): void;
|
89 | }
|
90 | export declare type CreateNotificationResponse = [Notification, Metadata];
|
91 | export interface DeleteBucketOptions {
|
92 | ignoreNotFound?: boolean;
|
93 | userProject?: string;
|
94 | }
|
95 | export declare type DeleteBucketResponse = [Metadata];
|
96 | export interface DeleteBucketCallback extends DeleteCallback {
|
97 | (err: Error | null, apiResponse: Metadata): void;
|
98 | }
|
99 | export interface DeleteFilesOptions extends GetFilesOptions, PreconditionOptions {
|
100 | force?: boolean;
|
101 | }
|
102 | export interface DeleteFilesCallback {
|
103 | (err: Error | Error[] | null, apiResponse?: object): void;
|
104 | }
|
105 | export declare type DeleteLabelsResponse = [Metadata];
|
106 | export declare type DeleteLabelsCallback = SetLabelsCallback;
|
107 | export declare type DisableRequesterPaysResponse = [Metadata];
|
108 | export interface DisableRequesterPaysCallback {
|
109 | (err?: Error | null, apiResponse?: object): void;
|
110 | }
|
111 | export declare type EnableRequesterPaysResponse = [Metadata];
|
112 | export interface EnableRequesterPaysCallback {
|
113 | (err?: Error | null, apiResponse?: Metadata): void;
|
114 | }
|
115 | export interface BucketExistsOptions extends GetConfig {
|
116 | userProject?: string;
|
117 | }
|
118 | export declare type BucketExistsResponse = [boolean];
|
119 | export declare type BucketExistsCallback = ExistsCallback;
|
120 | export interface GetBucketOptions extends GetConfig {
|
121 | userProject?: string;
|
122 | }
|
123 | export declare type GetBucketResponse = [Bucket, Metadata];
|
124 | export interface GetBucketCallback {
|
125 | (err: ApiError | null, bucket: Bucket | null, apiResponse: Metadata): void;
|
126 | }
|
127 | export interface GetLabelsOptions {
|
128 | userProject?: string;
|
129 | }
|
130 | export declare type GetLabelsResponse = [Metadata];
|
131 | export interface GetLabelsCallback {
|
132 | (err: Error | null, labels: object | null): void;
|
133 | }
|
134 | export declare type GetBucketMetadataResponse = [Metadata, Metadata];
|
135 | export interface GetBucketMetadataCallback {
|
136 | (err: ApiError | null, metadata: Metadata | null, apiResponse: Metadata): void;
|
137 | }
|
138 | export interface GetBucketMetadataOptions {
|
139 | userProject?: string;
|
140 | }
|
141 | export interface GetBucketSignedUrlConfig {
|
142 | action: 'list';
|
143 | version?: 'v2' | 'v4';
|
144 | cname?: string;
|
145 | virtualHostedStyle?: boolean;
|
146 | expires: string | number | Date;
|
147 | extensionHeaders?: http.OutgoingHttpHeaders;
|
148 | queryParams?: Query;
|
149 | }
|
150 | export declare enum BucketActionToHTTPMethod {
|
151 | list = "GET"
|
152 | }
|
153 | export declare enum AvailableServiceObjectMethods {
|
154 | setMetadata = 0,
|
155 | delete = 1
|
156 | }
|
157 | export interface GetNotificationsOptions {
|
158 | userProject?: string;
|
159 | }
|
160 | export interface GetNotificationsCallback {
|
161 | (err: Error | null, notifications: Notification[] | null, apiResponse: Metadata): void;
|
162 | }
|
163 | export declare type GetNotificationsResponse = [Notification[], Metadata];
|
164 | export interface MakeBucketPrivateOptions {
|
165 | includeFiles?: boolean;
|
166 | force?: boolean;
|
167 | metadata?: Metadata;
|
168 | userProject?: string;
|
169 | }
|
170 | export declare type MakeBucketPrivateResponse = [File[]];
|
171 | export interface MakeBucketPrivateCallback {
|
172 | (err?: Error | null, files?: File[]): void;
|
173 | }
|
174 | export interface MakeBucketPublicOptions {
|
175 | includeFiles?: boolean;
|
176 | force?: boolean;
|
177 | }
|
178 | export interface MakeBucketPublicCallback {
|
179 | (err?: Error | null, files?: File[]): void;
|
180 | }
|
181 | export declare type MakeBucketPublicResponse = [File[]];
|
182 | export interface SetBucketMetadataOptions {
|
183 | userProject?: string;
|
184 | }
|
185 | export declare type SetBucketMetadataResponse = [Metadata];
|
186 | export interface SetBucketMetadataCallback {
|
187 | (err?: Error | null, metadata?: Metadata): void;
|
188 | }
|
189 | export interface BucketLockCallback {
|
190 | (err?: Error | null, apiResponse?: Metadata): void;
|
191 | }
|
192 | export declare type BucketLockResponse = [Metadata];
|
193 | export interface Labels {
|
194 | [key: string]: string;
|
195 | }
|
196 | export interface SetLabelsOptions {
|
197 | userProject?: string;
|
198 | }
|
199 | export declare type SetLabelsResponse = [Metadata];
|
200 | export interface SetLabelsCallback {
|
201 | (err?: Error | null, metadata?: Metadata): void;
|
202 | }
|
203 | export interface SetBucketStorageClassOptions {
|
204 | userProject?: string;
|
205 | }
|
206 | export interface SetBucketStorageClassCallback {
|
207 | (err?: Error | null): void;
|
208 | }
|
209 | export declare type UploadResponse = [File, Metadata];
|
210 | export interface UploadCallback {
|
211 | (err: Error | null, file?: File | null, apiResponse?: Metadata): void;
|
212 | }
|
213 | export interface UploadOptions extends CreateResumableUploadOptions, CreateWriteStreamOptions {
|
214 | destination?: string | File;
|
215 | encryptionKey?: string | Buffer;
|
216 | kmsKeyName?: string;
|
217 | resumable?: boolean;
|
218 | timeout?: number;
|
219 | onUploadProgress?: (progressEvent: any) => void;
|
220 | }
|
221 | export interface MakeAllFilesPublicPrivateOptions {
|
222 | force?: boolean;
|
223 | private?: boolean;
|
224 | public?: boolean;
|
225 | userProject?: string;
|
226 | }
|
227 | interface MakeAllFilesPublicPrivateCallback {
|
228 | (err?: Error | Error[] | null, files?: File[]): void;
|
229 | }
|
230 | declare type MakeAllFilesPublicPrivateResponse = [File[]];
|
231 | export declare enum BucketExceptionMessages {
|
232 | PROVIDE_SOURCE_FILE = "You must provide at least one source file.",
|
233 | DESTINATION_FILE_NOT_SPECIFIED = "A destination file must be specified.",
|
234 | CHANNEL_ID_REQUIRED = "An ID is required to create a channel.",
|
235 | CHANNEL_ADDRESS_REQUIRED = "An address is required to create a channel.",
|
236 | TOPIC_NAME_REQUIRED = "A valid topic name is required.",
|
237 | CONFIGURATION_OBJECT_PREFIX_REQUIRED = "A configuration object with a prefix is required.",
|
238 | SPECIFY_FILE_NAME = "A file name must be specified.",
|
239 | METAGENERATION_NOT_PROVIDED = "A metageneration must be provided.",
|
240 | SUPPLY_NOTIFICATION_ID = "You must supply a notification ID."
|
241 | }
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | declare class Bucket extends ServiceObject {
|
456 | metadata: Metadata;
|
457 | name: string;
|
458 | |
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 | storage: Storage;
|
465 | |
466 |
|
467 |
|
468 |
|
469 |
|
470 | userProject?: string;
|
471 | acl: Acl;
|
472 | iam: Iam;
|
473 | getFilesStream(query?: GetFilesOptions): Readable;
|
474 | signer?: URLSigner;
|
475 | private instanceRetryValue?;
|
476 | instancePreconditionOpts?: PreconditionOptions;
|
477 | constructor(storage: Storage, name: string, options?: BucketOptions);
|
478 | addLifecycleRule(rule: LifecycleRule, options?: AddLifecycleRuleOptions): Promise<SetBucketMetadataResponse>;
|
479 | addLifecycleRule(rule: LifecycleRule, options: AddLifecycleRuleOptions, callback: SetBucketMetadataCallback): void;
|
480 | addLifecycleRule(rule: LifecycleRule, callback: SetBucketMetadataCallback): void;
|
481 | combine(sources: string[] | File[], destination: string | File, options?: CombineOptions): Promise<CombineResponse>;
|
482 | combine(sources: string[] | File[], destination: string | File, options: CombineOptions, callback: CombineCallback): void;
|
483 | combine(sources: string[] | File[], destination: string | File, callback: CombineCallback): void;
|
484 | createChannel(id: string, config: CreateChannelConfig, options?: CreateChannelOptions): Promise<CreateChannelResponse>;
|
485 | createChannel(id: string, config: CreateChannelConfig, callback: CreateChannelCallback): void;
|
486 | createChannel(id: string, config: CreateChannelConfig, options: CreateChannelOptions, callback: CreateChannelCallback): void;
|
487 | createNotification(topic: string, options?: CreateNotificationOptions): Promise<CreateNotificationResponse>;
|
488 | createNotification(topic: string, options: CreateNotificationOptions, callback: CreateNotificationCallback): void;
|
489 | createNotification(topic: string, callback: CreateNotificationCallback): void;
|
490 | deleteFiles(query?: DeleteFilesOptions): Promise<void>;
|
491 | deleteFiles(callback: DeleteFilesCallback): void;
|
492 | deleteFiles(query: DeleteFilesOptions, callback: DeleteFilesCallback): void;
|
493 | deleteLabels(labels?: string | string[]): Promise<DeleteLabelsResponse>;
|
494 | deleteLabels(callback: DeleteLabelsCallback): void;
|
495 | deleteLabels(labels: string | string[], callback: DeleteLabelsCallback): void;
|
496 | disableRequesterPays(): Promise<DisableRequesterPaysResponse>;
|
497 | disableRequesterPays(callback: DisableRequesterPaysCallback): void;
|
498 | enableLogging(config: EnableLoggingOptions): Promise<SetBucketMetadataResponse>;
|
499 | enableLogging(config: EnableLoggingOptions, callback: SetBucketMetadataCallback): void;
|
500 | enableRequesterPays(): Promise<EnableRequesterPaysResponse>;
|
501 | enableRequesterPays(callback: EnableRequesterPaysCallback): void;
|
502 | /**
|
503 | * Create a {@link File} object. See {@link File} to see how to handle
|
504 | * the different use cases you may have.
|
505 | *
|
506 | * @param {string} name The name of the file in this bucket.
|
507 | * @param {FileOptions} [options] Configuration options.
|
508 | * @param {string|number} [options.generation] Only use a specific revision of
|
509 | * this file.
|
510 | * @param {string} [options.encryptionKey] A custom encryption key. See
|
511 | * {@link https:
|
512 | * @param {string} [options.kmsKeyName] The name of the Cloud KMS key that will
|
513 | * be used to encrypt the object. Must be in the format:
|
514 | * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`.
|
515 | * KMS key ring must use the same location as the bucket.
|
516 | * @param {string} [options.userProject] The ID of the project which will be
|
517 | * billed for all requests made from File object.
|
518 | * @returns {File}
|
519 | *
|
520 | * @example
|
521 | * ```
|
522 | * const {Storage} = require('@google-cloud/storage');
|
523 | * const storage = new Storage();
|
524 | * const bucket = storage.bucket('albums');
|
525 | * const file = bucket.file('my-existing-file.png');
|
526 | * ```
|
527 | */
|
528 | file(name: string, options?: FileOptions): File;
|
529 | getFiles(query?: GetFilesOptions): Promise<GetFilesResponse>;
|
530 | getFiles(query: GetFilesOptions, callback: GetFilesCallback): void;
|
531 | getFiles(callback: GetFilesCallback): void;
|
532 | getLabels(options?: GetLabelsOptions): Promise<GetLabelsResponse>;
|
533 | getLabels(callback: GetLabelsCallback): void;
|
534 | getLabels(options: GetLabelsOptions, callback: GetLabelsCallback): void;
|
535 | getNotifications(options?: GetNotificationsOptions): Promise<GetNotificationsResponse>;
|
536 | getNotifications(callback: GetNotificationsCallback): void;
|
537 | getNotifications(options: GetNotificationsOptions, callback: GetNotificationsCallback): void;
|
538 | getSignedUrl(cfg: GetBucketSignedUrlConfig): Promise<GetSignedUrlResponse>;
|
539 | getSignedUrl(cfg: GetBucketSignedUrlConfig, callback: GetSignedUrlCallback): void;
|
540 | lock(metageneration: number | string): Promise<BucketLockResponse>;
|
541 | lock(metageneration: number | string, callback: BucketLockCallback): void;
|
542 | makePrivate(options?: MakeBucketPrivateOptions): Promise<MakeBucketPrivateResponse>;
|
543 | makePrivate(callback: MakeBucketPrivateCallback): void;
|
544 | makePrivate(options: MakeBucketPrivateOptions, callback: MakeBucketPrivateCallback): void;
|
545 | makePublic(options?: MakeBucketPublicOptions): Promise<MakeBucketPublicResponse>;
|
546 | makePublic(callback: MakeBucketPublicCallback): void;
|
547 | makePublic(options: MakeBucketPublicOptions, callback: MakeBucketPublicCallback): void;
|
548 | |
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 | notification(id: string): Notification;
|
564 | removeRetentionPeriod(): Promise<SetBucketMetadataResponse>;
|
565 | removeRetentionPeriod(callback: SetBucketMetadataCallback): void;
|
566 | request(reqOpts: DecorateRequestOptions): Promise<[ResponseBody, Metadata]>;
|
567 | request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
|
568 | setLabels(labels: Labels, options?: SetLabelsOptions): Promise<SetLabelsResponse>;
|
569 | setLabels(labels: Labels, callback: SetLabelsCallback): void;
|
570 | setLabels(labels: Labels, options: SetLabelsOptions, callback: SetLabelsCallback): void;
|
571 | setRetentionPeriod(duration: number): Promise<SetBucketMetadataResponse>;
|
572 | setRetentionPeriod(duration: number, callback: SetBucketMetadataCallback): void;
|
573 | setCorsConfiguration(corsConfiguration: Cors[]): Promise<SetBucketMetadataResponse>;
|
574 | setCorsConfiguration(corsConfiguration: Cors[], callback: SetBucketMetadataCallback): void;
|
575 | setStorageClass(storageClass: string, options?: SetBucketStorageClassOptions): Promise<SetBucketMetadataResponse>;
|
576 | setStorageClass(storageClass: string, callback: SetBucketStorageClassCallback): void;
|
577 | setStorageClass(storageClass: string, options: SetBucketStorageClassOptions, callback: SetBucketStorageClassCallback): void;
|
578 | |
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 | setUserProject(userProject: string): void;
|
594 | upload(pathString: string, options?: UploadOptions): Promise<UploadResponse>;
|
595 | upload(pathString: string, options: UploadOptions, callback: UploadCallback): void;
|
596 | upload(pathString: string, callback: UploadCallback): void;
|
597 | makeAllFilesPublicPrivate_(options?: MakeAllFilesPublicPrivateOptions): Promise<MakeAllFilesPublicPrivateResponse>;
|
598 | makeAllFilesPublicPrivate_(callback: MakeAllFilesPublicPrivateCallback): void;
|
599 | makeAllFilesPublicPrivate_(options: MakeAllFilesPublicPrivateOptions, callback: MakeAllFilesPublicPrivateCallback): void;
|
600 | getId(): string;
|
601 | disableAutoRetryConditionallyIdempotent_(coreOpts: any, methodType: AvailableServiceObjectMethods): void;
|
602 | }
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 | export { Bucket };
|