1 | /// <reference types="node" />
|
2 | import { ApiError, Metadata, Service, ServiceOptions } from './nodejs-common';
|
3 | import { Readable } from 'stream';
|
4 | import { Bucket } from './bucket';
|
5 | import { Channel } from './channel';
|
6 | import { File } from './file';
|
7 | import { HmacKey, HmacKeyMetadata, HmacKeyOptions } from './hmacKey';
|
8 | import { CRC32CValidatorGenerator } from './crc32c';
|
9 | export interface GetServiceAccountOptions {
|
10 | userProject?: string;
|
11 | }
|
12 | export interface ServiceAccount {
|
13 | emailAddress?: string;
|
14 | }
|
15 | export declare type GetServiceAccountResponse = [ServiceAccount, Metadata];
|
16 | export interface GetServiceAccountCallback {
|
17 | (err: Error | null, serviceAccount?: ServiceAccount, apiResponse?: Metadata): void;
|
18 | }
|
19 | export interface CreateBucketQuery {
|
20 | project: string;
|
21 | userProject: string;
|
22 | }
|
23 | export declare enum IdempotencyStrategy {
|
24 | RetryAlways = 0,
|
25 | RetryConditional = 1,
|
26 | RetryNever = 2
|
27 | }
|
28 | export interface RetryOptions {
|
29 | retryDelayMultiplier?: number;
|
30 | totalTimeout?: number;
|
31 | maxRetryDelay?: number;
|
32 | autoRetry?: boolean;
|
33 | maxRetries?: number;
|
34 | retryableErrorFn?: (err: ApiError) => boolean;
|
35 | idempotencyStrategy?: IdempotencyStrategy;
|
36 | }
|
37 | export interface PreconditionOptions {
|
38 | ifGenerationMatch?: number;
|
39 | ifGenerationNotMatch?: number;
|
40 | ifMetagenerationMatch?: number;
|
41 | ifMetagenerationNotMatch?: number;
|
42 | }
|
43 | export interface StorageOptions extends ServiceOptions {
|
44 | /**
|
45 | * The API endpoint of the service used to make requests.
|
46 | * Defaults to `storage.googleapis.com`.
|
47 | */
|
48 | apiEndpoint?: string;
|
49 | crc32cGenerator?: CRC32CValidatorGenerator;
|
50 | retryOptions?: RetryOptions;
|
51 | }
|
52 | export interface BucketOptions {
|
53 | crc32cGenerator?: CRC32CValidatorGenerator;
|
54 | kmsKeyName?: string;
|
55 | preconditionOpts?: PreconditionOptions;
|
56 | userProject?: string;
|
57 | }
|
58 | export interface Cors {
|
59 | maxAgeSeconds?: number;
|
60 | method?: string[];
|
61 | origin?: string[];
|
62 | responseHeader?: string[];
|
63 | }
|
64 | interface Versioning {
|
65 | enabled: boolean;
|
66 | }
|
67 | /**
|
68 | * Custom placement configuration.
|
69 | * Initially used for dual-region buckets.
|
70 | **/
|
71 | export interface CustomPlacementConfig {
|
72 | dataLocations?: string[];
|
73 | }
|
74 | export interface CreateBucketRequest {
|
75 | archive?: boolean;
|
76 | coldline?: boolean;
|
77 | cors?: Cors[];
|
78 | customPlacementConfig?: CustomPlacementConfig;
|
79 | dra?: boolean;
|
80 | location?: string;
|
81 | multiRegional?: boolean;
|
82 | nearline?: boolean;
|
83 | regional?: boolean;
|
84 | requesterPays?: boolean;
|
85 | retentionPolicy?: object;
|
86 | rpo?: string;
|
87 | standard?: boolean;
|
88 | storageClass?: string;
|
89 | userProject?: string;
|
90 | versioning?: Versioning;
|
91 | }
|
92 | export declare type CreateBucketResponse = [Bucket, Metadata];
|
93 | export interface BucketCallback {
|
94 | (err: Error | null, bucket?: Bucket | null, apiResponse?: Metadata): void;
|
95 | }
|
96 | export declare type GetBucketsResponse = [Bucket[], {}, Metadata];
|
97 | export interface GetBucketsCallback {
|
98 | (err: Error | null, buckets: Bucket[], nextQuery?: {}, apiResponse?: Metadata): void;
|
99 | }
|
100 | export interface GetBucketsRequest {
|
101 | prefix?: string;
|
102 | project?: string;
|
103 | autoPaginate?: boolean;
|
104 | maxApiCalls?: number;
|
105 | maxResults?: number;
|
106 | pageToken?: string;
|
107 | userProject?: string;
|
108 | }
|
109 | export interface HmacKeyResourceResponse {
|
110 | metadata: HmacKeyMetadata;
|
111 | secret: string;
|
112 | }
|
113 | export declare type CreateHmacKeyResponse = [HmacKey, string, HmacKeyResourceResponse];
|
114 | export interface CreateHmacKeyOptions {
|
115 | projectId?: string;
|
116 | userProject?: string;
|
117 | }
|
118 | export interface CreateHmacKeyCallback {
|
119 | (err: Error | null, hmacKey?: HmacKey | null, secret?: string | null, apiResponse?: HmacKeyResourceResponse): void;
|
120 | }
|
121 | export interface GetHmacKeysOptions {
|
122 | projectId?: string;
|
123 | serviceAccountEmail?: string;
|
124 | showDeletedKeys?: boolean;
|
125 | autoPaginate?: boolean;
|
126 | maxApiCalls?: number;
|
127 | maxResults?: number;
|
128 | pageToken?: string;
|
129 | userProject?: string;
|
130 | }
|
131 | export interface GetHmacKeysCallback {
|
132 | (err: Error | null, hmacKeys: HmacKey[] | null, nextQuery?: {}, apiResponse?: Metadata): void;
|
133 | }
|
134 | export declare enum ExceptionMessages {
|
135 | EXPIRATION_DATE_INVALID = "The expiration date provided was invalid.",
|
136 | EXPIRATION_DATE_PAST = "An expiration date cannot be in the past.",
|
137 | INVALID_ACTION = "The action is not provided or invalid."
|
138 | }
|
139 | export declare enum StorageExceptionMessages {
|
140 | BUCKET_NAME_REQUIRED = "A bucket name is needed to use Cloud Storage.",
|
141 | BUCKET_NAME_REQUIRED_CREATE = "A name is required to create a bucket.",
|
142 | HMAC_SERVICE_ACCOUNT = "The first argument must be a service account email to create an HMAC key.",
|
143 | HMAC_ACCESS_ID = "An access ID is needed to create an HmacKey object."
|
144 | }
|
145 | export declare type GetHmacKeysResponse = [HmacKey[]];
|
146 | export declare const PROTOCOL_REGEX: RegExp;
|
147 | /**
|
148 | * Default behavior: Automatically retry retriable server errors.
|
149 | *
|
150 | * @const {boolean}
|
151 | */
|
152 | export declare const AUTO_RETRY_DEFAULT = true;
|
153 | /**
|
154 | * Default behavior: Only attempt to retry retriable errors 3 times.
|
155 | *
|
156 | * @const {number}
|
157 | */
|
158 | export declare const MAX_RETRY_DEFAULT = 3;
|
159 | /**
|
160 | * Default behavior: Wait twice as long as previous retry before retrying.
|
161 | *
|
162 | * @const {number}
|
163 | */
|
164 | export declare const RETRY_DELAY_MULTIPLIER_DEFAULT = 2;
|
165 | /**
|
166 | * Default behavior: If the operation doesn't succeed after 600 seconds,
|
167 | * stop retrying.
|
168 | *
|
169 | * @const {number}
|
170 | */
|
171 | export declare const TOTAL_TIMEOUT_DEFAULT = 600;
|
172 | /**
|
173 | * Default behavior: Wait no more than 64 seconds between retries.
|
174 | *
|
175 | * @const {number}
|
176 | */
|
177 | export declare const MAX_RETRY_DELAY_DEFAULT = 64;
|
178 | /**
|
179 | * Returns true if the API request should be retried, given the error that was
|
180 | * given the first time the request was attempted.
|
181 | * @const
|
182 | * @param {error} err - The API error to check if it is appropriate to retry.
|
183 | * @return {boolean} True if the API request should be retried, false otherwise.
|
184 | */
|
185 | export declare const RETRYABLE_ERR_FN_DEFAULT: (err?: ApiError) => boolean;
|
186 | /*! Developer Documentation
|
187 | *
|
188 | * Invoke this method to create a new Storage object bound with pre-determined
|
189 | * configuration options. For each object that can be created (e.g., a bucket),
|
190 | * there is an equivalent static and instance method. While they are classes,
|
191 | * they can be instantiated without use of the `new` keyword.
|
192 | */
|
193 | /**
|
194 | * Cloud Storage uses access control lists (ACLs) to manage object and
|
195 | * bucket access. ACLs are the mechanism you use to share objects with other
|
196 | * users and allow other users to access your buckets and objects.
|
197 | *
|
198 | * This object provides constants to refer to the three permission levels that
|
199 | * can be granted to an entity:
|
200 | *
|
201 | * - `gcs.acl.OWNER_ROLE` - ("OWNER")
|
202 | * - `gcs.acl.READER_ROLE` - ("READER")
|
203 | * - `gcs.acl.WRITER_ROLE` - ("WRITER")
|
204 | *
|
205 | * See {@link https://cloud.google.com/storage/docs/access-control/lists| About Access Control Lists}
|
206 | *
|
207 | * @name Storage#acl
|
208 | * @type {object}
|
209 | * @property {string} OWNER_ROLE
|
210 | * @property {string} READER_ROLE
|
211 | * @property {string} WRITER_ROLE
|
212 | *
|
213 | * @example
|
214 | * ```
|
215 | * const {Storage} = require('@google-cloud/storage');
|
216 | * const storage = new Storage();
|
217 | * const albums = storage.bucket('albums');
|
218 | *
|
219 | * //-
|
220 | * // Make all of the files currently in a bucket publicly readable.
|
221 | * //-
|
222 | * const options = {
|
223 | * entity: 'allUsers',
|
224 | * role: storage.acl.READER_ROLE
|
225 | * };
|
226 | *
|
227 | * albums.acl.add(options, function(err, aclObject) {});
|
228 | *
|
229 | * //-
|
230 | * // Make any new objects added to a bucket publicly readable.
|
231 | * //-
|
232 | * albums.acl.default.add(options, function(err, aclObject) {});
|
233 | *
|
234 | * //-
|
235 | * // Grant a user ownership permissions to a bucket.
|
236 | * //-
|
237 | * albums.acl.add({
|
238 | * entity: 'user-useremail@example.com',
|
239 | * role: storage.acl.OWNER_ROLE
|
240 | * }, function(err, aclObject) {});
|
241 | *
|
242 | * //-
|
243 | * // If the callback is omitted, we'll return a Promise.
|
244 | * //-
|
245 | * albums.acl.add(options).then(function(data) {
|
246 | * const aclObject = data[0];
|
247 | * const apiResponse = data[1];
|
248 | * });
|
249 | * ```
|
250 | */
|
251 | /**
|
252 | * Get {@link Bucket} objects for all of the buckets in your project as
|
253 | * a readable object stream.
|
254 | *
|
255 | * @method Storage#getBucketsStream
|
256 | * @param {GetBucketsRequest} [query] Query object for listing buckets.
|
257 | * @returns {ReadableStream} A readable stream that emits {@link Bucket}
|
258 | * instances.
|
259 | *
|
260 | * @example
|
261 | * ```
|
262 | * storage.getBucketsStream()
|
263 | * .on('error', console.error)
|
264 | * .on('data', function(bucket) {
|
265 | * // bucket is a Bucket object.
|
266 | * })
|
267 | * .on('end', function() {
|
268 | * // All buckets retrieved.
|
269 | * });
|
270 | *
|
271 | * //-
|
272 | * // If you anticipate many results, you can end a stream early to prevent
|
273 | * // unnecessary processing and API requests.
|
274 | * //-
|
275 | * storage.getBucketsStream()
|
276 | * .on('data', function(bucket) {
|
277 | * this.end();
|
278 | * });
|
279 | * ```
|
280 | */
|
281 | /**
|
282 | * Get {@link HmacKey} objects for all of the HMAC keys in the project in a
|
283 | * readable object stream.
|
284 | *
|
285 | * @method Storage#getHmacKeysStream
|
286 | * @param {GetHmacKeysOptions} [options] Configuration options.
|
287 | * @returns {ReadableStream} A readable stream that emits {@link HmacKey}
|
288 | * instances.
|
289 | *
|
290 | * @example
|
291 | * ```
|
292 | * storage.getHmacKeysStream()
|
293 | * .on('error', console.error)
|
294 | * .on('data', function(hmacKey) {
|
295 | * // hmacKey is an HmacKey object.
|
296 | * })
|
297 | * .on('end', function() {
|
298 | * // All HmacKey retrieved.
|
299 | * });
|
300 | *
|
301 | * //-
|
302 | * // If you anticipate many results, you can end a stream early to prevent
|
303 | * // unnecessary processing and API requests.
|
304 | * //-
|
305 | * storage.getHmacKeysStream()
|
306 | * .on('data', function(bucket) {
|
307 | * this.end();
|
308 | * });
|
309 | * ```
|
310 | */
|
311 | /**
|
312 | * <h4>ACLs</h4>
|
313 | * Cloud Storage uses access control lists (ACLs) to manage object and
|
314 | * bucket access. ACLs are the mechanism you use to share files with other users
|
315 | * and allow other users to access your buckets and files.
|
316 | *
|
317 | * To learn more about ACLs, read this overview on
|
318 | * {@link https://cloud.google.com/storage/docs/access-control| Access Control}.
|
319 | *
|
320 | * See {@link https://cloud.google.com/storage/docs/overview| Cloud Storage overview}
|
321 | * See {@link https://cloud.google.com/storage/docs/access-control| Access Control}
|
322 | *
|
323 | * @class
|
324 | */
|
325 | export declare class Storage extends Service {
|
326 | /**
|
327 | * {@link Bucket} class.
|
328 | *
|
329 | * @name Storage.Bucket
|
330 | * @see Bucket
|
331 | * @type {Constructor}
|
332 | */
|
333 | static Bucket: typeof Bucket;
|
334 | /**
|
335 | * {@link Channel} class.
|
336 | *
|
337 | * @name Storage.Channel
|
338 | * @see Channel
|
339 | * @type {Constructor}
|
340 | */
|
341 | static Channel: typeof Channel;
|
342 | /**
|
343 | * {@link File} class.
|
344 | *
|
345 | * @name Storage.File
|
346 | * @see File
|
347 | * @type {Constructor}
|
348 | */
|
349 | static File: typeof File;
|
350 | /**
|
351 | * {@link HmacKey} class.
|
352 | *
|
353 | * @name Storage.HmacKey
|
354 | * @see HmacKey
|
355 | * @type {Constructor}
|
356 | */
|
357 | static HmacKey: typeof HmacKey;
|
358 | static acl: {
|
359 | OWNER_ROLE: string;
|
360 | READER_ROLE: string;
|
361 | WRITER_ROLE: string;
|
362 | };
|
363 | /**
|
364 | * Reference to {@link Storage.acl}.
|
365 | *
|
366 | * @name Storage#acl
|
367 | * @see Storage.acl
|
368 | */
|
369 | acl: typeof Storage.acl;
|
370 | crc32cGenerator: CRC32CValidatorGenerator;
|
371 | getBucketsStream(): Readable;
|
372 | getHmacKeysStream(): Readable;
|
373 | retryOptions: RetryOptions;
|
374 | /**
|
375 | * @callback Crc32cGeneratorToStringCallback
|
376 | * A method returning the CRC32C as a base64-encoded string.
|
377 | *
|
378 | * @returns {string}
|
379 | *
|
380 | * @example
|
381 | * Hashing the string 'data' should return 'rth90Q=='
|
382 | *
|
383 | * ```js
|
384 | * const buffer = Buffer.from('data');
|
385 | * crc32c.update(buffer);
|
386 | * crc32c.toString(); // 'rth90Q=='
|
387 | * ```
|
388 | **/
|
389 | /**
|
390 | * @callback Crc32cGeneratorValidateCallback
|
391 | * A method validating a base64-encoded CRC32C string.
|
392 | *
|
393 | * @param {string} [value] base64-encoded CRC32C string to validate
|
394 | * @returns {boolean}
|
395 | *
|
396 | * @example
|
397 | * Should return `true` if the value matches, `false` otherwise
|
398 | *
|
399 | * ```js
|
400 | * const buffer = Buffer.from('data');
|
401 | * crc32c.update(buffer);
|
402 | * crc32c.validate('DkjKuA=='); // false
|
403 | * crc32c.validate('rth90Q=='); // true
|
404 | * ```
|
405 | **/
|
406 | /**
|
407 | * @callback Crc32cGeneratorUpdateCallback
|
408 | * A method for passing `Buffer`s for CRC32C generation.
|
409 | *
|
410 | * @param {Buffer} [data] data to update CRC32C value with
|
411 | * @returns {undefined}
|
412 | *
|
413 | * @example
|
414 | * Hashing buffers from 'some ' and 'text\n'
|
415 | *
|
416 | * ```js
|
417 | * const buffer1 = Buffer.from('some ');
|
418 | * crc32c.update(buffer1);
|
419 | *
|
420 | * const buffer2 = Buffer.from('text\n');
|
421 | * crc32c.update(buffer2);
|
422 | *
|
423 | * crc32c.toString(); // 'DkjKuA=='
|
424 | * ```
|
425 | **/
|
426 | /**
|
427 | * @typedef {object} CRC32CValidator
|
428 | * @property {Crc32cGeneratorToStringCallback}
|
429 | * @property {Crc32cGeneratorValidateCallback}
|
430 | * @property {Crc32cGeneratorUpdateCallback}
|
431 | */
|
432 | /**
|
433 | * @callback Crc32cGeneratorCallback
|
434 | * @returns {CRC32CValidator}
|
435 | */
|
436 | /**
|
437 | * @typedef {object} StorageOptions
|
438 | * @property {string} [projectId] The project ID from the Google Developer's
|
439 | * Console, e.g. 'grape-spaceship-123'. We will also check the environment
|
440 | * variable `GCLOUD_PROJECT` for your project ID. If your app is running
|
441 | * in an environment which supports {@link
|
442 | * https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application
|
443 | * Application Default Credentials}, your project ID will be detected
|
444 | * automatically.
|
445 | * @property {string} [keyFilename] Full path to the a .json, .pem, or .p12 key
|
446 | * downloaded from the Google Developers Console. If you provide a path to
|
447 | * a JSON file, the `projectId` option above is not necessary. NOTE: .pem and
|
448 | * .p12 require you to specify the `email` option as well.
|
449 | * @property {string} [email] Account email address. Required when using a .pem
|
450 | * or .p12 keyFilename.
|
451 | * @property {object} [credentials] Credentials object.
|
452 | * @property {string} [credentials.client_email]
|
453 | * @property {string} [credentials.private_key]
|
454 | * @property {object} [retryOptions] Options for customizing retries. Retriable server errors
|
455 | * will be retried with exponential delay between them dictated by the formula
|
456 | * max(maxRetryDelay, retryDelayMultiplier*retryNumber) until maxRetries or totalTimeout
|
457 | * has been reached. Retries will only happen if autoRetry is set to true.
|
458 | * @property {boolean} [retryOptions.autoRetry=true] Automatically retry requests if the
|
459 | * response is related to rate limits or certain intermittent server
|
460 | * errors. We will exponentially backoff subsequent requests by default.
|
461 | * @property {number} [retryOptions.retryDelayMultiplier = 2] the multiplier by which to
|
462 | * increase the delay time between the completion of failed requests, and the
|
463 | * initiation of the subsequent retrying request.
|
464 | * @property {number} [retryOptions.totalTimeout = 600] The total time, starting from
|
465 | * when the initial request is sent, after which an error will
|
466 | * be returned, regardless of the retrying attempts made meanwhile.
|
467 | * @property {number} [retryOptions.maxRetryDelay = 64] The maximum delay time between requests.
|
468 | * When this value is reached, ``retryDelayMultiplier`` will no longer be used to
|
469 | * increase delay time.
|
470 | * @property {number} [retryOptions.maxRetries=3] Maximum number of automatic retries
|
471 | * attempted before returning the error.
|
472 | * @property {function} [retryOptions.retryableErrorFn] Function that returns true if a given
|
473 | * error should be retried and false otherwise.
|
474 | * @property {enum} [retryOptions.idempotencyStrategy=IdempotencyStrategy.RetryConditional] Enumeration
|
475 | * controls how conditionally idempotent operations are retried. Possible values are: RetryAlways -
|
476 | * will respect other retry settings and attempt to retry conditionally idempotent operations. RetryConditional -
|
477 | * will retry conditionally idempotent operations if the correct preconditions are set. RetryNever - never
|
478 | * retry a conditionally idempotent operation.
|
479 | * @property {string} [userAgent] The value to be prepended to the User-Agent
|
480 | * header in API requests.
|
481 | * @property {object} [authClient] `AuthClient` or `GoogleAuth` client to reuse instead of creating a new one.
|
482 | * @property {number} [timeout] The amount of time in milliseconds to wait per http request before timing out.
|
483 | * @property {object[]} [interceptors_] Array of custom request interceptors to be returned in the order they were assigned.
|
484 | * @property {string} [apiEndpoint = storage.google.com] The API endpoint of the service used to make requests.
|
485 | * @property {boolean} [useAuthWithCustomEndpoint = false] Controls whether or not to use authentication when using a custom endpoint.
|
486 | * @property {Crc32cGeneratorCallback} [callback] A function that generates a CRC32C Validator. Defaults to {@link CRC32C}
|
487 | */
|
488 | /**
|
489 | * Constructs the Storage client.
|
490 | *
|
491 | * @example
|
492 | * Create a client that uses Application Default Credentials
|
493 | * (ADC)
|
494 | * ```
|
495 | * const {Storage} = require('@google-cloud/storage');
|
496 | * const storage = new Storage();
|
497 | * ```
|
498 | *
|
499 | * @example
|
500 | * Create a client with explicit credentials
|
501 | * ```
|
502 | * const storage = new Storage({
|
503 | * projectId: 'your-project-id',
|
504 | * keyFilename: '/path/to/keyfile.json'
|
505 | * });
|
506 | * ```
|
507 | *
|
508 | * @example
|
509 | * Create a client with an `AuthClient` (e.g. `DownscopedClient`)
|
510 | * ```
|
511 | * const {DownscopedClient} = require('google-auth-library');
|
512 | * const authClient = new DownscopedClient({...});
|
513 | *
|
514 | * const storage = new Storage({authClient});
|
515 | * ```
|
516 | *
|
517 | * Additional samples:
|
518 | * - https://github.com/googleapis/google-auth-library-nodejs#sample-usage-1
|
519 | * - https://github.com/googleapis/google-auth-library-nodejs/blob/main/samples/downscopedclient.js
|
520 | *
|
521 | * @param {StorageOptions} [options] Configuration options.
|
522 | */
|
523 | constructor(options?: StorageOptions);
|
524 | private static sanitizeEndpoint;
|
525 | /**
|
526 | * Get a reference to a Cloud Storage bucket.
|
527 | *
|
528 | * @param {string} name Name of the bucket.
|
529 | * {object} [options] Configuration object.
|
530 | * string} [options.kmsKeyName] A Cloud KMS key that will be used to
{ |
531 | * encrypt objects inserted into this bucket, if no encryption method is
|
532 | * specified.
|
533 | * string} [options.userProject] User project to be billed for all
{ |
534 | * requests made from this Bucket object.
|
535 | * {Bucket}
|
536 | * Bucket
|
537 | *
|
538 | *
|
539 | * ```
|
540 | * const {Storage} = require('@google-cloud/storage');
|
541 | * const storage = new Storage();
|
542 | * const albums = storage.bucket('albums');
|
543 | * const photos = storage.bucket('photos');
|
544 | * ```
|
545 | */
|
546 | bucket(name: string, options?: BucketOptions): Bucket;
|
547 | /**
|
548 | * Reference a channel to receive notifications about changes to your bucket.
|
549 | *
|
550 | * @param {string} id The ID of the channel.
|
551 | * @param {string} resourceId The resource ID of the channel.
|
552 | * @returns {Channel}
|
553 | * @see Channel
|
554 | *
|
555 | * @example
|
556 | * ```
|
557 | * const {Storage} = require('@google-cloud/storage');
|
558 | * const storage = new Storage();
|
559 | * const channel = storage.channel('id', 'resource-id');
|
560 | * ```
|
561 | */
|
562 | channel(id: string, resourceId: string): Channel;
|
563 | createBucket(name: string, metadata?: CreateBucketRequest): Promise<CreateBucketResponse>;
|
564 | createBucket(name: string, callback: BucketCallback): void;
|
565 | createBucket(name: string, metadata: CreateBucketRequest, callback: BucketCallback): void;
|
566 | createBucket(name: string, metadata: CreateBucketRequest, callback: BucketCallback): void;
|
567 | createHmacKey(serviceAccountEmail: string, options?: CreateHmacKeyOptions): Promise<CreateHmacKeyResponse>;
|
568 | createHmacKey(serviceAccountEmail: string, callback: CreateHmacKeyCallback): void;
|
569 | createHmacKey(serviceAccountEmail: string, options: CreateHmacKeyOptions, callback: CreateHmacKeyCallback): void;
|
570 | getBuckets(options?: GetBucketsRequest): Promise<GetBucketsResponse>;
|
571 | getBuckets(options: GetBucketsRequest, callback: GetBucketsCallback): void;
|
572 | getBuckets(callback: GetBucketsCallback): void;
|
573 | /**
|
574 | * Query object for listing HMAC keys.
|
575 | *
|
576 | * @typedef {object} GetHmacKeysOptions
|
577 | * @property {string} [projectId] The project ID of the project that owns
|
578 | * the service account of the requested HMAC key. If not provided,
|
579 | * the project ID used to instantiate the Storage client will be used.
|
580 | * @property {string} [serviceAccountEmail] If present, only HMAC keys for the
|
581 | * given service account are returned.
|
582 | * @property {boolean} [showDeletedKeys=false] If true, include keys in the DELETE
|
583 | * state. Default is false.
|
584 | * @property {boolean} [autoPaginate=true] Have pagination handled
|
585 | * automatically.
|
586 | * @property {number} [maxApiCalls] Maximum number of API calls to make.
|
587 | * @property {number} [maxResults] Maximum number of items plus prefixes to
|
588 | * return per call.
|
589 | * Note: By default will handle pagination automatically
|
590 | * if more than 1 page worth of results are requested per call.
|
591 | * When `autoPaginate` is set to `false` the smaller of `maxResults`
|
592 | * or 1 page of results will be returned per call.
|
593 | * @property {string} [pageToken] A previously-returned page token
|
594 | * representing part of the larger set of results to view.
|
595 | * @property {string} [userProject] This parameter is currently ignored.
|
596 | */
|
597 | /**
|
598 | * @typedef {array} GetHmacKeysResponse
|
599 | * @property {HmacKey[]} 0 Array of {@link HmacKey} instances.
|
600 | * @param {object} nextQuery 1 A query object to receive more results.
|
601 | * @param {object} apiResponse 2 The full API response.
|
602 | */
|
603 | /**
|
604 | * @callback GetHmacKeysCallback
|
605 | * @param {?Error} err Request error, if any.
|
606 | * @param {HmacKey[]} hmacKeys Array of {@link HmacKey} instances.
|
607 | * @param {object} nextQuery A query object to receive more results.
|
608 | * @param {object} apiResponse The full API response.
|
609 | */
|
610 | /**
|
611 | * Retrieves a list of HMAC keys matching the criteria.
|
612 | *
|
613 | * The authenticated user must have storage.hmacKeys.list permission for the project in which the key exists.
|
614 | *
|
615 | * @param {GetHmacKeysOption} options Configuration options.
|
616 | * @param {GetHmacKeysCallback} callback Callback function.
|
617 | * @return {Promise<GetHmacKeysResponse>}
|
618 | *
|
619 | * @example
|
620 | * ```
|
621 | * const {Storage} = require('@google-cloud/storage');
|
622 | * const storage = new Storage();
|
623 | * storage.getHmacKeys(function(err, hmacKeys) {
|
624 | * if (!err) {
|
625 | * // hmacKeys is an array of HmacKey objects.
|
626 | * }
|
627 | * });
|
628 | *
|
629 | * //-
|
630 | * // To control how many API requests are made and page through the results
|
631 | * // manually, set `autoPaginate` to `false`.
|
632 | * //-
|
633 | * const callback = function(err, hmacKeys, nextQuery, apiResponse) {
|
634 | * if (nextQuery) {
|
635 | * // More results exist.
|
636 | * storage.getHmacKeys(nextQuery, callback);
|
637 | * }
|
638 | *
|
639 | * // The `metadata` property is populated for you with the metadata at the
|
640 | * // time of fetching.
|
641 | * hmacKeys[0].metadata;
|
642 | * };
|
643 | *
|
644 | * storage.getHmacKeys({
|
645 | * autoPaginate: false
|
646 | * }, callback);
|
647 | *
|
648 | * //-
|
649 | * // If the callback is omitted, we'll return a Promise.
|
650 | * //-
|
651 | * storage.getHmacKeys().then(function(data) {
|
652 | * const hmacKeys = data[0];
|
653 | * });
|
654 | * ```
|
655 | */
|
656 | getHmacKeys(options?: GetHmacKeysOptions): Promise<GetHmacKeysResponse>;
|
657 | getHmacKeys(callback: GetHmacKeysCallback): void;
|
658 | getHmacKeys(options: GetHmacKeysOptions, callback: GetHmacKeysCallback): void;
|
659 | getServiceAccount(options?: GetServiceAccountOptions): Promise<GetServiceAccountResponse>;
|
660 | getServiceAccount(options?: GetServiceAccountOptions): Promise<GetServiceAccountResponse>;
|
661 | getServiceAccount(options: GetServiceAccountOptions, callback: GetServiceAccountCallback): void;
|
662 | getServiceAccount(callback: GetServiceAccountCallback): void;
|
663 | /**
|
664 | * Get a reference to an HmacKey object.
|
665 | * Note: this does not fetch the HMAC key's metadata. Use HmacKey#get() to
|
666 | * retrieve and populate the metadata.
|
667 | *
|
668 | * To get a reference to an HMAC key that's not created for a service
|
669 | * account in the same project used to instantiate the Storage client,
|
670 | * supply the project's ID as `projectId` in the `options` argument.
|
671 | *
|
672 | * @param {string} accessId The HMAC key's access ID.
|
673 | * @param {HmacKeyOptions} options HmacKey constructor options.
|
674 | * @returns {HmacKey}
|
675 | * @see HmacKey
|
676 | *
|
677 | * @example
|
678 | * ```
|
679 | * const {Storage} = require('@google-cloud/storage');
|
680 | * const storage = new Storage();
|
681 | * const hmacKey = storage.hmacKey('ACCESS_ID');
|
682 | * ```
|
683 | */
|
684 | hmacKey(accessId: string, options?: HmacKeyOptions): HmacKey;
|
685 | }
|
686 | export {};
|