@openmeter/sdk 1.0.0-beta.4 → 1.0.0-beta.40

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,54 @@
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
+ get: operations['listPortalTokens'];
34
+ post: operations['createPortalToken'];
35
+ };
36
+ '/api/v1/portal/tokens/invalidate': {
37
+ post: operations['invalidatePortalTokens'];
38
+ };
39
+ '/api/v1/subjects': {
40
+ get: operations['listSubjects'];
41
+ /**
42
+ * @description Upserts a subject. Creates or updates subject.
43
+ * If the subject doesn't exist, it will be created.
44
+ * If the subject exists, it will be partially updated with the provided fields.
45
+ */
46
+ post: operations['upsertSubject'];
47
+ };
48
+ '/api/v1/subjects/{subjectIdOrKey}': {
49
+ get: operations['getSubject'];
50
+ delete: operations['deleteSubject'];
51
+ };
52
+ '/api/v1/portal/meters/{meterSlug}/query': {
53
+ get: operations['queryPortalMeter'];
29
54
  };
30
55
  }
31
56
  export type webhooks = Record<string, never>;
@@ -100,7 +125,7 @@ export interface components {
100
125
  * @example application/json
101
126
  * @enum {string|null}
102
127
  */
103
- datacontenttype?: "application/json" | null;
128
+ datacontenttype?: 'application/json' | null;
104
129
  /**
105
130
  * Format: uri
106
131
  * @description Identifies the schema that data adheres to.
@@ -128,6 +153,10 @@ export interface components {
128
153
  [key: string]: unknown;
129
154
  };
130
155
  };
156
+ IngestedEvent: {
157
+ event: components['schemas']['Event'];
158
+ validationError?: string;
159
+ };
131
160
  Meter: {
132
161
  /**
133
162
  * @description A unique identifier for the meter.
@@ -136,7 +165,7 @@ export interface components {
136
165
  id?: string;
137
166
  /**
138
167
  * @description A unique identifier for the meter.
139
- * @example my-meter
168
+ * @example my_meter
140
169
  */
141
170
  slug: string;
142
171
  /**
@@ -144,7 +173,8 @@ export interface components {
144
173
  * @example My Meter Description
145
174
  */
146
175
  description?: string | null;
147
- aggregation: components["schemas"]["MeterAggregation"];
176
+ aggregation: components['schemas']['MeterAggregation'];
177
+ windowSize: components['schemas']['WindowSize'];
148
178
  /**
149
179
  * @description The event type to aggregate.
150
180
  * @example api_request
@@ -154,104 +184,177 @@ export interface components {
154
184
  * @description JSONPath expression to extract the value from the event data.
155
185
  * @example $.duration_ms
156
186
  */
157
- valueProperty: string;
187
+ valueProperty?: string;
158
188
  /**
159
189
  * @description Named JSONPath expressions to extract the group by values from the event data.
160
190
  * @example {
161
- * "duration_ms": "$.duration_ms",
191
+ * "method": "$.method",
162
192
  * "path": "$.path"
163
193
  * }
164
194
  */
165
195
  groupBy?: {
166
196
  [key: string]: string;
167
197
  };
168
- windowSize: components["schemas"]["WindowSize"];
169
198
  };
170
199
  /**
171
200
  * @description The aggregation type to use for the meter.
172
201
  * @enum {string}
173
202
  */
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;
203
+ MeterAggregation: 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX';
204
+ /**
205
+ * @description Aggregation window size.
206
+ * @enum {string}
207
+ */
208
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
209
+ MeterQueryResult: {
210
+ /** Format: date-time */
211
+ from?: string;
212
+ /** Format: date-time */
213
+ to?: string;
214
+ windowSize?: components['schemas']['WindowSize'];
215
+ data: components['schemas']['MeterQueryRow'][];
216
+ };
217
+ MeterQueryRow: {
218
+ value: number;
180
219
  /** Format: date-time */
181
220
  windowStart: string;
182
221
  /** Format: date-time */
183
222
  windowEnd: string;
184
- value: number;
223
+ /** @description The subject of the meter value. */
224
+ subject?: string | null;
185
225
  groupBy?: {
186
226
  [key: string]: string;
187
227
  } | null;
188
228
  };
189
- IdOrSlug: string;
190
- Namespace: {
191
- /**
192
- * @description A namespace
193
- * @example my-namesapce
194
- */
195
- namespace: string;
229
+ PortalToken: {
230
+ id: string;
231
+ subject: string;
232
+ /** Format: date-time */
233
+ expiresAt: string;
234
+ expired?: boolean;
235
+ /** Format: date-time */
236
+ createdAt: string;
237
+ /** @description The token is only returned at creation. */
238
+ token?: string;
239
+ /** @description Optional, if defined only the specified meters will be allowed */
240
+ allowedMeterSlugs?: string[];
241
+ };
242
+ Subject: {
243
+ id: string;
244
+ key: string;
245
+ displayName?: string | null;
246
+ metadata?: {
247
+ [key: string]: unknown;
248
+ };
249
+ /** Format: date-time */
250
+ currentPeriodStart?: string | null;
251
+ /** Format: date-time */
252
+ currentPeriodEnd?: string | null;
253
+ stripeCustomerId?: string | null;
196
254
  };
255
+ IdOrSlug: string;
197
256
  };
198
257
  responses: {
199
258
  /** @description Bad Request */
200
259
  BadRequestProblemResponse: {
201
260
  content: {
202
- "application/problem+json": components["schemas"]["Problem"];
261
+ 'application/problem+json': components['schemas']['Problem'];
262
+ };
263
+ };
264
+ /** @description Unauthorized */
265
+ UnauthorizedProblemResponse: {
266
+ content: {
267
+ 'application/problem+json': components['schemas']['Problem'];
203
268
  };
204
269
  };
205
270
  /** @description Method not allowed, feature not supported */
206
271
  MethodNotAllowedProblemResponse: {
207
272
  content: {
208
- "application/problem+json": components["schemas"]["Problem"];
273
+ 'application/problem+json': components['schemas']['Problem'];
209
274
  };
210
275
  };
211
276
  /** @description Not Found */
212
277
  NotFoundProblemResponse: {
213
278
  content: {
214
- "application/problem+json": components["schemas"]["Problem"];
279
+ 'application/problem+json': components['schemas']['Problem'];
215
280
  };
216
281
  };
217
282
  /** @description Not Implemented */
218
283
  NotImplementedProblemResponse: {
219
284
  content: {
220
- "application/problem+json": components["schemas"]["Problem"];
285
+ 'application/problem+json': components['schemas']['Problem'];
221
286
  };
222
287
  };
223
288
  /** @description Unexpected error */
224
289
  UnexpectedProblemResponse: {
225
290
  content: {
226
- "application/problem+json": components["schemas"]["Problem"];
291
+ 'application/problem+json': components['schemas']['Problem'];
227
292
  };
228
293
  };
229
294
  };
230
295
  parameters: {
231
296
  /** @description A unique identifier for the meter. */
232
- meterIdOrSlug: components["schemas"]["IdOrSlug"];
297
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
298
+ /** @description A unique identifier for a subject. */
299
+ subjectIdOrKey: string;
233
300
  /**
234
- * @description Optional namespace
235
- * @default default
301
+ * @description Start date-time in RFC 3339 format.
302
+ * Inclusive.
236
303
  */
237
- namespaceParam?: string;
304
+ queryFrom?: string;
305
+ /**
306
+ * @description End date-time in RFC 3339 format.
307
+ * Inclusive.
308
+ */
309
+ queryTo?: string;
310
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
311
+ queryWindowSize?: components['schemas']['WindowSize'];
312
+ /**
313
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
314
+ * If not specified, the UTC timezone will be used.
315
+ */
316
+ queryWindowTimeZone?: string;
317
+ querySubject?: string[];
318
+ /**
319
+ * @description If not specified a single aggregate will be returned for each subject and time window.
320
+ * `subject` is a reserved group by value.
321
+ */
322
+ queryGroupBy?: string[];
238
323
  };
239
324
  requestBodies: never;
240
325
  headers: never;
241
326
  pathItems: never;
242
327
  }
328
+ export type $defs = Record<string, never>;
243
329
  export type external = Record<string, never>;
244
330
  export interface operations {
245
- /** @description Ingest events */
246
- ingestEvents: {
331
+ /** @description Retrieve latest raw events. */
332
+ listEvents: {
247
333
  parameters: {
248
- header?: {
249
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
334
+ query?: {
335
+ from?: components['parameters']['queryFrom'];
336
+ to?: components['parameters']['queryTo'];
337
+ /** @description Number of events to return. */
338
+ limit?: number;
339
+ };
340
+ };
341
+ responses: {
342
+ /** @description Events response */
343
+ 200: {
344
+ content: {
345
+ 'application/json': components['schemas']['IngestedEvent'][];
346
+ };
250
347
  };
348
+ 400: components['responses']['BadRequestProblemResponse'];
349
+ default: components['responses']['UnexpectedProblemResponse'];
251
350
  };
351
+ };
352
+ /** @description Ingest events */
353
+ ingestEvents: {
252
354
  requestBody: {
253
355
  content: {
254
- "application/cloudevents+json": components["schemas"]["Event"];
356
+ 'application/cloudevents+json': components['schemas']['Event'];
357
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
255
358
  };
256
359
  };
257
360
  responses: {
@@ -259,80 +362,64 @@ export interface operations {
259
362
  204: {
260
363
  content: never;
261
364
  };
262
- 400: components["responses"]["BadRequestProblemResponse"];
263
- default: components["responses"]["UnexpectedProblemResponse"];
365
+ 400: components['responses']['BadRequestProblemResponse'];
366
+ default: components['responses']['UnexpectedProblemResponse'];
264
367
  };
265
368
  };
266
369
  /** @description List meters */
267
370
  listMeters: {
268
- parameters: {
269
- header?: {
270
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
271
- };
272
- };
273
371
  responses: {
274
372
  /** @description Meters response */
275
373
  200: {
276
374
  content: {
277
- "application/json": components["schemas"]["Meter"][];
375
+ 'application/json': components['schemas']['Meter'][];
278
376
  };
279
377
  };
280
- default: components["responses"]["UnexpectedProblemResponse"];
378
+ default: components['responses']['UnexpectedProblemResponse'];
281
379
  };
282
380
  };
283
381
  /** @description Create meter */
284
382
  createMeter: {
285
- parameters: {
286
- header?: {
287
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
288
- };
289
- };
290
383
  requestBody: {
291
384
  content: {
292
- "application/json": components["schemas"]["Meter"];
385
+ 'application/json': components['schemas']['Meter'];
293
386
  };
294
387
  };
295
388
  responses: {
296
389
  /** @description Created */
297
390
  201: {
298
391
  content: {
299
- "application/json": components["schemas"]["Meter"];
392
+ 'application/json': components['schemas']['Meter'];
300
393
  };
301
394
  };
302
- 400: components["responses"]["BadRequestProblemResponse"];
303
- 501: components["responses"]["NotImplementedProblemResponse"];
304
- default: components["responses"]["UnexpectedProblemResponse"];
395
+ 400: components['responses']['BadRequestProblemResponse'];
396
+ 501: components['responses']['NotImplementedProblemResponse'];
397
+ default: components['responses']['UnexpectedProblemResponse'];
305
398
  };
306
399
  };
307
400
  /** @description Get meter by slugs */
308
401
  getMeter: {
309
402
  parameters: {
310
- header?: {
311
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
312
- };
313
403
  path: {
314
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
404
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
315
405
  };
316
406
  };
317
407
  responses: {
318
408
  /** @description OK */
319
409
  200: {
320
410
  content: {
321
- "application/json": components["schemas"]["Meter"];
411
+ 'application/json': components['schemas']['Meter'];
322
412
  };
323
413
  };
324
- 404: components["responses"]["NotFoundProblemResponse"];
325
- default: components["responses"]["UnexpectedProblemResponse"];
414
+ 404: components['responses']['NotFoundProblemResponse'];
415
+ default: components['responses']['UnexpectedProblemResponse'];
326
416
  };
327
417
  };
328
418
  /** @description Delete meter by slug */
329
419
  deleteMeter: {
330
420
  parameters: {
331
- header?: {
332
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
333
- };
334
421
  path: {
335
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
422
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
336
423
  };
337
424
  };
338
425
  responses: {
@@ -340,75 +427,199 @@ export interface operations {
340
427
  204: {
341
428
  content: never;
342
429
  };
343
- 404: components["responses"]["NotFoundProblemResponse"];
344
- 501: components["responses"]["NotImplementedProblemResponse"];
345
- default: components["responses"]["UnexpectedProblemResponse"];
430
+ 404: components['responses']['NotFoundProblemResponse'];
431
+ 501: components['responses']['NotImplementedProblemResponse'];
432
+ default: components['responses']['UnexpectedProblemResponse'];
346
433
  };
347
434
  };
348
- /** @description Get meter values */
349
- getMeterValues: {
435
+ /** @description Query meter */
436
+ queryMeter: {
350
437
  parameters: {
351
438
  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"];
439
+ from?: components['parameters']['queryFrom'];
440
+ to?: components['parameters']['queryTo'];
441
+ windowSize?: components['parameters']['queryWindowSize'];
442
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
443
+ subject?: components['parameters']['querySubject'];
444
+ groupBy?: components['parameters']['queryGroupBy'];
378
445
  };
379
446
  path: {
380
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
447
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
381
448
  };
382
449
  };
383
450
  responses: {
384
451
  /** @description OK */
385
452
  200: {
386
453
  content: {
387
- "application/json": {
388
- windowSize?: components["schemas"]["WindowSize"];
389
- data: components["schemas"]["MeterValue"][];
390
- };
454
+ 'application/json': components['schemas']['MeterQueryResult'];
455
+ 'text/csv': string;
391
456
  };
392
457
  };
393
- 400: components["responses"]["BadRequestProblemResponse"];
394
- default: components["responses"]["UnexpectedProblemResponse"];
458
+ 400: components['responses']['BadRequestProblemResponse'];
459
+ default: components['responses']['UnexpectedProblemResponse'];
395
460
  };
396
461
  };
397
- /** @description Create namespace */
398
- createNamespace: {
399
- requestBody: {
462
+ /** @description List meter subjects */
463
+ listMeterSubjects: {
464
+ parameters: {
465
+ path: {
466
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
467
+ };
468
+ };
469
+ responses: {
470
+ /** @description OK */
471
+ 200: {
472
+ content: {
473
+ 'application/json': string[];
474
+ };
475
+ };
476
+ 400: components['responses']['BadRequestProblemResponse'];
477
+ default: components['responses']['UnexpectedProblemResponse'];
478
+ };
479
+ };
480
+ listPortalTokens: {
481
+ parameters: {
482
+ query?: {
483
+ /** @description Number of portal tokens to return. Default is 25. */
484
+ limit?: number;
485
+ };
486
+ };
487
+ responses: {
488
+ /** @description OK */
489
+ 200: {
490
+ content: {
491
+ 'application/json': components['schemas']['PortalToken'][];
492
+ };
493
+ };
494
+ 400: components['responses']['BadRequestProblemResponse'];
495
+ default: components['responses']['UnexpectedProblemResponse'];
496
+ };
497
+ };
498
+ createPortalToken: {
499
+ requestBody?: {
400
500
  content: {
401
- "application/json": components["schemas"]["Namespace"];
501
+ 'application/json': components['schemas']['PortalToken'];
402
502
  };
403
503
  };
404
504
  responses: {
405
- /** @description Created */
406
- 201: {
505
+ /** @description OK */
506
+ 200: {
507
+ content: {
508
+ 'application/json': components['schemas']['PortalToken'];
509
+ };
510
+ };
511
+ 400: components['responses']['BadRequestProblemResponse'];
512
+ default: components['responses']['UnexpectedProblemResponse'];
513
+ };
514
+ };
515
+ invalidatePortalTokens: {
516
+ requestBody?: {
517
+ content: {
518
+ 'application/json': {
519
+ /** @description Optional portal token ID to invalidate one token by. */
520
+ id?: string;
521
+ /** @description Optional subject to invalidate all tokens for subject. */
522
+ subject?: string;
523
+ };
524
+ };
525
+ };
526
+ responses: {
527
+ /** @description No Content */
528
+ 204: {
529
+ content: never;
530
+ };
531
+ 400: components['responses']['BadRequestProblemResponse'];
532
+ default: components['responses']['UnexpectedProblemResponse'];
533
+ };
534
+ };
535
+ listSubjects: {
536
+ responses: {
537
+ /** @description OK */
538
+ 200: {
539
+ content: {
540
+ 'application/json': components['schemas']['Subject'][];
541
+ };
542
+ };
543
+ default: components['responses']['UnexpectedProblemResponse'];
544
+ };
545
+ };
546
+ /**
547
+ * @description Upserts a subject. Creates or updates subject.
548
+ * If the subject doesn't exist, it will be created.
549
+ * If the subject exists, it will be partially updated with the provided fields.
550
+ */
551
+ upsertSubject: {
552
+ requestBody?: {
553
+ content: {
554
+ 'application/json': components['schemas']['Subject'];
555
+ };
556
+ };
557
+ responses: {
558
+ /** @description OK */
559
+ 200: {
560
+ content: {
561
+ 'application/json': components['schemas']['Subject'];
562
+ };
563
+ };
564
+ 400: components['responses']['BadRequestProblemResponse'];
565
+ default: components['responses']['UnexpectedProblemResponse'];
566
+ };
567
+ };
568
+ getSubject: {
569
+ parameters: {
570
+ path: {
571
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
572
+ };
573
+ };
574
+ responses: {
575
+ /** @description OK */
576
+ 200: {
577
+ content: {
578
+ 'application/json': components['schemas']['Subject'];
579
+ };
580
+ };
581
+ default: components['responses']['UnexpectedProblemResponse'];
582
+ };
583
+ };
584
+ deleteSubject: {
585
+ parameters: {
586
+ path: {
587
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
588
+ };
589
+ };
590
+ responses: {
591
+ /** @description No Content */
592
+ 204: {
593
+ content: never;
594
+ };
595
+ 400: components['responses']['BadRequestProblemResponse'];
596
+ default: components['responses']['UnexpectedProblemResponse'];
597
+ };
598
+ };
599
+ queryPortalMeter: {
600
+ parameters: {
601
+ query?: {
602
+ from?: components['parameters']['queryFrom'];
603
+ to?: components['parameters']['queryTo'];
604
+ windowSize?: components['parameters']['queryWindowSize'];
605
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
606
+ groupBy?: components['parameters']['queryGroupBy'];
607
+ };
608
+ path: {
609
+ meterSlug: string;
610
+ };
611
+ };
612
+ responses: {
613
+ /** @description OK */
614
+ 200: {
407
615
  content: {
408
- "application/json": components["schemas"]["Namespace"];
616
+ 'application/json': components['schemas']['MeterQueryResult'];
617
+ 'text/csv': string;
409
618
  };
410
619
  };
411
- default: components["responses"]["UnexpectedProblemResponse"];
620
+ 400: components['responses']['BadRequestProblemResponse'];
621
+ 401: components['responses']['UnauthorizedProblemResponse'];
622
+ default: components['responses']['UnexpectedProblemResponse'];
412
623
  };
413
624
  };
414
625
  }