@openmeter/sdk 1.0.0-beta.3 → 1.0.0-beta.30

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.
@@ -3,29 +3,40 @@
3
3
  * Do not make direct changes to the file.
4
4
  */
5
5
  export interface paths {
6
- "/api/v1/events": {
6
+ '/api/v1/events': {
7
+ /** @description Retrieve latest raw events. */
8
+ get: operations['listEvents'];
7
9
  /** @description Ingest events */
8
- post: operations["ingestEvents"];
10
+ post: operations['ingestEvents'];
9
11
  };
10
- "/api/v1/meters": {
12
+ '/api/v1/meters': {
11
13
  /** @description List meters */
12
- get: operations["listMeters"];
14
+ get: operations['listMeters'];
13
15
  /** @description Create meter */
14
- post: operations["createMeter"];
16
+ post: operations['createMeter'];
15
17
  };
16
- "/api/v1/meters/{meterIdOrSlug}": {
18
+ '/api/v1/meters/{meterIdOrSlug}': {
17
19
  /** @description Get meter by slugs */
18
- get: operations["getMeter"];
20
+ get: operations['getMeter'];
19
21
  /** @description Delete meter by slug */
20
- delete: operations["deleteMeter"];
22
+ delete: operations['deleteMeter'];
21
23
  };
22
- "/api/v1/meters/{meterIdOrSlug}/values": {
23
- /** @description Get meter values */
24
- get: operations["getMeterValues"];
24
+ '/api/v1/meters/{meterIdOrSlug}/query': {
25
+ /** @description Query meter */
26
+ get: operations['queryMeter'];
25
27
  };
26
- "/api/v1/namespaces": {
27
- /** @description Create namespace */
28
- post: operations["createNamespace"];
28
+ '/api/v1/meters/{meterIdOrSlug}/subjects': {
29
+ /** @description List meter subjects */
30
+ get: operations['listMeterSubjects'];
31
+ };
32
+ '/api/v1/portal/tokens': {
33
+ post: operations['createPortalToken'];
34
+ };
35
+ '/api/v1/portal/tokens/invalidate': {
36
+ post: operations['invalidatePortalTokens'];
37
+ };
38
+ '/api/v1/portal/meters/{meterSlug}/query': {
39
+ get: operations['queryPortalMeter'];
29
40
  };
30
41
  }
31
42
  export type webhooks = Record<string, never>;
@@ -100,7 +111,7 @@ export interface components {
100
111
  * @example application/json
101
112
  * @enum {string|null}
102
113
  */
103
- datacontenttype?: "application/json" | null;
114
+ datacontenttype?: 'application/json' | null;
104
115
  /**
105
116
  * Format: uri
106
117
  * @description Identifies the schema that data adheres to.
@@ -128,6 +139,10 @@ export interface components {
128
139
  [key: string]: unknown;
129
140
  };
130
141
  };
142
+ IngestedEvent: {
143
+ event: components['schemas']['Event'];
144
+ validationError?: string;
145
+ };
131
146
  Meter: {
132
147
  /**
133
148
  * @description A unique identifier for the meter.
@@ -136,7 +151,7 @@ export interface components {
136
151
  id?: string;
137
152
  /**
138
153
  * @description A unique identifier for the meter.
139
- * @example my-meter
154
+ * @example my_meter
140
155
  */
141
156
  slug: string;
142
157
  /**
@@ -144,7 +159,8 @@ export interface components {
144
159
  * @example My Meter Description
145
160
  */
146
161
  description?: string | null;
147
- aggregation: components["schemas"]["MeterAggregation"];
162
+ aggregation: components['schemas']['MeterAggregation'];
163
+ windowSize: components['schemas']['WindowSize'];
148
164
  /**
149
165
  * @description The event type to aggregate.
150
166
  * @example api_request
@@ -154,104 +170,148 @@ export interface components {
154
170
  * @description JSONPath expression to extract the value from the event data.
155
171
  * @example $.duration_ms
156
172
  */
157
- valueProperty: string;
173
+ valueProperty?: string;
158
174
  /**
159
175
  * @description Named JSONPath expressions to extract the group by values from the event data.
160
176
  * @example {
161
- * "duration_ms": "$.duration_ms",
177
+ * "method": "$.method",
162
178
  * "path": "$.path"
163
179
  * }
164
180
  */
165
181
  groupBy?: {
166
182
  [key: string]: string;
167
183
  };
168
- windowSize: components["schemas"]["WindowSize"];
169
184
  };
170
185
  /**
171
186
  * @description The aggregation type to use for the meter.
172
187
  * @enum {string}
173
188
  */
174
- MeterAggregation: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX";
175
- /** @enum {string} */
176
- WindowSize: "MINUTE" | "HOUR" | "DAY";
177
- MeterValue: {
178
- /** @description The subject of the meter value. */
179
- subject?: string;
189
+ MeterAggregation: 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX';
190
+ /**
191
+ * @description Aggregation window size.
192
+ * @enum {string}
193
+ */
194
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
195
+ MeterQueryRow: {
196
+ value: number;
180
197
  /** Format: date-time */
181
198
  windowStart: string;
182
199
  /** Format: date-time */
183
200
  windowEnd: string;
184
- value: number;
201
+ /** @description The subject of the meter value. */
202
+ subject?: string | null;
185
203
  groupBy?: {
186
204
  [key: string]: string;
187
205
  } | null;
188
206
  };
189
- IdOrSlug: string;
190
- Namespace: {
191
- /**
192
- * @description A namespace
193
- * @example my-namesapce
194
- */
195
- namespace: string;
207
+ PortalToken: {
208
+ subject: string;
209
+ /** Format: date-time */
210
+ expiresAt: string;
211
+ token: string;
212
+ allowedMeterSlugs?: string[];
196
213
  };
214
+ IdOrSlug: string;
197
215
  };
198
216
  responses: {
199
217
  /** @description Bad Request */
200
218
  BadRequestProblemResponse: {
201
219
  content: {
202
- "application/problem+json": components["schemas"]["Problem"];
220
+ 'application/problem+json': components['schemas']['Problem'];
221
+ };
222
+ };
223
+ /** @description Unauthorized */
224
+ UnauthorizedProblemResponse: {
225
+ content: {
226
+ 'application/problem+json': components['schemas']['Problem'];
203
227
  };
204
228
  };
205
229
  /** @description Method not allowed, feature not supported */
206
230
  MethodNotAllowedProblemResponse: {
207
231
  content: {
208
- "application/problem+json": components["schemas"]["Problem"];
232
+ 'application/problem+json': components['schemas']['Problem'];
209
233
  };
210
234
  };
211
235
  /** @description Not Found */
212
236
  NotFoundProblemResponse: {
213
237
  content: {
214
- "application/problem+json": components["schemas"]["Problem"];
238
+ 'application/problem+json': components['schemas']['Problem'];
215
239
  };
216
240
  };
217
241
  /** @description Not Implemented */
218
242
  NotImplementedProblemResponse: {
219
243
  content: {
220
- "application/problem+json": components["schemas"]["Problem"];
244
+ 'application/problem+json': components['schemas']['Problem'];
221
245
  };
222
246
  };
223
247
  /** @description Unexpected error */
224
248
  UnexpectedProblemResponse: {
225
249
  content: {
226
- "application/problem+json": components["schemas"]["Problem"];
250
+ 'application/problem+json': components['schemas']['Problem'];
227
251
  };
228
252
  };
229
253
  };
230
254
  parameters: {
231
255
  /** @description A unique identifier for the meter. */
232
- meterIdOrSlug: components["schemas"]["IdOrSlug"];
256
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
233
257
  /**
234
- * @description Optional namespace
235
- * @default default
258
+ * @description Start date-time in RFC 3339 format.
259
+ * Inclusive.
236
260
  */
237
- namespaceParam?: string;
261
+ queryFrom?: string;
262
+ /**
263
+ * @description End date-time in RFC 3339 format.
264
+ * Inclusive.
265
+ */
266
+ queryTo?: string;
267
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
268
+ queryWindowSize?: components['schemas']['WindowSize'];
269
+ /**
270
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
271
+ * If not specified, the UTC timezone will be used.
272
+ */
273
+ queryWindowTimeZone?: string;
274
+ querySubject?: string[];
275
+ /**
276
+ * @description If not specified a single aggregate will be returned for each subject and time window.
277
+ * `subject` is a reserved group by value.
278
+ */
279
+ queryGroupBy?: string[];
238
280
  };
239
281
  requestBodies: never;
240
282
  headers: never;
241
283
  pathItems: never;
242
284
  }
285
+ export type $defs = Record<string, never>;
243
286
  export type external = Record<string, never>;
244
287
  export interface operations {
245
- /** @description Ingest events */
246
- ingestEvents: {
288
+ /** @description Retrieve latest raw events. */
289
+ listEvents: {
247
290
  parameters: {
248
- header?: {
249
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
291
+ query?: {
292
+ from?: components['parameters']['queryFrom'];
293
+ to?: components['parameters']['queryTo'];
294
+ /** @description Number of events to return. */
295
+ limit?: number;
296
+ };
297
+ };
298
+ responses: {
299
+ /** @description Events response */
300
+ 200: {
301
+ content: {
302
+ 'application/json': components['schemas']['IngestedEvent'][];
303
+ };
250
304
  };
305
+ 400: components['responses']['BadRequestProblemResponse'];
306
+ default: components['responses']['UnexpectedProblemResponse'];
251
307
  };
308
+ };
309
+ /** @description Ingest events */
310
+ ingestEvents: {
252
311
  requestBody: {
253
312
  content: {
254
- "application/cloudevents+json": components["schemas"]["Event"];
313
+ 'application/cloudevents+json': components['schemas']['Event'];
314
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
255
315
  };
256
316
  };
257
317
  responses: {
@@ -259,80 +319,64 @@ export interface operations {
259
319
  204: {
260
320
  content: never;
261
321
  };
262
- 400: components["responses"]["BadRequestProblemResponse"];
263
- default: components["responses"]["UnexpectedProblemResponse"];
322
+ 400: components['responses']['BadRequestProblemResponse'];
323
+ default: components['responses']['UnexpectedProblemResponse'];
264
324
  };
265
325
  };
266
326
  /** @description List meters */
267
327
  listMeters: {
268
- parameters: {
269
- header?: {
270
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
271
- };
272
- };
273
328
  responses: {
274
329
  /** @description Meters response */
275
330
  200: {
276
331
  content: {
277
- "application/json": components["schemas"]["Meter"][];
332
+ 'application/json': components['schemas']['Meter'][];
278
333
  };
279
334
  };
280
- default: components["responses"]["UnexpectedProblemResponse"];
335
+ default: components['responses']['UnexpectedProblemResponse'];
281
336
  };
282
337
  };
283
338
  /** @description Create meter */
284
339
  createMeter: {
285
- parameters: {
286
- header?: {
287
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
288
- };
289
- };
290
340
  requestBody: {
291
341
  content: {
292
- "application/json": components["schemas"]["Meter"];
342
+ 'application/json': components['schemas']['Meter'];
293
343
  };
294
344
  };
295
345
  responses: {
296
346
  /** @description Created */
297
347
  201: {
298
348
  content: {
299
- "application/json": components["schemas"]["Meter"];
349
+ 'application/json': components['schemas']['Meter'];
300
350
  };
301
351
  };
302
- 400: components["responses"]["BadRequestProblemResponse"];
303
- 501: components["responses"]["NotImplementedProblemResponse"];
304
- default: components["responses"]["UnexpectedProblemResponse"];
352
+ 400: components['responses']['BadRequestProblemResponse'];
353
+ 501: components['responses']['NotImplementedProblemResponse'];
354
+ default: components['responses']['UnexpectedProblemResponse'];
305
355
  };
306
356
  };
307
357
  /** @description Get meter by slugs */
308
358
  getMeter: {
309
359
  parameters: {
310
- header?: {
311
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
312
- };
313
360
  path: {
314
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
361
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
315
362
  };
316
363
  };
317
364
  responses: {
318
365
  /** @description OK */
319
366
  200: {
320
367
  content: {
321
- "application/json": components["schemas"]["Meter"];
368
+ 'application/json': components['schemas']['Meter'];
322
369
  };
323
370
  };
324
- 404: components["responses"]["NotFoundProblemResponse"];
325
- default: components["responses"]["UnexpectedProblemResponse"];
371
+ 404: components['responses']['NotFoundProblemResponse'];
372
+ default: components['responses']['UnexpectedProblemResponse'];
326
373
  };
327
374
  };
328
375
  /** @description Delete meter by slug */
329
376
  deleteMeter: {
330
377
  parameters: {
331
- header?: {
332
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
333
- };
334
378
  path: {
335
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
379
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
336
380
  };
337
381
  };
338
382
  responses: {
@@ -340,75 +384,128 @@ export interface operations {
340
384
  204: {
341
385
  content: never;
342
386
  };
343
- 404: components["responses"]["NotFoundProblemResponse"];
344
- 501: components["responses"]["NotImplementedProblemResponse"];
345
- default: components["responses"]["UnexpectedProblemResponse"];
387
+ 404: components['responses']['NotFoundProblemResponse'];
388
+ 501: components['responses']['NotImplementedProblemResponse'];
389
+ default: components['responses']['UnexpectedProblemResponse'];
346
390
  };
347
391
  };
348
- /** @description Get meter values */
349
- getMeterValues: {
392
+ /** @description Query meter */
393
+ queryMeter: {
350
394
  parameters: {
351
395
  query?: {
352
- subject?: string;
353
- /**
354
- * @description Start date-time in RFC 3339 format.
355
- * Must be aligned with the window size.
356
- * Inclusive.
357
- */
358
- from?: string;
359
- /**
360
- * @description End date-time in RFC 3339 format.
361
- * Must be aligned with the window size.
362
- * Inclusive.
363
- */
364
- to?: string;
365
- /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
366
- windowSize?: components["schemas"]["WindowSize"];
367
- /**
368
- * @description If not specified, OpenMeter will use the default aggregation type.
369
- * As OpenMeter stores aggregates defined by meter config, passing a different aggregate can lead to inaccurate results.
370
- * For example getting the MIN of SUMs.
371
- */
372
- aggregation?: components["schemas"]["MeterAggregation"];
373
- /** @description If not specified a single aggregate will be returned for each subject and time window. */
374
- groupBy?: string;
375
- };
376
- header?: {
377
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
396
+ from?: components['parameters']['queryFrom'];
397
+ to?: components['parameters']['queryTo'];
398
+ windowSize?: components['parameters']['queryWindowSize'];
399
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
400
+ subject?: components['parameters']['querySubject'];
401
+ groupBy?: components['parameters']['queryGroupBy'];
378
402
  };
379
403
  path: {
380
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
404
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
381
405
  };
382
406
  };
383
407
  responses: {
384
408
  /** @description OK */
385
409
  200: {
386
410
  content: {
387
- "application/json": {
388
- windowSize?: components["schemas"]["WindowSize"];
389
- data: components["schemas"]["MeterValue"][];
411
+ 'application/json': {
412
+ /** Format: date-time */
413
+ from?: string;
414
+ /** Format: date-time */
415
+ to?: string;
416
+ windowSize?: components['schemas']['WindowSize'];
417
+ data: components['schemas']['MeterQueryRow'][];
390
418
  };
419
+ 'text/csv': string;
391
420
  };
392
421
  };
393
- 400: components["responses"]["BadRequestProblemResponse"];
394
- default: components["responses"]["UnexpectedProblemResponse"];
422
+ 400: components['responses']['BadRequestProblemResponse'];
423
+ default: components['responses']['UnexpectedProblemResponse'];
395
424
  };
396
425
  };
397
- /** @description Create namespace */
398
- createNamespace: {
399
- requestBody: {
426
+ /** @description List meter subjects */
427
+ listMeterSubjects: {
428
+ parameters: {
429
+ path: {
430
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
431
+ };
432
+ };
433
+ responses: {
434
+ /** @description OK */
435
+ 200: {
436
+ content: {
437
+ 'application/json': string[];
438
+ };
439
+ };
440
+ 400: components['responses']['BadRequestProblemResponse'];
441
+ default: components['responses']['UnexpectedProblemResponse'];
442
+ };
443
+ };
444
+ createPortalToken: {
445
+ requestBody?: {
400
446
  content: {
401
- "application/json": components["schemas"]["Namespace"];
447
+ 'application/json': components['schemas']['PortalToken'];
402
448
  };
403
449
  };
404
450
  responses: {
405
- /** @description Created */
406
- 201: {
451
+ /** @description OK */
452
+ 200: {
407
453
  content: {
408
- "application/json": components["schemas"]["Namespace"];
454
+ 'application/json': components['schemas']['PortalToken'];
455
+ };
456
+ };
457
+ 400: components['responses']['BadRequestProblemResponse'];
458
+ default: components['responses']['UnexpectedProblemResponse'];
459
+ };
460
+ };
461
+ invalidatePortalTokens: {
462
+ requestBody?: {
463
+ content: {
464
+ 'application/json': {
465
+ subject?: string;
466
+ };
467
+ };
468
+ };
469
+ responses: {
470
+ /** @description No Content */
471
+ 204: {
472
+ content: never;
473
+ };
474
+ 400: components['responses']['BadRequestProblemResponse'];
475
+ default: components['responses']['UnexpectedProblemResponse'];
476
+ };
477
+ };
478
+ queryPortalMeter: {
479
+ parameters: {
480
+ query?: {
481
+ from?: components['parameters']['queryFrom'];
482
+ to?: components['parameters']['queryTo'];
483
+ windowSize?: components['parameters']['queryWindowSize'];
484
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
485
+ groupBy?: components['parameters']['queryGroupBy'];
486
+ };
487
+ path: {
488
+ meterSlug: string;
489
+ };
490
+ };
491
+ responses: {
492
+ /** @description OK */
493
+ 200: {
494
+ content: {
495
+ 'application/json': {
496
+ /** Format: date-time */
497
+ from?: string;
498
+ /** Format: date-time */
499
+ to?: string;
500
+ windowSize?: components['schemas']['WindowSize'];
501
+ data: components['schemas']['MeterQueryRow'][];
502
+ };
503
+ 'text/csv': string;
409
504
  };
410
505
  };
411
- default: components["responses"]["UnexpectedProblemResponse"];
506
+ 400: components['responses']['BadRequestProblemResponse'];
507
+ 401: components['responses']['UnauthorizedProblemResponse'];
508
+ default: components['responses']['UnexpectedProblemResponse'];
412
509
  };
413
510
  };
414
511
  }