UNPKG

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