UNPKG

31.2 kBTypeScriptView Raw
1import { ApiError, BodyResponseCallback, DecorateRequestOptions, DeleteCallback, ExistsCallback, GetConfig, MetadataCallback, ServiceObject, SetMetadataResponse } from './nodejs-common/index.js';
2import { RequestResponse } from './nodejs-common/service-object.js';
3import * as http from 'http';
4import { Acl, AclMetadata } from './acl.js';
5import { Channel } from './channel.js';
6import { File, FileOptions, CreateResumableUploadOptions, CreateWriteStreamOptions } from './file.js';
7import { Iam } from './iam.js';
8import { Notification } from './notification.js';
9import { Storage, Cors, PreconditionOptions, BucketOptions } from './storage.js';
10import { GetSignedUrlResponse, GetSignedUrlCallback, SignerGetSignedUrlConfig, URLSigner, Query } from './signer.js';
11import { Readable } from 'stream';
12import { CRC32CValidatorGenerator } from './crc32c.js';
13import { URL } from 'url';
14import { BaseMetadata, SetMetadataOptions } from './nodejs-common/service-object.js';
15export type GetFilesResponse = [
16 File[],
17 (GetFilesOptions | {}) & Partial<Pick<GetFilesOptions, 'pageToken'>>,
18 unknown
19];
20export interface GetFilesCallback {
21 (err: Error | null, files?: File[], nextQuery?: {}, apiResponse?: unknown): void;
22}
23interface WatchAllOptions {
24 delimiter?: string;
25 maxResults?: number;
26 pageToken?: string;
27 prefix?: string;
28 projection?: string;
29 userProject?: string;
30 versions?: boolean;
31}
32export interface AddLifecycleRuleOptions extends PreconditionOptions {
33 append?: boolean;
34}
35export interface LifecycleAction {
36 type: 'Delete' | 'SetStorageClass' | 'AbortIncompleteMultipartUpload';
37 storageClass?: string;
38}
39export interface LifecycleCondition {
40 age?: number;
41 createdBefore?: Date | string;
42 customTimeBefore?: Date | string;
43 daysSinceCustomTime?: number;
44 daysSinceNoncurrentTime?: number;
45 isLive?: boolean;
46 matchesPrefix?: string[];
47 matchesSuffix?: string[];
48 matchesStorageClass?: string[];
49 noncurrentTimeBefore?: Date | string;
50 numNewerVersions?: number;
51}
52export interface LifecycleRule {
53 action: LifecycleAction;
54 condition: LifecycleCondition;
55}
56export interface LifecycleCondition {
57 age?: number;
58 createdBefore?: Date | string;
59 customTimeBefore?: Date | string;
60 daysSinceCustomTime?: number;
61 daysSinceNoncurrentTime?: number;
62 isLive?: boolean;
63 matchesPrefix?: string[];
64 matchesSuffix?: string[];
65 matchesStorageClass?: string[];
66 noncurrentTimeBefore?: Date | string;
67 numNewerVersions?: number;
68}
69export interface LifecycleRule {
70 action: LifecycleAction;
71 condition: LifecycleCondition;
72}
73export interface EnableLoggingOptions extends PreconditionOptions {
74 bucket?: string | Bucket;
75 prefix: string;
76}
77export interface GetFilesOptions {
78 autoPaginate?: boolean;
79 delimiter?: string;
80 endOffset?: string;
81 includeFoldersAsPrefixes?: boolean;
82 includeTrailingDelimiter?: boolean;
83 prefix?: string;
84 matchGlob?: string;
85 maxApiCalls?: number;
86 maxResults?: number;
87 pageToken?: string;
88 softDeleted?: boolean;
89 startOffset?: string;
90 userProject?: string;
91 versions?: boolean;
92 fields?: string;
93}
94export interface CombineOptions extends PreconditionOptions {
95 kmsKeyName?: string;
96 userProject?: string;
97}
98export interface CombineCallback {
99 (err: Error | null, newFile: File | null, apiResponse: unknown): void;
100}
101export type CombineResponse = [File, unknown];
102export interface CreateChannelConfig extends WatchAllOptions {
103 address: string;
104}
105export interface CreateChannelOptions {
106 userProject?: string;
107}
108export type CreateChannelResponse = [Channel, unknown];
109export interface CreateChannelCallback {
110 (err: Error | null, channel: Channel | null, apiResponse: unknown): void;
111}
112export interface CreateNotificationOptions {
113 customAttributes?: {
114 [key: string]: string;
115 };
116 eventTypes?: string[];
117 objectNamePrefix?: string;
118 payloadFormat?: string;
119 userProject?: string;
120}
121export interface CreateNotificationCallback {
122 (err: Error | null, notification: Notification | null, apiResponse: unknown): void;
123}
124export type CreateNotificationResponse = [Notification, unknown];
125export interface DeleteBucketOptions {
126 ignoreNotFound?: boolean;
127 userProject?: string;
128}
129export type DeleteBucketResponse = [unknown];
130export interface DeleteBucketCallback extends DeleteCallback {
131 (err: Error | null, apiResponse: unknown): void;
132}
133export interface DeleteFilesOptions extends GetFilesOptions, PreconditionOptions {
134 force?: boolean;
135}
136export interface DeleteFilesCallback {
137 (err: Error | Error[] | null, apiResponse?: object): void;
138}
139export type DeleteLabelsResponse = [unknown];
140export type DeleteLabelsCallback = SetLabelsCallback;
141export type DeleteLabelsOptions = PreconditionOptions;
142export type DisableRequesterPaysOptions = PreconditionOptions;
143export type DisableRequesterPaysResponse = [unknown];
144export interface DisableRequesterPaysCallback {
145 (err?: Error | null, apiResponse?: object): void;
146}
147export type EnableRequesterPaysResponse = [unknown];
148export interface EnableRequesterPaysCallback {
149 (err?: Error | null, apiResponse?: unknown): void;
150}
151export type EnableRequesterPaysOptions = PreconditionOptions;
152export interface BucketExistsOptions extends GetConfig {
153 userProject?: string;
154}
155export type BucketExistsResponse = [boolean];
156export type BucketExistsCallback = ExistsCallback;
157export interface GetBucketOptions extends GetConfig {
158 userProject?: string;
159}
160export type GetBucketResponse = [Bucket, unknown];
161export interface GetBucketCallback {
162 (err: ApiError | null, bucket: Bucket | null, apiResponse: unknown): void;
163}
164export interface GetLabelsOptions {
165 userProject?: string;
166}
167export type GetLabelsResponse = [unknown];
168export interface GetLabelsCallback {
169 (err: Error | null, labels: object | null): void;
170}
171export interface RestoreOptions {
172 generation: string;
173 projection?: 'full' | 'noAcl';
174}
175export interface BucketMetadata extends BaseMetadata {
176 acl?: AclMetadata[] | null;
177 autoclass?: {
178 enabled?: boolean;
179 toggleTime?: string;
180 terminalStorageClass?: string;
181 terminalStorageClassUpdateTime?: string;
182 };
183 billing?: {
184 requesterPays?: boolean;
185 };
186 cors?: Cors[];
187 customPlacementConfig?: {
188 dataLocations?: string[];
189 };
190 defaultEventBasedHold?: boolean;
191 defaultObjectAcl?: AclMetadata[];
192 encryption?: {
193 defaultKmsKeyName?: string;
194 } | null;
195 hierarchicalNamespace?: {
196 enabled?: boolean;
197 };
198 iamConfiguration?: {
199 publicAccessPrevention?: string;
200 uniformBucketLevelAccess?: {
201 enabled?: boolean;
202 lockedTime?: string;
203 };
204 };
205 labels?: {
206 [key: string]: string | null;
207 };
208 lifecycle?: {
209 rule?: LifecycleRule[];
210 } | null;
211 location?: string;
212 locationType?: string;
213 logging?: {
214 logBucket?: string;
215 logObjectPrefix?: string;
216 };
217 generation?: string;
218 metageneration?: string;
219 name?: string;
220 objectRetention?: {
221 mode?: string;
222 };
223 owner?: {
224 entity?: string;
225 entityId?: string;
226 };
227 projectNumber?: string | number;
228 retentionPolicy?: {
229 effectiveTime?: string;
230 isLocked?: boolean;
231 retentionPeriod?: string | number;
232 } | null;
233 rpo?: string;
234 softDeleteTime?: string;
235 hardDeleteTime?: string;
236 softDeletePolicy?: {
237 retentionDurationSeconds?: string | number;
238 readonly effectiveTime?: string;
239 };
240 storageClass?: string;
241 timeCreated?: string;
242 updated?: string;
243 versioning?: {
244 enabled?: boolean;
245 };
246 website?: {
247 mainPageSuffix?: string;
248 notFoundPage?: string;
249 };
250}
251export type GetBucketMetadataResponse = [BucketMetadata, unknown];
252export interface GetBucketMetadataCallback {
253 (err: ApiError | null, metadata: BucketMetadata | null, apiResponse: unknown): void;
254}
255export interface GetBucketMetadataOptions {
256 userProject?: string;
257}
258export interface GetBucketSignedUrlConfig extends Pick<SignerGetSignedUrlConfig, 'host' | 'signingEndpoint'> {
259 action: 'list';
260 version?: 'v2' | 'v4';
261 cname?: string;
262 virtualHostedStyle?: boolean;
263 expires: string | number | Date;
264 extensionHeaders?: http.OutgoingHttpHeaders;
265 queryParams?: Query;
266}
267export declare enum BucketActionToHTTPMethod {
268 list = "GET"
269}
270export declare enum AvailableServiceObjectMethods {
271 setMetadata = 0,
272 delete = 1
273}
274export interface GetNotificationsOptions {
275 userProject?: string;
276}
277export interface GetNotificationsCallback {
278 (err: Error | null, notifications: Notification[] | null, apiResponse: unknown): void;
279}
280export type GetNotificationsResponse = [Notification[], unknown];
281export interface MakeBucketPrivateOptions {
282 includeFiles?: boolean;
283 force?: boolean;
284 metadata?: BucketMetadata;
285 userProject?: string;
286 preconditionOpts?: PreconditionOptions;
287}
288export type MakeBucketPrivateResponse = [File[]];
289export interface MakeBucketPrivateCallback {
290 (err?: Error | null, files?: File[]): void;
291}
292export interface MakeBucketPublicOptions {
293 includeFiles?: boolean;
294 force?: boolean;
295}
296export interface MakeBucketPublicCallback {
297 (err?: Error | null, files?: File[]): void;
298}
299export type MakeBucketPublicResponse = [File[]];
300export interface SetBucketMetadataOptions extends PreconditionOptions {
301 userProject?: string;
302}
303export type SetBucketMetadataResponse = [BucketMetadata];
304export interface SetBucketMetadataCallback {
305 (err?: Error | null, metadata?: BucketMetadata): void;
306}
307export interface BucketLockCallback {
308 (err?: Error | null, apiResponse?: unknown): void;
309}
310export type BucketLockResponse = [unknown];
311export interface Labels {
312 [key: string]: string;
313}
314export interface SetLabelsOptions extends PreconditionOptions {
315 userProject?: string;
316}
317export type SetLabelsResponse = [unknown];
318export interface SetLabelsCallback {
319 (err?: Error | null, metadata?: unknown): void;
320}
321export interface SetBucketStorageClassOptions extends PreconditionOptions {
322 userProject?: string;
323}
324export interface SetBucketStorageClassCallback {
325 (err?: Error | null): void;
326}
327export type UploadResponse = [File, unknown];
328export interface UploadCallback {
329 (err: Error | null, file?: File | null, apiResponse?: unknown): void;
330}
331export interface UploadOptions extends CreateResumableUploadOptions, CreateWriteStreamOptions {
332 destination?: string | File;
333 encryptionKey?: string | Buffer;
334 kmsKeyName?: string;
335 onUploadProgress?: (progressEvent: any) => void;
336}
337export interface MakeAllFilesPublicPrivateOptions {
338 force?: boolean;
339 private?: boolean;
340 public?: boolean;
341 userProject?: string;
342}
343interface MakeAllFilesPublicPrivateCallback {
344 (err?: Error | Error[] | null, files?: File[]): void;
345}
346type MakeAllFilesPublicPrivateResponse = [File[]];
347export declare enum BucketExceptionMessages {
348 PROVIDE_SOURCE_FILE = "You must provide at least one source file.",
349 DESTINATION_FILE_NOT_SPECIFIED = "A destination file must be specified.",
350 CHANNEL_ID_REQUIRED = "An ID is required to create a channel.",
351 TOPIC_NAME_REQUIRED = "A valid topic name is required.",
352 CONFIGURATION_OBJECT_PREFIX_REQUIRED = "A configuration object with a prefix is required.",
353 SPECIFY_FILE_NAME = "A file name must be specified.",
354 METAGENERATION_NOT_PROVIDED = "A metageneration must be provided.",
355 SUPPLY_NOTIFICATION_ID = "You must supply a notification ID."
356}
357/**
358 * @callback Crc32cGeneratorToStringCallback
359 * A method returning the CRC32C as a base64-encoded string.
360 *
361 * @returns {string}
362 *
363 * @example
364 * Hashing the string 'data' should return 'rth90Q=='
365 *
366 * ```js
367 * const buffer = Buffer.from('data');
368 * crc32c.update(buffer);
369 * crc32c.toString(); // 'rth90Q=='
370 * ```
371 **/
372/**
373 * @callback Crc32cGeneratorValidateCallback
374 * A method validating a base64-encoded CRC32C string.
375 *
376 * @param {string} [value] base64-encoded CRC32C string to validate
377 * @returns {boolean}
378 *
379 * @example
380 * Should return `true` if the value matches, `false` otherwise
381 *
382 * ```js
383 * const buffer = Buffer.from('data');
384 * crc32c.update(buffer);
385 * crc32c.validate('DkjKuA=='); // false
386 * crc32c.validate('rth90Q=='); // true
387 * ```
388 **/
389/**
390 * @callback Crc32cGeneratorUpdateCallback
391 * A method for passing `Buffer`s for CRC32C generation.
392 *
393 * @param {Buffer} [data] data to update CRC32C value with
394 * @returns {undefined}
395 *
396 * @example
397 * Hashing buffers from 'some ' and 'text\n'
398 *
399 * ```js
400 * const buffer1 = Buffer.from('some ');
401 * crc32c.update(buffer1);
402 *
403 * const buffer2 = Buffer.from('text\n');
404 * crc32c.update(buffer2);
405 *
406 * crc32c.toString(); // 'DkjKuA=='
407 * ```
408 **/
409/**
410 * @typedef {object} CRC32CValidator
411 * @property {Crc32cGeneratorToStringCallback}
412 * @property {Crc32cGeneratorValidateCallback}
413 * @property {Crc32cGeneratorUpdateCallback}
414 */
415/**
416 * A function that generates a CRC32C Validator. Defaults to {@link CRC32C}
417 *
418 * @name Bucket#crc32cGenerator
419 * @type {CRC32CValidator}
420 */
421/**
422 * Get and set IAM policies for your bucket.
423 *
424 * @name Bucket#iam
425 * @mixes Iam
426 *
427 * See {@link https://cloud.google.com/storage/docs/access-control/iam#short_title_iam_management| Cloud Storage IAM Management}
428 * See {@link https://cloud.google.com/iam/docs/granting-changing-revoking-access| Granting, Changing, and Revoking Access}
429 * See {@link https://cloud.google.com/iam/docs/understanding-roles| IAM Roles}
430 *
431 * @example
432 * ```
433 * const {Storage} = require('@google-cloud/storage');
434 * const storage = new Storage();
435 * const bucket = storage.bucket('albums');
436 *
437 * //-
438 * // Get the IAM policy for your bucket.
439 * //-
440 * bucket.iam.getPolicy(function(err, policy) {
441 * console.log(policy);
442 * });
443 *
444 * //-
445 * // If the callback is omitted, we'll return a Promise.
446 * //-
447 * bucket.iam.getPolicy().then(function(data) {
448 * const policy = data[0];
449 * const apiResponse = data[1];
450 * });
451 *
452 * ```
453 * @example <caption>include:samples/iam.js</caption>
454 * region_tag:storage_view_bucket_iam_members
455 * Example of retrieving a bucket's IAM policy:
456 *
457 * @example <caption>include:samples/iam.js</caption>
458 * region_tag:storage_add_bucket_iam_member
459 * Example of adding to a bucket's IAM policy:
460 *
461 * @example <caption>include:samples/iam.js</caption>
462 * region_tag:storage_remove_bucket_iam_member
463 * Example of removing from a bucket's IAM policy:
464 */
465/**
466 * Cloud Storage uses access control lists (ACLs) to manage object and
467 * bucket access. ACLs are the mechanism you use to share objects with other
468 * users and allow other users to access your buckets and objects.
469 *
470 * An ACL consists of one or more entries, where each entry grants permissions
471 * to an entity. Permissions define the actions that can be performed against
472 * an object or bucket (for example, `READ` or `WRITE`); the entity defines
473 * who the permission applies to (for example, a specific user or group of
474 * users).
475 *
476 * The `acl` object on a Bucket instance provides methods to get you a list of
477 * the ACLs defined on your bucket, as well as set, update, and delete them.
478 *
479 * Buckets also have
480 * {@link https://cloud.google.com/storage/docs/access-control/lists#default| default ACLs}
481 * for all created files. Default ACLs specify permissions that all new
482 * objects added to the bucket will inherit by default. You can add, delete,
483 * get, and update entities and permissions for these as well with
484 * {@link Bucket#acl.default}.
485 *
486 * See {@link http://goo.gl/6qBBPO| About Access Control Lists}
487 * See {@link https://cloud.google.com/storage/docs/access-control/lists#default| Default ACLs}
488 *
489 * @name Bucket#acl
490 * @mixes Acl
491 * @property {Acl} default Cloud Storage Buckets have
492 * {@link https://cloud.google.com/storage/docs/access-control/lists#default| default ACLs}
493 * for all created files. You can add, delete, get, and update entities and
494 * permissions for these as well. The method signatures and examples are all
495 * the same, after only prefixing the method call with `default`.
496 *
497 * @example
498 * ```
499 * const {Storage} = require('@google-cloud/storage');
500 * const storage = new Storage();
501 *
502 * //-
503 * // Make a bucket's contents publicly readable.
504 * //-
505 * const myBucket = storage.bucket('my-bucket');
506 *
507 * const options = {
508 * entity: 'allUsers',
509 * role: storage.acl.READER_ROLE
510 * };
511 *
512 * myBucket.acl.add(options, function(err, aclObject) {});
513 *
514 * //-
515 * // If the callback is omitted, we'll return a Promise.
516 * //-
517 * myBucket.acl.add(options).then(function(data) {
518 * const aclObject = data[0];
519 * const apiResponse = data[1];
520 * });
521 *
522 * ```
523 * @example <caption>include:samples/acl.js</caption>
524 * region_tag:storage_print_bucket_acl
525 * Example of printing a bucket's ACL:
526 *
527 * @example <caption>include:samples/acl.js</caption>
528 * region_tag:storage_print_bucket_acl_for_user
529 * Example of printing a bucket's ACL for a specific user:
530 *
531 * @example <caption>include:samples/acl.js</caption>
532 * region_tag:storage_add_bucket_owner
533 * Example of adding an owner to a bucket:
534 *
535 * @example <caption>include:samples/acl.js</caption>
536 * region_tag:storage_remove_bucket_owner
537 * Example of removing an owner from a bucket:
538 *
539 * @example <caption>include:samples/acl.js</caption>
540 * region_tag:storage_add_bucket_default_owner
541 * Example of adding a default owner to a bucket:
542 *
543 * @example <caption>include:samples/acl.js</caption>
544 * region_tag:storage_remove_bucket_default_owner
545 * Example of removing a default owner from a bucket:
546 */
547/**
548 * The API-formatted resource description of the bucket.
549 *
550 * Note: This is not guaranteed to be up-to-date when accessed. To get the
551 * latest record, call the `getMetadata()` method.
552 *
553 * @name Bucket#metadata
554 * @type {object}
555 */
556/**
557 * The bucket's name.
558 * @name Bucket#name
559 * @type {string}
560 */
561/**
562 * Get {@link File} objects for the files currently in the bucket as a
563 * readable object stream.
564 *
565 * @method Bucket#getFilesStream
566 * @param {GetFilesOptions} [query] Query object for listing files.
567 * @returns {ReadableStream} A readable stream that emits {@link File} instances.
568 *
569 * @example
570 * ```
571 * const {Storage} = require('@google-cloud/storage');
572 * const storage = new Storage();
573 * const bucket = storage.bucket('albums');
574 *
575 * bucket.getFilesStream()
576 * .on('error', console.error)
577 * .on('data', function(file) {
578 * // file is a File object.
579 * })
580 * .on('end', function() {
581 * // All files retrieved.
582 * });
583 *
584 * //-
585 * // If you anticipate many results, you can end a stream early to prevent
586 * // unnecessary processing and API requests.
587 * //-
588 * bucket.getFilesStream()
589 * .on('data', function(file) {
590 * this.end();
591 * });
592 *
593 * //-
594 * // If you're filtering files with a delimiter, you should use
595 * // {@link Bucket#getFiles} and set `autoPaginate: false` in order to
596 * // preserve the `apiResponse` argument.
597 * //-
598 * const prefixes = [];
599 *
600 * function callback(err, files, nextQuery, apiResponse) {
601 * prefixes = prefixes.concat(apiResponse.prefixes);
602 *
603 * if (nextQuery) {
604 * bucket.getFiles(nextQuery, callback);
605 * } else {
606 * // prefixes = The finished array of prefixes.
607 * }
608 * }
609 *
610 * bucket.getFiles({
611 * autoPaginate: false,
612 * delimiter: '/'
613 * }, callback);
614 * ```
615 */
616/**
617 * Create a Bucket object to interact with a Cloud Storage bucket.
618 *
619 * @class
620 * @hideconstructor
621 *
622 * @param {Storage} storage A {@link Storage} instance.
623 * @param {string} name The name of the bucket.
624 * @param {object} [options] Configuration object.
625 * @param {string} [options.userProject] User project.
626 *
627 * @example
628 * ```
629 * const {Storage} = require('@google-cloud/storage');
630 * const storage = new Storage();
631 * const bucket = storage.bucket('albums');
632 * ```
633 */
634declare class Bucket extends ServiceObject<Bucket, BucketMetadata> {
635 name: string;
636 /**
637 * A reference to the {@link Storage} associated with this {@link Bucket}
638 * instance.
639 * @name Bucket#storage
640 * @type {Storage}
641 */
642 storage: Storage;
643 /**
644 * A user project to apply to each request from this bucket.
645 * @name Bucket#userProject
646 * @type {string}
647 */
648 userProject?: string;
649 acl: Acl;
650 iam: Iam;
651 crc32cGenerator: CRC32CValidatorGenerator;
652 getFilesStream(query?: GetFilesOptions): Readable;
653 signer?: URLSigner;
654 private instanceRetryValue?;
655 instancePreconditionOpts?: PreconditionOptions;
656 constructor(storage: Storage, name: string, options?: BucketOptions);
657 /**
658 * The bucket's Cloud Storage URI (`gs://`)
659 *
660 * @example
661 * ```ts
662 * const {Storage} = require('@google-cloud/storage');
663 * const storage = new Storage();
664 * const bucket = storage.bucket('my-bucket');
665 *
666 * // `gs://my-bucket`
667 * const href = bucket.cloudStorageURI.href;
668 * ```
669 */
670 get cloudStorageURI(): URL;
671 addLifecycleRule(rule: LifecycleRule | LifecycleRule[], options?: AddLifecycleRuleOptions): Promise<SetBucketMetadataResponse>;
672 addLifecycleRule(rule: LifecycleRule | LifecycleRule[], options: AddLifecycleRuleOptions, callback: SetBucketMetadataCallback): void;
673 addLifecycleRule(rule: LifecycleRule | LifecycleRule[], callback: SetBucketMetadataCallback): void;
674 combine(sources: string[] | File[], destination: string | File, options?: CombineOptions): Promise<CombineResponse>;
675 combine(sources: string[] | File[], destination: string | File, options: CombineOptions, callback: CombineCallback): void;
676 combine(sources: string[] | File[], destination: string | File, callback: CombineCallback): void;
677 createChannel(id: string, config: CreateChannelConfig, options?: CreateChannelOptions): Promise<CreateChannelResponse>;
678 createChannel(id: string, config: CreateChannelConfig, callback: CreateChannelCallback): void;
679 createChannel(id: string, config: CreateChannelConfig, options: CreateChannelOptions, callback: CreateChannelCallback): void;
680 createNotification(topic: string, options?: CreateNotificationOptions): Promise<CreateNotificationResponse>;
681 createNotification(topic: string, options: CreateNotificationOptions, callback: CreateNotificationCallback): void;
682 createNotification(topic: string, callback: CreateNotificationCallback): void;
683 deleteFiles(query?: DeleteFilesOptions): Promise<void>;
684 deleteFiles(callback: DeleteFilesCallback): void;
685 deleteFiles(query: DeleteFilesOptions, callback: DeleteFilesCallback): void;
686 deleteLabels(labels?: string | string[]): Promise<DeleteLabelsResponse>;
687 deleteLabels(options: DeleteLabelsOptions): Promise<DeleteLabelsResponse>;
688 deleteLabels(callback: DeleteLabelsCallback): void;
689 deleteLabels(labels: string | string[], options: DeleteLabelsOptions): Promise<DeleteLabelsResponse>;
690 deleteLabels(labels: string | string[], callback: DeleteLabelsCallback): void;
691 deleteLabels(labels: string | string[], options: DeleteLabelsOptions, callback: DeleteLabelsCallback): void;
692 disableRequesterPays(options?: DisableRequesterPaysOptions): Promise<DisableRequesterPaysResponse>;
693 disableRequesterPays(callback: DisableRequesterPaysCallback): void;
694 disableRequesterPays(options: DisableRequesterPaysOptions, callback: DisableRequesterPaysCallback): void;
695 enableLogging(config: EnableLoggingOptions): Promise<SetBucketMetadataResponse>;
696 enableLogging(config: EnableLoggingOptions, callback: SetBucketMetadataCallback): void;
697 enableRequesterPays(options?: EnableRequesterPaysOptions): Promise<EnableRequesterPaysResponse>;
698 enableRequesterPays(callback: EnableRequesterPaysCallback): void;
699 enableRequesterPays(options: EnableRequesterPaysOptions, callback: EnableRequesterPaysCallback): void;
700 /**
701 * Create a {@link File} object. See {@link File} to see how to handle
702 * the different use cases you may have.
703 *
704 * @param {string} name The name of the file in this bucket.
705 * @param {FileOptions} [options] Configuration options.
706 * @param {string|number} [options.generation] Only use a specific revision of
707 * this file.
708 * @param {string} [options.encryptionKey] A custom encryption key. See
709 * {@link https://cloud.google.com/storage/docs/encryption#customer-supplied| Customer-supplied Encryption Keys}.
710 * @param {string} [options.kmsKeyName] The name of the Cloud KMS key that will
711 * be used to encrypt the object. Must be in the format:
712 * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`.
713 * KMS key ring must use the same location as the bucket.
714 * @param {string} [options.userProject] The ID of the project which will be
715 * billed for all requests made from File object.
716 * @returns {File}
717 *
718 * @example
719 * ```
720 * const {Storage} = require('@google-cloud/storage');
721 * const storage = new Storage();
722 * const bucket = storage.bucket('albums');
723 * const file = bucket.file('my-existing-file.png');
724 * ```
725 */
726 file(name: string, options?: FileOptions): File;
727 getFiles(query?: GetFilesOptions): Promise<GetFilesResponse>;
728 getFiles(query: GetFilesOptions, callback: GetFilesCallback): void;
729 getFiles(callback: GetFilesCallback): void;
730 getLabels(options?: GetLabelsOptions): Promise<GetLabelsResponse>;
731 getLabels(callback: GetLabelsCallback): void;
732 getLabels(options: GetLabelsOptions, callback: GetLabelsCallback): void;
733 getNotifications(options?: GetNotificationsOptions): Promise<GetNotificationsResponse>;
734 getNotifications(callback: GetNotificationsCallback): void;
735 getNotifications(options: GetNotificationsOptions, callback: GetNotificationsCallback): void;
736 getSignedUrl(cfg: GetBucketSignedUrlConfig): Promise<GetSignedUrlResponse>;
737 getSignedUrl(cfg: GetBucketSignedUrlConfig, callback: GetSignedUrlCallback): void;
738 lock(metageneration: number | string): Promise<BucketLockResponse>;
739 lock(metageneration: number | string, callback: BucketLockCallback): void;
740 /**
741 * @typedef {object} RestoreOptions Options for Bucket#restore(). See an
742 * {@link https://cloud.google.com/storage/docs/json_api/v1/buckets/restore#resource| Object resource}.
743 * @param {number} [generation] If present, selects a specific revision of this object.
744 * @param {string} [projection] Specifies the set of properties to return. If used, must be 'full' or 'noAcl'.
745 */
746 /**
747 * Restores a soft-deleted bucket
748 * @param {RestoreOptions} options Restore options.
749 * @returns {Promise<Bucket>}
750 */
751 restore(options: RestoreOptions): Promise<Bucket>;
752 makePrivate(options?: MakeBucketPrivateOptions): Promise<MakeBucketPrivateResponse>;
753 makePrivate(callback: MakeBucketPrivateCallback): void;
754 makePrivate(options: MakeBucketPrivateOptions, callback: MakeBucketPrivateCallback): void;
755 makePublic(options?: MakeBucketPublicOptions): Promise<MakeBucketPublicResponse>;
756 makePublic(callback: MakeBucketPublicCallback): void;
757 makePublic(options: MakeBucketPublicOptions, callback: MakeBucketPublicCallback): void;
758 /**
759 * Get a reference to a Cloud Pub/Sub Notification.
760 *
761 * @param {string} id ID of notification.
762 * @returns {Notification}
763 * @see Notification
764 *
765 * @example
766 * ```
767 * const {Storage} = require('@google-cloud/storage');
768 * const storage = new Storage();
769 * const bucket = storage.bucket('my-bucket');
770 * const notification = bucket.notification('1');
771 * ```
772 */
773 notification(id: string): Notification;
774 removeRetentionPeriod(options?: SetBucketMetadataOptions): Promise<SetBucketMetadataResponse>;
775 removeRetentionPeriod(callback: SetBucketMetadataCallback): void;
776 removeRetentionPeriod(options: SetBucketMetadataOptions, callback: SetBucketMetadataCallback): void;
777 request(reqOpts: DecorateRequestOptions): Promise<RequestResponse>;
778 request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
779 setLabels(labels: Labels, options?: SetLabelsOptions): Promise<SetLabelsResponse>;
780 setLabels(labels: Labels, callback: SetLabelsCallback): void;
781 setLabels(labels: Labels, options: SetLabelsOptions, callback: SetLabelsCallback): void;
782 setMetadata(metadata: BucketMetadata, options?: SetMetadataOptions): Promise<SetMetadataResponse<BucketMetadata>>;
783 setMetadata(metadata: BucketMetadata, callback: MetadataCallback<BucketMetadata>): void;
784 setMetadata(metadata: BucketMetadata, options: SetMetadataOptions, callback: MetadataCallback<BucketMetadata>): void;
785 setRetentionPeriod(duration: number, options?: SetBucketMetadataOptions): Promise<SetBucketMetadataResponse>;
786 setRetentionPeriod(duration: number, callback: SetBucketMetadataCallback): void;
787 setRetentionPeriod(duration: number, options: SetBucketMetadataOptions, callback: SetBucketMetadataCallback): void;
788 setCorsConfiguration(corsConfiguration: Cors[], options?: SetBucketMetadataOptions): Promise<SetBucketMetadataResponse>;
789 setCorsConfiguration(corsConfiguration: Cors[], callback: SetBucketMetadataCallback): void;
790 setCorsConfiguration(corsConfiguration: Cors[], options: SetBucketMetadataOptions, callback: SetBucketMetadataCallback): void;
791 setStorageClass(storageClass: string, options?: SetBucketStorageClassOptions): Promise<SetBucketMetadataResponse>;
792 setStorageClass(storageClass: string, callback: SetBucketStorageClassCallback): void;
793 setStorageClass(storageClass: string, options: SetBucketStorageClassOptions, callback: SetBucketStorageClassCallback): void;
794 /**
795 * Set a user project to be billed for all requests made from this Bucket
796 * object and any files referenced from this Bucket object.
797 *
798 * @param {string} userProject The user project.
799 *
800 * @example
801 * ```
802 * const {Storage} = require('@google-cloud/storage');
803 * const storage = new Storage();
804 * const bucket = storage.bucket('albums');
805 *
806 * bucket.setUserProject('grape-spaceship-123');
807 * ```
808 */
809 setUserProject(userProject: string): void;
810 upload(pathString: string, options?: UploadOptions): Promise<UploadResponse>;
811 upload(pathString: string, options: UploadOptions, callback: UploadCallback): void;
812 upload(pathString: string, callback: UploadCallback): void;
813 makeAllFilesPublicPrivate_(options?: MakeAllFilesPublicPrivateOptions): Promise<MakeAllFilesPublicPrivateResponse>;
814 makeAllFilesPublicPrivate_(callback: MakeAllFilesPublicPrivateCallback): void;
815 makeAllFilesPublicPrivate_(options: MakeAllFilesPublicPrivateOptions, callback: MakeAllFilesPublicPrivateCallback): void;
816 getId(): string;
817 disableAutoRetryConditionallyIdempotent_(coreOpts: any, methodType: AvailableServiceObjectMethods, localPreconditionOptions?: PreconditionOptions): void;
818}
819/**
820 * Reference to the {@link Bucket} class.
821 * @name module:@google-cloud/storage.Bucket
822 * @see Bucket
823 */
824export { Bucket };
825
\No newline at end of file