UNPKG

3.49 kBTypeScriptView Raw
1import { ServiceObject, MetadataCallback, SetMetadataResponse } from './nodejs-common/index.js';
2import { BaseMetadata, SetMetadataOptions } from './nodejs-common/service-object.js';
3import { Storage } from './storage.js';
4export interface HmacKeyOptions {
5 projectId?: string;
6}
7export interface HmacKeyMetadata extends BaseMetadata {
8 accessId?: string;
9 etag?: string;
10 projectId?: string;
11 serviceAccountEmail?: string;
12 state?: string;
13 timeCreated?: string;
14 updated?: string;
15}
16export interface SetHmacKeyMetadataOptions {
17 /**
18 * This parameter is currently ignored.
19 */
20 userProject?: string;
21}
22export interface SetHmacKeyMetadata {
23 state?: 'ACTIVE' | 'INACTIVE';
24 etag?: string;
25}
26export interface HmacKeyMetadataCallback {
27 (err: Error | null, metadata?: HmacKeyMetadata, apiResponse?: unknown): void;
28}
29export type HmacKeyMetadataResponse = [HmacKeyMetadata, unknown];
30/**
31 * The API-formatted resource description of the HMAC key.
32 *
33 * Note: This is not guaranteed to be up-to-date when accessed. To get the
34 * latest record, call the `getMetadata()` method.
35 *
36 * @name HmacKey#metadata
37 * @type {object}
38 */
39/**
40 * An HmacKey object contains metadata of an HMAC key created from a
41 * service account through the {@link Storage} client using
42 * {@link Storage#createHmacKey}.
43 *
44 * See {@link https://cloud.google.com/storage/docs/authentication/hmackeys| HMAC keys documentation}
45 *
46 * @class
47 */
48export declare class HmacKey extends ServiceObject<HmacKey, HmacKeyMetadata> {
49 /**
50 * A reference to the {@link Storage} associated with this {@link HmacKey}
51 * instance.
52 * @name HmacKey#storage
53 * @type {Storage}
54 */
55 storage: Storage;
56 private instanceRetryValue?;
57 /**
58 * @typedef {object} HmacKeyOptions
59 * @property {string} [projectId] The project ID of the project that owns
60 * the service account of the requested HMAC key. If not provided,
61 * the project ID used to instantiate the Storage client will be used.
62 */
63 /**
64 * Constructs an HmacKey object.
65 *
66 * Note: this only create a local reference to an HMAC key, to create
67 * an HMAC key, use {@link Storage#createHmacKey}.
68 *
69 * @param {Storage} storage The Storage instance this HMAC key is
70 * attached to.
71 * @param {string} accessId The unique accessId for this HMAC key.
72 * @param {HmacKeyOptions} options Constructor configurations.
73 * @example
74 * ```
75 * const {Storage} = require('@google-cloud/storage');
76 * const storage = new Storage();
77 * const hmacKey = storage.hmacKey('access-id');
78 * ```
79 */
80 constructor(storage: Storage, accessId: string, options?: HmacKeyOptions);
81 /**
82 * Set the metadata for this object.
83 *
84 * @param {object} metadata - The metadata to set on this object.
85 * @param {object=} options - Configuration options.
86 * @param {function=} callback - The callback function.
87 * @param {?error} callback.err - An error returned while making this request.
88 * @param {object} callback.apiResponse - The full API response.
89 */
90 setMetadata(metadata: HmacKeyMetadata, options?: SetMetadataOptions): Promise<SetMetadataResponse<HmacKeyMetadata>>;
91 setMetadata(metadata: HmacKeyMetadata, callback: MetadataCallback<HmacKeyMetadata>): void;
92 setMetadata(metadata: HmacKeyMetadata, options: SetMetadataOptions, callback: MetadataCallback<HmacKeyMetadata>): void;
93}