@nirvana-labs/nirvana 1.98.1 → 1.98.2
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 +7 -0
- package/client.d.mts +1 -3
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -3
- package/client.d.ts.map +1 -1
- package/client.js +0 -3
- package/client.js.map +1 -1
- package/client.mjs +0 -3
- package/client.mjs.map +1 -1
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/tslib.js +22 -22
- package/internal/utils/query.d.mts +0 -3
- package/internal/utils/query.d.mts.map +1 -1
- package/internal/utils/query.d.ts +0 -3
- package/internal/utils/query.d.ts.map +1 -1
- package/internal/utils/query.js +3 -16
- package/internal/utils/query.js.map +1 -1
- package/internal/utils/query.mjs +2 -16
- package/internal/utils/query.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/compute/vms/index.d.mts +2 -0
- package/resources/compute/vms/index.d.mts.map +1 -1
- package/resources/compute/vms/index.d.ts +2 -0
- package/resources/compute/vms/index.d.ts.map +1 -1
- package/resources/compute/vms/index.js +5 -1
- package/resources/compute/vms/index.js.map +1 -1
- package/resources/compute/vms/index.mjs +2 -0
- package/resources/compute/vms/index.mjs.map +1 -1
- package/resources/compute/vms/metric-descriptors.d.mts +61 -0
- package/resources/compute/vms/metric-descriptors.d.mts.map +1 -0
- package/resources/compute/vms/metric-descriptors.d.ts +61 -0
- package/resources/compute/vms/metric-descriptors.d.ts.map +1 -0
- package/resources/compute/vms/metric-descriptors.js +23 -0
- package/resources/compute/vms/metric-descriptors.js.map +1 -0
- package/resources/compute/vms/metric-descriptors.mjs +19 -0
- package/resources/compute/vms/metric-descriptors.mjs.map +1 -0
- package/resources/compute/vms/metrics.d.mts +113 -0
- package/resources/compute/vms/metrics.d.mts.map +1 -0
- package/resources/compute/vms/metrics.d.ts +113 -0
- package/resources/compute/vms/metrics.d.ts.map +1 -0
- package/resources/compute/vms/metrics.js +25 -0
- package/resources/compute/vms/metrics.js.map +1 -0
- package/resources/compute/vms/metrics.mjs +21 -0
- package/resources/compute/vms/metrics.mjs.map +1 -0
- package/resources/compute/vms/os-images.d.mts +15 -0
- package/resources/compute/vms/os-images.d.mts.map +1 -1
- package/resources/compute/vms/os-images.d.ts +15 -0
- package/resources/compute/vms/os-images.d.ts.map +1 -1
- package/resources/compute/vms/vms.d.mts +42 -0
- package/resources/compute/vms/vms.d.mts.map +1 -1
- package/resources/compute/vms/vms.d.ts +42 -0
- package/resources/compute/vms/vms.d.ts.map +1 -1
- package/resources/compute/vms/vms.js +8 -0
- package/resources/compute/vms/vms.js.map +1 -1
- package/resources/compute/vms/vms.mjs +8 -0
- package/resources/compute/vms/vms.mjs.map +1 -1
- package/resources/compute/vms/volumes.d.mts +26 -0
- package/resources/compute/vms/volumes.d.mts.map +1 -1
- package/resources/compute/vms/volumes.d.ts +26 -0
- package/resources/compute/vms/volumes.d.ts.map +1 -1
- package/resources/compute/volumes/volumes.d.mts +39 -0
- package/resources/compute/volumes/volumes.d.mts.map +1 -1
- package/resources/compute/volumes/volumes.d.ts +39 -0
- package/resources/compute/volumes/volumes.d.ts.map +1 -1
- package/resources/compute/volumes/volumes.js.map +1 -1
- package/resources/compute/volumes/volumes.mjs.map +1 -1
- package/resources/instance-types/instance-types.d.mts +49 -0
- package/resources/instance-types/instance-types.d.mts.map +1 -1
- package/resources/instance-types/instance-types.d.ts +49 -0
- package/resources/instance-types/instance-types.d.ts.map +1 -1
- package/resources/networking/connect/connections/connections.d.mts +34 -0
- package/resources/networking/connect/connections/connections.d.mts.map +1 -1
- package/resources/networking/connect/connections/connections.d.ts +34 -0
- package/resources/networking/connect/connections/connections.d.ts.map +1 -1
- package/resources/networking/connect/connections/connections.js.map +1 -1
- package/resources/networking/connect/connections/connections.mjs.map +1 -1
- package/resources/networking/connect/routes.d.mts +17 -0
- package/resources/networking/connect/routes.d.mts.map +1 -1
- package/resources/networking/connect/routes.d.ts +17 -0
- package/resources/networking/connect/routes.d.ts.map +1 -1
- package/resources/networking/firewall-rules.d.mts +22 -0
- package/resources/networking/firewall-rules.d.mts.map +1 -1
- package/resources/networking/firewall-rules.d.ts +22 -0
- package/resources/networking/firewall-rules.d.ts.map +1 -1
- package/resources/networking/vpcs/vpcs.d.mts +22 -0
- package/resources/networking/vpcs/vpcs.d.mts.map +1 -1
- package/resources/networking/vpcs/vpcs.d.ts +22 -0
- package/resources/networking/vpcs/vpcs.d.ts.map +1 -1
- package/resources/networking/vpcs/vpcs.js.map +1 -1
- package/resources/networking/vpcs/vpcs.mjs.map +1 -1
- package/resources/rpc-nodes/dedicated/dedicated.d.mts +22 -0
- package/resources/rpc-nodes/dedicated/dedicated.d.mts.map +1 -1
- package/resources/rpc-nodes/dedicated/dedicated.d.ts +22 -0
- package/resources/rpc-nodes/dedicated/dedicated.d.ts.map +1 -1
- package/resources/rpc-nodes/dedicated/dedicated.js.map +1 -1
- package/resources/rpc-nodes/dedicated/dedicated.mjs.map +1 -1
- package/resources/rpc-nodes/flex/flex.d.mts +22 -0
- package/resources/rpc-nodes/flex/flex.d.mts.map +1 -1
- package/resources/rpc-nodes/flex/flex.d.ts +22 -0
- package/resources/rpc-nodes/flex/flex.d.ts.map +1 -1
- package/resources/rpc-nodes/flex/flex.js.map +1 -1
- package/resources/rpc-nodes/flex/flex.mjs.map +1 -1
- package/resources/shared.d.mts +4 -0
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +4 -0
- package/resources/shared.d.ts.map +1 -1
- package/src/client.ts +1 -3
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/utils/query.ts +2 -18
- package/src/resources/compute/api.md +23 -0
- package/src/resources/compute/vms/index.ts +12 -0
- package/src/resources/compute/vms/metric-descriptors.ts +77 -0
- package/src/resources/compute/vms/metrics.ts +149 -0
- package/src/resources/compute/vms/os-images.ts +19 -1
- package/src/resources/compute/vms/vms.ts +66 -0
- package/src/resources/compute/vms/volumes.ts +33 -1
- package/src/resources/compute/volumes/volumes.ts +48 -0
- package/src/resources/instance-types/instance-types.ts +62 -1
- package/src/resources/networking/connect/connections/connections.ts +42 -0
- package/src/resources/networking/connect/routes.ts +22 -1
- package/src/resources/networking/firewall-rules.ts +28 -1
- package/src/resources/networking/vpcs/vpcs.ts +27 -0
- package/src/resources/rpc-nodes/dedicated/dedicated.ts +27 -0
- package/src/resources/rpc-nodes/flex/flex.ts +27 -0
- package/src/resources/shared.ts +5 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { RFC1738 } from './formats';
|
|
2
|
+
import type { DefaultEncoder, Format } from './types';
|
|
3
|
+
import { isArray } from '../utils/values';
|
|
4
|
+
|
|
5
|
+
export let has = (obj: object, key: PropertyKey): boolean => (
|
|
6
|
+
(has = (Object as any).hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty)),
|
|
7
|
+
has(obj, key)
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const hex_table = /* @__PURE__ */ (() => {
|
|
11
|
+
const array = [];
|
|
12
|
+
for (let i = 0; i < 256; ++i) {
|
|
13
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return array;
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
|
|
20
|
+
while (queue.length > 1) {
|
|
21
|
+
const item = queue.pop();
|
|
22
|
+
if (!item) continue;
|
|
23
|
+
|
|
24
|
+
const obj = item.obj[item.prop];
|
|
25
|
+
|
|
26
|
+
if (isArray(obj)) {
|
|
27
|
+
const compacted: unknown[] = [];
|
|
28
|
+
|
|
29
|
+
for (let j = 0; j < obj.length; ++j) {
|
|
30
|
+
if (typeof obj[j] !== 'undefined') {
|
|
31
|
+
compacted.push(obj[j]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
item.obj[item.prop] = compacted;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function array_to_object(source: any[], options: { plainObjects: boolean }) {
|
|
42
|
+
const obj = options && options.plainObjects ? Object.create(null) : {};
|
|
43
|
+
for (let i = 0; i < source.length; ++i) {
|
|
44
|
+
if (typeof source[i] !== 'undefined') {
|
|
45
|
+
obj[i] = source[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function merge(
|
|
53
|
+
target: any,
|
|
54
|
+
source: any,
|
|
55
|
+
options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
|
|
56
|
+
) {
|
|
57
|
+
if (!source) {
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof source !== 'object') {
|
|
62
|
+
if (isArray(target)) {
|
|
63
|
+
target.push(source);
|
|
64
|
+
} else if (target && typeof target === 'object') {
|
|
65
|
+
if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) {
|
|
66
|
+
target[source] = true;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
return [target, source];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!target || typeof target !== 'object') {
|
|
76
|
+
return [target].concat(source);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let mergeTarget = target;
|
|
80
|
+
if (isArray(target) && !isArray(source)) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
mergeTarget = array_to_object(target, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isArray(target) && isArray(source)) {
|
|
86
|
+
source.forEach(function (item, i) {
|
|
87
|
+
if (has(target, i)) {
|
|
88
|
+
const targetItem = target[i];
|
|
89
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
90
|
+
target[i] = merge(targetItem, item, options);
|
|
91
|
+
} else {
|
|
92
|
+
target.push(item);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
target[i] = item;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
102
|
+
const value = source[key];
|
|
103
|
+
|
|
104
|
+
if (has(acc, key)) {
|
|
105
|
+
acc[key] = merge(acc[key], value, options);
|
|
106
|
+
} else {
|
|
107
|
+
acc[key] = value;
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, mergeTarget);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function assign_single_source(target: any, source: any) {
|
|
114
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
115
|
+
acc[key] = source[key];
|
|
116
|
+
return acc;
|
|
117
|
+
}, target);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function decode(str: string, _: any, charset: string) {
|
|
121
|
+
const strWithoutPlus = str.replace(/\+/g, ' ');
|
|
122
|
+
if (charset === 'iso-8859-1') {
|
|
123
|
+
// unescape never throws, no try...catch needed:
|
|
124
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
125
|
+
}
|
|
126
|
+
// utf-8
|
|
127
|
+
try {
|
|
128
|
+
return decodeURIComponent(strWithoutPlus);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return strWithoutPlus;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const limit = 1024;
|
|
135
|
+
|
|
136
|
+
export const encode: (
|
|
137
|
+
str: any,
|
|
138
|
+
defaultEncoder: DefaultEncoder,
|
|
139
|
+
charset: string,
|
|
140
|
+
type: 'key' | 'value',
|
|
141
|
+
format: Format,
|
|
142
|
+
) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
|
|
143
|
+
// This code was originally written by Brian White for the io.js core querystring library.
|
|
144
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
145
|
+
if (str.length === 0) {
|
|
146
|
+
return str;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let string = str;
|
|
150
|
+
if (typeof str === 'symbol') {
|
|
151
|
+
string = Symbol.prototype.toString.call(str);
|
|
152
|
+
} else if (typeof str !== 'string') {
|
|
153
|
+
string = String(str);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (charset === 'iso-8859-1') {
|
|
157
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
158
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let out = '';
|
|
163
|
+
for (let j = 0; j < string.length; j += limit) {
|
|
164
|
+
const segment = string.length >= limit ? string.slice(j, j + limit) : string;
|
|
165
|
+
const arr = [];
|
|
166
|
+
|
|
167
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
168
|
+
let c = segment.charCodeAt(i);
|
|
169
|
+
if (
|
|
170
|
+
c === 0x2d || // -
|
|
171
|
+
c === 0x2e || // .
|
|
172
|
+
c === 0x5f || // _
|
|
173
|
+
c === 0x7e || // ~
|
|
174
|
+
(c >= 0x30 && c <= 0x39) || // 0-9
|
|
175
|
+
(c >= 0x41 && c <= 0x5a) || // a-z
|
|
176
|
+
(c >= 0x61 && c <= 0x7a) || // A-Z
|
|
177
|
+
(format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
178
|
+
) {
|
|
179
|
+
arr[arr.length] = segment.charAt(i);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (c < 0x80) {
|
|
184
|
+
arr[arr.length] = hex_table[c];
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (c < 0x800) {
|
|
189
|
+
arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (c < 0xd800 || c >= 0xe000) {
|
|
194
|
+
arr[arr.length] =
|
|
195
|
+
hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
i += 1;
|
|
200
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
201
|
+
|
|
202
|
+
arr[arr.length] =
|
|
203
|
+
hex_table[0xf0 | (c >> 18)]! +
|
|
204
|
+
hex_table[0x80 | ((c >> 12) & 0x3f)] +
|
|
205
|
+
hex_table[0x80 | ((c >> 6) & 0x3f)] +
|
|
206
|
+
hex_table[0x80 | (c & 0x3f)];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
out += arr.join('');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return out;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function compact(value: any) {
|
|
216
|
+
const queue = [{ obj: { o: value }, prop: 'o' }];
|
|
217
|
+
const refs = [];
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
220
|
+
const item = queue[i];
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
const obj = item.obj[item.prop];
|
|
223
|
+
|
|
224
|
+
const keys = Object.keys(obj);
|
|
225
|
+
for (let j = 0; j < keys.length; ++j) {
|
|
226
|
+
const key = keys[j]!;
|
|
227
|
+
const val = obj[key];
|
|
228
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
229
|
+
queue.push({ obj: obj, prop: key });
|
|
230
|
+
refs.push(val);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
compact_queue(queue);
|
|
236
|
+
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function is_regexp(obj: any) {
|
|
241
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function is_buffer(obj: any) {
|
|
245
|
+
if (!obj || typeof obj !== 'object') {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function combine(a: any, b: any) {
|
|
253
|
+
return [].concat(a, b);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
257
|
+
if (isArray(val)) {
|
|
258
|
+
const mapped = [];
|
|
259
|
+
for (let i = 0; i < val.length; i += 1) {
|
|
260
|
+
mapped.push(fn(val[i]!));
|
|
261
|
+
}
|
|
262
|
+
return mapped;
|
|
263
|
+
}
|
|
264
|
+
return fn(val);
|
|
265
|
+
}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as qs from '../qs/stringify';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
7
|
-
*/
|
|
8
5
|
export function stringifyQuery(query: object | Record<string, unknown>) {
|
|
9
|
-
return
|
|
10
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
11
|
-
.map(([key, value]) => {
|
|
12
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
13
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
14
|
-
}
|
|
15
|
-
if (value === null) {
|
|
16
|
-
return `${encodeURIComponent(key)}=`;
|
|
17
|
-
}
|
|
18
|
-
throw new NirvanaLabsError(
|
|
19
|
-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
20
|
-
);
|
|
21
|
-
})
|
|
22
|
-
.join('&');
|
|
6
|
+
return qs.stringify(query, { arrayFormat: 'comma' });
|
|
23
7
|
}
|
|
@@ -46,6 +46,29 @@ Methods:
|
|
|
46
46
|
|
|
47
47
|
- <code title="get /v1/compute/vms/os_images">client.compute.vms.osImages.<a href="./src/resources/compute/vms/os-images.ts">list</a>({ ...params }) -> OSImagesCursor</code>
|
|
48
48
|
|
|
49
|
+
### Metrics
|
|
50
|
+
|
|
51
|
+
Types:
|
|
52
|
+
|
|
53
|
+
- <code><a href="./src/resources/compute/vms/metrics.ts">VMMetricPoint</a></code>
|
|
54
|
+
- <code><a href="./src/resources/compute/vms/metrics.ts">VMMetricSeries</a></code>
|
|
55
|
+
- <code><a href="./src/resources/compute/vms/metrics.ts">VMMetrics</a></code>
|
|
56
|
+
|
|
57
|
+
Methods:
|
|
58
|
+
|
|
59
|
+
- <code title="get /v1/compute/vms/{vm_id}/metrics">client.compute.vms.metrics.<a href="./src/resources/compute/vms/metrics.ts">list</a>(vmID, { ...params }) -> VMMetrics</code>
|
|
60
|
+
|
|
61
|
+
### MetricDescriptors
|
|
62
|
+
|
|
63
|
+
Types:
|
|
64
|
+
|
|
65
|
+
- <code><a href="./src/resources/compute/vms/metric-descriptors.ts">VMMetricDescriptor</a></code>
|
|
66
|
+
- <code><a href="./src/resources/compute/vms/metric-descriptors.ts">VMMetricDescriptorList</a></code>
|
|
67
|
+
|
|
68
|
+
Methods:
|
|
69
|
+
|
|
70
|
+
- <code title="get /v1/compute/metric_descriptors">client.compute.vms.metricDescriptors.<a href="./src/resources/compute/vms/metric-descriptors.ts">list</a>() -> VMMetricDescriptorList</code>
|
|
71
|
+
|
|
49
72
|
## Volumes
|
|
50
73
|
|
|
51
74
|
Types:
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
export { Availability, type AvailabilityCreateParams, type AvailabilityUpdateParams } from './availability';
|
|
4
4
|
export { Cost, type CostCreateParams, type CostUpdateParams } from './cost';
|
|
5
|
+
export {
|
|
6
|
+
MetricDescriptors,
|
|
7
|
+
type VMMetricDescriptor,
|
|
8
|
+
type VMMetricDescriptorList,
|
|
9
|
+
} from './metric-descriptors';
|
|
10
|
+
export {
|
|
11
|
+
Metrics,
|
|
12
|
+
type VMMetricPoint,
|
|
13
|
+
type VMMetricSeries,
|
|
14
|
+
type VMMetrics,
|
|
15
|
+
type MetricListParams,
|
|
16
|
+
} from './metrics';
|
|
5
17
|
export { OSImages, type OSImageListParams } from './os-images';
|
|
6
18
|
export {
|
|
7
19
|
VMs,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../core/resource';
|
|
4
|
+
import * as Shared from '../../shared';
|
|
5
|
+
import { APIPromise } from '../../../core/api-promise';
|
|
6
|
+
import { RequestOptions } from '../../../internal/request-options';
|
|
7
|
+
|
|
8
|
+
export class MetricDescriptors extends APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* Describe every metric a VM reports: its name, unit, the range its values fall
|
|
11
|
+
* in, and whether a value can be null. Read this instead of holding a list of
|
|
12
|
+
* metric names, so a metric published later is picked up without a client change.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const vmMetricDescriptorList =
|
|
17
|
+
* await client.compute.vms.metricDescriptors.list();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
list(options?: RequestOptions): APIPromise<VMMetricDescriptorList> {
|
|
21
|
+
return this._client.get('/v1/compute/metric_descriptors', options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Describes one metric a VM reports: how to name it, what its values mean, and the
|
|
27
|
+
* range they fall in.
|
|
28
|
+
*/
|
|
29
|
+
export interface VMMetricDescriptor {
|
|
30
|
+
/**
|
|
31
|
+
* What the metric measures.
|
|
32
|
+
*/
|
|
33
|
+
description: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Highest value the metric reports, or null when it has no ceiling of its own.
|
|
37
|
+
*/
|
|
38
|
+
max_value: number | null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Fully-qualified name of the metric, and the only spelling the metric query
|
|
42
|
+
* parameter accepts.
|
|
43
|
+
*/
|
|
44
|
+
metric: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Lowest value the metric reports.
|
|
48
|
+
*/
|
|
49
|
+
min_value: number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether a point's value can be null. A null means the VM reported no observation
|
|
53
|
+
* for that period, which is what a stopped VM looks like.
|
|
54
|
+
*/
|
|
55
|
+
nullable: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Unit the values are expressed in.
|
|
59
|
+
*/
|
|
60
|
+
unit: Shared.VMMetricUnit;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface VMMetricDescriptorList {
|
|
64
|
+
items: Array<VMMetricDescriptor>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Pagination response details.
|
|
68
|
+
*/
|
|
69
|
+
pagination: Shared.Pagination;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export declare namespace MetricDescriptors {
|
|
73
|
+
export {
|
|
74
|
+
type VMMetricDescriptor as VMMetricDescriptor,
|
|
75
|
+
type VMMetricDescriptorList as VMMetricDescriptorList,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../core/resource';
|
|
4
|
+
import * as Shared from '../../shared';
|
|
5
|
+
import { APIPromise } from '../../../core/api-promise';
|
|
6
|
+
import { RequestOptions } from '../../../internal/request-options';
|
|
7
|
+
import { path } from '../../../internal/utils/path';
|
|
8
|
+
|
|
9
|
+
export class Metrics extends APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Read a VM's resource metrics over an interval. Every series covers the same
|
|
12
|
+
* periods, so they line up index for index, and a period the VM reported no
|
|
13
|
+
* observation for carries a null value.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const vmMetrics = await client.compute.vms.metrics.list(
|
|
18
|
+
* 'vm_id',
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
list(
|
|
23
|
+
vmID: string,
|
|
24
|
+
query: MetricListParams | null | undefined = {},
|
|
25
|
+
options?: RequestOptions,
|
|
26
|
+
): APIPromise<VMMetrics> {
|
|
27
|
+
return this._client.get(path`/v1/compute/vms/${vmID}/metrics`, { query, ...options });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One period's value.
|
|
33
|
+
*/
|
|
34
|
+
export interface VMMetricPoint {
|
|
35
|
+
/**
|
|
36
|
+
* End of the period the value covers, so a point timestamped 00:05 over
|
|
37
|
+
* five-minute periods describes 00:00 through 00:05.
|
|
38
|
+
*/
|
|
39
|
+
timestamp: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Value over the period, in the series' unit. Null means the VM reported no
|
|
43
|
+
* observation for this period, which is what a stopped VM looks like.
|
|
44
|
+
*/
|
|
45
|
+
value: number | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* One metric's values over the interval served.
|
|
50
|
+
*/
|
|
51
|
+
export interface VMMetricSeries {
|
|
52
|
+
/**
|
|
53
|
+
* Fully-qualified name of the metric.
|
|
54
|
+
*/
|
|
55
|
+
metric: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Values over the interval, oldest first. Every series in a response covers the
|
|
59
|
+
* same periods, so they line up index for index.
|
|
60
|
+
*/
|
|
61
|
+
points: Array<VMMetricPoint>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Unit the values are expressed in.
|
|
65
|
+
*/
|
|
66
|
+
unit: Shared.VMMetricUnit;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A VM's metrics over an interval: one series per metric, on a shared grid of
|
|
71
|
+
* periods.
|
|
72
|
+
*/
|
|
73
|
+
export interface VMMetrics {
|
|
74
|
+
/**
|
|
75
|
+
* How the samples inside one period were folded into a single value.
|
|
76
|
+
*/
|
|
77
|
+
aggregation: 'mean' | 'max' | 'min';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* End of the interval served, exclusive.
|
|
81
|
+
*/
|
|
82
|
+
end_time: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* One series per requested metric, in the order they were requested.
|
|
86
|
+
*/
|
|
87
|
+
metrics: Array<VMMetricSeries>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Width of one period, and so the spacing between consecutive points.
|
|
91
|
+
*/
|
|
92
|
+
period: '5m' | '15m' | '1h' | '6h' | '24h';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Start of the interval served, inclusive. It can be later than the requested
|
|
96
|
+
* start when the request asked for more than the available history.
|
|
97
|
+
*/
|
|
98
|
+
start_time: string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* ID of the VM the series belong to.
|
|
102
|
+
*/
|
|
103
|
+
vm_id: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface MetricListParams {
|
|
107
|
+
/**
|
|
108
|
+
* How the samples inside one period are folded into a single value.
|
|
109
|
+
*/
|
|
110
|
+
aggregation?: 'mean' | 'max' | 'min';
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* End of the interval, exclusive, as an RFC 3339 timestamp. Defaults to now.
|
|
114
|
+
*/
|
|
115
|
+
end_time?: string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Metric to return. Repeat the parameter for several; every metric is returned
|
|
119
|
+
* when it is left out.
|
|
120
|
+
*/
|
|
121
|
+
metric?: Array<
|
|
122
|
+
| 'compute.nirvanalabs.io/vm/cpu/used_cores'
|
|
123
|
+
| 'compute.nirvanalabs.io/vm/cpu/utilization'
|
|
124
|
+
| 'compute.nirvanalabs.io/vm/memory/used_bytes'
|
|
125
|
+
| 'compute.nirvanalabs.io/vm/memory/utilization'
|
|
126
|
+
>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Width of one period, and so the spacing between points. An interval holding more
|
|
130
|
+
* than 1440 periods is rejected; the error names a period that fits.
|
|
131
|
+
*/
|
|
132
|
+
period?: '5m' | '15m' | '1h' | '6h' | '24h';
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Start of the interval, inclusive, as an RFC 3339 timestamp. Defaults to an hour
|
|
136
|
+
* before end_time. A start older than the 30 days of history kept is served from
|
|
137
|
+
* where that history begins.
|
|
138
|
+
*/
|
|
139
|
+
start_time?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export declare namespace Metrics {
|
|
143
|
+
export {
|
|
144
|
+
type VMMetricPoint as VMMetricPoint,
|
|
145
|
+
type VMMetricSeries as VMMetricSeries,
|
|
146
|
+
type VMMetrics as VMMetrics,
|
|
147
|
+
type MetricListParams as MetricListParams,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -29,7 +29,25 @@ export class OSImages extends APIResource {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export interface OSImageListParams extends CursorParams {
|
|
32
|
+
export interface OSImageListParams extends CursorParams {
|
|
33
|
+
/**
|
|
34
|
+
* Filter by a case-insensitive substring of the OS Image display name
|
|
35
|
+
*/
|
|
36
|
+
display_name?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Filter by a case-insensitive substring of the OS Image name
|
|
40
|
+
*/
|
|
41
|
+
name?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Comma-separated sort terms in precedence order, each field:asc or field:desc.
|
|
45
|
+
* Fields: created_at, name, display_name, position. An image name embeds its
|
|
46
|
+
* version, so name:asc is lexicographic rather than newest-first; position is the
|
|
47
|
+
* catalog's intended display order.
|
|
48
|
+
*/
|
|
49
|
+
sort?: string;
|
|
50
|
+
}
|
|
33
51
|
|
|
34
52
|
export declare namespace OSImages {
|
|
35
53
|
export { type OSImageListParams as OSImageListParams };
|
|
@@ -7,6 +7,10 @@ import * as AvailabilityAPI from './availability';
|
|
|
7
7
|
import { Availability, AvailabilityCreateParams, AvailabilityUpdateParams } from './availability';
|
|
8
8
|
import * as CostAPI from './cost';
|
|
9
9
|
import { Cost, CostCreateParams, CostUpdateParams } from './cost';
|
|
10
|
+
import * as MetricDescriptorsAPI from './metric-descriptors';
|
|
11
|
+
import { MetricDescriptors, VMMetricDescriptor, VMMetricDescriptorList } from './metric-descriptors';
|
|
12
|
+
import * as MetricsAPI from './metrics';
|
|
13
|
+
import { MetricListParams, Metrics, VMMetricPoint, VMMetricSeries, VMMetrics } from './metrics';
|
|
10
14
|
import * as OSImagesAPI from './os-images';
|
|
11
15
|
import { OSImageListParams, OSImages } from './os-images';
|
|
12
16
|
import * as VolumesAPI from './volumes';
|
|
@@ -22,6 +26,10 @@ export class VMs extends APIResource {
|
|
|
22
26
|
cost: CostAPI.Cost = new CostAPI.Cost(this._client);
|
|
23
27
|
volumes: VolumesAPI.Volumes = new VolumesAPI.Volumes(this._client);
|
|
24
28
|
osImages: OSImagesAPI.OSImages = new OSImagesAPI.OSImages(this._client);
|
|
29
|
+
metrics: MetricsAPI.Metrics = new MetricsAPI.Metrics(this._client);
|
|
30
|
+
metricDescriptors: MetricDescriptorsAPI.MetricDescriptors = new MetricDescriptorsAPI.MetricDescriptors(
|
|
31
|
+
this._client,
|
|
32
|
+
);
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* Create a VM
|
|
@@ -408,12 +416,56 @@ export interface VMListParams extends CursorParams {
|
|
|
408
416
|
* Project ID of resources to request
|
|
409
417
|
*/
|
|
410
418
|
project_id: string;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Filter by a case-insensitive substring of the VM name
|
|
422
|
+
*/
|
|
423
|
+
name?: string;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Filter by whether a public IP is enabled
|
|
427
|
+
*/
|
|
428
|
+
public_ip_enabled?: boolean;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Filter by region
|
|
432
|
+
*/
|
|
433
|
+
region?: string;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Comma-separated sort terms in precedence order, each field:asc or field:desc.
|
|
437
|
+
* Fields: created_at, updated_at, name, status, vcpu, memory
|
|
438
|
+
*/
|
|
439
|
+
sort?: string;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Filter by VM status
|
|
443
|
+
*/
|
|
444
|
+
status?: 'pending' | 'creating' | 'updating' | 'ready' | 'deleting' | 'error';
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Filter by the subnet the VM is attached to
|
|
448
|
+
*/
|
|
449
|
+
subnet_id?: string;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Filter by tags. Repeat the parameter to require several tags; a VM must carry
|
|
453
|
+
* all of them.
|
|
454
|
+
*/
|
|
455
|
+
tags?: Array<string>;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Filter by the VPC the VM is attached to
|
|
459
|
+
*/
|
|
460
|
+
vpc_id?: string;
|
|
411
461
|
}
|
|
412
462
|
|
|
413
463
|
VMs.Availability = Availability;
|
|
414
464
|
VMs.Cost = Cost;
|
|
415
465
|
VMs.Volumes = Volumes;
|
|
416
466
|
VMs.OSImages = OSImages;
|
|
467
|
+
VMs.Metrics = Metrics;
|
|
468
|
+
VMs.MetricDescriptors = MetricDescriptors;
|
|
417
469
|
|
|
418
470
|
export declare namespace VMs {
|
|
419
471
|
export {
|
|
@@ -444,4 +496,18 @@ export declare namespace VMs {
|
|
|
444
496
|
export { Volumes as Volumes, type VolumeListParams as VolumeListParams };
|
|
445
497
|
|
|
446
498
|
export { OSImages as OSImages, type OSImageListParams as OSImageListParams };
|
|
499
|
+
|
|
500
|
+
export {
|
|
501
|
+
Metrics as Metrics,
|
|
502
|
+
type VMMetricPoint as VMMetricPoint,
|
|
503
|
+
type VMMetricSeries as VMMetricSeries,
|
|
504
|
+
type VMMetrics as VMMetrics,
|
|
505
|
+
type MetricListParams as MetricListParams,
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
export {
|
|
509
|
+
MetricDescriptors as MetricDescriptors,
|
|
510
|
+
type VMMetricDescriptor as VMMetricDescriptor,
|
|
511
|
+
type VMMetricDescriptorList as VMMetricDescriptorList,
|
|
512
|
+
};
|
|
447
513
|
}
|