UNPKG

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