@ovh-api/common
Version:
Common class used to enable Ovh Api new calls Syntax
80 lines (79 loc) • 2.23 kB
TypeScript
/**
* all type that should be sent as parameter to Ovh calls
*/
export type OvhParamType = {
[key: string]: any;
};
/**
* Public interface of a silot
* you can have one silot per Ovh API call
*/
export interface ICacheSilot {
options: ICacheOptions;
flush(): Promise<void>;
store(path: string, value: any, size: number): Promise<boolean>;
get(path: string): Promise<any | undefined>;
discard(path: string): Promise<boolean>;
}
/**
* constructor for a silot cache
*/
export type SlotConstructor = new (template: string, options: ICacheOptions) => ICacheSilot;
/**
* params to configure cache
*/
export interface ICacheOptions {
/**
* Time to live in second
*/
ttl?: number;
/**
* max memmory used to store your cache
*/
size?: number;
/**
* max number of entry in your cache
*/
count?: number;
/**
* explicite silot construtor used to overwrite in memory default silotCache
*/
silotClass?: SlotConstructor;
}
/**
* 'flush' and 'disable' are the main action, other can be add later
*/
export type CacheAction = 'flush' | 'disable' | string;
/**
* common interface used to call ovh engine
*/
export interface OvhRequestable {
/**
* Execute a request on the API with promise
*
* @param httpMethod: The HTTP method GET POST PUT DELETE
* @param path: The request final path
* @param pathTemplate: The request path with {pathParams}
* @param params: The request parameters (passed as query string or body params)
*/
doRequest(httpMethod: string, path: string, pathTemplate: string, params?: any): Promise<any>;
/**
* Execute a request on the API with promise
*
* @param httpMethod: The HTTP method GET POST PUT DELETE
* @param path: The request path with {pathParams}
* @param params: The request parameters (passed as query string or body params)
* @deprecated
*/
/**
* cache controle
*/
cache(template: string, param: ICacheOptions | CacheAction): Promise<any>;
}
/**
* Build Ovh API 2.0 Proxy
*
* @param ovhEngine
* @param path
*/
export declare function buildOvhProxy(ovhEngine: OvhRequestable, path: string): any;