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