UNPKG

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