@openmeter/sdk 1.0.0-beta.2 → 1.0.0-beta.22

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