UNPKG

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