UNPKG

2.43 kBTypeScriptView Raw
1import { Metadata, ServiceObject } from '@google-cloud/common';
2import { Storage } from './storage';
3export interface HmacKeyOptions {
4 projectId?: string;
5}
6export interface HmacKeyMetadata {
7 accessId: string;
8 etag?: string;
9 id?: 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?: Metadata): void;
28}
29export declare type HmacKeyMetadataResponse = [HmacKeyMetadata, Metadata];
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 [HMAC keys documentation]{@link https://cloud.google.com/storage/docs/authentication/hmackeys}
45 *
46 * @class
47 */
48export declare class HmacKey extends ServiceObject<HmacKeyMetadata | undefined> {
49 metadata: HmacKeyMetadata | undefined;
50 /**
51 * @typedef {object} HmacKeyOptions
52 * @property {string} [projectId] The project ID of the project that owns
53 * the service account of the requested HMAC key. If not provided,
54 * the project ID used to instantiate the Storage client will be used.
55 */
56 /**
57 * Constructs an HmacKey object.
58 *
59 * Note: this only create a local reference to an HMAC key, to create
60 * an HMAC key, use {@link Storage#createHmacKey}.
61 *
62 * @param {Storage} storage The Storage instance this HMAC key is
63 * attached to.
64 * @param {string} accessId The unique accessId for this HMAC key.
65 * @param {HmacKeyOptions} options Constructor configurations.
66 * @example
67 * const {Storage} = require('@google-cloud/storage');
68 * const storage = new Storage();
69 * const hmacKey = storage.hmacKey('access-id');
70 */
71 constructor(storage: Storage, accessId: string, options?: HmacKeyOptions);
72}