1 |
|
2 | import { ApiError, BodyResponseCallback, DecorateRequestOptions, DeleteCallback, ExistsCallback, GetConfig, Metadata, ResponseBody, ServiceObject } from '@google-cloud/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 } from './storage';
|
10 | import { GetSignedUrlResponse, GetSignedUrlCallback, URLSigner, Query } from './signer';
|
11 | interface BucketOptions {
|
12 | userProject?: string;
|
13 | }
|
14 | export declare type GetFilesResponse = [File[], {}, Metadata];
|
15 | export interface GetFilesCallback {
|
16 | (err: Error | null, files?: File[], nextQuery?: {}, apiResponse?: Metadata): void;
|
17 | }
|
18 | interface WatchAllOptions {
|
19 | delimiter?: string;
|
20 | maxResults?: number;
|
21 | pageToken?: string;
|
22 | prefix?: string;
|
23 | projection?: string;
|
24 | userProject?: string;
|
25 | versions?: boolean;
|
26 | }
|
27 | export interface AddLifecycleRuleOptions {
|
28 | append?: boolean;
|
29 | }
|
30 | export interface LifecycleRule {
|
31 | action: {
|
32 | type: string;
|
33 | storageClass?: string;
|
34 | } | string;
|
35 | condition: {
|
36 | [key: string]: boolean | Date | number | string;
|
37 | };
|
38 | storageClass?: string;
|
39 | }
|
40 | export interface EnableLoggingOptions {
|
41 | bucket?: string | Bucket;
|
42 | prefix: string;
|
43 | }
|
44 | export interface GetFilesOptions {
|
45 | autoPaginate?: boolean;
|
46 | delimiter?: string;
|
47 |
|
48 | directory?: string;
|
49 | endOffset?: string;
|
50 | includeTrailingDelimiter?: boolean;
|
51 | prefix?: string;
|
52 | maxApiCalls?: number;
|
53 | maxResults?: number;
|
54 | pageToken?: string;
|
55 | startOffset?: string;
|
56 | userProject?: string;
|
57 | versions?: boolean;
|
58 | }
|
59 | export interface CombineOptions {
|
60 | kmsKeyName?: string;
|
61 | userProject?: string;
|
62 | }
|
63 | export interface CombineCallback {
|
64 | (err: Error | null, newFile: File | null, apiResponse: Metadata): void;
|
65 | }
|
66 | export declare type CombineResponse = [File, Metadata];
|
67 | export interface CreateChannelConfig extends WatchAllOptions {
|
68 | address: string;
|
69 | }
|
70 | export interface CreateChannelOptions {
|
71 | userProject?: string;
|
72 | }
|
73 | export declare type CreateChannelResponse = [Channel, Metadata];
|
74 | export interface CreateChannelCallback {
|
75 | (err: Error | null, channel: Channel | null, apiResponse: Metadata): void;
|
76 | }
|
77 | export interface CreateNotificationOptions {
|
78 | customAttributes?: {
|
79 | [key: string]: string;
|
80 | };
|
81 | eventTypes?: string[];
|
82 | objectNamePrefix?: string;
|
83 | payloadFormat?: string;
|
84 | userProject?: string;
|
85 | }
|
86 | export interface CreateNotificationCallback {
|
87 | (err: Error | null, notification: Notification | null, apiResponse: Metadata): void;
|
88 | }
|
89 | export declare type CreateNotificationResponse = [Notification, Metadata];
|
90 | export interface DeleteBucketOptions {
|
91 | ignoreNotFound?: boolean;
|
92 | userProject?: string;
|
93 | }
|
94 | export declare type DeleteBucketResponse = [Metadata];
|
95 | export interface DeleteBucketCallback extends DeleteCallback {
|
96 | (err: Error | null, apiResponse: Metadata): void;
|
97 | }
|
98 | export interface DeleteFilesOptions extends GetFilesOptions {
|
99 | force?: boolean;
|
100 | }
|
101 | export interface DeleteFilesCallback {
|
102 | (err: Error | Error[] | null, apiResponse?: object): void;
|
103 | }
|
104 | export declare type DeleteLabelsResponse = [Metadata];
|
105 | export declare type DeleteLabelsCallback = SetLabelsCallback;
|
106 | export declare type DisableRequesterPaysResponse = [Metadata];
|
107 | export interface DisableRequesterPaysCallback {
|
108 | (err?: Error | null, apiResponse?: object): void;
|
109 | }
|
110 | export declare type EnableRequesterPaysResponse = [Metadata];
|
111 | export interface EnableRequesterPaysCallback {
|
112 | (err?: Error | null, apiResponse?: Metadata): void;
|
113 | }
|
114 | export interface BucketExistsOptions extends GetConfig {
|
115 | userProject?: string;
|
116 | }
|
117 | export declare type BucketExistsResponse = [boolean];
|
118 | export declare type BucketExistsCallback = ExistsCallback;
|
119 | export interface GetBucketOptions extends GetConfig {
|
120 | userProject?: string;
|
121 | }
|
122 | export declare type GetBucketResponse = [Bucket, Metadata];
|
123 | export interface GetBucketCallback {
|
124 | (err: ApiError | null, bucket: Bucket | null, apiResponse: Metadata): void;
|
125 | }
|
126 | export interface GetLabelsOptions {
|
127 | userProject?: string;
|
128 | }
|
129 | export declare type GetLabelsResponse = [Metadata];
|
130 | export interface GetLabelsCallback {
|
131 | (err: Error | null, labels: object | null): void;
|
132 | }
|
133 | export declare type GetBucketMetadataResponse = [Metadata, Metadata];
|
134 | export interface GetBucketMetadataCallback {
|
135 | (err: ApiError | null, metadata: Metadata | null, apiResponse: Metadata): void;
|
136 | }
|
137 | export interface GetBucketMetadataOptions {
|
138 | userProject?: string;
|
139 | }
|
140 | export interface GetBucketSignedUrlConfig {
|
141 | action: 'list';
|
142 | version?: 'v2' | 'v4';
|
143 | cname?: string;
|
144 | virtualHostedStyle?: boolean;
|
145 | expires: string | number | Date;
|
146 | extensionHeaders?: http.OutgoingHttpHeaders;
|
147 | queryParams?: Query;
|
148 | }
|
149 | export declare enum BucketActionToHTTPMethod {
|
150 | list = "GET"
|
151 | }
|
152 | export interface GetNotificationsOptions {
|
153 | userProject?: string;
|
154 | }
|
155 | export interface GetNotificationsCallback {
|
156 | (err: Error | null, notifications: Notification[] | null, apiResponse: Metadata): void;
|
157 | }
|
158 | export declare type GetNotificationsResponse = [Notification[], Metadata];
|
159 | export interface MakeBucketPrivateOptions {
|
160 | includeFiles?: boolean;
|
161 | force?: boolean;
|
162 | metadata?: Metadata;
|
163 | userProject?: string;
|
164 | }
|
165 | export declare type MakeBucketPrivateResponse = [File[]];
|
166 | export interface MakeBucketPrivateCallback {
|
167 | (err?: Error | null, files?: File[]): void;
|
168 | }
|
169 | export interface MakeBucketPublicOptions {
|
170 | includeFiles?: boolean;
|
171 | force?: boolean;
|
172 | }
|
173 | export interface MakeBucketPublicCallback {
|
174 | (err?: Error | null, files?: File[]): void;
|
175 | }
|
176 | export declare type MakeBucketPublicResponse = [File[]];
|
177 | export interface SetBucketMetadataOptions {
|
178 | userProject?: string;
|
179 | }
|
180 | export declare type SetBucketMetadataResponse = [Metadata];
|
181 | export interface SetBucketMetadataCallback {
|
182 | (err?: Error | null, metadata?: Metadata): void;
|
183 | }
|
184 | export interface BucketLockCallback {
|
185 | (err?: Error | null, apiResponse?: Metadata): void;
|
186 | }
|
187 | export declare type BucketLockResponse = [Metadata];
|
188 | export interface Labels {
|
189 | [key: string]: string;
|
190 | }
|
191 | export interface SetLabelsOptions {
|
192 | userProject?: string;
|
193 | }
|
194 | export declare type SetLabelsResponse = [Metadata];
|
195 | export interface SetLabelsCallback {
|
196 | (err?: Error | null, metadata?: Metadata): void;
|
197 | }
|
198 | export interface SetBucketStorageClassOptions {
|
199 | userProject?: string;
|
200 | }
|
201 | export interface SetBucketStorageClassCallback {
|
202 | (err?: Error | null): void;
|
203 | }
|
204 | export declare type UploadResponse = [File, Metadata];
|
205 | export interface UploadCallback {
|
206 | (err: Error | null, file?: File | null, apiResponse?: Metadata): void;
|
207 | }
|
208 | export interface UploadOptions extends CreateResumableUploadOptions, CreateWriteStreamOptions {
|
209 | destination?: string | File;
|
210 | encryptionKey?: string | Buffer;
|
211 | kmsKeyName?: string;
|
212 | resumable?: boolean;
|
213 | timeout?: number;
|
214 | onUploadProgress?: (progressEvent: any) => void;
|
215 | }
|
216 | export interface MakeAllFilesPublicPrivateOptions {
|
217 | force?: boolean;
|
218 | private?: boolean;
|
219 | public?: boolean;
|
220 | userProject?: string;
|
221 | }
|
222 | interface MakeAllFilesPublicPrivateCallback {
|
223 | (err?: Error | Error[] | null, files?: File[]): void;
|
224 | }
|
225 | declare type MakeAllFilesPublicPrivateResponse = [File[]];
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
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 | declare class Bucket extends ServiceObject {
|
434 | metadata: Metadata;
|
435 | name: string;
|
436 | |
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 | storage: Storage;
|
443 | |
444 |
|
445 |
|
446 |
|
447 |
|
448 | userProject?: string;
|
449 | acl: Acl;
|
450 | iam: Iam;
|
451 | getFilesStream: Function;
|
452 | signer?: URLSigner;
|
453 | constructor(storage: Storage, name: string, options?: BucketOptions);
|
454 | addLifecycleRule(rule: LifecycleRule, options?: AddLifecycleRuleOptions): Promise<SetBucketMetadataResponse>;
|
455 | addLifecycleRule(rule: LifecycleRule, options: AddLifecycleRuleOptions, callback: SetBucketMetadataCallback): void;
|
456 | addLifecycleRule(rule: LifecycleRule, callback: SetBucketMetadataCallback): void;
|
457 | combine(sources: string[] | File[], destination: string | File, options?: CombineOptions): Promise<CombineResponse>;
|
458 | combine(sources: string[] | File[], destination: string | File, options: CombineOptions, callback: CombineCallback): void;
|
459 | combine(sources: string[] | File[], destination: string | File, callback: CombineCallback): void;
|
460 | createChannel(id: string, config: CreateChannelConfig, options?: CreateChannelOptions): Promise<CreateChannelResponse>;
|
461 | createChannel(id: string, config: CreateChannelConfig, callback: CreateChannelCallback): void;
|
462 | createChannel(id: string, config: CreateChannelConfig, options: CreateChannelOptions, callback: CreateChannelCallback): void;
|
463 | createNotification(topic: string, options?: CreateNotificationOptions): Promise<CreateNotificationResponse>;
|
464 | createNotification(topic: string, options: CreateNotificationOptions, callback: CreateNotificationCallback): void;
|
465 | createNotification(topic: string, callback: CreateNotificationCallback): void;
|
466 | deleteFiles(query?: DeleteFilesOptions): Promise<void>;
|
467 | deleteFiles(callback: DeleteFilesCallback): void;
|
468 | deleteFiles(query: DeleteFilesOptions, callback: DeleteFilesCallback): void;
|
469 | deleteLabels(labels?: string | string[]): Promise<DeleteLabelsResponse>;
|
470 | deleteLabels(callback: DeleteLabelsCallback): void;
|
471 | deleteLabels(labels: string | string[], callback: DeleteLabelsCallback): void;
|
472 | disableRequesterPays(): Promise<DisableRequesterPaysResponse>;
|
473 | disableRequesterPays(callback: DisableRequesterPaysCallback): void;
|
474 | enableLogging(config: EnableLoggingOptions): Promise<SetBucketMetadataResponse>;
|
475 | enableLogging(config: EnableLoggingOptions, callback: SetBucketMetadataCallback): void;
|
476 | enableRequesterPays(): Promise<EnableRequesterPaysResponse>;
|
477 | enableRequesterPays(callback: EnableRequesterPaysCallback): void;
|
478 | /**
|
479 | * Create a {@link File} object. See {@link File} to see how to handle
|
480 | * the different use cases you may have.
|
481 | *
|
482 | * @param {string} name The name of the file in this bucket.
|
483 | * @param {FileOptions} [options] Configuration options.
|
484 | * @param {string|number} [options.generation] Only use a specific revision of
|
485 | * this file.
|
486 | * @param {string} [options.encryptionKey] A custom encryption key. See
|
487 | * [Customer-supplied Encryption
|
488 | * Keys](https:
|
489 | * @param {string} [options.kmsKeyName] The name of the Cloud KMS key that will
|
490 | * be used to encrypt the object. Must be in the format:
|
491 | * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`.
|
492 | * KMS key ring must use the same location as the bucket.
|
493 | * @param {string} [options.userProject] The ID of the project which will be
|
494 | * billed for all requests made from File object.
|
495 | * @returns {File}
|
496 | *
|
497 | * @example
|
498 | * const {Storage} = require('@google-cloud/storage');
|
499 | * const storage = new Storage();
|
500 | * const bucket = storage.bucket('albums');
|
501 | * const file = bucket.file('my-existing-file.png');
|
502 | */
|
503 | file(name: string, options?: FileOptions): File;
|
504 | getFiles(query?: GetFilesOptions): Promise<GetFilesResponse>;
|
505 | getFiles(query: GetFilesOptions, callback: GetFilesCallback): void;
|
506 | getFiles(callback: GetFilesCallback): void;
|
507 | getLabels(options: GetLabelsOptions): Promise<GetLabelsResponse>;
|
508 | getLabels(callback: GetLabelsCallback): void;
|
509 | getLabels(options: GetLabelsOptions, callback: GetLabelsCallback): void;
|
510 | getNotifications(options?: GetNotificationsOptions): Promise<GetNotificationsResponse>;
|
511 | getNotifications(callback: GetNotificationsCallback): void;
|
512 | getNotifications(options: GetNotificationsOptions, callback: GetNotificationsCallback): void;
|
513 | getSignedUrl(cfg: GetBucketSignedUrlConfig): Promise<GetSignedUrlResponse>;
|
514 | getSignedUrl(cfg: GetBucketSignedUrlConfig, callback: GetSignedUrlCallback): void;
|
515 | lock(metageneration: number | string): Promise<BucketLockResponse>;
|
516 | lock(metageneration: number | string, callback: BucketLockCallback): void;
|
517 | makePrivate(options?: MakeBucketPrivateOptions): Promise<MakeBucketPrivateResponse>;
|
518 | makePrivate(callback: MakeBucketPrivateCallback): void;
|
519 | makePrivate(options: MakeBucketPrivateOptions, callback: MakeBucketPrivateCallback): void;
|
520 | makePublic(options?: MakeBucketPublicOptions): Promise<MakeBucketPublicResponse>;
|
521 | makePublic(callback: MakeBucketPublicCallback): void;
|
522 | makePublic(options: MakeBucketPublicOptions, callback: MakeBucketPublicCallback): void;
|
523 | |
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 | notification(id: string): Notification;
|
537 | removeRetentionPeriod(): Promise<SetBucketMetadataResponse>;
|
538 | removeRetentionPeriod(callback: SetBucketMetadataCallback): void;
|
539 | request(reqOpts: DecorateRequestOptions): Promise<[ResponseBody, Metadata]>;
|
540 | request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
|
541 | setLabels(labels: Labels, options?: SetLabelsOptions): Promise<SetLabelsResponse>;
|
542 | setLabels(labels: Labels, callback: SetLabelsCallback): void;
|
543 | setLabels(labels: Labels, options: SetLabelsOptions, callback: SetLabelsCallback): void;
|
544 | setRetentionPeriod(duration: number): Promise<SetBucketMetadataResponse>;
|
545 | setRetentionPeriod(duration: number, callback: SetBucketMetadataCallback): void;
|
546 | setCorsConfiguration(corsConfiguration: Cors[]): Promise<SetBucketMetadataResponse>;
|
547 | setCorsConfiguration(corsConfiguration: Cors[], callback: SetBucketMetadataCallback): void;
|
548 | setStorageClass(storageClass: string, options?: SetBucketStorageClassOptions): Promise<SetBucketMetadataResponse>;
|
549 | setStorageClass(storageClass: string, callback: SetBucketStorageClassCallback): void;
|
550 | setStorageClass(storageClass: string, options: SetBucketStorageClassOptions, callback: SetBucketStorageClassCallback): void;
|
551 | |
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | setUserProject(userProject: string): void;
|
565 | upload(pathString: string, options?: UploadOptions): Promise<UploadResponse>;
|
566 | upload(pathString: string, options: UploadOptions, callback: UploadCallback): void;
|
567 | upload(pathString: string, callback: UploadCallback): void;
|
568 | makeAllFilesPublicPrivate_(options?: MakeAllFilesPublicPrivateOptions): Promise<MakeAllFilesPublicPrivateResponse>;
|
569 | makeAllFilesPublicPrivate_(callback: MakeAllFilesPublicPrivateCallback): void;
|
570 | makeAllFilesPublicPrivate_(options: MakeAllFilesPublicPrivateOptions, callback: MakeAllFilesPublicPrivateCallback): void;
|
571 | getId(): string;
|
572 | }
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 | export { Bucket };
|