UNPKG

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