@openmeter/client 1.0.0-beta-62b7ce950326 → 1.0.0-beta-106e6d4e7951

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.
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List billing invoices
@@ -17,6 +17,9 @@ import * as schemas from '../models/schemas.js';
17
17
  */
18
18
  export function listInvoices(client, req = {}, options) {
19
19
  return request(() => {
20
+ if (client._options.validate && req.sort !== undefined) {
21
+ assertValid(schemas.listInvoicesQueryParams.shape.sort, req.sort);
22
+ }
20
23
  const query = toWire({
21
24
  page: req.page,
22
25
  sort: encodeSort(req.sort, toSnakeCase),
@@ -49,11 +52,20 @@ export function listInvoices(client, req = {}, options) {
49
52
  */
50
53
  export function getInvoice(client, req, options) {
51
54
  return request(() => {
55
+ const pathParamsInput = {
56
+ invoiceId: req.invoiceId,
57
+ };
58
+ const pathParams = client._options.validate
59
+ ? toPathWire(pathParamsInput, schemas.getInvoicePathParams)
60
+ : pathParamsInput;
61
+ if (client._options.validate) {
62
+ assertValid(schemas.getInvoicePathParamsWire, pathParams);
63
+ }
52
64
  const path = `openmeter/billing/invoices/${(() => {
53
- if (req.invoiceId === undefined) {
65
+ if (pathParams.invoiceId === undefined) {
54
66
  throw new Error('missing path parameter: invoiceId');
55
67
  }
56
- return encodeURIComponent(String(req.invoiceId));
68
+ return encodeURIComponent(String(pathParams.invoiceId));
57
69
  })()}`;
58
70
  return http(client)
59
71
  .get(path, options)
@@ -81,11 +93,20 @@ export function getInvoice(client, req, options) {
81
93
  */
82
94
  export function updateInvoice(client, req, options) {
83
95
  return request(() => {
96
+ const pathParamsInput = {
97
+ invoiceId: req.invoiceId,
98
+ };
99
+ const pathParams = client._options.validate
100
+ ? toPathWire(pathParamsInput, schemas.updateInvoicePathParams)
101
+ : pathParamsInput;
102
+ if (client._options.validate) {
103
+ assertValid(schemas.updateInvoicePathParamsWire, pathParams);
104
+ }
84
105
  const path = `openmeter/billing/invoices/${(() => {
85
- if (req.invoiceId === undefined) {
106
+ if (pathParams.invoiceId === undefined) {
86
107
  throw new Error('missing path parameter: invoiceId');
87
108
  }
88
- return encodeURIComponent(String(req.invoiceId));
109
+ return encodeURIComponent(String(pathParams.invoiceId));
89
110
  })()}`;
90
111
  const body = toWire(req.body, schemas.updateInvoiceBody);
91
112
  if (client._options.validate) {
@@ -114,11 +135,20 @@ export function updateInvoice(client, req, options) {
114
135
  */
115
136
  export function deleteInvoice(client, req, options) {
116
137
  return request(async () => {
138
+ const pathParamsInput = {
139
+ invoiceId: req.invoiceId,
140
+ };
141
+ const pathParams = client._options.validate
142
+ ? toPathWire(pathParamsInput, schemas.deleteInvoicePathParams)
143
+ : pathParamsInput;
144
+ if (client._options.validate) {
145
+ assertValid(schemas.deleteInvoicePathParamsWire, pathParams);
146
+ }
117
147
  const path = `openmeter/billing/invoices/${(() => {
118
- if (req.invoiceId === undefined) {
148
+ if (pathParams.invoiceId === undefined) {
119
149
  throw new Error('missing path parameter: invoiceId');
120
150
  }
121
- return encodeURIComponent(String(req.invoiceId));
151
+ return encodeURIComponent(String(pathParams.invoiceId));
122
152
  })()}`;
123
153
  await http(client).delete(path, options);
124
154
  });
@@ -136,11 +166,20 @@ export function deleteInvoice(client, req, options) {
136
166
  */
137
167
  export function advanceInvoice(client, req, options) {
138
168
  return request(() => {
169
+ const pathParamsInput = {
170
+ invoiceId: req.invoiceId,
171
+ };
172
+ const pathParams = client._options.validate
173
+ ? toPathWire(pathParamsInput, schemas.advanceInvoicePathParams)
174
+ : pathParamsInput;
175
+ if (client._options.validate) {
176
+ assertValid(schemas.advanceInvoicePathParamsWire, pathParams);
177
+ }
139
178
  const path = `openmeter/billing/invoices/${(() => {
140
- if (req.invoiceId === undefined) {
179
+ if (pathParams.invoiceId === undefined) {
141
180
  throw new Error('missing path parameter: invoiceId');
142
181
  }
143
- return encodeURIComponent(String(req.invoiceId));
182
+ return encodeURIComponent(String(pathParams.invoiceId));
144
183
  })()}/advance`;
145
184
  return http(client)
146
185
  .post(path, options)
@@ -172,11 +211,20 @@ export function advanceInvoice(client, req, options) {
172
211
  */
173
212
  export function approveInvoice(client, req, options) {
174
213
  return request(() => {
214
+ const pathParamsInput = {
215
+ invoiceId: req.invoiceId,
216
+ };
217
+ const pathParams = client._options.validate
218
+ ? toPathWire(pathParamsInput, schemas.approveInvoicePathParams)
219
+ : pathParamsInput;
220
+ if (client._options.validate) {
221
+ assertValid(schemas.approveInvoicePathParamsWire, pathParams);
222
+ }
175
223
  const path = `openmeter/billing/invoices/${(() => {
176
- if (req.invoiceId === undefined) {
224
+ if (pathParams.invoiceId === undefined) {
177
225
  throw new Error('missing path parameter: invoiceId');
178
226
  }
179
- return encodeURIComponent(String(req.invoiceId));
227
+ return encodeURIComponent(String(pathParams.invoiceId));
180
228
  })()}/approve`;
181
229
  return http(client)
182
230
  .post(path, options)
@@ -203,11 +251,20 @@ export function approveInvoice(client, req, options) {
203
251
  */
204
252
  export function retryInvoice(client, req, options) {
205
253
  return request(() => {
254
+ const pathParamsInput = {
255
+ invoiceId: req.invoiceId,
256
+ };
257
+ const pathParams = client._options.validate
258
+ ? toPathWire(pathParamsInput, schemas.retryInvoicePathParams)
259
+ : pathParamsInput;
260
+ if (client._options.validate) {
261
+ assertValid(schemas.retryInvoicePathParamsWire, pathParams);
262
+ }
206
263
  const path = `openmeter/billing/invoices/${(() => {
207
- if (req.invoiceId === undefined) {
264
+ if (pathParams.invoiceId === undefined) {
208
265
  throw new Error('missing path parameter: invoiceId');
209
266
  }
210
- return encodeURIComponent(String(req.invoiceId));
267
+ return encodeURIComponent(String(pathParams.invoiceId));
211
268
  })()}/retry`;
212
269
  return http(client)
213
270
  .post(path, options)
@@ -235,11 +292,20 @@ export function retryInvoice(client, req, options) {
235
292
  */
236
293
  export function snapshotQuantitiesInvoice(client, req, options) {
237
294
  return request(() => {
295
+ const pathParamsInput = {
296
+ invoiceId: req.invoiceId,
297
+ };
298
+ const pathParams = client._options.validate
299
+ ? toPathWire(pathParamsInput, schemas.snapshotQuantitiesInvoicePathParams)
300
+ : pathParamsInput;
301
+ if (client._options.validate) {
302
+ assertValid(schemas.snapshotQuantitiesInvoicePathParamsWire, pathParams);
303
+ }
238
304
  const path = `openmeter/billing/invoices/${(() => {
239
- if (req.invoiceId === undefined) {
305
+ if (pathParams.invoiceId === undefined) {
240
306
  throw new Error('missing path parameter: invoiceId');
241
307
  }
242
- return encodeURIComponent(String(req.invoiceId));
308
+ return encodeURIComponent(String(pathParams.invoiceId));
243
309
  })()}/snapshot-quantities`;
244
310
  return http(client)
245
311
  .post(path, options)
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List LLM cost prices
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listLlmCostPrices(client, req = {}, options) {
15
15
  return request(() => {
16
+ if (client._options.validate && req.sort !== undefined) {
17
+ assertValid(schemas.listLlmCostPricesQueryParams.shape.sort, req.sort);
18
+ }
16
19
  const query = toWire({
17
20
  filter: req.filter,
18
21
  sort: encodeSort(req.sort, toSnakeCase),
@@ -43,11 +46,20 @@ export function listLlmCostPrices(client, req = {}, options) {
43
46
  */
44
47
  export function getLlmCostPrice(client, req, options) {
45
48
  return request(() => {
49
+ const pathParamsInput = {
50
+ priceId: req.priceId,
51
+ };
52
+ const pathParams = client._options.validate
53
+ ? toPathWire(pathParamsInput, schemas.getLlmCostPricePathParams)
54
+ : pathParamsInput;
55
+ if (client._options.validate) {
56
+ assertValid(schemas.getLlmCostPricePathParamsWire, pathParams);
57
+ }
46
58
  const path = `openmeter/llm-cost/prices/${(() => {
47
- if (req.priceId === undefined) {
59
+ if (pathParams.priceId === undefined) {
48
60
  throw new Error('missing path parameter: priceId');
49
61
  }
50
- return encodeURIComponent(String(req.priceId));
62
+ return encodeURIComponent(String(pathParams.priceId));
51
63
  })()}`;
52
64
  return http(client)
53
65
  .get(path, options)
@@ -121,11 +133,20 @@ export function createLlmCostOverride(client, req, options) {
121
133
  */
122
134
  export function deleteLlmCostOverride(client, req, options) {
123
135
  return request(async () => {
136
+ const pathParamsInput = {
137
+ priceId: req.priceId,
138
+ };
139
+ const pathParams = client._options.validate
140
+ ? toPathWire(pathParamsInput, schemas.deleteLlmCostOverridePathParams)
141
+ : pathParamsInput;
142
+ if (client._options.validate) {
143
+ assertValid(schemas.deleteLlmCostOverridePathParamsWire, pathParams);
144
+ }
124
145
  const path = `openmeter/llm-cost/overrides/${(() => {
125
- if (req.priceId === undefined) {
146
+ if (pathParams.priceId === undefined) {
126
147
  throw new Error('missing path parameter: priceId');
127
148
  }
128
- return encodeURIComponent(String(req.priceId));
149
+ return encodeURIComponent(String(pathParams.priceId));
129
150
  })()}`;
130
151
  await http(client).delete(path, options);
131
152
  });
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * Create meter
@@ -37,11 +37,20 @@ export function createMeter(client, req, options) {
37
37
  */
38
38
  export function getMeter(client, req, options) {
39
39
  return request(() => {
40
+ const pathParamsInput = {
41
+ meterId: req.meterId,
42
+ };
43
+ const pathParams = client._options.validate
44
+ ? toPathWire(pathParamsInput, schemas.getMeterPathParams)
45
+ : pathParamsInput;
46
+ if (client._options.validate) {
47
+ assertValid(schemas.getMeterPathParamsWire, pathParams);
48
+ }
40
49
  const path = `openmeter/meters/${(() => {
41
- if (req.meterId === undefined) {
50
+ if (pathParams.meterId === undefined) {
42
51
  throw new Error('missing path parameter: meterId');
43
52
  }
44
- return encodeURIComponent(String(req.meterId));
53
+ return encodeURIComponent(String(pathParams.meterId));
45
54
  })()}`;
46
55
  return http(client)
47
56
  .get(path, options)
@@ -63,6 +72,9 @@ export function getMeter(client, req, options) {
63
72
  */
64
73
  export function listMeters(client, req = {}, options) {
65
74
  return request(() => {
75
+ if (client._options.validate && req.sort !== undefined) {
76
+ assertValid(schemas.listMetersQueryParams.shape.sort, req.sort);
77
+ }
66
78
  const query = toWire({
67
79
  page: req.page,
68
80
  sort: encodeSort(req.sort, toSnakeCase),
@@ -92,11 +104,20 @@ export function listMeters(client, req = {}, options) {
92
104
  */
93
105
  export function updateMeter(client, req, options) {
94
106
  return request(() => {
107
+ const pathParamsInput = {
108
+ meterId: req.meterId,
109
+ };
110
+ const pathParams = client._options.validate
111
+ ? toPathWire(pathParamsInput, schemas.updateMeterPathParams)
112
+ : pathParamsInput;
113
+ if (client._options.validate) {
114
+ assertValid(schemas.updateMeterPathParamsWire, pathParams);
115
+ }
95
116
  const path = `openmeter/meters/${(() => {
96
- if (req.meterId === undefined) {
117
+ if (pathParams.meterId === undefined) {
97
118
  throw new Error('missing path parameter: meterId');
98
119
  }
99
- return encodeURIComponent(String(req.meterId));
120
+ return encodeURIComponent(String(pathParams.meterId));
100
121
  })()}`;
101
122
  const body = toWire(req.body, schemas.updateMeterBody);
102
123
  if (client._options.validate) {
@@ -122,11 +143,20 @@ export function updateMeter(client, req, options) {
122
143
  */
123
144
  export function deleteMeter(client, req, options) {
124
145
  return request(async () => {
146
+ const pathParamsInput = {
147
+ meterId: req.meterId,
148
+ };
149
+ const pathParams = client._options.validate
150
+ ? toPathWire(pathParamsInput, schemas.deleteMeterPathParams)
151
+ : pathParamsInput;
152
+ if (client._options.validate) {
153
+ assertValid(schemas.deleteMeterPathParamsWire, pathParams);
154
+ }
125
155
  const path = `openmeter/meters/${(() => {
126
- if (req.meterId === undefined) {
156
+ if (pathParams.meterId === undefined) {
127
157
  throw new Error('missing path parameter: meterId');
128
158
  }
129
- return encodeURIComponent(String(req.meterId));
159
+ return encodeURIComponent(String(pathParams.meterId));
130
160
  })()}`;
131
161
  await http(client).delete(path, options);
132
162
  });
@@ -150,11 +180,20 @@ export function deleteMeter(client, req, options) {
150
180
  */
151
181
  export function queryMeter(client, req, options) {
152
182
  return request(() => {
183
+ const pathParamsInput = {
184
+ meterId: req.meterId,
185
+ };
186
+ const pathParams = client._options.validate
187
+ ? toPathWire(pathParamsInput, schemas.queryMeterPathParams)
188
+ : pathParamsInput;
189
+ if (client._options.validate) {
190
+ assertValid(schemas.queryMeterPathParamsWire, pathParams);
191
+ }
153
192
  const path = `openmeter/meters/${(() => {
154
- if (req.meterId === undefined) {
193
+ if (pathParams.meterId === undefined) {
155
194
  throw new Error('missing path parameter: meterId');
156
195
  }
157
- return encodeURIComponent(String(req.meterId));
196
+ return encodeURIComponent(String(pathParams.meterId));
158
197
  })()}/query`;
159
198
  const body = toWire(req.body, schemas.queryMeterBody);
160
199
  if (client._options.validate) {
@@ -176,11 +215,20 @@ export function queryMeterCsv(client, req, options) {
176
215
  const headers = new Headers(options?.headers);
177
216
  headers.set('accept', 'text/csv');
178
217
  return request(() => {
218
+ const pathParamsInput = {
219
+ meterId: req.meterId,
220
+ };
221
+ const pathParams = client._options.validate
222
+ ? toPathWire(pathParamsInput, schemas.queryMeterCsvPathParams)
223
+ : pathParamsInput;
224
+ if (client._options.validate) {
225
+ assertValid(schemas.queryMeterCsvPathParamsWire, pathParams);
226
+ }
179
227
  const path = `openmeter/meters/${(() => {
180
- if (req.meterId === undefined) {
228
+ if (pathParams.meterId === undefined) {
181
229
  throw new Error('missing path parameter: meterId');
182
230
  }
183
- return encodeURIComponent(String(req.meterId));
231
+ return encodeURIComponent(String(pathParams.meterId));
184
232
  })()}/query`;
185
233
  const body = toWire(req.body, schemas.queryMeterCsvBody);
186
234
  if (client._options.validate) {
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List add-ons for plan
@@ -13,11 +13,20 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listPlanAddons(client, req, options) {
15
15
  return request(() => {
16
+ const pathParamsInput = {
17
+ planId: req.planId,
18
+ };
19
+ const pathParams = client._options.validate
20
+ ? toPathWire(pathParamsInput, schemas.listPlanAddonsPathParams)
21
+ : pathParamsInput;
22
+ if (client._options.validate) {
23
+ assertValid(schemas.listPlanAddonsPathParamsWire, pathParams);
24
+ }
16
25
  const path = `openmeter/plans/${(() => {
17
- if (req.planId === undefined) {
26
+ if (pathParams.planId === undefined) {
18
27
  throw new Error('missing path parameter: planId');
19
28
  }
20
- return encodeURIComponent(String(req.planId));
29
+ return encodeURIComponent(String(pathParams.planId));
21
30
  })()}/addons`;
22
31
  const query = toWire({
23
32
  page: req.page,
@@ -46,11 +55,20 @@ export function listPlanAddons(client, req, options) {
46
55
  */
47
56
  export function createPlanAddon(client, req, options) {
48
57
  return request(() => {
58
+ const pathParamsInput = {
59
+ planId: req.planId,
60
+ };
61
+ const pathParams = client._options.validate
62
+ ? toPathWire(pathParamsInput, schemas.createPlanAddonPathParams)
63
+ : pathParamsInput;
64
+ if (client._options.validate) {
65
+ assertValid(schemas.createPlanAddonPathParamsWire, pathParams);
66
+ }
49
67
  const path = `openmeter/plans/${(() => {
50
- if (req.planId === undefined) {
68
+ if (pathParams.planId === undefined) {
51
69
  throw new Error('missing path parameter: planId');
52
70
  }
53
- return encodeURIComponent(String(req.planId));
71
+ return encodeURIComponent(String(pathParams.planId));
54
72
  })()}/addons`;
55
73
  const body = toWire(req.body, schemas.createPlanAddonBody);
56
74
  if (client._options.validate) {
@@ -76,16 +94,26 @@ export function createPlanAddon(client, req, options) {
76
94
  */
77
95
  export function getPlanAddon(client, req, options) {
78
96
  return request(() => {
97
+ const pathParamsInput = {
98
+ planId: req.planId,
99
+ planAddonId: req.planAddonId,
100
+ };
101
+ const pathParams = client._options.validate
102
+ ? toPathWire(pathParamsInput, schemas.getPlanAddonPathParams)
103
+ : pathParamsInput;
104
+ if (client._options.validate) {
105
+ assertValid(schemas.getPlanAddonPathParamsWire, pathParams);
106
+ }
79
107
  const path = `openmeter/plans/${(() => {
80
- if (req.planId === undefined) {
108
+ if (pathParams.planId === undefined) {
81
109
  throw new Error('missing path parameter: planId');
82
110
  }
83
- return encodeURIComponent(String(req.planId));
111
+ return encodeURIComponent(String(pathParams.planId));
84
112
  })()}/addons/${(() => {
85
- if (req.planAddonId === undefined) {
113
+ if (pathParams.planAddonId === undefined) {
86
114
  throw new Error('missing path parameter: planAddonId');
87
115
  }
88
- return encodeURIComponent(String(req.planAddonId));
116
+ return encodeURIComponent(String(pathParams.planAddonId));
89
117
  })()}`;
90
118
  return http(client)
91
119
  .get(path, options)
@@ -107,16 +135,26 @@ export function getPlanAddon(client, req, options) {
107
135
  */
108
136
  export function updatePlanAddon(client, req, options) {
109
137
  return request(() => {
138
+ const pathParamsInput = {
139
+ planId: req.planId,
140
+ planAddonId: req.planAddonId,
141
+ };
142
+ const pathParams = client._options.validate
143
+ ? toPathWire(pathParamsInput, schemas.updatePlanAddonPathParams)
144
+ : pathParamsInput;
145
+ if (client._options.validate) {
146
+ assertValid(schemas.updatePlanAddonPathParamsWire, pathParams);
147
+ }
110
148
  const path = `openmeter/plans/${(() => {
111
- if (req.planId === undefined) {
149
+ if (pathParams.planId === undefined) {
112
150
  throw new Error('missing path parameter: planId');
113
151
  }
114
- return encodeURIComponent(String(req.planId));
152
+ return encodeURIComponent(String(pathParams.planId));
115
153
  })()}/addons/${(() => {
116
- if (req.planAddonId === undefined) {
154
+ if (pathParams.planAddonId === undefined) {
117
155
  throw new Error('missing path parameter: planAddonId');
118
156
  }
119
- return encodeURIComponent(String(req.planAddonId));
157
+ return encodeURIComponent(String(pathParams.planAddonId));
120
158
  })()}`;
121
159
  const body = toWire(req.body, schemas.updatePlanAddonBody);
122
160
  if (client._options.validate) {
@@ -142,16 +180,26 @@ export function updatePlanAddon(client, req, options) {
142
180
  */
143
181
  export function deletePlanAddon(client, req, options) {
144
182
  return request(async () => {
183
+ const pathParamsInput = {
184
+ planId: req.planId,
185
+ planAddonId: req.planAddonId,
186
+ };
187
+ const pathParams = client._options.validate
188
+ ? toPathWire(pathParamsInput, schemas.deletePlanAddonPathParams)
189
+ : pathParamsInput;
190
+ if (client._options.validate) {
191
+ assertValid(schemas.deletePlanAddonPathParamsWire, pathParams);
192
+ }
145
193
  const path = `openmeter/plans/${(() => {
146
- if (req.planId === undefined) {
194
+ if (pathParams.planId === undefined) {
147
195
  throw new Error('missing path parameter: planId');
148
196
  }
149
- return encodeURIComponent(String(req.planId));
197
+ return encodeURIComponent(String(pathParams.planId));
150
198
  })()}/addons/${(() => {
151
- if (req.planAddonId === undefined) {
199
+ if (pathParams.planAddonId === undefined) {
152
200
  throw new Error('missing path parameter: planAddonId');
153
201
  }
154
- return encodeURIComponent(String(req.planAddonId));
202
+ return encodeURIComponent(String(pathParams.planAddonId));
155
203
  })()}`;
156
204
  await http(client).delete(path, options);
157
205
  });
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List plans
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listPlans(client, req = {}, options) {
15
15
  return request(() => {
16
+ if (client._options.validate && req.sort !== undefined) {
17
+ assertValid(schemas.listPlansQueryParams.shape.sort, req.sort);
18
+ }
16
19
  const query = toWire({
17
20
  page: req.page,
18
21
  sort: encodeSort(req.sort, toSnakeCase),
@@ -66,11 +69,20 @@ export function createPlan(client, req, options) {
66
69
  */
67
70
  export function updatePlan(client, req, options) {
68
71
  return request(() => {
72
+ const pathParamsInput = {
73
+ planId: req.planId,
74
+ };
75
+ const pathParams = client._options.validate
76
+ ? toPathWire(pathParamsInput, schemas.updatePlanPathParams)
77
+ : pathParamsInput;
78
+ if (client._options.validate) {
79
+ assertValid(schemas.updatePlanPathParamsWire, pathParams);
80
+ }
69
81
  const path = `openmeter/plans/${(() => {
70
- if (req.planId === undefined) {
82
+ if (pathParams.planId === undefined) {
71
83
  throw new Error('missing path parameter: planId');
72
84
  }
73
- return encodeURIComponent(String(req.planId));
85
+ return encodeURIComponent(String(pathParams.planId));
74
86
  })()}`;
75
87
  const body = toWire(req.body, schemas.updatePlanBody);
76
88
  if (client._options.validate) {
@@ -96,11 +108,20 @@ export function updatePlan(client, req, options) {
96
108
  */
97
109
  export function getPlan(client, req, options) {
98
110
  return request(() => {
111
+ const pathParamsInput = {
112
+ planId: req.planId,
113
+ };
114
+ const pathParams = client._options.validate
115
+ ? toPathWire(pathParamsInput, schemas.getPlanPathParams)
116
+ : pathParamsInput;
117
+ if (client._options.validate) {
118
+ assertValid(schemas.getPlanPathParamsWire, pathParams);
119
+ }
99
120
  const path = `openmeter/plans/${(() => {
100
- if (req.planId === undefined) {
121
+ if (pathParams.planId === undefined) {
101
122
  throw new Error('missing path parameter: planId');
102
123
  }
103
- return encodeURIComponent(String(req.planId));
124
+ return encodeURIComponent(String(pathParams.planId));
104
125
  })()}`;
105
126
  return http(client)
106
127
  .get(path, options)
@@ -122,11 +143,20 @@ export function getPlan(client, req, options) {
122
143
  */
123
144
  export function deletePlan(client, req, options) {
124
145
  return request(async () => {
146
+ const pathParamsInput = {
147
+ planId: req.planId,
148
+ };
149
+ const pathParams = client._options.validate
150
+ ? toPathWire(pathParamsInput, schemas.deletePlanPathParams)
151
+ : pathParamsInput;
152
+ if (client._options.validate) {
153
+ assertValid(schemas.deletePlanPathParamsWire, pathParams);
154
+ }
125
155
  const path = `openmeter/plans/${(() => {
126
- if (req.planId === undefined) {
156
+ if (pathParams.planId === undefined) {
127
157
  throw new Error('missing path parameter: planId');
128
158
  }
129
- return encodeURIComponent(String(req.planId));
159
+ return encodeURIComponent(String(pathParams.planId));
130
160
  })()}`;
131
161
  await http(client).delete(path, options);
132
162
  });
@@ -140,11 +170,20 @@ export function deletePlan(client, req, options) {
140
170
  */
141
171
  export function archivePlan(client, req, options) {
142
172
  return request(() => {
173
+ const pathParamsInput = {
174
+ planId: req.planId,
175
+ };
176
+ const pathParams = client._options.validate
177
+ ? toPathWire(pathParamsInput, schemas.archivePlanPathParams)
178
+ : pathParamsInput;
179
+ if (client._options.validate) {
180
+ assertValid(schemas.archivePlanPathParamsWire, pathParams);
181
+ }
143
182
  const path = `openmeter/plans/${(() => {
144
- if (req.planId === undefined) {
183
+ if (pathParams.planId === undefined) {
145
184
  throw new Error('missing path parameter: planId');
146
185
  }
147
- return encodeURIComponent(String(req.planId));
186
+ return encodeURIComponent(String(pathParams.planId));
148
187
  })()}/archive`;
149
188
  return http(client)
150
189
  .post(path, options)
@@ -166,11 +205,20 @@ export function archivePlan(client, req, options) {
166
205
  */
167
206
  export function publishPlan(client, req, options) {
168
207
  return request(() => {
208
+ const pathParamsInput = {
209
+ planId: req.planId,
210
+ };
211
+ const pathParams = client._options.validate
212
+ ? toPathWire(pathParamsInput, schemas.publishPlanPathParams)
213
+ : pathParamsInput;
214
+ if (client._options.validate) {
215
+ assertValid(schemas.publishPlanPathParamsWire, pathParams);
216
+ }
169
217
  const path = `openmeter/plans/${(() => {
170
- if (req.planId === undefined) {
218
+ if (pathParams.planId === undefined) {
171
219
  throw new Error('missing path parameter: planId');
172
220
  }
173
- return encodeURIComponent(String(req.planId));
221
+ return encodeURIComponent(String(pathParams.planId));
174
222
  })()}/publish`;
175
223
  return http(client)
176
224
  .post(path, options)