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