@openmeter/sdk 1.0.0-beta.8 → 1.0.0-beta.80

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 (59) hide show
  1. package/README.md +76 -1
  2. package/dist/cjs/clients/client.cjs +117 -0
  3. package/dist/cjs/clients/client.d.cts +40 -0
  4. package/dist/cjs/clients/client.js.map +1 -0
  5. package/dist/cjs/clients/event.cjs +71 -0
  6. package/dist/cjs/clients/event.d.cts +79 -0
  7. package/dist/cjs/clients/event.js.map +1 -0
  8. package/dist/cjs/clients/meter.cjs +69 -0
  9. package/dist/cjs/clients/meter.d.cts +75 -0
  10. package/dist/cjs/clients/meter.js.map +1 -0
  11. package/dist/cjs/clients/portal.cjs +41 -0
  12. package/dist/cjs/clients/portal.d.cts +22 -0
  13. package/dist/cjs/clients/portal.js.map +1 -0
  14. package/dist/cjs/clients/subject.cjs +60 -0
  15. package/dist/cjs/clients/subject.d.cts +27 -0
  16. package/dist/cjs/clients/subject.js.map +1 -0
  17. package/dist/cjs/index.cjs +24 -0
  18. package/dist/cjs/index.d.cts +15 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/schemas/openapi.cjs +7 -0
  21. package/dist/cjs/schemas/openapi.d.cts +1790 -0
  22. package/dist/cjs/schemas/openapi.js.map +1 -0
  23. package/dist/cjs/test/agent.cjs +266 -0
  24. package/dist/cjs/test/agent.d.cts +2 -0
  25. package/dist/cjs/test/agent.js.map +1 -0
  26. package/dist/cjs/test/mocks.cjs +44 -0
  27. package/dist/cjs/test/mocks.d.cts +14 -0
  28. package/dist/cjs/test/mocks.js.map +1 -0
  29. package/dist/cjs/tsconfig.0fbdac75.tsbuildinfo +1 -0
  30. package/dist/cjs/tsconfig.9f533246.tsbuildinfo +1 -0
  31. package/dist/clients/client.d.ts +1 -1
  32. package/dist/clients/client.js +9 -1
  33. package/dist/clients/client.js.map +1 -0
  34. package/dist/clients/event.d.ts +16 -2
  35. package/dist/clients/event.js +43 -18
  36. package/dist/clients/event.js.map +1 -0
  37. package/dist/clients/meter.d.ts +12 -32
  38. package/dist/clients/meter.js +1 -15
  39. package/dist/clients/meter.js.map +1 -0
  40. package/dist/clients/portal.d.ts +22 -0
  41. package/dist/clients/portal.js +37 -0
  42. package/dist/clients/portal.js.map +1 -0
  43. package/dist/clients/subject.d.ts +27 -0
  44. package/dist/clients/subject.js +56 -0
  45. package/dist/clients/subject.js.map +1 -0
  46. package/dist/index.d.ts +6 -2
  47. package/dist/index.js +8 -1
  48. package/dist/index.js.map +1 -0
  49. package/dist/schemas/openapi.d.ts +1453 -178
  50. package/dist/schemas/openapi.js +1 -0
  51. package/dist/schemas/openapi.js.map +1 -0
  52. package/dist/test/agent.js +120 -28
  53. package/dist/test/agent.js.map +1 -0
  54. package/dist/test/mocks.d.ts +4 -1
  55. package/dist/test/mocks.js +20 -0
  56. package/dist/test/mocks.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +45 -31
  59. package/index.ts +0 -22
@@ -0,0 +1,1790 @@
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
+ '/api/v1/features': {
126
+ /**
127
+ * List features
128
+ * @description List features.
129
+ */
130
+ get: operations['listFeatures'];
131
+ /**
132
+ * Create feature
133
+ * @description Creates a feature.
134
+ */
135
+ post: operations['createFeature'];
136
+ };
137
+ '/api/v1/features/{featureID}': {
138
+ /**
139
+ * Get feature
140
+ * @description Get feature by key.
141
+ */
142
+ get: operations['getFeature'];
143
+ /**
144
+ * Delete feature
145
+ * @description Delete a feature by key.
146
+ */
147
+ delete: operations['deleteFeature'];
148
+ };
149
+ '/api/v1/ledgers': {
150
+ /**
151
+ * List the already defined ledgers.
152
+ * @description List the already defined ledgers.
153
+ */
154
+ get: operations['listLedgers'];
155
+ /**
156
+ * Creates the specified ledger
157
+ * @description Create or update the specified ledger.
158
+ */
159
+ post: operations['createLedger'];
160
+ };
161
+ '/api/v1/ledgers/{ledgerID}/balance': {
162
+ /**
163
+ * Get the balance of a specific subject.
164
+ * @description Get the balance of a specific subject.
165
+ */
166
+ get: operations['getLedgerBalance'];
167
+ };
168
+ '/api/v1/ledgers/{ledgerID}/history': {
169
+ /**
170
+ * Get the history of a ledger
171
+ * @description Get the history of a specific ledger
172
+ */
173
+ get: operations['getLedgerHistory'];
174
+ };
175
+ '/api/v1/ledgers/{ledgerID}/reset': {
176
+ /**
177
+ * Reset the ledger's balance
178
+ * @description Resets the ledger's balances to zero for a specific subject and re-apply active grants with rollover configuration.
179
+ */
180
+ post: operations['resetLedger'];
181
+ };
182
+ '/api/v1/ledgers/grants': {
183
+ /**
184
+ * List grants for multiple ledgers.
185
+ * @description List grants for multiple ledgers.
186
+ */
187
+ get: operations['listLedgerGrants'];
188
+ };
189
+ '/api/v1/ledgers/{ledgerID}/grants': {
190
+ /**
191
+ * List ledger grants
192
+ * @description List ledger grants for a specific ledger.
193
+ */
194
+ get: operations['listLedgerGrantsByLedger'];
195
+ /**
196
+ * Create a grant on a specific ledger.
197
+ * @description Create a grant on a specific ledger.
198
+ */
199
+ post: operations['createLedgerGrant'];
200
+ };
201
+ '/api/v1/ledgers/{ledgerID}/grants/{ledgerGrantID}': {
202
+ /**
203
+ * Get a single grant.
204
+ * @description Gets the grant for a ledger by ID.
205
+ */
206
+ get: operations['getLedgerGrant'];
207
+ /**
208
+ * Void ledger grant
209
+ * @description Void a ledger grant by ID. Partially or fully used grants cannot be voided.
210
+ * Voided grant won't be applied to the subject's balance anymore.
211
+ */
212
+ delete: operations['voidLedgerGrant'];
213
+ };
214
+ }
215
+ export type webhooks = Record<string, never>;
216
+ export interface components {
217
+ schemas: {
218
+ /**
219
+ * @description A Problem Details object (RFC 7807).
220
+ * Additional properties specific to the problem type may be present.
221
+ * @example {
222
+ * "type": "urn:problem-type:bad-request",
223
+ * "title": "Bad Request",
224
+ * "status": 400,
225
+ * "detail": "body must be a JSON object"
226
+ * }
227
+ */
228
+ Problem: {
229
+ /**
230
+ * Format: uri
231
+ * @description Type contains a URI that identifies the problem type.
232
+ * @example urn:problem-type:bad-request
233
+ */
234
+ type: string;
235
+ /**
236
+ * @description A a short, human-readable summary of the problem type.
237
+ * @example Bad Request
238
+ */
239
+ title: string;
240
+ /**
241
+ * Format: int32
242
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
243
+ * @example 400
244
+ */
245
+ status: number;
246
+ /**
247
+ * @description A human-readable explanation specific to this occurrence of the problem.
248
+ * @example body must be a JSON object
249
+ */
250
+ detail: string;
251
+ /**
252
+ * Format: uri
253
+ * @description A URI reference that identifies the specific occurrence of the problem.
254
+ * @example urn:request:local/JMOlctsKV8-000001
255
+ */
256
+ instance?: string;
257
+ [key: string]: unknown;
258
+ };
259
+ /**
260
+ * @description CloudEvents Specification JSON Schema
261
+ * @example {
262
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3c",
263
+ * "source": "service-name",
264
+ * "specversion": "1.0",
265
+ * "type": "prompt",
266
+ * "subject": "customer-id",
267
+ * "time": "2023-01-01T01:01:01.001Z",
268
+ * "data": {
269
+ * "tokens": "1234",
270
+ * "model": "gpt-4-turbo",
271
+ * "type": "input"
272
+ * }
273
+ * }
274
+ */
275
+ Event: {
276
+ /**
277
+ * @description Identifies the event.
278
+ * @example 5c10fade-1c9e-4d6c-8275-c52c36731d3c
279
+ */
280
+ id: string;
281
+ /**
282
+ * Format: uri-reference
283
+ * @description Identifies the context in which an event happened.
284
+ * @example service-name
285
+ */
286
+ source: string;
287
+ /**
288
+ * @description The version of the CloudEvents specification which the event uses.
289
+ * @example 1.0
290
+ */
291
+ specversion: string;
292
+ /**
293
+ * @description Describes the type of event related to the originating occurrence.
294
+ * @example prompt
295
+ */
296
+ type: string;
297
+ /**
298
+ * @description Content type of the data value. Must adhere to RFC 2046 format.
299
+ * @example application/json
300
+ * @enum {string|null}
301
+ */
302
+ datacontenttype?: 'application/json' | null;
303
+ /**
304
+ * Format: uri
305
+ * @description Identifies the schema that data adheres to.
306
+ */
307
+ dataschema?: string | null;
308
+ /**
309
+ * @description Describes the subject of the event in the context of the event producer (identified by source).
310
+ * @example customer-id
311
+ */
312
+ subject: string;
313
+ /**
314
+ * Format: date-time
315
+ * @description Timestamp of when the occurrence happened. Must adhere to RFC 3339.
316
+ * @example 2023-01-01T01:01:01.001Z
317
+ */
318
+ time?: string | null;
319
+ /**
320
+ * @description The event payload.
321
+ * @example {
322
+ * "tokens": "1234",
323
+ * "model": "gpt-4-turbo"
324
+ * }
325
+ */
326
+ data?: {
327
+ [key: string]: unknown;
328
+ };
329
+ };
330
+ /**
331
+ * @description An ingested event with optional validation error.
332
+ * @example {
333
+ * "event": {
334
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3d",
335
+ * "source": "service-name",
336
+ * "specversion": "1.0",
337
+ * "type": "prompt",
338
+ * "subject": "customer-id",
339
+ * "time": "2023-01-01T01:01:01.001Z",
340
+ * "data": {
341
+ * "tokens": "1234",
342
+ * "model": "gpt-4-turbo"
343
+ * }
344
+ * },
345
+ * "validationError": "meter not found for event"
346
+ * }
347
+ */
348
+ IngestedEvent: {
349
+ event: components['schemas']['Event'];
350
+ /** @example invalid event */
351
+ validationError?: string;
352
+ };
353
+ /**
354
+ * @description A feature is a feature or service offered to a customer.
355
+ * For example: CPU-Hours, Tokens, API Calls, etc.
356
+ */
357
+ Feature: {
358
+ /**
359
+ * @description Readonly unique ULID identifier of the feature.
360
+ *
361
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
362
+ */
363
+ id?: string;
364
+ /**
365
+ * @description The name of the feature.
366
+ *
367
+ * @example AI Tokens
368
+ */
369
+ name: string;
370
+ /**
371
+ * @description The meter that the feature is associated with and decreases grants by usage.
372
+ *
373
+ * @example tokens_total
374
+ */
375
+ meterSlug: string;
376
+ /**
377
+ * @description Optional meter group by filters. Useful if the meter scope is broader than what feature tracks.
378
+ *
379
+ * @example {
380
+ * "model": "gpt-4"
381
+ * }
382
+ */
383
+ meterGroupByFilters?: {
384
+ [key: string]: string;
385
+ };
386
+ /**
387
+ * @description If the feature is archived, it will not be used for grants or usage.
388
+ *
389
+ * @example false
390
+ */
391
+ archived?: boolean;
392
+ /**
393
+ * Format: date-time
394
+ * @description The time the feature was created.
395
+ *
396
+ * @example 2023-01-01T00:00:00Z
397
+ */
398
+ createdAt?: string;
399
+ /**
400
+ * Format: date-time
401
+ * @description The time the feature was last updated.
402
+ *
403
+ * @example 2023-01-01T00:00:00Z
404
+ */
405
+ updatedAt?: string;
406
+ };
407
+ /**
408
+ * @description A ledger represented in open meter. A ledger must be assigned to a single
409
+ * subject.
410
+ */
411
+ CreateLedger: {
412
+ /** @description The metering subject this ledger used to track grants for. */
413
+ subject: string;
414
+ /**
415
+ * @example {
416
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
417
+ * }
418
+ */
419
+ metadata?: {
420
+ [key: string]: string;
421
+ };
422
+ };
423
+ /**
424
+ * @description Ledger Exists
425
+ * @example {
426
+ * "type": "about:blank",
427
+ * "title": "Conflict",
428
+ * "status": 409,
429
+ * "detail": "ledger (default.01HXVNDJR532E8GTBVSC2XK5D4) already exitst for subject subject-1",
430
+ * "instance": "urn:request:local/JMOlctsKV8-000001",
431
+ * "conflictingEntity": {
432
+ * "id": "01HXVNDJR532E8GTBVSC2XK5D4",
433
+ * "subject": "subject-1"
434
+ * }
435
+ * }
436
+ */
437
+ LedgerAlreadyExistsProblem: {
438
+ /**
439
+ * Format: uri
440
+ * @description Type contains a URI that identifies the problem type.
441
+ * @example urn:problem-type:bad-request
442
+ */
443
+ type: string;
444
+ /**
445
+ * @description A a short, human-readable summary of the problem type.
446
+ * @example Bad Request
447
+ */
448
+ title: string;
449
+ /**
450
+ * Format: int32
451
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
452
+ * @example 400
453
+ */
454
+ status: number;
455
+ /**
456
+ * @description A human-readable explanation specific to this occurrence of the problem.
457
+ * @example body must be a JSON object
458
+ */
459
+ detail: string;
460
+ /**
461
+ * Format: uri
462
+ * @description A URI reference that identifies the specific occurrence of the problem.
463
+ * @example urn:request:local/JMOlctsKV8-000001
464
+ */
465
+ instance?: string;
466
+ conflictingEntity?: components['schemas']['Ledger'];
467
+ [key: string]: unknown;
468
+ };
469
+ /** @description A ledger represented in our system. */
470
+ Ledger: components['schemas']['CreateLedger'] & {
471
+ /**
472
+ * @description Readonly unique ULID identifier of the ledger.
473
+ *
474
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
475
+ */
476
+ id: string;
477
+ /**
478
+ * Format: date-time
479
+ * @description The time the ledger was created.
480
+ *
481
+ * @example 2023-01-01T00:00:00Z
482
+ */
483
+ createdAt?: string;
484
+ };
485
+ /** @description A ledger entry. */
486
+ LedgerEntry: {
487
+ /**
488
+ * @description Readonly unique ULID identifier of the ledger entry.
489
+ *
490
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
491
+ */
492
+ id: string;
493
+ type: components['schemas']['LedgerEntryType'];
494
+ /**
495
+ * Format: date-time
496
+ * @description The time the ledger entry was created.
497
+ *
498
+ * @example 2023-01-01T00:00:00Z
499
+ */
500
+ time: string;
501
+ /**
502
+ * @description The amount to apply. Can be positive or negative number. If applicable.
503
+ *
504
+ * @example 100
505
+ */
506
+ amount?: number;
507
+ period?: components['schemas']['Period'];
508
+ };
509
+ /** @description A time period */
510
+ Period: {
511
+ /**
512
+ * Format: date-time
513
+ * @description Period start time where the amount was applied. If applicable.
514
+ *
515
+ * @example 2023-01-01T00:00:00Z
516
+ */
517
+ from: string;
518
+ /**
519
+ * Format: date-time
520
+ * @description Period end time where the amount was applied. If applicable.
521
+ *
522
+ * @example 2023-01-01T00:00:00Z
523
+ */
524
+ to: string;
525
+ };
526
+ /**
527
+ * @example GRANT
528
+ * @enum {string}
529
+ */
530
+ LedgerEntryType: 'GRANT' | 'VOID' | 'RESET' | 'GRANT_USAGE';
531
+ /** @description Balance of a subject. */
532
+ LedgerBalance: {
533
+ /** @description Features with balances. */
534
+ features?: components['schemas']['FeatureBalance'][];
535
+ /** @description The grants applied to the subject. */
536
+ grants: components['schemas']['LedgerGrantBalance'][];
537
+ };
538
+ /** @description Ledger reset configuration. */
539
+ LedgerReset: {
540
+ /**
541
+ * @description Readonly unique ULID identifier of the reset.
542
+ *
543
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
544
+ */
545
+ id: string;
546
+ /**
547
+ * Format: date-time
548
+ * @description The time to reset the ledger. It cannot be in the future.
549
+ *
550
+ * @example 2023-01-01T00:00:00Z
551
+ */
552
+ effectiveAt: string;
553
+ };
554
+ LedgerGrantBalance: components['schemas']['LedgerGrantResponse'] & {
555
+ /**
556
+ * @description The balance of the grant.
557
+ *
558
+ * @example 100
559
+ */
560
+ balance?: number;
561
+ };
562
+ FeatureBalance: components['schemas']['Feature'] & {
563
+ /**
564
+ * @description The balance of the feature.
565
+ *
566
+ * @example 100
567
+ */
568
+ balance?: number;
569
+ };
570
+ /** @description Grants are used to increase balance of specific subjects. */
571
+ CreateLedgerGrantRequest: {
572
+ type: components['schemas']['LedgerGrantType'];
573
+ /**
574
+ * @description The amount to grant. Can be positive or negative number.
575
+ *
576
+ * @example 100
577
+ */
578
+ amount: number;
579
+ /**
580
+ * @description The unique feature ULID that the grant is associated with, if any.
581
+ *
582
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
583
+ */
584
+ featureID: string;
585
+ /**
586
+ * @description The priority of the grant. Grants with higher priority are applied first.
587
+ * Priority is a positive decimal numbers. With lower numbers indicating higher importance.
588
+ * For example, a priority of 1 is more urgent than a priority of 2.
589
+ * When there are several grants available for the same subject, the system selects the grant with the highest priority.
590
+ * In cases where grants share the same priority level, the grant closest to its expiration will be used first.
591
+ * In the case of two grants have identical priorities and expiration dates, the system will use the grant that was created first.
592
+ *
593
+ * @default 1
594
+ * @example 1
595
+ */
596
+ priority?: number;
597
+ /**
598
+ * Format: date-time
599
+ * @description The effective date.
600
+ *
601
+ * @example 2023-01-01T00:00:00Z
602
+ */
603
+ effectiveAt: string;
604
+ expiration: components['schemas']['LedgerGrantExpirationPeriod'];
605
+ rollover?: components['schemas']['LedgerGrantRollover'];
606
+ /**
607
+ * @example {
608
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
609
+ * }
610
+ */
611
+ metadata?: {
612
+ [key: string]: string;
613
+ };
614
+ /**
615
+ * Format: date-time
616
+ * @description The time the grant was created.
617
+ *
618
+ * @example 2023-01-01T00:00:00Z
619
+ */
620
+ createdAt?: string;
621
+ /**
622
+ * Format: date-time
623
+ * @description The time the grant was last updated.
624
+ *
625
+ * @example 2023-01-01T00:00:00Z
626
+ */
627
+ updatedAt?: string;
628
+ };
629
+ LedgerGrantResponse: components['schemas']['CreateLedgerGrantRequest'] & {
630
+ /**
631
+ * @description Readonly unique ULID identifier of the grant.
632
+ *
633
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
634
+ */
635
+ id: string;
636
+ /**
637
+ * @description The subject to grant the amount to.
638
+ *
639
+ * @example customer-id
640
+ */
641
+ subject: string;
642
+ /**
643
+ * Format: date-time
644
+ * @description The expiration date of the grant.
645
+ *
646
+ * @example 2023-01-01T00:00:00Z
647
+ */
648
+ expiresAt?: string;
649
+ };
650
+ /**
651
+ * @description The grant type:
652
+ * - `USAGE` - Increase balance by the amount in the unit of the associated meter.
653
+ *
654
+ * @example USAGE
655
+ * @enum {string}
656
+ */
657
+ LedgerGrantType: 'USAGE';
658
+ /** @description Grant rollover configuration. */
659
+ LedgerGrantRollover: {
660
+ type: components['schemas']['LedgerGrantRolloverType'];
661
+ /** @description Maximum amount to rollover. */
662
+ maxAmount?: number;
663
+ };
664
+ /**
665
+ * @description The rollover type to use:
666
+ * - `REMAINING_AMOUNT` - Rollover remaining amount.
667
+ * - `ORIGINAL_AMOUNT` - Rollover re-applies the full grant amount.
668
+ *
669
+ * @example ORIGINAL_AMOUNT
670
+ * @enum {string}
671
+ */
672
+ LedgerGrantRolloverType: 'REMAINING_AMOUNT' | 'ORIGINAL_AMOUNT';
673
+ /** @description Expiration period of a ledger grant. */
674
+ LedgerGrantExpirationPeriod: {
675
+ /**
676
+ * @description The expiration period duration like month.
677
+ *
678
+ * @enum {string}
679
+ */
680
+ duration: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
681
+ /**
682
+ * @description The expiration period count like 12 months.
683
+ *
684
+ * @example 12
685
+ */
686
+ count: number;
687
+ };
688
+ /**
689
+ * @description A meter is a configuration that defines how to match and aggregate events.
690
+ * @example {
691
+ * "slug": "tokens_total",
692
+ * "description": "AI token usage",
693
+ * "aggregation": "SUM",
694
+ * "windowSize": "MINUTE",
695
+ * "eventType": "prompt",
696
+ * "valueProperty": "$.tokens",
697
+ * "groupBy": {
698
+ * "model": "$.model",
699
+ * "type": "$.type"
700
+ * }
701
+ * }
702
+ */
703
+ Meter: {
704
+ /**
705
+ * @description A unique identifier for the meter.
706
+ * @example 01G65Z755AFWAKHE12NY0CQ9FH
707
+ */
708
+ id?: string;
709
+ /**
710
+ * @description A unique, human-readable identifier for the meter. Must consist only alphanumeric and underscore characters.
711
+ * @example tokens_total
712
+ */
713
+ slug: string;
714
+ /**
715
+ * @description A description of the meter.
716
+ * @example AI Token Usage
717
+ */
718
+ description?: string | null;
719
+ aggregation: components['schemas']['MeterAggregation'];
720
+ windowSize: components['schemas']['WindowSize'];
721
+ /**
722
+ * @description The event type to aggregate.
723
+ * @example prompt
724
+ */
725
+ eventType: string;
726
+ /**
727
+ * @description JSONPath expression to extract the value from the ingested event's data property.
728
+ * The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a string that can be parsed to a number.
729
+ * For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT aggregation the valueProperty is ignored.
730
+ *
731
+ * @example $.tokens
732
+ */
733
+ valueProperty?: string;
734
+ /**
735
+ * @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.
736
+ * @example {
737
+ * "model": "$.model",
738
+ * "type": "$.type"
739
+ * }
740
+ */
741
+ groupBy?: {
742
+ [key: string]: string;
743
+ };
744
+ };
745
+ /**
746
+ * @description The aggregation type to use for the meter.
747
+ * @example SUM
748
+ * @enum {string}
749
+ */
750
+ MeterAggregation: 'SUM' | 'COUNT' | 'UNIQUE_COUNT' | 'AVG' | 'MIN' | 'MAX';
751
+ /**
752
+ * @description Aggregation window size.
753
+ * @example MINUTE
754
+ * @enum {string}
755
+ */
756
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
757
+ /**
758
+ * @description The result of a meter query.
759
+ * @example {
760
+ * "from": "2023-01-01T00:00:00Z",
761
+ * "to": "2023-01-02T00:00:00Z",
762
+ * "windowSize": "MINUTE",
763
+ * "data": [
764
+ * {
765
+ * "value": 12,
766
+ * "windowStart": "2023-01-01T00:00:00Z",
767
+ * "windowEnd": "2023-01-02T00:00:00Z",
768
+ * "subject": "customer-id",
769
+ * "groupBy": {
770
+ * "model": "gpt-4-turbo",
771
+ * "type": "prompt"
772
+ * }
773
+ * }
774
+ * ]
775
+ * }
776
+ */
777
+ MeterQueryResult: {
778
+ /**
779
+ * Format: date-time
780
+ * @example 2023-01-01T00:00:00Z
781
+ */
782
+ from?: string;
783
+ /**
784
+ * Format: date-time
785
+ * @example 2023-01-02T00:00:00Z
786
+ */
787
+ to?: string;
788
+ windowSize?: components['schemas']['WindowSize'];
789
+ /**
790
+ * @example [
791
+ * {
792
+ * "value": 12,
793
+ * "windowStart": "2023-01-01T00:00:00Z",
794
+ * "windowEnd": "2023-01-02T00:00:00Z",
795
+ * "subject": "customer-id",
796
+ * "groupBy": {
797
+ * "model": "gpt-4-turbo",
798
+ * "type": "prompt"
799
+ * }
800
+ * }
801
+ * ]
802
+ */
803
+ data: components['schemas']['MeterQueryRow'][];
804
+ };
805
+ /**
806
+ * @description A row in the result of a meter query.
807
+ * @example {
808
+ * "value": 12,
809
+ * "windowStart": "2023-01-01T00:00:00Z",
810
+ * "windowEnd": "2023-01-02T00:00:00Z",
811
+ * "subject": "customer-id",
812
+ * "groupBy": {
813
+ * "model": "gpt-4-turbo",
814
+ * "type": "prompt"
815
+ * }
816
+ * }
817
+ */
818
+ MeterQueryRow: {
819
+ /** @example 12 */
820
+ value: number;
821
+ /**
822
+ * Format: date-time
823
+ * @example 2023-01-01T00:00:00Z
824
+ */
825
+ windowStart: string;
826
+ /**
827
+ * Format: date-time
828
+ * @example 2023-01-02T00:00:00Z
829
+ */
830
+ windowEnd: string;
831
+ /**
832
+ * @description The subject of the meter value.
833
+ * @example customer-id
834
+ */
835
+ subject?: string | null;
836
+ /**
837
+ * @example {
838
+ * "model": "gpt-4-turbo",
839
+ * "type": "prompt"
840
+ * }
841
+ */
842
+ groupBy?: {
843
+ [key: string]: string;
844
+ } | null;
845
+ };
846
+ /**
847
+ * @description A consumer portal token.
848
+ * @example {
849
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
850
+ * "subject": "customer-id",
851
+ * "expiresAt": "2023-01-02T00:00:00Z",
852
+ * "expired": false,
853
+ * "createdAt": "2023-01-01T00:00:00Z",
854
+ * "token": "om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo",
855
+ * "allowedMeterSlugs": [
856
+ * "tokens_total"
857
+ * ]
858
+ * }
859
+ */
860
+ PortalToken: {
861
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
862
+ id?: string;
863
+ /** @example customer-id */
864
+ subject: string;
865
+ /**
866
+ * Format: date-time
867
+ * @example 2023-01-02T00:00:00Z
868
+ */
869
+ expiresAt?: string;
870
+ expired?: boolean;
871
+ /**
872
+ * Format: date-time
873
+ * @example 2023-01-01T00:00:00Z
874
+ */
875
+ createdAt?: string;
876
+ /**
877
+ * @description The token is only returned at creation.
878
+ * @example om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo
879
+ */
880
+ token?: string;
881
+ /**
882
+ * @description Optional, if defined only the specified meters will be allowed
883
+ * @example [
884
+ * "tokens_total"
885
+ * ]
886
+ */
887
+ allowedMeterSlugs?: string[];
888
+ };
889
+ /**
890
+ * @description A subject is a unique identifier for a user or entity.
891
+ * @example {
892
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
893
+ * "key": "customer-id",
894
+ * "displayName": "Customer Name",
895
+ * "metadata": {
896
+ * "hubspotId": "123456"
897
+ * },
898
+ * "currentPeriodStart": "2023-01-01T00:00:00Z",
899
+ * "currentPeriodEnd": "2023-02-01T00:00:00Z",
900
+ * "stripeCustomerId": "cus_JMOlctsKV8"
901
+ * }
902
+ */
903
+ Subject: {
904
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
905
+ id?: string;
906
+ /** @example customer-id */
907
+ key: string;
908
+ /** @example Customer Name */
909
+ displayName?: string | null;
910
+ /**
911
+ * @example {
912
+ * "hubspotId": "123456"
913
+ * }
914
+ */
915
+ metadata?: {
916
+ [key: string]: unknown;
917
+ } | null;
918
+ /**
919
+ * Format: date-time
920
+ * @example 2023-01-01T00:00:00Z
921
+ */
922
+ currentPeriodStart?: string | null;
923
+ /**
924
+ * Format: date-time
925
+ * @example 2023-02-01T00:00:00Z
926
+ */
927
+ currentPeriodEnd?: string | null;
928
+ /** @example cus_JMOlctsKV8 */
929
+ stripeCustomerId?: string | null;
930
+ };
931
+ /**
932
+ * @description A unique identifier.
933
+ * @example tokens_total
934
+ */
935
+ IdOrSlug: string;
936
+ };
937
+ responses: {
938
+ /** @description Bad Request */
939
+ BadRequestProblemResponse: {
940
+ content: {
941
+ 'application/problem+json': components['schemas']['Problem'];
942
+ };
943
+ };
944
+ /** @description Unauthorized */
945
+ UnauthorizedProblemResponse: {
946
+ content: {
947
+ 'application/problem+json': components['schemas']['Problem'];
948
+ };
949
+ };
950
+ /** @description Ledger Exists */
951
+ LedgerAlreadyExistsProblemResponse: {
952
+ content: {
953
+ 'application/problem+json': components['schemas']['LedgerAlreadyExistsProblem'];
954
+ };
955
+ };
956
+ /** @description Not Found */
957
+ NotFoundProblemResponse: {
958
+ content: {
959
+ 'application/problem+json': components['schemas']['Problem'];
960
+ };
961
+ };
962
+ /** @description Not Implemented */
963
+ NotImplementedProblemResponse: {
964
+ content: {
965
+ 'application/problem+json': components['schemas']['Problem'];
966
+ };
967
+ };
968
+ /** @description Unexpected error */
969
+ UnexpectedProblemResponse: {
970
+ content: {
971
+ 'application/problem+json': components['schemas']['Problem'];
972
+ };
973
+ };
974
+ };
975
+ parameters: {
976
+ /** @description A unique identifier for the meter. */
977
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
978
+ /** @description A unique identifier for a subject. */
979
+ subjectIdOrKey: string;
980
+ /** @description A unique ULID identifier for a feature. */
981
+ featureID: string;
982
+ /** @description A unique identifier for a ledger grant. */
983
+ ledgerGrantID: string;
984
+ /** @description A unique identifier for a ledger. */
985
+ ledgerID: string;
986
+ /** @description Number of entries to return */
987
+ ledgerQueryLimit?: number;
988
+ /** @description Number of entries to skip */
989
+ ledgerQueryOffset?: number;
990
+ /**
991
+ * @description Start date-time in RFC 3339 format.
992
+ * Inclusive.
993
+ */
994
+ queryFrom?: string;
995
+ /**
996
+ * @description End date-time in RFC 3339 format.
997
+ * Inclusive.
998
+ */
999
+ queryTo?: string;
1000
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
1001
+ queryWindowSize?: components['schemas']['WindowSize'];
1002
+ /**
1003
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
1004
+ * If not specified, the UTC timezone will be used.
1005
+ */
1006
+ queryWindowTimeZone?: string;
1007
+ /**
1008
+ * @description Filtering and group by multiple subjects.
1009
+ *
1010
+ * Usage: `?ledgerID=01HX6VK5C498B3ABY9PR1069PP`
1011
+ *
1012
+ * @example 01HX6VK5C498B3ABY9PR1069PP
1013
+ */
1014
+ queryFilterLedgerID?: string;
1015
+ /**
1016
+ * @description Filtering by multiple subjects.
1017
+ *
1018
+ * Usage: ?subject=customer-1&subject=customer-2
1019
+ */
1020
+ queryFilterSubject?: string[];
1021
+ queryFilterGroupBy?: {
1022
+ [key: string]: string;
1023
+ };
1024
+ /**
1025
+ * @description If not specified a single aggregate will be returned for each subject and time window.
1026
+ * `subject` is a reserved group by value.
1027
+ */
1028
+ queryGroupBy?: string[];
1029
+ };
1030
+ requestBodies: never;
1031
+ headers: never;
1032
+ pathItems: never;
1033
+ }
1034
+ export type $defs = Record<string, never>;
1035
+ export type external = Record<string, never>;
1036
+ export interface operations {
1037
+ /**
1038
+ * List ingested events
1039
+ * @description List ingested events within a time range.
1040
+ */
1041
+ listEvents: {
1042
+ parameters: {
1043
+ query?: {
1044
+ from?: components['parameters']['queryFrom'];
1045
+ to?: components['parameters']['queryTo'];
1046
+ /** @description Number of events to return */
1047
+ limit?: number;
1048
+ };
1049
+ };
1050
+ responses: {
1051
+ /** @description List of events for debugging. */
1052
+ 200: {
1053
+ content: {
1054
+ 'application/json': components['schemas']['IngestedEvent'][];
1055
+ };
1056
+ };
1057
+ 400: components['responses']['BadRequestProblemResponse'];
1058
+ 401: components['responses']['UnauthorizedProblemResponse'];
1059
+ default: components['responses']['UnexpectedProblemResponse'];
1060
+ };
1061
+ };
1062
+ /**
1063
+ * Ingest events
1064
+ * @description Ingests an event or batch of events following the CloudEvents specification.
1065
+ */
1066
+ ingestEvents: {
1067
+ /**
1068
+ * @description The event or batch of events to ingest.
1069
+ * The request body must be a CloudEvents JSON object or an array of CloudEvents JSON objects.
1070
+ * The CloudEvents JSON object must adhere to the CloudEvents Specification JSON Schema.
1071
+ */
1072
+ requestBody: {
1073
+ content: {
1074
+ 'application/cloudevents+json': components['schemas']['Event'];
1075
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
1076
+ };
1077
+ };
1078
+ responses: {
1079
+ /** @description Successfully ingested. */
1080
+ 204: {
1081
+ content: never;
1082
+ };
1083
+ 400: components['responses']['BadRequestProblemResponse'];
1084
+ 401: components['responses']['UnauthorizedProblemResponse'];
1085
+ default: components['responses']['UnexpectedProblemResponse'];
1086
+ };
1087
+ };
1088
+ /**
1089
+ * List meters
1090
+ * @description List meters.
1091
+ */
1092
+ listMeters: {
1093
+ responses: {
1094
+ /** @description List of meters. */
1095
+ 200: {
1096
+ content: {
1097
+ 'application/json': components['schemas']['Meter'][];
1098
+ };
1099
+ };
1100
+ 401: components['responses']['UnauthorizedProblemResponse'];
1101
+ default: components['responses']['UnexpectedProblemResponse'];
1102
+ };
1103
+ };
1104
+ /**
1105
+ * ☁ Create meter
1106
+ * @description *Available in OpenMeter Cloud.*
1107
+ * *In the open-source version, meters are created in the configuration file.*
1108
+ *
1109
+ * Create a meter.
1110
+ */
1111
+ createMeter: {
1112
+ /** @description The meter to create. */
1113
+ requestBody: {
1114
+ content: {
1115
+ 'application/json': components['schemas']['Meter'];
1116
+ };
1117
+ };
1118
+ responses: {
1119
+ /** @description Created. */
1120
+ 201: {
1121
+ content: {
1122
+ 'application/json': components['schemas']['Meter'];
1123
+ };
1124
+ };
1125
+ 400: components['responses']['BadRequestProblemResponse'];
1126
+ 401: components['responses']['UnauthorizedProblemResponse'];
1127
+ 501: components['responses']['NotImplementedProblemResponse'];
1128
+ default: components['responses']['UnexpectedProblemResponse'];
1129
+ };
1130
+ };
1131
+ /**
1132
+ * Get meter
1133
+ * @description Get meter by ID or slug
1134
+ */
1135
+ getMeter: {
1136
+ parameters: {
1137
+ path: {
1138
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1139
+ };
1140
+ };
1141
+ responses: {
1142
+ /** @description Meter found. */
1143
+ 200: {
1144
+ content: {
1145
+ 'application/json': components['schemas']['Meter'];
1146
+ };
1147
+ };
1148
+ 404: components['responses']['NotFoundProblemResponse'];
1149
+ default: components['responses']['UnexpectedProblemResponse'];
1150
+ };
1151
+ };
1152
+ /**
1153
+ * ☁ Delete meter
1154
+ * @description *Available in OpenMeter Cloud.*
1155
+ *
1156
+ * Delete a meter by ID or slug.
1157
+ */
1158
+ deleteMeter: {
1159
+ parameters: {
1160
+ path: {
1161
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1162
+ };
1163
+ };
1164
+ responses: {
1165
+ /** @description Meter deleted. */
1166
+ 204: {
1167
+ content: never;
1168
+ };
1169
+ 404: components['responses']['NotFoundProblemResponse'];
1170
+ 501: components['responses']['NotImplementedProblemResponse'];
1171
+ default: components['responses']['UnexpectedProblemResponse'];
1172
+ };
1173
+ };
1174
+ /**
1175
+ * Query meter
1176
+ * @description Query meter for usage.
1177
+ */
1178
+ queryMeter: {
1179
+ parameters: {
1180
+ query?: {
1181
+ from?: components['parameters']['queryFrom'];
1182
+ to?: components['parameters']['queryTo'];
1183
+ windowSize?: components['parameters']['queryWindowSize'];
1184
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1185
+ subject?: components['parameters']['queryFilterSubject'];
1186
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1187
+ groupBy?: components['parameters']['queryGroupBy'];
1188
+ };
1189
+ path: {
1190
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1191
+ };
1192
+ };
1193
+ responses: {
1194
+ /** @description Usage data. */
1195
+ 200: {
1196
+ content: {
1197
+ 'application/json': components['schemas']['MeterQueryResult'];
1198
+ 'text/csv': string;
1199
+ };
1200
+ };
1201
+ 400: components['responses']['BadRequestProblemResponse'];
1202
+ 401: components['responses']['UnauthorizedProblemResponse'];
1203
+ default: components['responses']['UnexpectedProblemResponse'];
1204
+ };
1205
+ };
1206
+ /**
1207
+ * List meter subjects
1208
+ * @description List subjects for a meter.
1209
+ */
1210
+ listMeterSubjects: {
1211
+ parameters: {
1212
+ path: {
1213
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1214
+ };
1215
+ };
1216
+ responses: {
1217
+ /** @description List of subjects. */
1218
+ 200: {
1219
+ content: {
1220
+ 'application/json': string[];
1221
+ };
1222
+ };
1223
+ 400: components['responses']['BadRequestProblemResponse'];
1224
+ default: components['responses']['UnexpectedProblemResponse'];
1225
+ };
1226
+ };
1227
+ /**
1228
+ * ☁ List portal tokens
1229
+ * @description *Available in OpenMeter Cloud.*
1230
+ *
1231
+ * List consumer portal tokens.
1232
+ */
1233
+ listPortalTokens: {
1234
+ parameters: {
1235
+ query?: {
1236
+ /** @description Number of portal tokens to return. Default is 25. */
1237
+ limit?: number;
1238
+ };
1239
+ };
1240
+ responses: {
1241
+ /** @description List of portal tokens. */
1242
+ 200: {
1243
+ content: {
1244
+ 'application/json': components['schemas']['PortalToken'][];
1245
+ };
1246
+ };
1247
+ 400: components['responses']['BadRequestProblemResponse'];
1248
+ 401: components['responses']['UnauthorizedProblemResponse'];
1249
+ 501: components['responses']['NotImplementedProblemResponse'];
1250
+ default: components['responses']['UnexpectedProblemResponse'];
1251
+ };
1252
+ };
1253
+ /**
1254
+ * Create portal token
1255
+ * @description Create a consumer portal token.
1256
+ */
1257
+ createPortalToken: {
1258
+ /** @description The portal token to create. */
1259
+ requestBody: {
1260
+ content: {
1261
+ /**
1262
+ * @example {
1263
+ * "subject": "customer-id",
1264
+ * "allowedMeterSlugs": [
1265
+ * "tokens_total"
1266
+ * ]
1267
+ * }
1268
+ */
1269
+ 'application/json': components['schemas']['PortalToken'];
1270
+ };
1271
+ };
1272
+ responses: {
1273
+ /** @description Created. */
1274
+ 200: {
1275
+ content: {
1276
+ 'application/json': components['schemas']['PortalToken'];
1277
+ };
1278
+ };
1279
+ 400: components['responses']['BadRequestProblemResponse'];
1280
+ 401: components['responses']['UnauthorizedProblemResponse'];
1281
+ default: components['responses']['UnexpectedProblemResponse'];
1282
+ };
1283
+ };
1284
+ /**
1285
+ * ☁ Invalidate portal tokens
1286
+ * @description *Available in OpenMeter Cloud.*
1287
+ *
1288
+ * Invalidates consumer portal tokens by ID or subject.
1289
+ */
1290
+ invalidatePortalTokens: {
1291
+ /** @description If no id or subject is specified, all tokens will be invalidated. */
1292
+ requestBody: {
1293
+ content: {
1294
+ 'application/json': {
1295
+ /** @description Invalidate a portal token by ID. */
1296
+ id?: string;
1297
+ /** @description Invalidate all portal tokens for a subject. */
1298
+ subject?: string;
1299
+ };
1300
+ };
1301
+ };
1302
+ responses: {
1303
+ /** @description Portal tokens invalidated. */
1304
+ 204: {
1305
+ content: never;
1306
+ };
1307
+ 400: components['responses']['BadRequestProblemResponse'];
1308
+ 401: components['responses']['UnauthorizedProblemResponse'];
1309
+ 501: components['responses']['NotImplementedProblemResponse'];
1310
+ default: components['responses']['UnexpectedProblemResponse'];
1311
+ };
1312
+ };
1313
+ /**
1314
+ * ☁ List subjects
1315
+ * @description *Available in OpenMeter Cloud.*
1316
+ *
1317
+ * List subjects.
1318
+ */
1319
+ listSubjects: {
1320
+ responses: {
1321
+ /** @description List of subjects. */
1322
+ 200: {
1323
+ content: {
1324
+ 'application/json': components['schemas']['Subject'][];
1325
+ };
1326
+ };
1327
+ 401: components['responses']['UnauthorizedProblemResponse'];
1328
+ default: components['responses']['UnexpectedProblemResponse'];
1329
+ };
1330
+ };
1331
+ /**
1332
+ * ☁ Upsert subject
1333
+ * @description *Available in OpenMeter Cloud.*
1334
+ *
1335
+ * Upserts a subject. Creates or updates subject.
1336
+ * If the subject doesn't exist, it will be created.
1337
+ * If the subject exists, it will be partially updated with the provided fields.
1338
+ */
1339
+ upsertSubject: {
1340
+ /** @description The subject to upsert. */
1341
+ requestBody: {
1342
+ content: {
1343
+ 'application/json': components['schemas']['Subject'][];
1344
+ };
1345
+ };
1346
+ responses: {
1347
+ /** @description Subject upserted. */
1348
+ 200: {
1349
+ content: {
1350
+ 'application/json': components['schemas']['Subject'][];
1351
+ };
1352
+ };
1353
+ 400: components['responses']['BadRequestProblemResponse'];
1354
+ 401: components['responses']['UnauthorizedProblemResponse'];
1355
+ 501: components['responses']['NotImplementedProblemResponse'];
1356
+ default: components['responses']['UnexpectedProblemResponse'];
1357
+ };
1358
+ };
1359
+ /**
1360
+ * ☁ Get subject
1361
+ * @description *Available in OpenMeter Cloud.*
1362
+ *
1363
+ * Get subject by ID or key.
1364
+ */
1365
+ getSubject: {
1366
+ parameters: {
1367
+ path: {
1368
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1369
+ };
1370
+ };
1371
+ responses: {
1372
+ /** @description Subject found. */
1373
+ 200: {
1374
+ content: {
1375
+ 'application/json': components['schemas']['Subject'];
1376
+ };
1377
+ };
1378
+ 401: components['responses']['UnauthorizedProblemResponse'];
1379
+ 404: components['responses']['NotFoundProblemResponse'];
1380
+ default: components['responses']['UnexpectedProblemResponse'];
1381
+ };
1382
+ };
1383
+ /**
1384
+ * ☁ Delete subject
1385
+ * @description *Available in OpenMeter Cloud.*
1386
+ *
1387
+ * Delete a subject by ID or key.
1388
+ */
1389
+ deleteSubject: {
1390
+ parameters: {
1391
+ path: {
1392
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1393
+ };
1394
+ };
1395
+ responses: {
1396
+ /** @description Subject deleted. */
1397
+ 204: {
1398
+ content: never;
1399
+ };
1400
+ 400: components['responses']['BadRequestProblemResponse'];
1401
+ 401: components['responses']['UnauthorizedProblemResponse'];
1402
+ 404: components['responses']['NotFoundProblemResponse'];
1403
+ 501: components['responses']['NotImplementedProblemResponse'];
1404
+ default: components['responses']['UnexpectedProblemResponse'];
1405
+ };
1406
+ };
1407
+ /**
1408
+ * Query portal meter
1409
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
1410
+ */
1411
+ queryPortalMeter: {
1412
+ parameters: {
1413
+ query?: {
1414
+ from?: components['parameters']['queryFrom'];
1415
+ to?: components['parameters']['queryTo'];
1416
+ windowSize?: components['parameters']['queryWindowSize'];
1417
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1418
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1419
+ groupBy?: components['parameters']['queryGroupBy'];
1420
+ };
1421
+ path: {
1422
+ /** @description A unique identifier for the meter. */
1423
+ meterSlug: string;
1424
+ };
1425
+ };
1426
+ responses: {
1427
+ /** @description Usage data. */
1428
+ 200: {
1429
+ content: {
1430
+ 'application/json': components['schemas']['MeterQueryResult'];
1431
+ 'text/csv': string;
1432
+ };
1433
+ };
1434
+ 400: components['responses']['BadRequestProblemResponse'];
1435
+ 401: components['responses']['UnauthorizedProblemResponse'];
1436
+ default: components['responses']['UnexpectedProblemResponse'];
1437
+ };
1438
+ };
1439
+ /**
1440
+ * List features
1441
+ * @description List features.
1442
+ */
1443
+ listFeatures: {
1444
+ parameters: {
1445
+ query?: {
1446
+ limit?: components['parameters']['ledgerQueryLimit'];
1447
+ offset?: components['parameters']['ledgerQueryOffset'];
1448
+ /** @description Order by field */
1449
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
1450
+ /** @description Include archived features. */
1451
+ includeArchived?: boolean;
1452
+ };
1453
+ };
1454
+ responses: {
1455
+ /** @description List of features. */
1456
+ 200: {
1457
+ content: {
1458
+ 'application/json': components['schemas']['Feature'][];
1459
+ };
1460
+ };
1461
+ 401: components['responses']['UnauthorizedProblemResponse'];
1462
+ default: components['responses']['UnexpectedProblemResponse'];
1463
+ };
1464
+ };
1465
+ /**
1466
+ * Create feature
1467
+ * @description Creates a feature.
1468
+ */
1469
+ createFeature: {
1470
+ /** @description The feature to create. */
1471
+ requestBody: {
1472
+ content: {
1473
+ 'application/json': components['schemas']['Feature'];
1474
+ };
1475
+ };
1476
+ responses: {
1477
+ /** @description Feature created. */
1478
+ 201: {
1479
+ content: {
1480
+ 'application/json': components['schemas']['Feature'];
1481
+ };
1482
+ };
1483
+ 400: components['responses']['BadRequestProblemResponse'];
1484
+ 401: components['responses']['UnauthorizedProblemResponse'];
1485
+ 501: components['responses']['NotImplementedProblemResponse'];
1486
+ default: components['responses']['UnexpectedProblemResponse'];
1487
+ };
1488
+ };
1489
+ /**
1490
+ * Get feature
1491
+ * @description Get feature by key.
1492
+ */
1493
+ getFeature: {
1494
+ parameters: {
1495
+ path: {
1496
+ featureID: components['parameters']['featureID'];
1497
+ };
1498
+ };
1499
+ responses: {
1500
+ /** @description Feature found. */
1501
+ 200: {
1502
+ content: {
1503
+ 'application/json': components['schemas']['Feature'];
1504
+ };
1505
+ };
1506
+ 401: components['responses']['UnauthorizedProblemResponse'];
1507
+ 404: components['responses']['NotFoundProblemResponse'];
1508
+ default: components['responses']['UnexpectedProblemResponse'];
1509
+ };
1510
+ };
1511
+ /**
1512
+ * Delete feature
1513
+ * @description Delete a feature by key.
1514
+ */
1515
+ deleteFeature: {
1516
+ parameters: {
1517
+ path: {
1518
+ featureID: components['parameters']['featureID'];
1519
+ };
1520
+ };
1521
+ responses: {
1522
+ /** @description Feature deleted. */
1523
+ 204: {
1524
+ content: never;
1525
+ };
1526
+ 401: components['responses']['UnauthorizedProblemResponse'];
1527
+ 404: components['responses']['NotFoundProblemResponse'];
1528
+ default: components['responses']['UnexpectedProblemResponse'];
1529
+ };
1530
+ };
1531
+ /**
1532
+ * List the already defined ledgers.
1533
+ * @description List the already defined ledgers.
1534
+ */
1535
+ listLedgers: {
1536
+ parameters: {
1537
+ query?: {
1538
+ /** @description Query ledgers specific to subjects. */
1539
+ subject?: string[];
1540
+ /** @description Query ledgers with subjects that are similar to the provided text. */
1541
+ subjectSimilarTo?: string;
1542
+ limit?: components['parameters']['ledgerQueryLimit'];
1543
+ offset?: components['parameters']['ledgerQueryOffset'];
1544
+ /** @description Order by field */
1545
+ orderBy?: 'subject' | 'createdAt' | 'id';
1546
+ };
1547
+ };
1548
+ responses: {
1549
+ /** @description List of the matching ledgers. */
1550
+ 200: {
1551
+ content: {
1552
+ 'application/json': components['schemas']['Ledger'][];
1553
+ };
1554
+ };
1555
+ 400: components['responses']['BadRequestProblemResponse'];
1556
+ 401: components['responses']['UnauthorizedProblemResponse'];
1557
+ default: components['responses']['UnexpectedProblemResponse'];
1558
+ };
1559
+ };
1560
+ /**
1561
+ * Creates the specified ledger
1562
+ * @description Create or update the specified ledger.
1563
+ */
1564
+ createLedger: {
1565
+ /** @description The ledger to be created */
1566
+ requestBody: {
1567
+ content: {
1568
+ 'application/json': components['schemas']['CreateLedger'];
1569
+ };
1570
+ };
1571
+ responses: {
1572
+ /** @description The created ledger. */
1573
+ 201: {
1574
+ content: {
1575
+ 'application/json': components['schemas']['Ledger'];
1576
+ };
1577
+ };
1578
+ 400: components['responses']['BadRequestProblemResponse'];
1579
+ 401: components['responses']['UnauthorizedProblemResponse'];
1580
+ 409: components['responses']['LedgerAlreadyExistsProblemResponse'];
1581
+ default: components['responses']['UnexpectedProblemResponse'];
1582
+ };
1583
+ };
1584
+ /**
1585
+ * Get the balance of a specific subject.
1586
+ * @description Get the balance of a specific subject.
1587
+ */
1588
+ getLedgerBalance: {
1589
+ parameters: {
1590
+ query?: {
1591
+ /** @description Point of time to query balances: date-time in RFC 3339 format. Defaults to now. */
1592
+ time?: string;
1593
+ };
1594
+ path: {
1595
+ ledgerID: components['parameters']['ledgerID'];
1596
+ };
1597
+ };
1598
+ responses: {
1599
+ /** @description Ledger balances available. */
1600
+ 200: {
1601
+ content: {
1602
+ 'application/json': components['schemas']['LedgerBalance'];
1603
+ };
1604
+ };
1605
+ 401: components['responses']['UnauthorizedProblemResponse'];
1606
+ 404: components['responses']['NotFoundProblemResponse'];
1607
+ default: components['responses']['UnexpectedProblemResponse'];
1608
+ };
1609
+ };
1610
+ /**
1611
+ * Get the history of a ledger
1612
+ * @description Get the history of a specific ledger
1613
+ */
1614
+ getLedgerHistory: {
1615
+ parameters: {
1616
+ query: {
1617
+ limit?: components['parameters']['ledgerQueryLimit'];
1618
+ offset?: components['parameters']['ledgerQueryOffset'];
1619
+ /** @description Start of time range to query ledger: date-time in RFC 3339 format. */
1620
+ from: string;
1621
+ /** @description End of time range to query ledger: date-time in RFC 3339 format. Defaults to now. */
1622
+ to?: string;
1623
+ };
1624
+ path: {
1625
+ ledgerID: components['parameters']['ledgerID'];
1626
+ };
1627
+ };
1628
+ responses: {
1629
+ /** @description Ledger balance history. */
1630
+ 200: {
1631
+ content: {
1632
+ 'application/json': components['schemas']['LedgerEntry'][];
1633
+ };
1634
+ };
1635
+ 401: components['responses']['UnauthorizedProblemResponse'];
1636
+ 404: components['responses']['NotFoundProblemResponse'];
1637
+ default: components['responses']['UnexpectedProblemResponse'];
1638
+ };
1639
+ };
1640
+ /**
1641
+ * Reset the ledger's balance
1642
+ * @description Resets the ledger's balances to zero for a specific subject and re-apply active grants with rollover configuration.
1643
+ */
1644
+ resetLedger: {
1645
+ parameters: {
1646
+ path: {
1647
+ ledgerID: components['parameters']['ledgerID'];
1648
+ };
1649
+ };
1650
+ /** @description Details for the reset. */
1651
+ requestBody: {
1652
+ content: {
1653
+ 'application/json': components['schemas']['LedgerReset'];
1654
+ };
1655
+ };
1656
+ responses: {
1657
+ /** @description Ledger balance reset. */
1658
+ 201: {
1659
+ content: {
1660
+ 'application/json': components['schemas']['LedgerReset'];
1661
+ };
1662
+ };
1663
+ 400: components['responses']['BadRequestProblemResponse'];
1664
+ 401: components['responses']['UnauthorizedProblemResponse'];
1665
+ 404: components['responses']['NotFoundProblemResponse'];
1666
+ default: components['responses']['UnexpectedProblemResponse'];
1667
+ };
1668
+ };
1669
+ /**
1670
+ * List grants for multiple ledgers.
1671
+ * @description List grants for multiple ledgers.
1672
+ */
1673
+ listLedgerGrants: {
1674
+ parameters: {
1675
+ query?: {
1676
+ ledgerID?: components['parameters']['queryFilterLedgerID'];
1677
+ limit?: components['parameters']['ledgerQueryLimit'];
1678
+ };
1679
+ };
1680
+ responses: {
1681
+ /** @description List of ledger grants. */
1682
+ 200: {
1683
+ content: {
1684
+ 'application/json': components['schemas']['LedgerGrantResponse'][];
1685
+ };
1686
+ };
1687
+ 400: components['responses']['BadRequestProblemResponse'];
1688
+ 401: components['responses']['UnauthorizedProblemResponse'];
1689
+ default: components['responses']['UnexpectedProblemResponse'];
1690
+ };
1691
+ };
1692
+ /**
1693
+ * List ledger grants
1694
+ * @description List ledger grants for a specific ledger.
1695
+ */
1696
+ listLedgerGrantsByLedger: {
1697
+ parameters: {
1698
+ query?: {
1699
+ limit?: components['parameters']['ledgerQueryLimit'];
1700
+ };
1701
+ path: {
1702
+ ledgerID: components['parameters']['ledgerID'];
1703
+ };
1704
+ };
1705
+ responses: {
1706
+ /** @description List of ledger grants created. */
1707
+ 200: {
1708
+ content: {
1709
+ 'application/json': components['schemas']['LedgerGrantResponse'][];
1710
+ };
1711
+ };
1712
+ 400: components['responses']['BadRequestProblemResponse'];
1713
+ 401: components['responses']['UnauthorizedProblemResponse'];
1714
+ default: components['responses']['UnexpectedProblemResponse'];
1715
+ };
1716
+ };
1717
+ /**
1718
+ * Create a grant on a specific ledger.
1719
+ * @description Create a grant on a specific ledger.
1720
+ */
1721
+ createLedgerGrant: {
1722
+ parameters: {
1723
+ path: {
1724
+ ledgerID: components['parameters']['ledgerID'];
1725
+ };
1726
+ };
1727
+ /** @description The grant to create. */
1728
+ requestBody: {
1729
+ content: {
1730
+ 'application/json': components['schemas']['CreateLedgerGrantRequest'];
1731
+ };
1732
+ };
1733
+ responses: {
1734
+ /** @description LedgerGrant created. */
1735
+ 201: {
1736
+ content: {
1737
+ 'application/json': components['schemas']['LedgerGrantResponse'];
1738
+ };
1739
+ };
1740
+ 400: components['responses']['BadRequestProblemResponse'];
1741
+ 401: components['responses']['UnauthorizedProblemResponse'];
1742
+ default: components['responses']['UnexpectedProblemResponse'];
1743
+ };
1744
+ };
1745
+ /**
1746
+ * Get a single grant.
1747
+ * @description Gets the grant for a ledger by ID.
1748
+ */
1749
+ getLedgerGrant: {
1750
+ parameters: {
1751
+ path: {
1752
+ ledgerID: components['parameters']['ledgerID'];
1753
+ ledgerGrantID: components['parameters']['ledgerGrantID'];
1754
+ };
1755
+ };
1756
+ responses: {
1757
+ /** @description Ledger grant found. */
1758
+ 200: {
1759
+ content: {
1760
+ 'application/json': components['schemas']['LedgerGrantResponse'];
1761
+ };
1762
+ };
1763
+ 401: components['responses']['UnauthorizedProblemResponse'];
1764
+ 404: components['responses']['NotFoundProblemResponse'];
1765
+ default: components['responses']['UnexpectedProblemResponse'];
1766
+ };
1767
+ };
1768
+ /**
1769
+ * Void ledger grant
1770
+ * @description Void a ledger grant by ID. Partially or fully used grants cannot be voided.
1771
+ * Voided grant won't be applied to the subject's balance anymore.
1772
+ */
1773
+ voidLedgerGrant: {
1774
+ parameters: {
1775
+ path: {
1776
+ ledgerGrantID: components['parameters']['ledgerGrantID'];
1777
+ ledgerID: components['parameters']['ledgerID'];
1778
+ };
1779
+ };
1780
+ responses: {
1781
+ /** @description Ledger grant voided. */
1782
+ 204: {
1783
+ content: never;
1784
+ };
1785
+ 401: components['responses']['UnauthorizedProblemResponse'];
1786
+ 404: components['responses']['NotFoundProblemResponse'];
1787
+ default: components['responses']['UnexpectedProblemResponse'];
1788
+ };
1789
+ };
1790
+ }