@nirvana-labs/nirvana 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -0
- package/LICENSE +201 -0
- package/README.md +371 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +241 -0
- package/core.d.ts.map +1 -0
- package/core.js +908 -0
- package/core.js.map +1 -0
- package/core.mjs +876 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +47 -0
- package/error.d.ts.map +1 -0
- package/error.js +113 -0
- package/error.js.map +1 -0
- package/error.mjs +97 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +118 -0
- package/index.d.ts +118 -0
- package/index.d.ts.map +1 -0
- package/index.js +128 -0
- package/index.js.map +1 -0
- package/index.mjs +85 -0
- package/index.mjs.map +1 -0
- package/package.json +103 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/compute/compute.d.ts +14 -0
- package/resources/compute/compute.d.ts.map +1 -0
- package/resources/compute/compute.js +43 -0
- package/resources/compute/compute.js.map +1 -0
- package/resources/compute/compute.mjs +16 -0
- package/resources/compute/compute.mjs.map +1 -0
- package/resources/compute/index.d.ts +4 -0
- package/resources/compute/index.d.ts.map +1 -0
- package/resources/compute/index.js +11 -0
- package/resources/compute/index.js.map +1 -0
- package/resources/compute/index.mjs +5 -0
- package/resources/compute/index.mjs.map +1 -0
- package/resources/compute/vms/index.d.ts +3 -0
- package/resources/compute/vms/index.d.ts.map +1 -0
- package/resources/compute/vms/index.js +9 -0
- package/resources/compute/vms/index.js.map +1 -0
- package/resources/compute/vms/index.mjs +4 -0
- package/resources/compute/vms/index.mjs.map +1 -0
- package/resources/compute/vms/os-images.d.ts +14 -0
- package/resources/compute/vms/os-images.d.ts.map +1 -0
- package/resources/compute/vms/os-images.js +15 -0
- package/resources/compute/vms/os-images.js.map +1 -0
- package/resources/compute/vms/os-images.mjs +11 -0
- package/resources/compute/vms/os-images.mjs.map +1 -0
- package/resources/compute/vms/vms.d.ts +164 -0
- package/resources/compute/vms/vms.d.ts.map +1 -0
- package/resources/compute/vms/vms.js +69 -0
- package/resources/compute/vms/vms.js.map +1 -0
- package/resources/compute/vms/vms.mjs +42 -0
- package/resources/compute/vms/vms.mjs.map +1 -0
- package/resources/compute/volumes.d.ts +72 -0
- package/resources/compute/volumes.d.ts.map +1 -0
- package/resources/compute/volumes.js +39 -0
- package/resources/compute/volumes.js.map +1 -0
- package/resources/compute/volumes.mjs +35 -0
- package/resources/compute/volumes.mjs.map +1 -0
- package/resources/index.d.ts +5 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +26 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +6 -0
- package/resources/index.mjs.map +1 -0
- package/resources/networking/firewall-rules.d.ts +90 -0
- package/resources/networking/firewall-rules.d.ts.map +1 -0
- package/resources/networking/firewall-rules.js +42 -0
- package/resources/networking/firewall-rules.js.map +1 -0
- package/resources/networking/firewall-rules.mjs +38 -0
- package/resources/networking/firewall-rules.mjs.map +1 -0
- package/resources/networking/index.d.ts +4 -0
- package/resources/networking/index.d.ts.map +1 -0
- package/resources/networking/index.js +11 -0
- package/resources/networking/index.js.map +1 -0
- package/resources/networking/index.mjs +5 -0
- package/resources/networking/index.mjs.map +1 -0
- package/resources/networking/networking.d.ts +14 -0
- package/resources/networking/networking.d.ts.map +1 -0
- package/resources/networking/networking.js +43 -0
- package/resources/networking/networking.js.map +1 -0
- package/resources/networking/networking.mjs +16 -0
- package/resources/networking/networking.mjs.map +1 -0
- package/resources/networking/vpcs.d.ts +60 -0
- package/resources/networking/vpcs.d.ts.map +1 -0
- package/resources/networking/vpcs.js +33 -0
- package/resources/networking/vpcs.js.map +1 -0
- package/resources/networking/vpcs.mjs +29 -0
- package/resources/networking/vpcs.mjs.map +1 -0
- package/resources/operations.d.ts +26 -0
- package/resources/operations.d.ts.map +1 -0
- package/resources/operations.js +21 -0
- package/resources/operations.js.map +1 -0
- package/resources/operations.mjs +17 -0
- package/resources/operations.mjs.map +1 -0
- package/resources/shared.d.ts +3 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1201 -0
- package/src/error.ts +130 -0
- package/src/index.ts +198 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +11 -0
- package/src/resources/compute/compute.ts +49 -0
- package/src/resources/compute/index.ts +24 -0
- package/src/resources/compute/vms/index.ts +14 -0
- package/src/resources/compute/vms/os-images.ts +20 -0
- package/src/resources/compute/vms/vms.ts +239 -0
- package/src/resources/compute/volumes.ts +120 -0
- package/src/resources/index.ts +6 -0
- package/src/resources/networking/firewall-rules.ts +149 -0
- package/src/resources/networking/index.ts +12 -0
- package/src/resources/networking/networking.ts +41 -0
- package/src/resources/networking/vpcs.ts +96 -0
- package/src/resources/operations.ts +41 -0
- package/src/resources/shared.ts +22 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +255 -0
- package/src/version.ts +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +171 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +158 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
package/src/error.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { castToError, Headers } from './core';
|
|
4
|
+
|
|
5
|
+
export class NirvanaLabsError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class APIError<
|
|
8
|
+
TStatus extends number | undefined = number | undefined,
|
|
9
|
+
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
+
TError extends Object | undefined = Object | undefined,
|
|
11
|
+
> extends NirvanaLabsError {
|
|
12
|
+
/** HTTP status for the response that caused the error */
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
/** HTTP headers for the response that caused the error */
|
|
15
|
+
readonly headers: THeaders;
|
|
16
|
+
/** JSON body of the response that caused the error */
|
|
17
|
+
readonly error: TError;
|
|
18
|
+
|
|
19
|
+
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
20
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.headers = headers;
|
|
23
|
+
this.error = error;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
27
|
+
const msg =
|
|
28
|
+
error?.message ?
|
|
29
|
+
typeof error.message === 'string' ?
|
|
30
|
+
error.message
|
|
31
|
+
: JSON.stringify(error.message)
|
|
32
|
+
: error ? JSON.stringify(error)
|
|
33
|
+
: message;
|
|
34
|
+
|
|
35
|
+
if (status && msg) {
|
|
36
|
+
return `${status} ${msg}`;
|
|
37
|
+
}
|
|
38
|
+
if (status) {
|
|
39
|
+
return `${status} status code (no body)`;
|
|
40
|
+
}
|
|
41
|
+
if (msg) {
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
return '(no status code or body)';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static generate(
|
|
48
|
+
status: number | undefined,
|
|
49
|
+
errorResponse: Object | undefined,
|
|
50
|
+
message: string | undefined,
|
|
51
|
+
headers: Headers | undefined,
|
|
52
|
+
): APIError {
|
|
53
|
+
if (!status || !headers) {
|
|
54
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const error = errorResponse as Record<string, any>;
|
|
58
|
+
|
|
59
|
+
if (status === 400) {
|
|
60
|
+
return new BadRequestError(status, error, message, headers);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (status === 401) {
|
|
64
|
+
return new AuthenticationError(status, error, message, headers);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (status === 403) {
|
|
68
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === 404) {
|
|
72
|
+
return new NotFoundError(status, error, message, headers);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (status === 409) {
|
|
76
|
+
return new ConflictError(status, error, message, headers);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (status === 422) {
|
|
80
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (status === 429) {
|
|
84
|
+
return new RateLimitError(status, error, message, headers);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (status >= 500) {
|
|
88
|
+
return new InternalServerError(status, error, message, headers);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return new APIError(status, error, message, headers);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
|
+
constructor({ message }: { message?: string } = {}) {
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
102
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
103
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
104
|
+
// in some environments the 'cause' property is already declared
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
if (cause) this.cause = cause;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
111
|
+
constructor({ message }: { message?: string } = {}) {
|
|
112
|
+
super({ message: message ?? 'Request timed out.' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class BadRequestError extends APIError<400, Headers> {}
|
|
117
|
+
|
|
118
|
+
export class AuthenticationError extends APIError<401, Headers> {}
|
|
119
|
+
|
|
120
|
+
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
121
|
+
|
|
122
|
+
export class NotFoundError extends APIError<404, Headers> {}
|
|
123
|
+
|
|
124
|
+
export class ConflictError extends APIError<409, Headers> {}
|
|
125
|
+
|
|
126
|
+
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
127
|
+
|
|
128
|
+
export class RateLimitError extends APIError<429, Headers> {}
|
|
129
|
+
|
|
130
|
+
export class InternalServerError extends APIError<number, Headers> {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { type Agent } from './_shims/index';
|
|
4
|
+
import * as Core from './core';
|
|
5
|
+
import * as Errors from './error';
|
|
6
|
+
import * as Uploads from './uploads';
|
|
7
|
+
import * as API from './resources/index';
|
|
8
|
+
import { Operations } from './resources/operations';
|
|
9
|
+
import { Compute } from './resources/compute/compute';
|
|
10
|
+
import { Networking } from './resources/networking/networking';
|
|
11
|
+
|
|
12
|
+
export interface ClientOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Defaults to process.env['NIRVANA_LABS_AUTH_TOKEN'].
|
|
15
|
+
*/
|
|
16
|
+
authToken?: string | undefined;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
20
|
+
*
|
|
21
|
+
* Defaults to process.env['NIRVANA_LABS_BASE_URL'].
|
|
22
|
+
*/
|
|
23
|
+
baseURL?: string | null | undefined;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
27
|
+
* from the server before timing out a single request.
|
|
28
|
+
*
|
|
29
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
30
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
31
|
+
*/
|
|
32
|
+
timeout?: number | undefined;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
36
|
+
*
|
|
37
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
38
|
+
* otherwise no agent is used.
|
|
39
|
+
*/
|
|
40
|
+
httpAgent?: Agent | undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Specify a custom `fetch` function implementation.
|
|
44
|
+
*
|
|
45
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
46
|
+
* defined globally.
|
|
47
|
+
*/
|
|
48
|
+
fetch?: Core.Fetch | undefined;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
52
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
53
|
+
*
|
|
54
|
+
* @default 2
|
|
55
|
+
*/
|
|
56
|
+
maxRetries?: number | undefined;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Default headers to include with every request to the API.
|
|
60
|
+
*
|
|
61
|
+
* These can be removed in individual requests by explicitly setting the
|
|
62
|
+
* header to `undefined` or `null` in request options.
|
|
63
|
+
*/
|
|
64
|
+
defaultHeaders?: Core.Headers | undefined;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Default query parameters to include with every request to the API.
|
|
68
|
+
*
|
|
69
|
+
* These can be removed in individual requests by explicitly setting the
|
|
70
|
+
* param to `undefined` in request options.
|
|
71
|
+
*/
|
|
72
|
+
defaultQuery?: Core.DefaultQuery | undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* API Client for interfacing with the Nirvana Labs API.
|
|
77
|
+
*/
|
|
78
|
+
export class NirvanaLabs extends Core.APIClient {
|
|
79
|
+
authToken: string;
|
|
80
|
+
|
|
81
|
+
private _options: ClientOptions;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* API Client for interfacing with the Nirvana Labs API.
|
|
85
|
+
*
|
|
86
|
+
* @param {string | undefined} [opts.authToken=process.env['NIRVANA_LABS_AUTH_TOKEN'] ?? undefined]
|
|
87
|
+
* @param {string} [opts.baseURL=process.env['NIRVANA_LABS_BASE_URL'] ?? https://api.nirvanalabs.io/] - Override the default base URL for the API.
|
|
88
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
89
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
90
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
91
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
92
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
93
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
94
|
+
*/
|
|
95
|
+
constructor({
|
|
96
|
+
baseURL = Core.readEnv('NIRVANA_LABS_BASE_URL'),
|
|
97
|
+
authToken = Core.readEnv('NIRVANA_LABS_AUTH_TOKEN'),
|
|
98
|
+
...opts
|
|
99
|
+
}: ClientOptions = {}) {
|
|
100
|
+
if (authToken === undefined) {
|
|
101
|
+
throw new Errors.NirvanaLabsError(
|
|
102
|
+
"The NIRVANA_LABS_AUTH_TOKEN environment variable is missing or empty; either provide it, or instantiate the NirvanaLabs client with an authToken option, like new NirvanaLabs({ authToken: 'My Auth Token' }).",
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const options: ClientOptions = {
|
|
107
|
+
authToken,
|
|
108
|
+
...opts,
|
|
109
|
+
baseURL: baseURL || `https://api.nirvanalabs.io/`,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
super({
|
|
113
|
+
baseURL: options.baseURL!,
|
|
114
|
+
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
115
|
+
httpAgent: options.httpAgent,
|
|
116
|
+
maxRetries: options.maxRetries,
|
|
117
|
+
fetch: options.fetch,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
this._options = options;
|
|
121
|
+
|
|
122
|
+
this.authToken = authToken;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
operations: API.Operations = new API.Operations(this);
|
|
126
|
+
compute: API.Compute = new API.Compute(this);
|
|
127
|
+
networking: API.Networking = new API.Networking(this);
|
|
128
|
+
|
|
129
|
+
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
130
|
+
return this._options.defaultQuery;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
134
|
+
return {
|
|
135
|
+
...super.defaultHeaders(opts),
|
|
136
|
+
...this._options.defaultHeaders,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
141
|
+
return { Authorization: `Bearer ${this.authToken}` };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static NirvanaLabs = this;
|
|
145
|
+
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
146
|
+
|
|
147
|
+
static NirvanaLabsError = Errors.NirvanaLabsError;
|
|
148
|
+
static APIError = Errors.APIError;
|
|
149
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
150
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
151
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
152
|
+
static NotFoundError = Errors.NotFoundError;
|
|
153
|
+
static ConflictError = Errors.ConflictError;
|
|
154
|
+
static RateLimitError = Errors.RateLimitError;
|
|
155
|
+
static BadRequestError = Errors.BadRequestError;
|
|
156
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
157
|
+
static InternalServerError = Errors.InternalServerError;
|
|
158
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
159
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
160
|
+
|
|
161
|
+
static toFile = Uploads.toFile;
|
|
162
|
+
static fileFromPath = Uploads.fileFromPath;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
NirvanaLabs.Operations = Operations;
|
|
166
|
+
NirvanaLabs.Compute = Compute;
|
|
167
|
+
NirvanaLabs.Networking = Networking;
|
|
168
|
+
export declare namespace NirvanaLabs {
|
|
169
|
+
export type RequestOptions = Core.RequestOptions;
|
|
170
|
+
|
|
171
|
+
export { Operations as Operations };
|
|
172
|
+
|
|
173
|
+
export { Compute as Compute };
|
|
174
|
+
|
|
175
|
+
export { Networking as Networking };
|
|
176
|
+
|
|
177
|
+
export type RegionName = API.RegionName;
|
|
178
|
+
export type ResourceStatus = API.ResourceStatus;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { toFile, fileFromPath } from './uploads';
|
|
182
|
+
export {
|
|
183
|
+
NirvanaLabsError,
|
|
184
|
+
APIError,
|
|
185
|
+
APIConnectionError,
|
|
186
|
+
APIConnectionTimeoutError,
|
|
187
|
+
APIUserAbortError,
|
|
188
|
+
NotFoundError,
|
|
189
|
+
ConflictError,
|
|
190
|
+
RateLimitError,
|
|
191
|
+
BadRequestError,
|
|
192
|
+
AuthenticationError,
|
|
193
|
+
InternalServerError,
|
|
194
|
+
PermissionDeniedError,
|
|
195
|
+
UnprocessableEntityError,
|
|
196
|
+
} from './error';
|
|
197
|
+
|
|
198
|
+
export default NirvanaLabs;
|
package/src/lib/.keep
ADDED
package/src/resource.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { NirvanaLabs } from './index';
|
|
4
|
+
|
|
5
|
+
export class APIResource {
|
|
6
|
+
protected _client: NirvanaLabs;
|
|
7
|
+
|
|
8
|
+
constructor(client: NirvanaLabs) {
|
|
9
|
+
this._client = client;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../resource';
|
|
4
|
+
import * as VolumesAPI from './volumes';
|
|
5
|
+
import {
|
|
6
|
+
StorageType,
|
|
7
|
+
Volume,
|
|
8
|
+
VolumeCreateParams,
|
|
9
|
+
VolumeDeleteParams,
|
|
10
|
+
VolumeKind,
|
|
11
|
+
VolumeListResponse,
|
|
12
|
+
VolumeUpdateParams,
|
|
13
|
+
Volumes,
|
|
14
|
+
} from './volumes';
|
|
15
|
+
import * as VMsAPI from './vms/vms';
|
|
16
|
+
import { CPU, OSImage, Ram, SSHKey, VM, VMCreateParams, VMList, VMUpdateParams, VMs } from './vms/vms';
|
|
17
|
+
|
|
18
|
+
export class Compute extends APIResource {
|
|
19
|
+
vms: VMsAPI.VMs = new VMsAPI.VMs(this._client);
|
|
20
|
+
volumes: VolumesAPI.Volumes = new VolumesAPI.Volumes(this._client);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Compute.VMs = VMs;
|
|
24
|
+
Compute.Volumes = Volumes;
|
|
25
|
+
|
|
26
|
+
export declare namespace Compute {
|
|
27
|
+
export {
|
|
28
|
+
VMs as VMs,
|
|
29
|
+
type CPU as CPU,
|
|
30
|
+
type OSImage as OSImage,
|
|
31
|
+
type Ram as Ram,
|
|
32
|
+
type SSHKey as SSHKey,
|
|
33
|
+
type VM as VM,
|
|
34
|
+
type VMList as VMList,
|
|
35
|
+
type VMCreateParams as VMCreateParams,
|
|
36
|
+
type VMUpdateParams as VMUpdateParams,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
Volumes as Volumes,
|
|
41
|
+
type StorageType as StorageType,
|
|
42
|
+
type Volume as Volume,
|
|
43
|
+
type VolumeKind as VolumeKind,
|
|
44
|
+
type VolumeListResponse as VolumeListResponse,
|
|
45
|
+
type VolumeCreateParams as VolumeCreateParams,
|
|
46
|
+
type VolumeUpdateParams as VolumeUpdateParams,
|
|
47
|
+
type VolumeDeleteParams as VolumeDeleteParams,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export { Compute } from './compute';
|
|
4
|
+
export {
|
|
5
|
+
VMs,
|
|
6
|
+
type CPU,
|
|
7
|
+
type OSImage,
|
|
8
|
+
type Ram,
|
|
9
|
+
type SSHKey,
|
|
10
|
+
type VM,
|
|
11
|
+
type VMList,
|
|
12
|
+
type VMCreateParams,
|
|
13
|
+
type VMUpdateParams,
|
|
14
|
+
} from './vms/index';
|
|
15
|
+
export {
|
|
16
|
+
Volumes,
|
|
17
|
+
type StorageType,
|
|
18
|
+
type Volume,
|
|
19
|
+
type VolumeKind,
|
|
20
|
+
type VolumeListResponse,
|
|
21
|
+
type VolumeCreateParams,
|
|
22
|
+
type VolumeUpdateParams,
|
|
23
|
+
type VolumeDeleteParams,
|
|
24
|
+
} from './volumes';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export { OSImages, type OSImageListResponse } from './os-images';
|
|
4
|
+
export {
|
|
5
|
+
VMs,
|
|
6
|
+
type CPU,
|
|
7
|
+
type OSImage,
|
|
8
|
+
type Ram,
|
|
9
|
+
type SSHKey,
|
|
10
|
+
type VM,
|
|
11
|
+
type VMList,
|
|
12
|
+
type VMCreateParams,
|
|
13
|
+
type VMUpdateParams,
|
|
14
|
+
} from './vms';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../resource';
|
|
4
|
+
import * as Core from '../../../core';
|
|
5
|
+
import * as VMsAPI from './vms';
|
|
6
|
+
|
|
7
|
+
export class OSImages extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* List all OS Images
|
|
10
|
+
*/
|
|
11
|
+
list(options?: Core.RequestOptions): Core.APIPromise<OSImageListResponse> {
|
|
12
|
+
return this._client.get('/compute/vms/os_images', options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type OSImageListResponse = Array<VMsAPI.OSImage>;
|
|
17
|
+
|
|
18
|
+
export declare namespace OSImages {
|
|
19
|
+
export { type OSImageListResponse as OSImageListResponse };
|
|
20
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../resource';
|
|
4
|
+
import * as Core from '../../../core';
|
|
5
|
+
import * as OperationsAPI from '../../operations';
|
|
6
|
+
import * as Shared from '../../shared';
|
|
7
|
+
import * as VolumesAPI from '../volumes';
|
|
8
|
+
import * as OSImagesAPI from './os-images';
|
|
9
|
+
import { OSImageListResponse, OSImages } from './os-images';
|
|
10
|
+
|
|
11
|
+
export class VMs extends APIResource {
|
|
12
|
+
osImages: OSImagesAPI.OSImages = new OSImagesAPI.OSImages(this._client);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a VM
|
|
16
|
+
*/
|
|
17
|
+
create(body: VMCreateParams, options?: Core.RequestOptions): Core.APIPromise<OperationsAPI.Operation> {
|
|
18
|
+
return this._client.post('/compute/vms', { body, ...options });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Update a VM
|
|
23
|
+
*/
|
|
24
|
+
update(
|
|
25
|
+
vmId: string,
|
|
26
|
+
body: VMUpdateParams,
|
|
27
|
+
options?: Core.RequestOptions,
|
|
28
|
+
): Core.APIPromise<OperationsAPI.Operation> {
|
|
29
|
+
return this._client.patch(`/compute/vms/${vmId}`, { body, ...options });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* List all VMs
|
|
34
|
+
*/
|
|
35
|
+
list(options?: Core.RequestOptions): Core.APIPromise<VMList> {
|
|
36
|
+
return this._client.get('/compute/vms', options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Delete a VM
|
|
41
|
+
*/
|
|
42
|
+
delete(vmId: string, options?: Core.RequestOptions): Core.APIPromise<OperationsAPI.Operation> {
|
|
43
|
+
return this._client.delete(`/compute/vms/${vmId}`, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get details about a VM
|
|
48
|
+
*/
|
|
49
|
+
get(vmId: string, options?: Core.RequestOptions): Core.APIPromise<VM> {
|
|
50
|
+
return this._client.get(`/compute/vms/${vmId}`, options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* CPU details.
|
|
56
|
+
*/
|
|
57
|
+
export interface CPU {
|
|
58
|
+
cores: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface OSImage {
|
|
62
|
+
created_at: string;
|
|
63
|
+
|
|
64
|
+
display_name: string;
|
|
65
|
+
|
|
66
|
+
name: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* RAM details.
|
|
71
|
+
*/
|
|
72
|
+
export interface Ram {
|
|
73
|
+
/**
|
|
74
|
+
* RAM size
|
|
75
|
+
*/
|
|
76
|
+
size: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* SSH key details.
|
|
81
|
+
*/
|
|
82
|
+
export interface SSHKey {
|
|
83
|
+
public_key: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* VM details.
|
|
88
|
+
*/
|
|
89
|
+
export interface VM {
|
|
90
|
+
id: string;
|
|
91
|
+
|
|
92
|
+
boot_volume_id: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* CPU details.
|
|
96
|
+
*/
|
|
97
|
+
cpu_config: CPU;
|
|
98
|
+
|
|
99
|
+
created_at: string;
|
|
100
|
+
|
|
101
|
+
data_volume_ids: Array<string>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* RAM details.
|
|
105
|
+
*/
|
|
106
|
+
mem_config: Ram;
|
|
107
|
+
|
|
108
|
+
name: string;
|
|
109
|
+
|
|
110
|
+
public_ip: string;
|
|
111
|
+
|
|
112
|
+
region: Shared.RegionName;
|
|
113
|
+
|
|
114
|
+
status: Shared.ResourceStatus;
|
|
115
|
+
|
|
116
|
+
updated_at: string;
|
|
117
|
+
|
|
118
|
+
vpc_id: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface VMList {
|
|
122
|
+
items: Array<VM>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface VMCreateParams {
|
|
126
|
+
/**
|
|
127
|
+
* Boot volume create request.
|
|
128
|
+
*/
|
|
129
|
+
boot_volume: VMCreateParams.BootVolume;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* CPU details.
|
|
133
|
+
*/
|
|
134
|
+
cpu: CPU;
|
|
135
|
+
|
|
136
|
+
name: string;
|
|
137
|
+
|
|
138
|
+
os_image_name: string;
|
|
139
|
+
|
|
140
|
+
ports: Array<string>;
|
|
141
|
+
|
|
142
|
+
public_ip_enabled: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* RAM details.
|
|
146
|
+
*/
|
|
147
|
+
ram: Ram;
|
|
148
|
+
|
|
149
|
+
region: Shared.RegionName;
|
|
150
|
+
|
|
151
|
+
source_address: string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* SSH key details.
|
|
155
|
+
*/
|
|
156
|
+
ssh_key: SSHKey;
|
|
157
|
+
|
|
158
|
+
data_volumes?: Array<VMCreateParams.DataVolume>;
|
|
159
|
+
|
|
160
|
+
subnet_id?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export namespace VMCreateParams {
|
|
164
|
+
/**
|
|
165
|
+
* Boot volume create request.
|
|
166
|
+
*/
|
|
167
|
+
export interface BootVolume {
|
|
168
|
+
size: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* VM data volume create request.
|
|
173
|
+
*/
|
|
174
|
+
export interface DataVolume {
|
|
175
|
+
size: number;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Storage type.
|
|
179
|
+
*/
|
|
180
|
+
type?: VolumesAPI.StorageType;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface VMUpdateParams {
|
|
185
|
+
/**
|
|
186
|
+
* Boot volume create request.
|
|
187
|
+
*/
|
|
188
|
+
boot_volume?: VMUpdateParams.BootVolume;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* CPU details.
|
|
192
|
+
*/
|
|
193
|
+
cpu?: CPU;
|
|
194
|
+
|
|
195
|
+
data_volumes?: Array<VMUpdateParams.DataVolume>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* RAM details.
|
|
199
|
+
*/
|
|
200
|
+
ram?: Ram;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export namespace VMUpdateParams {
|
|
204
|
+
/**
|
|
205
|
+
* Boot volume create request.
|
|
206
|
+
*/
|
|
207
|
+
export interface BootVolume {
|
|
208
|
+
size: number;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* VM data volume create request.
|
|
213
|
+
*/
|
|
214
|
+
export interface DataVolume {
|
|
215
|
+
size: number;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Storage type.
|
|
219
|
+
*/
|
|
220
|
+
type?: VolumesAPI.StorageType;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
VMs.OSImages = OSImages;
|
|
225
|
+
|
|
226
|
+
export declare namespace VMs {
|
|
227
|
+
export {
|
|
228
|
+
type CPU as CPU,
|
|
229
|
+
type OSImage as OSImage,
|
|
230
|
+
type Ram as Ram,
|
|
231
|
+
type SSHKey as SSHKey,
|
|
232
|
+
type VM as VM,
|
|
233
|
+
type VMList as VMList,
|
|
234
|
+
type VMCreateParams as VMCreateParams,
|
|
235
|
+
type VMUpdateParams as VMUpdateParams,
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export { OSImages as OSImages, type OSImageListResponse as OSImageListResponse };
|
|
239
|
+
}
|