UNPKG

2.39 kBTypeScriptView Raw
1/**
2 * all type that should be sent as parameter to Ovh calls
3 */
4export type OvhParamType = {
5 [key: string]: any;
6};
7/**
8 * Public interface of a silot
9 * you can have one silot per Ovh API call
10 */
11export interface ICacheSilot {
12 options: ICacheOptions;
13 flush(): Promise<void>;
14 store(path: string, value: any, size: number): Promise<boolean>;
15 get(path: string): Promise<any | undefined>;
16 discard(path: string): Promise<boolean>;
17}
18/**
19 * constructor for a silot cache
20 */
21export type SlotConstructor = new (template: string, options: ICacheOptions) => ICacheSilot;
22/**
23 * params to configure cache
24 */
25export interface ICacheOptions {
26 /**
27 * Time to live in second
28 */
29 ttl?: number;
30 /**
31 * max memmory used to store your cache
32 */
33 size?: number;
34 /**
35 * max number of entry in your cache
36 */
37 count?: number;
38 /**
39 * explicite silot construtor used to overwrite in memory default silotCache
40 */
41 silotClass?: SlotConstructor;
42}
43/**
44 * 'flush' and 'disable' are the main action, other can be add later
45 */
46export type CacheAction = 'flush' | 'disable' | string;
47/**
48 * common interface used to call ovh engine
49 */
50export interface OvhRequestable {
51 /**
52 * Execute a request on the API with promise
53 *
54 * @param httpMethod: The HTTP method GET POST PUT DELETE
55 * @param path: The request final path
56 * @param pathTemplate: The request path with {pathParams}
57 * @param params: The request parameters (passed as query string or body params)
58 */
59 doRequest(httpMethod: string, path: string, pathTemplate: string, params?: any): Promise<any>;
60 /**
61 * Execute a request on the API with promise
62 *
63 * @param httpMethod: The HTTP method GET POST PUT DELETE
64 * @param path: The request path with {pathParams}
65 * @param params: The request parameters (passed as query string or body params)
66 * @deprecated
67 */
68 request(httpMethod: string, path: string, params?: OvhParamType): Promise<any>;
69 /**
70 * cache controle
71 */
72 cache(template: string, param: ICacheOptions | CacheAction): Promise<any>;
73}
74/**
75 * Build Ovh API 2.0 Proxy
76 *
77 * @param ovhEngine
78 * @param path
79 */
80export declare function buildOvhProxy(ovhEngine: OvhRequestable, path: string): any;