@openmeter/sdk 1.0.0-beta.63 → 1.0.0-beta.64

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.
Files changed (52) hide show
  1. package/dist/cjs/clients/client.cjs +117 -0
  2. package/dist/cjs/clients/client.d.cts +40 -0
  3. package/dist/cjs/clients/client.js.map +1 -0
  4. package/dist/cjs/clients/event.cjs +71 -0
  5. package/dist/cjs/clients/event.d.cts +79 -0
  6. package/dist/cjs/clients/event.js.map +1 -0
  7. package/dist/cjs/clients/meter.cjs +69 -0
  8. package/dist/cjs/clients/meter.d.cts +75 -0
  9. package/dist/cjs/clients/meter.js.map +1 -0
  10. package/dist/cjs/clients/portal.cjs +41 -0
  11. package/dist/cjs/clients/portal.d.cts +22 -0
  12. package/dist/cjs/clients/portal.js.map +1 -0
  13. package/dist/cjs/clients/subject.cjs +60 -0
  14. package/dist/cjs/clients/subject.d.cts +27 -0
  15. package/dist/cjs/clients/subject.js.map +1 -0
  16. package/dist/cjs/index.cjs +24 -0
  17. package/dist/cjs/index.d.cts +15 -0
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/schemas/openapi.cjs +7 -0
  20. package/dist/cjs/schemas/openapi.d.cts +990 -0
  21. package/dist/cjs/schemas/openapi.js.map +1 -0
  22. package/dist/cjs/test/agent.cjs +266 -0
  23. package/dist/cjs/test/agent.d.cts +2 -0
  24. package/dist/cjs/test/agent.js.map +1 -0
  25. package/dist/cjs/test/mocks.cjs +44 -0
  26. package/dist/cjs/test/mocks.d.cts +14 -0
  27. package/dist/cjs/test/mocks.js.map +1 -0
  28. package/dist/cjs/tsconfig.95235403.tsbuildinfo +1 -0
  29. package/dist/clients/client.js +112 -0
  30. package/dist/clients/client.js.map +1 -0
  31. package/dist/clients/event.js +64 -0
  32. package/dist/clients/event.js.map +1 -0
  33. package/dist/clients/meter.js +65 -0
  34. package/dist/clients/meter.js.map +1 -0
  35. package/dist/clients/portal.js +37 -0
  36. package/dist/clients/portal.js.map +1 -0
  37. package/dist/clients/subject.js +56 -0
  38. package/dist/clients/subject.js.map +1 -0
  39. package/dist/index.js +7 -335
  40. package/dist/index.js.map +1 -1
  41. package/dist/schemas/openapi.js +6 -0
  42. package/dist/schemas/openapi.js.map +1 -0
  43. package/dist/test/agent.js +263 -0
  44. package/dist/test/agent.js.map +1 -0
  45. package/dist/test/mocks.js +41 -0
  46. package/dist/test/mocks.js.map +1 -0
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +21 -13
  49. package/dist/index.cjs +0 -348
  50. package/dist/index.cjs.map +0 -1
  51. package/index.ts +0 -23
  52. package/rollup.config.js +0 -22
@@ -0,0 +1,990 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+ export interface paths {
6
+ '/api/v1/events': {
7
+ /**
8
+ * List ingested events
9
+ * @description List ingested events within a time range.
10
+ */
11
+ get: operations['listEvents'];
12
+ /**
13
+ * Ingest events
14
+ * @description Ingests an event or batch of events following the CloudEvents specification.
15
+ */
16
+ post: operations['ingestEvents'];
17
+ };
18
+ '/api/v1/meters': {
19
+ /**
20
+ * List meters
21
+ * @description List meters.
22
+ */
23
+ get: operations['listMeters'];
24
+ /**
25
+ * ☁ Create meter
26
+ * @description *Available in OpenMeter Cloud.*
27
+ * *In the open-source version, meters are created in the configuration file.*
28
+ *
29
+ * Create a meter.
30
+ */
31
+ post: operations['createMeter'];
32
+ };
33
+ '/api/v1/meters/{meterIdOrSlug}': {
34
+ /**
35
+ * Get meter
36
+ * @description Get meter by ID or slug
37
+ */
38
+ get: operations['getMeter'];
39
+ /**
40
+ * ☁ Delete meter
41
+ * @description *Available in OpenMeter Cloud.*
42
+ *
43
+ * Delete a meter by ID or slug.
44
+ */
45
+ delete: operations['deleteMeter'];
46
+ };
47
+ '/api/v1/meters/{meterIdOrSlug}/query': {
48
+ /**
49
+ * Query meter
50
+ * @description Query meter for usage.
51
+ */
52
+ get: operations['queryMeter'];
53
+ };
54
+ '/api/v1/meters/{meterIdOrSlug}/subjects': {
55
+ /**
56
+ * List meter subjects
57
+ * @description List subjects for a meter.
58
+ */
59
+ get: operations['listMeterSubjects'];
60
+ };
61
+ '/api/v1/portal/tokens': {
62
+ /**
63
+ * ☁ List portal tokens
64
+ * @description *Available in OpenMeter Cloud.*
65
+ *
66
+ * List consumer portal tokens.
67
+ */
68
+ get: operations['listPortalTokens'];
69
+ /**
70
+ * Create portal token
71
+ * @description Create a consumer portal token.
72
+ */
73
+ post: operations['createPortalToken'];
74
+ };
75
+ '/api/v1/portal/tokens/invalidate': {
76
+ /**
77
+ * ☁ Invalidate portal tokens
78
+ * @description *Available in OpenMeter Cloud.*
79
+ *
80
+ * Invalidates consumer portal tokens by ID or subject.
81
+ */
82
+ post: operations['invalidatePortalTokens'];
83
+ };
84
+ '/api/v1/subjects': {
85
+ /**
86
+ * ☁ List subjects
87
+ * @description *Available in OpenMeter Cloud.*
88
+ *
89
+ * List subjects.
90
+ */
91
+ get: operations['listSubjects'];
92
+ /**
93
+ * ☁ Upsert subject
94
+ * @description *Available in OpenMeter Cloud.*
95
+ *
96
+ * Upserts a subject. Creates or updates subject.
97
+ * If the subject doesn't exist, it will be created.
98
+ * If the subject exists, it will be partially updated with the provided fields.
99
+ */
100
+ post: operations['upsertSubject'];
101
+ };
102
+ '/api/v1/subjects/{subjectIdOrKey}': {
103
+ /**
104
+ * ☁ Get subject
105
+ * @description *Available in OpenMeter Cloud.*
106
+ *
107
+ * Get subject by ID or key.
108
+ */
109
+ get: operations['getSubject'];
110
+ /**
111
+ * ☁ Delete subject
112
+ * @description *Available in OpenMeter Cloud.*
113
+ *
114
+ * Delete a subject by ID or key.
115
+ */
116
+ delete: operations['deleteSubject'];
117
+ };
118
+ '/api/v1/portal/meters/{meterSlug}/query': {
119
+ /**
120
+ * Query portal meter
121
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
122
+ */
123
+ get: operations['queryPortalMeter'];
124
+ };
125
+ }
126
+ export type webhooks = Record<string, never>;
127
+ export interface components {
128
+ schemas: {
129
+ /**
130
+ * @description A Problem Details object (RFC 7807).
131
+ * Additional properties specific to the problem type may be present.
132
+ * @example {
133
+ * "type": "urn:problem-type:bad-request",
134
+ * "title": "Bad Request",
135
+ * "status": 400,
136
+ * "detail": "body must be a JSON object"
137
+ * }
138
+ */
139
+ Problem: {
140
+ /**
141
+ * Format: uri
142
+ * @description Type contains a URI that identifies the problem type.
143
+ * @example urn:problem-type:bad-request
144
+ */
145
+ type: string;
146
+ /**
147
+ * @description A a short, human-readable summary of the problem type.
148
+ * @example Bad Request
149
+ */
150
+ title: string;
151
+ /**
152
+ * Format: int32
153
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
154
+ * @example 400
155
+ */
156
+ status: number;
157
+ /**
158
+ * @description A human-readable explanation specific to this occurrence of the problem.
159
+ * @example body must be a JSON object
160
+ */
161
+ detail: string;
162
+ /**
163
+ * Format: uri
164
+ * @description A URI reference that identifies the specific occurrence of the problem.
165
+ * @example urn:request:local/JMOlctsKV8-000001
166
+ */
167
+ instance?: string;
168
+ [key: string]: unknown;
169
+ };
170
+ /**
171
+ * @description CloudEvents Specification JSON Schema
172
+ * @example {
173
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3c",
174
+ * "source": "service-name",
175
+ * "specversion": "1.0",
176
+ * "type": "prompt",
177
+ * "subject": "customer-id",
178
+ * "time": "2023-01-01T01:01:01.001Z",
179
+ * "data": {
180
+ * "tokens": "1234",
181
+ * "model": "gpt-4-turbo",
182
+ * "type": "input"
183
+ * }
184
+ * }
185
+ */
186
+ Event: {
187
+ /**
188
+ * @description Identifies the event.
189
+ * @example 5c10fade-1c9e-4d6c-8275-c52c36731d3c
190
+ */
191
+ id: string;
192
+ /**
193
+ * Format: uri-reference
194
+ * @description Identifies the context in which an event happened.
195
+ * @example service-name
196
+ */
197
+ source: string;
198
+ /**
199
+ * @description The version of the CloudEvents specification which the event uses.
200
+ * @example 1.0
201
+ */
202
+ specversion: string;
203
+ /**
204
+ * @description Describes the type of event related to the originating occurrence.
205
+ * @example prompt
206
+ */
207
+ type: string;
208
+ /**
209
+ * @description Content type of the data value. Must adhere to RFC 2046 format.
210
+ * @example application/json
211
+ * @enum {string|null}
212
+ */
213
+ datacontenttype?: 'application/json' | null;
214
+ /**
215
+ * Format: uri
216
+ * @description Identifies the schema that data adheres to.
217
+ */
218
+ dataschema?: string | null;
219
+ /**
220
+ * @description Describes the subject of the event in the context of the event producer (identified by source).
221
+ * @example customer-id
222
+ */
223
+ subject: string;
224
+ /**
225
+ * Format: date-time
226
+ * @description Timestamp of when the occurrence happened. Must adhere to RFC 3339.
227
+ * @example 2023-01-01T01:01:01.001Z
228
+ */
229
+ time?: string | null;
230
+ /**
231
+ * @description The event payload.
232
+ * @example {
233
+ * "tokens": "1234",
234
+ * "model": "gpt-4-turbo"
235
+ * }
236
+ */
237
+ data?: {
238
+ [key: string]: unknown;
239
+ };
240
+ };
241
+ /**
242
+ * @description An ingested event with optional validation error.
243
+ * @example {
244
+ * "event": {
245
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3d",
246
+ * "source": "service-name",
247
+ * "specversion": "1.0",
248
+ * "type": "prompt",
249
+ * "subject": "customer-id",
250
+ * "time": "2023-01-01T01:01:01.001Z",
251
+ * "data": {
252
+ * "tokens": "1234",
253
+ * "model": "gpt-4-turbo"
254
+ * }
255
+ * },
256
+ * "validationError": "meter not found for event"
257
+ * }
258
+ */
259
+ IngestedEvent: {
260
+ event: components['schemas']['Event'];
261
+ /** @example invalid event */
262
+ validationError?: string;
263
+ };
264
+ /**
265
+ * @description A meter is a configuration that defines how to match and aggregate events.
266
+ * @example {
267
+ * "slug": "tokens_total",
268
+ * "description": "AI token usage",
269
+ * "aggregation": "SUM",
270
+ * "windowSize": "MINUTE",
271
+ * "eventType": "prompt",
272
+ * "valueProperty": "$.tokens",
273
+ * "groupBy": {
274
+ * "model": "$.model",
275
+ * "type": "$.type"
276
+ * }
277
+ * }
278
+ */
279
+ Meter: {
280
+ /**
281
+ * @description A unique identifier for the meter.
282
+ * @example 01G65Z755AFWAKHE12NY0CQ9FH
283
+ */
284
+ id?: string;
285
+ /**
286
+ * @description A unique, human-readable identifier for the meter. Must consist only alphanumeric and underscore characters.
287
+ * @example tokens_total
288
+ */
289
+ slug: string;
290
+ /**
291
+ * @description A description of the meter.
292
+ * @example AI Token Usage
293
+ */
294
+ description?: string | null;
295
+ aggregation: components['schemas']['MeterAggregation'];
296
+ windowSize: components['schemas']['WindowSize'];
297
+ /**
298
+ * @description The event type to aggregate.
299
+ * @example prompt
300
+ */
301
+ eventType: string;
302
+ /**
303
+ * @description JSONPath expression to extract the value from the ingested event's data property.
304
+ * The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a string that can be parsed to a number.
305
+ * For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT aggregation the valueProperty is ignored.
306
+ *
307
+ * @example $.tokens
308
+ */
309
+ valueProperty?: string;
310
+ /**
311
+ * @description Named JSONPath expressions to extract the group by values from the event data. Keys must be unique and consist only alphanumeric and underscore characters.
312
+ * @example {
313
+ * "model": "$.model",
314
+ * "type": "$.type"
315
+ * }
316
+ */
317
+ groupBy?: {
318
+ [key: string]: string;
319
+ };
320
+ };
321
+ /**
322
+ * @description The aggregation type to use for the meter.
323
+ * @example SUM
324
+ * @enum {string}
325
+ */
326
+ MeterAggregation: 'SUM' | 'COUNT' | 'UNIQUE_COUNT' | 'AVG' | 'MIN' | 'MAX';
327
+ /**
328
+ * @description Aggregation window size.
329
+ * @example MINUTE
330
+ * @enum {string}
331
+ */
332
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
333
+ /**
334
+ * @description The result of a meter query.
335
+ * @example {
336
+ * "from": "2023-01-01T00:00:00Z",
337
+ * "to": "2023-01-02T00:00:00Z",
338
+ * "windowSize": "MINUTE",
339
+ * "data": [
340
+ * {
341
+ * "value": 12,
342
+ * "windowStart": "2023-01-01T00:00:00Z",
343
+ * "windowEnd": "2023-01-02T00:00:00Z",
344
+ * "subject": "customer-id",
345
+ * "groupBy": {
346
+ * "model": "gpt-4-turbo",
347
+ * "type": "prompt"
348
+ * }
349
+ * }
350
+ * ]
351
+ * }
352
+ */
353
+ MeterQueryResult: {
354
+ /**
355
+ * Format: date-time
356
+ * @example 2023-01-01T00:00:00Z
357
+ */
358
+ from?: string;
359
+ /**
360
+ * Format: date-time
361
+ * @example 2023-01-02T00:00:00Z
362
+ */
363
+ to?: string;
364
+ windowSize?: components['schemas']['WindowSize'];
365
+ /**
366
+ * @example [
367
+ * {
368
+ * "value": 12,
369
+ * "windowStart": "2023-01-01T00:00:00Z",
370
+ * "windowEnd": "2023-01-02T00:00:00Z",
371
+ * "subject": "customer-id",
372
+ * "groupBy": {
373
+ * "model": "gpt-4-turbo",
374
+ * "type": "prompt"
375
+ * }
376
+ * }
377
+ * ]
378
+ */
379
+ data: components['schemas']['MeterQueryRow'][];
380
+ };
381
+ /**
382
+ * @description A row in the result of a meter query.
383
+ * @example {
384
+ * "value": 12,
385
+ * "windowStart": "2023-01-01T00:00:00Z",
386
+ * "windowEnd": "2023-01-02T00:00:00Z",
387
+ * "subject": "customer-id",
388
+ * "groupBy": {
389
+ * "model": "gpt-4-turbo",
390
+ * "type": "prompt"
391
+ * }
392
+ * }
393
+ */
394
+ MeterQueryRow: {
395
+ /** @example 12 */
396
+ value: number;
397
+ /**
398
+ * Format: date-time
399
+ * @example 2023-01-01T00:00:00Z
400
+ */
401
+ windowStart: string;
402
+ /**
403
+ * Format: date-time
404
+ * @example 2023-01-02T00:00:00Z
405
+ */
406
+ windowEnd: string;
407
+ /**
408
+ * @description The subject of the meter value.
409
+ * @example customer-id
410
+ */
411
+ subject?: string | null;
412
+ /**
413
+ * @example {
414
+ * "model": "gpt-4-turbo",
415
+ * "type": "prompt"
416
+ * }
417
+ */
418
+ groupBy?: {
419
+ [key: string]: string;
420
+ } | null;
421
+ };
422
+ /**
423
+ * @description A consumer portal token.
424
+ * @example {
425
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
426
+ * "subject": "customer-id",
427
+ * "expiresAt": "2023-01-02T00:00:00Z",
428
+ * "expired": false,
429
+ * "createdAt": "2023-01-01T00:00:00Z",
430
+ * "token": "om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo",
431
+ * "allowedMeterSlugs": [
432
+ * "tokens_total"
433
+ * ]
434
+ * }
435
+ */
436
+ PortalToken: {
437
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
438
+ id?: string;
439
+ /** @example customer-id */
440
+ subject: string;
441
+ /**
442
+ * Format: date-time
443
+ * @example 2023-01-02T00:00:00Z
444
+ */
445
+ expiresAt?: string;
446
+ expired?: boolean;
447
+ /**
448
+ * Format: date-time
449
+ * @example 2023-01-01T00:00:00Z
450
+ */
451
+ createdAt?: string;
452
+ /**
453
+ * @description The token is only returned at creation.
454
+ * @example om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo
455
+ */
456
+ token?: string;
457
+ /**
458
+ * @description Optional, if defined only the specified meters will be allowed
459
+ * @example [
460
+ * "tokens_total"
461
+ * ]
462
+ */
463
+ allowedMeterSlugs?: string[];
464
+ };
465
+ /**
466
+ * @description A subject is a unique identifier for a user or entity.
467
+ * @example {
468
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
469
+ * "key": "customer-id",
470
+ * "displayName": "Customer Name",
471
+ * "metadata": {
472
+ * "hubspotId": "123456"
473
+ * },
474
+ * "currentPeriodStart": "2023-01-01T00:00:00Z",
475
+ * "currentPeriodEnd": "2023-02-01T00:00:00Z",
476
+ * "stripeCustomerId": "cus_JMOlctsKV8"
477
+ * }
478
+ */
479
+ Subject: {
480
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
481
+ id?: string;
482
+ /** @example customer-id */
483
+ key: string;
484
+ /** @example Customer Name */
485
+ displayName?: string | null;
486
+ /**
487
+ * @example {
488
+ * "hubspotId": "123456"
489
+ * }
490
+ */
491
+ metadata?: {
492
+ [key: string]: unknown;
493
+ } | null;
494
+ /**
495
+ * Format: date-time
496
+ * @example 2023-01-01T00:00:00Z
497
+ */
498
+ currentPeriodStart?: string | null;
499
+ /**
500
+ * Format: date-time
501
+ * @example 2023-02-01T00:00:00Z
502
+ */
503
+ currentPeriodEnd?: string | null;
504
+ /** @example cus_JMOlctsKV8 */
505
+ stripeCustomerId?: string | null;
506
+ };
507
+ /**
508
+ * @description A unique identifier.
509
+ * @example tokens_total
510
+ */
511
+ IdOrSlug: string;
512
+ };
513
+ responses: {
514
+ /** @description Bad Request */
515
+ BadRequestProblemResponse: {
516
+ content: {
517
+ 'application/problem+json': components['schemas']['Problem'];
518
+ };
519
+ };
520
+ /** @description Unauthorized */
521
+ UnauthorizedProblemResponse: {
522
+ content: {
523
+ 'application/problem+json': components['schemas']['Problem'];
524
+ };
525
+ };
526
+ /** @description Not Found */
527
+ NotFoundProblemResponse: {
528
+ content: {
529
+ 'application/problem+json': components['schemas']['Problem'];
530
+ };
531
+ };
532
+ /** @description Not Implemented */
533
+ NotImplementedProblemResponse: {
534
+ content: {
535
+ 'application/problem+json': components['schemas']['Problem'];
536
+ };
537
+ };
538
+ /** @description Unexpected error */
539
+ UnexpectedProblemResponse: {
540
+ content: {
541
+ 'application/problem+json': components['schemas']['Problem'];
542
+ };
543
+ };
544
+ };
545
+ parameters: {
546
+ /** @description A unique identifier for the meter. */
547
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
548
+ /** @description A unique identifier for a subject. */
549
+ subjectIdOrKey: string;
550
+ /**
551
+ * @description Start date-time in RFC 3339 format.
552
+ * Inclusive.
553
+ */
554
+ queryFrom?: string;
555
+ /**
556
+ * @description End date-time in RFC 3339 format.
557
+ * Inclusive.
558
+ */
559
+ queryTo?: string;
560
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
561
+ queryWindowSize?: components['schemas']['WindowSize'];
562
+ /**
563
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
564
+ * If not specified, the UTC timezone will be used.
565
+ */
566
+ queryWindowTimeZone?: string;
567
+ /**
568
+ * @description Filtering and group by multiple subjects.
569
+ * Usage: ?subject=customer-1&subject=customer-2
570
+ */
571
+ queryFilterSubject?: string[];
572
+ queryFilterGroupBy?: {
573
+ [key: string]: string;
574
+ };
575
+ /**
576
+ * @description If not specified a single aggregate will be returned for each subject and time window.
577
+ * `subject` is a reserved group by value.
578
+ */
579
+ queryGroupBy?: string[];
580
+ };
581
+ requestBodies: never;
582
+ headers: never;
583
+ pathItems: never;
584
+ }
585
+ export type $defs = Record<string, never>;
586
+ export type external = Record<string, never>;
587
+ export interface operations {
588
+ /**
589
+ * List ingested events
590
+ * @description List ingested events within a time range.
591
+ */
592
+ listEvents: {
593
+ parameters: {
594
+ query?: {
595
+ from?: components['parameters']['queryFrom'];
596
+ to?: components['parameters']['queryTo'];
597
+ /** @description Number of events to return */
598
+ limit?: number;
599
+ };
600
+ };
601
+ responses: {
602
+ /** @description List of events for debugging. */
603
+ 200: {
604
+ content: {
605
+ 'application/json': components['schemas']['IngestedEvent'][];
606
+ };
607
+ };
608
+ 400: components['responses']['BadRequestProblemResponse'];
609
+ 401: components['responses']['UnauthorizedProblemResponse'];
610
+ default: components['responses']['UnexpectedProblemResponse'];
611
+ };
612
+ };
613
+ /**
614
+ * Ingest events
615
+ * @description Ingests an event or batch of events following the CloudEvents specification.
616
+ */
617
+ ingestEvents: {
618
+ /**
619
+ * @description The event or batch of events to ingest.
620
+ * The request body must be a CloudEvents JSON object or an array of CloudEvents JSON objects.
621
+ * The CloudEvents JSON object must adhere to the CloudEvents Specification JSON Schema.
622
+ */
623
+ requestBody: {
624
+ content: {
625
+ 'application/cloudevents+json': components['schemas']['Event'];
626
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
627
+ };
628
+ };
629
+ responses: {
630
+ /** @description Successfully ingested. */
631
+ 204: {
632
+ content: never;
633
+ };
634
+ 400: components['responses']['BadRequestProblemResponse'];
635
+ 401: components['responses']['UnauthorizedProblemResponse'];
636
+ default: components['responses']['UnexpectedProblemResponse'];
637
+ };
638
+ };
639
+ /**
640
+ * List meters
641
+ * @description List meters.
642
+ */
643
+ listMeters: {
644
+ responses: {
645
+ /** @description List of meters. */
646
+ 200: {
647
+ content: {
648
+ 'application/json': components['schemas']['Meter'][];
649
+ };
650
+ };
651
+ 401: components['responses']['UnauthorizedProblemResponse'];
652
+ default: components['responses']['UnexpectedProblemResponse'];
653
+ };
654
+ };
655
+ /**
656
+ * ☁ Create meter
657
+ * @description *Available in OpenMeter Cloud.*
658
+ * *In the open-source version, meters are created in the configuration file.*
659
+ *
660
+ * Create a meter.
661
+ */
662
+ createMeter: {
663
+ /** @description The meter to create. */
664
+ requestBody: {
665
+ content: {
666
+ 'application/json': components['schemas']['Meter'];
667
+ };
668
+ };
669
+ responses: {
670
+ /** @description Created. */
671
+ 201: {
672
+ content: {
673
+ 'application/json': components['schemas']['Meter'];
674
+ };
675
+ };
676
+ 400: components['responses']['BadRequestProblemResponse'];
677
+ 401: components['responses']['UnauthorizedProblemResponse'];
678
+ 501: components['responses']['NotImplementedProblemResponse'];
679
+ default: components['responses']['UnexpectedProblemResponse'];
680
+ };
681
+ };
682
+ /**
683
+ * Get meter
684
+ * @description Get meter by ID or slug
685
+ */
686
+ getMeter: {
687
+ parameters: {
688
+ path: {
689
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
690
+ };
691
+ };
692
+ responses: {
693
+ /** @description Meter found. */
694
+ 200: {
695
+ content: {
696
+ 'application/json': components['schemas']['Meter'];
697
+ };
698
+ };
699
+ 404: components['responses']['NotFoundProblemResponse'];
700
+ default: components['responses']['UnexpectedProblemResponse'];
701
+ };
702
+ };
703
+ /**
704
+ * ☁ Delete meter
705
+ * @description *Available in OpenMeter Cloud.*
706
+ *
707
+ * Delete a meter by ID or slug.
708
+ */
709
+ deleteMeter: {
710
+ parameters: {
711
+ path: {
712
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
713
+ };
714
+ };
715
+ responses: {
716
+ /** @description Meter deleted. */
717
+ 204: {
718
+ content: never;
719
+ };
720
+ 404: components['responses']['NotFoundProblemResponse'];
721
+ 501: components['responses']['NotImplementedProblemResponse'];
722
+ default: components['responses']['UnexpectedProblemResponse'];
723
+ };
724
+ };
725
+ /**
726
+ * Query meter
727
+ * @description Query meter for usage.
728
+ */
729
+ queryMeter: {
730
+ parameters: {
731
+ query?: {
732
+ from?: components['parameters']['queryFrom'];
733
+ to?: components['parameters']['queryTo'];
734
+ windowSize?: components['parameters']['queryWindowSize'];
735
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
736
+ subject?: components['parameters']['queryFilterSubject'];
737
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
738
+ groupBy?: components['parameters']['queryGroupBy'];
739
+ };
740
+ path: {
741
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
742
+ };
743
+ };
744
+ responses: {
745
+ /** @description Usage data. */
746
+ 200: {
747
+ content: {
748
+ 'application/json': components['schemas']['MeterQueryResult'];
749
+ 'text/csv': string;
750
+ };
751
+ };
752
+ 400: components['responses']['BadRequestProblemResponse'];
753
+ 401: components['responses']['UnauthorizedProblemResponse'];
754
+ default: components['responses']['UnexpectedProblemResponse'];
755
+ };
756
+ };
757
+ /**
758
+ * List meter subjects
759
+ * @description List subjects for a meter.
760
+ */
761
+ listMeterSubjects: {
762
+ parameters: {
763
+ path: {
764
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
765
+ };
766
+ };
767
+ responses: {
768
+ /** @description List of subjects. */
769
+ 200: {
770
+ content: {
771
+ 'application/json': string[];
772
+ };
773
+ };
774
+ 400: components['responses']['BadRequestProblemResponse'];
775
+ default: components['responses']['UnexpectedProblemResponse'];
776
+ };
777
+ };
778
+ /**
779
+ * ☁ List portal tokens
780
+ * @description *Available in OpenMeter Cloud.*
781
+ *
782
+ * List consumer portal tokens.
783
+ */
784
+ listPortalTokens: {
785
+ parameters: {
786
+ query?: {
787
+ /** @description Number of portal tokens to return. Default is 25. */
788
+ limit?: number;
789
+ };
790
+ };
791
+ responses: {
792
+ /** @description List of portal tokens. */
793
+ 200: {
794
+ content: {
795
+ 'application/json': components['schemas']['PortalToken'][];
796
+ };
797
+ };
798
+ 400: components['responses']['BadRequestProblemResponse'];
799
+ 401: components['responses']['UnauthorizedProblemResponse'];
800
+ 501: components['responses']['NotImplementedProblemResponse'];
801
+ default: components['responses']['UnexpectedProblemResponse'];
802
+ };
803
+ };
804
+ /**
805
+ * Create portal token
806
+ * @description Create a consumer portal token.
807
+ */
808
+ createPortalToken: {
809
+ /** @description The portal token to create. */
810
+ requestBody: {
811
+ content: {
812
+ /**
813
+ * @example {
814
+ * "subject": "customer-id",
815
+ * "allowedMeterSlugs": [
816
+ * "tokens_total"
817
+ * ]
818
+ * }
819
+ */
820
+ 'application/json': components['schemas']['PortalToken'];
821
+ };
822
+ };
823
+ responses: {
824
+ /** @description Created. */
825
+ 200: {
826
+ content: {
827
+ 'application/json': components['schemas']['PortalToken'];
828
+ };
829
+ };
830
+ 400: components['responses']['BadRequestProblemResponse'];
831
+ 401: components['responses']['UnauthorizedProblemResponse'];
832
+ default: components['responses']['UnexpectedProblemResponse'];
833
+ };
834
+ };
835
+ /**
836
+ * ☁ Invalidate portal tokens
837
+ * @description *Available in OpenMeter Cloud.*
838
+ *
839
+ * Invalidates consumer portal tokens by ID or subject.
840
+ */
841
+ invalidatePortalTokens: {
842
+ /** @description If no id or subject is specified, all tokens will be invalidated. */
843
+ requestBody: {
844
+ content: {
845
+ 'application/json': {
846
+ /** @description Invalidate a portal token by ID. */
847
+ id?: string;
848
+ /** @description Invalidate all portal tokens for a subject. */
849
+ subject?: string;
850
+ };
851
+ };
852
+ };
853
+ responses: {
854
+ /** @description Portal tokens invalidated. */
855
+ 204: {
856
+ content: never;
857
+ };
858
+ 400: components['responses']['BadRequestProblemResponse'];
859
+ 401: components['responses']['UnauthorizedProblemResponse'];
860
+ 501: components['responses']['NotImplementedProblemResponse'];
861
+ default: components['responses']['UnexpectedProblemResponse'];
862
+ };
863
+ };
864
+ /**
865
+ * ☁ List subjects
866
+ * @description *Available in OpenMeter Cloud.*
867
+ *
868
+ * List subjects.
869
+ */
870
+ listSubjects: {
871
+ responses: {
872
+ /** @description List of subjects. */
873
+ 200: {
874
+ content: {
875
+ 'application/json': components['schemas']['Subject'][];
876
+ };
877
+ };
878
+ 401: components['responses']['UnauthorizedProblemResponse'];
879
+ default: components['responses']['UnexpectedProblemResponse'];
880
+ };
881
+ };
882
+ /**
883
+ * ☁ Upsert subject
884
+ * @description *Available in OpenMeter Cloud.*
885
+ *
886
+ * Upserts a subject. Creates or updates subject.
887
+ * If the subject doesn't exist, it will be created.
888
+ * If the subject exists, it will be partially updated with the provided fields.
889
+ */
890
+ upsertSubject: {
891
+ /** @description The subject to upsert. */
892
+ requestBody: {
893
+ content: {
894
+ 'application/json': components['schemas']['Subject'][];
895
+ };
896
+ };
897
+ responses: {
898
+ /** @description Subject upserted. */
899
+ 200: {
900
+ content: {
901
+ 'application/json': components['schemas']['Subject'][];
902
+ };
903
+ };
904
+ 400: components['responses']['BadRequestProblemResponse'];
905
+ 401: components['responses']['UnauthorizedProblemResponse'];
906
+ 501: components['responses']['NotImplementedProblemResponse'];
907
+ default: components['responses']['UnexpectedProblemResponse'];
908
+ };
909
+ };
910
+ /**
911
+ * ☁ Get subject
912
+ * @description *Available in OpenMeter Cloud.*
913
+ *
914
+ * Get subject by ID or key.
915
+ */
916
+ getSubject: {
917
+ parameters: {
918
+ path: {
919
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
920
+ };
921
+ };
922
+ responses: {
923
+ /** @description Subject found. */
924
+ 200: {
925
+ content: {
926
+ 'application/json': components['schemas']['Subject'];
927
+ };
928
+ };
929
+ 401: components['responses']['UnauthorizedProblemResponse'];
930
+ 404: components['responses']['NotFoundProblemResponse'];
931
+ default: components['responses']['UnexpectedProblemResponse'];
932
+ };
933
+ };
934
+ /**
935
+ * ☁ Delete subject
936
+ * @description *Available in OpenMeter Cloud.*
937
+ *
938
+ * Delete a subject by ID or key.
939
+ */
940
+ deleteSubject: {
941
+ parameters: {
942
+ path: {
943
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
944
+ };
945
+ };
946
+ responses: {
947
+ /** @description Subject deleted. */
948
+ 204: {
949
+ content: never;
950
+ };
951
+ 400: components['responses']['BadRequestProblemResponse'];
952
+ 401: components['responses']['UnauthorizedProblemResponse'];
953
+ 404: components['responses']['NotFoundProblemResponse'];
954
+ 501: components['responses']['NotImplementedProblemResponse'];
955
+ default: components['responses']['UnexpectedProblemResponse'];
956
+ };
957
+ };
958
+ /**
959
+ * Query portal meter
960
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
961
+ */
962
+ queryPortalMeter: {
963
+ parameters: {
964
+ query?: {
965
+ from?: components['parameters']['queryFrom'];
966
+ to?: components['parameters']['queryTo'];
967
+ windowSize?: components['parameters']['queryWindowSize'];
968
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
969
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
970
+ groupBy?: components['parameters']['queryGroupBy'];
971
+ };
972
+ path: {
973
+ /** @description A unique identifier for the meter. */
974
+ meterSlug: string;
975
+ };
976
+ };
977
+ responses: {
978
+ /** @description Usage data. */
979
+ 200: {
980
+ content: {
981
+ 'application/json': components['schemas']['MeterQueryResult'];
982
+ 'text/csv': string;
983
+ };
984
+ };
985
+ 400: components['responses']['BadRequestProblemResponse'];
986
+ 401: components['responses']['UnauthorizedProblemResponse'];
987
+ default: components['responses']['UnexpectedProblemResponse'];
988
+ };
989
+ };
990
+ }