lark-billing 0.0.9 → 0.1.0
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.
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/pricingMetrics/client/Client.d.ts +25 -6
- package/dist/cjs/api/resources/pricingMetrics/client/Client.js +72 -4
- package/dist/cjs/api/resources/pricingMetrics/client/requests/CreatePricingMetricRequest.d.ts +9 -5
- package/dist/cjs/api/resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.d.ts +20 -0
- package/dist/cjs/api/resources/pricingMetrics/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/pricingMetrics/types/PricingMetricAggregation.d.ts +13 -1
- package/dist/cjs/api/resources/rateCards/client/Client.d.ts +27 -1
- package/dist/cjs/api/resources/rateCards/client/Client.js +27 -1
- package/dist/cjs/api/resources/rateCards/client/requests/CreateRateCardRequest.d.ts +29 -1
- package/dist/cjs/api/resources/subjects/client/Client.d.ts +8 -1
- package/dist/cjs/api/resources/subjects/client/Client.js +8 -1
- package/dist/cjs/api/resources/subjects/client/requests/CreateSubjectRequest.d.ts +8 -1
- package/dist/cjs/api/resources/usageEvents/client/Client.d.ts +7 -23
- package/dist/cjs/api/resources/usageEvents/client/Client.js +7 -72
- package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventRequest.d.ts +8 -5
- package/dist/cjs/api/resources/usageEvents/client/requests/index.d.ts +0 -1
- package/dist/cjs/api/types/Aggregation.d.ts +10 -1
- package/dist/cjs/api/types/BillingStateResponse.d.ts +2 -0
- package/dist/cjs/api/types/CountAggregationPricingMetricInterface.d.ts +3 -0
- package/dist/cjs/api/types/CustomAggregationPricingMetricInterface.d.ts +10 -0
- package/dist/cjs/api/types/LastAggregationPricingMetricInterface.d.ts +10 -0
- package/dist/cjs/api/types/LastAggregationPricingMetricResource.d.ts +7 -0
- package/dist/cjs/api/types/LastAggregationPricingMetricResource.js +5 -0
- package/dist/cjs/api/types/MaxAggregationPricingMetricInterface.d.ts +10 -0
- package/dist/cjs/api/types/MaxAggregationPricingMetricInterface.js +5 -0
- package/dist/cjs/api/types/MaxAggregationPricingMetricResource.d.ts +7 -0
- package/dist/cjs/api/types/MaxAggregationPricingMetricResource.js +5 -0
- package/dist/cjs/api/types/PricingMetricResource.d.ts +5 -0
- package/dist/cjs/api/types/PricingMetricSummaryResource.d.ts +16 -0
- package/dist/cjs/api/types/PricingMetricSummaryResource.js +5 -0
- package/dist/cjs/api/types/SumAggregationPricingMetricInterface.d.ts +3 -0
- package/dist/cjs/api/types/SumAggregationPricingMetricResource.d.ts +1 -0
- package/dist/cjs/api/types/index.d.ts +7 -4
- package/dist/cjs/api/types/index.js +7 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/pricingMetrics/client/Client.d.mts +25 -6
- package/dist/esm/api/resources/pricingMetrics/client/Client.mjs +72 -4
- package/dist/esm/api/resources/pricingMetrics/client/requests/CreatePricingMetricRequest.d.mts +9 -5
- package/dist/esm/api/resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.d.mts +20 -0
- package/dist/esm/api/resources/pricingMetrics/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/pricingMetrics/types/PricingMetricAggregation.d.mts +13 -1
- package/dist/esm/api/resources/rateCards/client/Client.d.mts +27 -1
- package/dist/esm/api/resources/rateCards/client/Client.mjs +27 -1
- package/dist/esm/api/resources/rateCards/client/requests/CreateRateCardRequest.d.mts +29 -1
- package/dist/esm/api/resources/subjects/client/Client.d.mts +8 -1
- package/dist/esm/api/resources/subjects/client/Client.mjs +8 -1
- package/dist/esm/api/resources/subjects/client/requests/CreateSubjectRequest.d.mts +8 -1
- package/dist/esm/api/resources/usageEvents/client/Client.d.mts +7 -23
- package/dist/esm/api/resources/usageEvents/client/Client.mjs +7 -72
- package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventRequest.d.mts +8 -5
- package/dist/esm/api/resources/usageEvents/client/requests/index.d.mts +0 -1
- package/dist/esm/api/types/Aggregation.d.mts +10 -1
- package/dist/esm/api/types/BillingStateResponse.d.mts +2 -0
- package/dist/esm/api/types/CountAggregationPricingMetricInterface.d.mts +3 -0
- package/dist/esm/api/types/CustomAggregationPricingMetricInterface.d.mts +10 -0
- package/dist/esm/api/types/LastAggregationPricingMetricInterface.d.mts +10 -0
- package/dist/esm/api/types/LastAggregationPricingMetricResource.d.mts +7 -0
- package/dist/esm/api/types/LastAggregationPricingMetricResource.mjs +4 -0
- package/dist/esm/api/types/MaxAggregationPricingMetricInterface.d.mts +10 -0
- package/dist/esm/api/types/MaxAggregationPricingMetricInterface.mjs +4 -0
- package/dist/esm/api/types/MaxAggregationPricingMetricResource.d.mts +7 -0
- package/dist/esm/api/types/MaxAggregationPricingMetricResource.mjs +4 -0
- package/dist/esm/api/types/PricingMetricResource.d.mts +5 -0
- package/dist/esm/api/types/PricingMetricSummaryResource.d.mts +16 -0
- package/dist/esm/api/types/PricingMetricSummaryResource.mjs +4 -0
- package/dist/esm/api/types/SumAggregationPricingMetricInterface.d.mts +3 -0
- package/dist/esm/api/types/SumAggregationPricingMetricResource.d.mts +1 -0
- package/dist/esm/api/types/index.d.mts +7 -4
- package/dist/esm/api/types/index.mjs +7 -4
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +114 -67
- package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.d.ts +0 -30
- package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.js +0 -14
- package/dist/cjs/api/types/CreatePricingMetricResponse.d.ts +0 -11
- package/dist/cjs/api/types/CreateUsageEventSummaryResponse.d.ts +0 -10
- package/dist/cjs/api/types/GetPricingMetricResponse.d.ts +0 -11
- package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.d.mts +0 -30
- package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.mjs +0 -11
- package/dist/esm/api/types/CreatePricingMetricResponse.d.mts +0 -11
- package/dist/esm/api/types/CreateUsageEventSummaryResponse.d.mts +0 -10
- package/dist/esm/api/types/GetPricingMetricResponse.d.mts +0 -11
- /package/dist/cjs/api/{types/CreatePricingMetricResponse.js → resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.js} +0 -0
- /package/dist/cjs/api/types/{CreateUsageEventSummaryResponse.js → CustomAggregationPricingMetricInterface.js} +0 -0
- /package/dist/cjs/api/types/{GetPricingMetricResponse.js → LastAggregationPricingMetricInterface.js} +0 -0
- /package/dist/esm/api/{types/CreatePricingMetricResponse.mjs → resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.mjs} +0 -0
- /package/dist/esm/api/types/{CreateUsageEventSummaryResponse.mjs → CustomAggregationPricingMetricInterface.mjs} +0 -0
- /package/dist/esm/api/types/{GetPricingMetricResponse.mjs → LastAggregationPricingMetricInterface.mjs} +0 -0
package/dist/cjs/Client.js
CHANGED
|
@@ -53,8 +53,8 @@ class LarkClient {
|
|
|
53
53
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
54
54
|
"X-Fern-Language": "JavaScript",
|
|
55
55
|
"X-Fern-SDK-Name": "lark-billing",
|
|
56
|
-
"X-Fern-SDK-Version": "0.0
|
|
57
|
-
"User-Agent": "lark-billing/0.0
|
|
56
|
+
"X-Fern-SDK-Version": "0.1.0",
|
|
57
|
+
"User-Agent": "lark-billing/0.1.0",
|
|
58
58
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
59
59
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
60
60
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -50,15 +50,16 @@ export declare class PricingMetrics {
|
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* await client.pricingMetrics.createPricingMetric({
|
|
53
|
-
* name: "
|
|
54
|
-
* event_name: "
|
|
53
|
+
* name: "Compute Hours",
|
|
54
|
+
* event_name: "job_completed",
|
|
55
55
|
* aggregation: {
|
|
56
|
-
* aggregation_type: "
|
|
56
|
+
* aggregation_type: "sum",
|
|
57
|
+
* value_field: "value_field"
|
|
57
58
|
* },
|
|
58
|
-
* unit: "
|
|
59
|
+
* unit: "hours"
|
|
59
60
|
* })
|
|
60
61
|
*/
|
|
61
|
-
createPricingMetric(request: Lark.CreatePricingMetricRequest, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.
|
|
62
|
+
createPricingMetric(request: Lark.CreatePricingMetricRequest, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.PricingMetricResource>;
|
|
62
63
|
private __createPricingMetric;
|
|
63
64
|
/**
|
|
64
65
|
* @param {string} pricingMetricId
|
|
@@ -69,8 +70,26 @@ export declare class PricingMetrics {
|
|
|
69
70
|
* @example
|
|
70
71
|
* await client.pricingMetrics.getPricingMetric("pricing_metric_id")
|
|
71
72
|
*/
|
|
72
|
-
getPricingMetric(pricingMetricId: string, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.
|
|
73
|
+
getPricingMetric(pricingMetricId: string, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.PricingMetricResource>;
|
|
73
74
|
private __getPricingMetric;
|
|
75
|
+
/**
|
|
76
|
+
* @param {string} pricingMetricId
|
|
77
|
+
* @param {Lark.CreatePricingMetricSummaryRequest} request
|
|
78
|
+
* @param {PricingMetrics.RequestOptions} requestOptions - Request-specific configuration.
|
|
79
|
+
*
|
|
80
|
+
* @throws {@link Lark.UnprocessableEntityError}
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* await client.pricingMetrics.createPricingMetricSummary("pricing_metric_id", {
|
|
84
|
+
* subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
85
|
+
* period: {
|
|
86
|
+
* start: "2025-10-01T00:00:00Z",
|
|
87
|
+
* end: "2025-11-01T00:00:00Z"
|
|
88
|
+
* }
|
|
89
|
+
* })
|
|
90
|
+
*/
|
|
91
|
+
createPricingMetricSummary(pricingMetricId: string, request: Lark.CreatePricingMetricSummaryRequest, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.PricingMetricSummaryResource>;
|
|
92
|
+
private __createPricingMetricSummary;
|
|
74
93
|
protected _getCustomAuthorizationHeaders(): Promise<{
|
|
75
94
|
"X-API-Key": string;
|
|
76
95
|
}>;
|
|
@@ -127,12 +127,13 @@ class PricingMetrics {
|
|
|
127
127
|
*
|
|
128
128
|
* @example
|
|
129
129
|
* await client.pricingMetrics.createPricingMetric({
|
|
130
|
-
* name: "
|
|
131
|
-
* event_name: "
|
|
130
|
+
* name: "Compute Hours",
|
|
131
|
+
* event_name: "job_completed",
|
|
132
132
|
* aggregation: {
|
|
133
|
-
* aggregation_type: "
|
|
133
|
+
* aggregation_type: "sum",
|
|
134
|
+
* value_field: "value_field"
|
|
134
135
|
* },
|
|
135
|
-
* unit: "
|
|
136
|
+
* unit: "hours"
|
|
136
137
|
* })
|
|
137
138
|
*/
|
|
138
139
|
createPricingMetric(request, requestOptions) {
|
|
@@ -243,6 +244,73 @@ class PricingMetrics {
|
|
|
243
244
|
}
|
|
244
245
|
});
|
|
245
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* @param {string} pricingMetricId
|
|
249
|
+
* @param {Lark.CreatePricingMetricSummaryRequest} request
|
|
250
|
+
* @param {PricingMetrics.RequestOptions} requestOptions - Request-specific configuration.
|
|
251
|
+
*
|
|
252
|
+
* @throws {@link Lark.UnprocessableEntityError}
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* await client.pricingMetrics.createPricingMetricSummary("pricing_metric_id", {
|
|
256
|
+
* subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
257
|
+
* period: {
|
|
258
|
+
* start: "2025-10-01T00:00:00Z",
|
|
259
|
+
* end: "2025-11-01T00:00:00Z"
|
|
260
|
+
* }
|
|
261
|
+
* })
|
|
262
|
+
*/
|
|
263
|
+
createPricingMetricSummary(pricingMetricId, request, requestOptions) {
|
|
264
|
+
return core.HttpResponsePromise.fromPromise(this.__createPricingMetricSummary(pricingMetricId, request, requestOptions));
|
|
265
|
+
}
|
|
266
|
+
__createPricingMetricSummary(pricingMetricId, request, requestOptions) {
|
|
267
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
+
var _a, _b, _c;
|
|
269
|
+
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
270
|
+
const _response = yield core.fetcher({
|
|
271
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LarkEnvironment.Default, `pricing-metrics/${encodeURIComponent(pricingMetricId)}/summary`),
|
|
272
|
+
method: "POST",
|
|
273
|
+
headers: _headers,
|
|
274
|
+
contentType: "application/json",
|
|
275
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
276
|
+
requestType: "json",
|
|
277
|
+
body: request,
|
|
278
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
279
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
280
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
281
|
+
});
|
|
282
|
+
if (_response.ok) {
|
|
283
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
284
|
+
}
|
|
285
|
+
if (_response.error.reason === "status-code") {
|
|
286
|
+
switch (_response.error.statusCode) {
|
|
287
|
+
case 422:
|
|
288
|
+
throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
289
|
+
default:
|
|
290
|
+
throw new errors.LarkError({
|
|
291
|
+
statusCode: _response.error.statusCode,
|
|
292
|
+
body: _response.error.body,
|
|
293
|
+
rawResponse: _response.rawResponse,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
switch (_response.error.reason) {
|
|
298
|
+
case "non-json":
|
|
299
|
+
throw new errors.LarkError({
|
|
300
|
+
statusCode: _response.error.statusCode,
|
|
301
|
+
body: _response.error.rawBody,
|
|
302
|
+
rawResponse: _response.rawResponse,
|
|
303
|
+
});
|
|
304
|
+
case "timeout":
|
|
305
|
+
throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /pricing-metrics/{pricing_metric_id}/summary.");
|
|
306
|
+
case "unknown":
|
|
307
|
+
throw new errors.LarkError({
|
|
308
|
+
message: _response.error.errorMessage,
|
|
309
|
+
rawResponse: _response.rawResponse,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
246
314
|
_getCustomAuthorizationHeaders() {
|
|
247
315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
316
|
const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
|
package/dist/cjs/api/resources/pricingMetrics/client/requests/CreatePricingMetricRequest.d.ts
CHANGED
|
@@ -5,18 +5,22 @@ import * as Lark from "../../../../index.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {
|
|
8
|
-
* name: "
|
|
9
|
-
* event_name: "
|
|
8
|
+
* name: "Compute Hours",
|
|
9
|
+
* event_name: "job_completed",
|
|
10
10
|
* aggregation: {
|
|
11
|
-
* aggregation_type: "
|
|
11
|
+
* aggregation_type: "sum",
|
|
12
|
+
* value_field: "value_field"
|
|
12
13
|
* },
|
|
13
|
-
* unit: "
|
|
14
|
+
* unit: "hours"
|
|
14
15
|
* }
|
|
15
16
|
*/
|
|
16
17
|
export interface CreatePricingMetricRequest {
|
|
18
|
+
/** The name of the pricing metric. */
|
|
17
19
|
name: string;
|
|
20
|
+
/** The name of the event that the pricing metric is computed on. */
|
|
18
21
|
event_name: string;
|
|
22
|
+
/** The aggregation function used to compute the value of the pricing metric. */
|
|
19
23
|
aggregation: Lark.PricingMetricAggregation;
|
|
20
|
-
/** Unit of measurement for the pricing metric */
|
|
24
|
+
/** Unit of measurement for the pricing metric. */
|
|
21
25
|
unit: string;
|
|
22
26
|
}
|
package/dist/cjs/api/resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as Lark from "../../../../index.js";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
9
|
+
* period: {
|
|
10
|
+
* start: "2025-10-01T00:00:00Z",
|
|
11
|
+
* end: "2025-11-01T00:00:00Z"
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export interface CreatePricingMetricSummaryRequest {
|
|
16
|
+
/** The ID of the subject that the summary should be computed for. */
|
|
17
|
+
subject_id: string;
|
|
18
|
+
/** The period that the summary should be computed over. */
|
|
19
|
+
period: Lark.Period;
|
|
20
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { type ListPricingMetricsPricingMetricsGetRequest } from "./ListPricingMetricsPricingMetricsGetRequest.js";
|
|
2
2
|
export { type CreatePricingMetricRequest } from "./CreatePricingMetricRequest.js";
|
|
3
|
+
export { type CreatePricingMetricSummaryRequest } from "./CreatePricingMetricSummaryRequest.js";
|
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
import * as Lark from "../../../index.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The aggregation function used to compute the value of the pricing metric.
|
|
7
|
+
*/
|
|
8
|
+
export type PricingMetricAggregation = Lark.PricingMetricAggregation.Count | Lark.PricingMetricAggregation.Custom | Lark.PricingMetricAggregation.Last | Lark.PricingMetricAggregation.Max | Lark.PricingMetricAggregation.Sum;
|
|
6
9
|
export declare namespace PricingMetricAggregation {
|
|
7
10
|
interface Count extends Lark.CountAggregationPricingMetricInterface {
|
|
8
11
|
aggregation_type: "count";
|
|
9
12
|
}
|
|
13
|
+
interface Custom extends Lark.CustomAggregationPricingMetricInterface {
|
|
14
|
+
aggregation_type: "custom";
|
|
15
|
+
}
|
|
16
|
+
interface Last extends Lark.LastAggregationPricingMetricInterface {
|
|
17
|
+
aggregation_type: "last";
|
|
18
|
+
}
|
|
19
|
+
interface Max extends Lark.MaxAggregationPricingMetricInterface {
|
|
20
|
+
aggregation_type: "max";
|
|
21
|
+
}
|
|
10
22
|
interface Sum extends Lark.SumAggregationPricingMetricInterface {
|
|
11
23
|
aggregation_type: "sum";
|
|
12
24
|
}
|
|
@@ -51,7 +51,33 @@ export declare class RateCards {
|
|
|
51
51
|
* @example
|
|
52
52
|
* await client.rateCards.createRateCard({
|
|
53
53
|
* name: "Pro Plan",
|
|
54
|
-
*
|
|
54
|
+
* description: "For production applications with moderate usage.",
|
|
55
|
+
* billing_interval: "monthly",
|
|
56
|
+
* fixed_rates: [{
|
|
57
|
+
* name: "Base Rate",
|
|
58
|
+
* price: {
|
|
59
|
+
* price_type: "flat",
|
|
60
|
+
* amount: {
|
|
61
|
+
* value: "2500",
|
|
62
|
+
* currency_code: "usd"
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* }],
|
|
66
|
+
* usage_based_rates: [{
|
|
67
|
+
* usage_based_rate_type: "simple",
|
|
68
|
+
* name: "name",
|
|
69
|
+
* price: {
|
|
70
|
+
* price_type: "flat",
|
|
71
|
+
* amount: {
|
|
72
|
+
* value: "2500",
|
|
73
|
+
* currency_code: "usd"
|
|
74
|
+
* }
|
|
75
|
+
* },
|
|
76
|
+
* pricing_metric_id: "pricing_metric_id"
|
|
77
|
+
* }],
|
|
78
|
+
* metadata: {
|
|
79
|
+
* "key": "value"
|
|
80
|
+
* }
|
|
55
81
|
* })
|
|
56
82
|
*/
|
|
57
83
|
createRateCard(request: Lark.CreateRateCardRequest, requestOptions?: RateCards.RequestOptions): core.HttpResponsePromise<Lark.RateCardResource>;
|
|
@@ -128,7 +128,33 @@ class RateCards {
|
|
|
128
128
|
* @example
|
|
129
129
|
* await client.rateCards.createRateCard({
|
|
130
130
|
* name: "Pro Plan",
|
|
131
|
-
*
|
|
131
|
+
* description: "For production applications with moderate usage.",
|
|
132
|
+
* billing_interval: "monthly",
|
|
133
|
+
* fixed_rates: [{
|
|
134
|
+
* name: "Base Rate",
|
|
135
|
+
* price: {
|
|
136
|
+
* price_type: "flat",
|
|
137
|
+
* amount: {
|
|
138
|
+
* value: "2500",
|
|
139
|
+
* currency_code: "usd"
|
|
140
|
+
* }
|
|
141
|
+
* }
|
|
142
|
+
* }],
|
|
143
|
+
* usage_based_rates: [{
|
|
144
|
+
* usage_based_rate_type: "simple",
|
|
145
|
+
* name: "name",
|
|
146
|
+
* price: {
|
|
147
|
+
* price_type: "flat",
|
|
148
|
+
* amount: {
|
|
149
|
+
* value: "2500",
|
|
150
|
+
* currency_code: "usd"
|
|
151
|
+
* }
|
|
152
|
+
* },
|
|
153
|
+
* pricing_metric_id: "pricing_metric_id"
|
|
154
|
+
* }],
|
|
155
|
+
* metadata: {
|
|
156
|
+
* "key": "value"
|
|
157
|
+
* }
|
|
132
158
|
* })
|
|
133
159
|
*/
|
|
134
160
|
createRateCard(request, requestOptions) {
|
|
@@ -6,7 +6,33 @@ import * as Lark from "../../../../index.js";
|
|
|
6
6
|
* @example
|
|
7
7
|
* {
|
|
8
8
|
* name: "Pro Plan",
|
|
9
|
-
*
|
|
9
|
+
* description: "For production applications with moderate usage.",
|
|
10
|
+
* billing_interval: "monthly",
|
|
11
|
+
* fixed_rates: [{
|
|
12
|
+
* name: "Base Rate",
|
|
13
|
+
* price: {
|
|
14
|
+
* price_type: "flat",
|
|
15
|
+
* amount: {
|
|
16
|
+
* value: "2500",
|
|
17
|
+
* currency_code: "usd"
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* }],
|
|
21
|
+
* usage_based_rates: [{
|
|
22
|
+
* usage_based_rate_type: "simple",
|
|
23
|
+
* name: "name",
|
|
24
|
+
* price: {
|
|
25
|
+
* price_type: "flat",
|
|
26
|
+
* amount: {
|
|
27
|
+
* value: "2500",
|
|
28
|
+
* currency_code: "usd"
|
|
29
|
+
* }
|
|
30
|
+
* },
|
|
31
|
+
* pricing_metric_id: "pricing_metric_id"
|
|
32
|
+
* }],
|
|
33
|
+
* metadata: {
|
|
34
|
+
* "key": "value"
|
|
35
|
+
* }
|
|
10
36
|
* }
|
|
11
37
|
*/
|
|
12
38
|
export interface CreateRateCardRequest {
|
|
@@ -16,7 +42,9 @@ export interface CreateRateCardRequest {
|
|
|
16
42
|
description?: string;
|
|
17
43
|
/** How often the customer will be billed for this rate card. */
|
|
18
44
|
billing_interval: CreateRateCardRequest.BillingInterval;
|
|
45
|
+
/** The fixed rates of the rate card. These are billed at the start of each billing cycle. */
|
|
19
46
|
fixed_rates?: Lark.CreateFixedRateRequest[];
|
|
47
|
+
/** The usage based rates of the rate card. These are billed at the end of each billing cycle. */
|
|
20
48
|
usage_based_rates?: Lark.CreateRateCardRequestUsageBasedRatesItem[];
|
|
21
49
|
metadata?: Record<string, string>;
|
|
22
50
|
}
|
|
@@ -50,7 +50,14 @@ export declare class Subjects {
|
|
|
50
50
|
* @throws {@link Lark.UnprocessableEntityError}
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
|
-
* await client.subjects.createSubject(
|
|
53
|
+
* await client.subjects.createSubject({
|
|
54
|
+
* external_id: "user_1234567890",
|
|
55
|
+
* name: "John Doe",
|
|
56
|
+
* email: "john.doe@example.com",
|
|
57
|
+
* metadata: {
|
|
58
|
+
* "key": "value"
|
|
59
|
+
* }
|
|
60
|
+
* })
|
|
54
61
|
*/
|
|
55
62
|
createSubject(request?: Lark.CreateSubjectRequest, requestOptions?: Subjects.RequestOptions): core.HttpResponsePromise<Lark.CreateSubjectResponse>;
|
|
56
63
|
private __createSubject;
|
|
@@ -130,7 +130,14 @@ class Subjects {
|
|
|
130
130
|
* @throws {@link Lark.UnprocessableEntityError}
|
|
131
131
|
*
|
|
132
132
|
* @example
|
|
133
|
-
* await client.subjects.createSubject(
|
|
133
|
+
* await client.subjects.createSubject({
|
|
134
|
+
* external_id: "user_1234567890",
|
|
135
|
+
* name: "John Doe",
|
|
136
|
+
* email: "john.doe@example.com",
|
|
137
|
+
* metadata: {
|
|
138
|
+
* "key": "value"
|
|
139
|
+
* }
|
|
140
|
+
* })
|
|
134
141
|
*/
|
|
135
142
|
createSubject(request = {}, requestOptions) {
|
|
136
143
|
return core.HttpResponsePromise.fromPromise(this.__createSubject(request, requestOptions));
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
|
-
* {
|
|
6
|
+
* {
|
|
7
|
+
* external_id: "user_1234567890",
|
|
8
|
+
* name: "John Doe",
|
|
9
|
+
* email: "john.doe@example.com",
|
|
10
|
+
* metadata: {
|
|
11
|
+
* "key": "value"
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
7
14
|
*/
|
|
8
15
|
export interface CreateSubjectRequest {
|
|
9
16
|
/** The ID of the subject in your system. If provided, you may use pass it to the API in place of the subject ID. Must be unique. */
|
|
@@ -37,35 +37,19 @@ export declare class UsageEvents {
|
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
39
|
* await client.usageEvents.createUsageEvent({
|
|
40
|
-
* idempotency_key: "
|
|
41
|
-
* event_name: "
|
|
42
|
-
* subject_id: "
|
|
40
|
+
* idempotency_key: "6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
|
|
41
|
+
* event_name: "compute_hours",
|
|
42
|
+
* subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
43
|
+
* timestamp: "2025-10-31T20:29:47Z",
|
|
43
44
|
* data: {
|
|
44
|
-
* "
|
|
45
|
+
* "compute_hours": 100,
|
|
46
|
+
* "instance_type": "t2.micro",
|
|
47
|
+
* "region": "us-east-1"
|
|
45
48
|
* }
|
|
46
49
|
* })
|
|
47
50
|
*/
|
|
48
51
|
createUsageEvent(request: Lark.CreateUsageEventRequest, requestOptions?: UsageEvents.RequestOptions): core.HttpResponsePromise<unknown>;
|
|
49
52
|
private __createUsageEvent;
|
|
50
|
-
/**
|
|
51
|
-
* @param {Lark.CreateUsageEventSummaryRequest} request
|
|
52
|
-
* @param {UsageEvents.RequestOptions} requestOptions - Request-specific configuration.
|
|
53
|
-
*
|
|
54
|
-
* @throws {@link Lark.UnprocessableEntityError}
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* await client.usageEvents.createUsageEventSummary({
|
|
58
|
-
* event_name: "event_name",
|
|
59
|
-
* subject_id: "subject_id",
|
|
60
|
-
* period: {
|
|
61
|
-
* start: "2024-01-15T09:30:00Z",
|
|
62
|
-
* end: "2024-01-15T09:30:00Z"
|
|
63
|
-
* },
|
|
64
|
-
* aggregation_type: "sum"
|
|
65
|
-
* })
|
|
66
|
-
*/
|
|
67
|
-
createUsageEventSummary(request: Lark.CreateUsageEventSummaryRequest, requestOptions?: UsageEvents.RequestOptions): core.HttpResponsePromise<Lark.CreateUsageEventSummaryResponse>;
|
|
68
|
-
private __createUsageEventSummary;
|
|
69
53
|
protected _getCustomAuthorizationHeaders(): Promise<{
|
|
70
54
|
"X-API-Key": string;
|
|
71
55
|
}>;
|
|
@@ -63,11 +63,14 @@ class UsageEvents {
|
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* await client.usageEvents.createUsageEvent({
|
|
66
|
-
* idempotency_key: "
|
|
67
|
-
* event_name: "
|
|
68
|
-
* subject_id: "
|
|
66
|
+
* idempotency_key: "6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
|
|
67
|
+
* event_name: "compute_hours",
|
|
68
|
+
* subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
69
|
+
* timestamp: "2025-10-31T20:29:47Z",
|
|
69
70
|
* data: {
|
|
70
|
-
* "
|
|
71
|
+
* "compute_hours": 100,
|
|
72
|
+
* "instance_type": "t2.micro",
|
|
73
|
+
* "region": "us-east-1"
|
|
71
74
|
* }
|
|
72
75
|
* })
|
|
73
76
|
*/
|
|
@@ -122,74 +125,6 @@ class UsageEvents {
|
|
|
122
125
|
}
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
|
-
/**
|
|
126
|
-
* @param {Lark.CreateUsageEventSummaryRequest} request
|
|
127
|
-
* @param {UsageEvents.RequestOptions} requestOptions - Request-specific configuration.
|
|
128
|
-
*
|
|
129
|
-
* @throws {@link Lark.UnprocessableEntityError}
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* await client.usageEvents.createUsageEventSummary({
|
|
133
|
-
* event_name: "event_name",
|
|
134
|
-
* subject_id: "subject_id",
|
|
135
|
-
* period: {
|
|
136
|
-
* start: "2024-01-15T09:30:00Z",
|
|
137
|
-
* end: "2024-01-15T09:30:00Z"
|
|
138
|
-
* },
|
|
139
|
-
* aggregation_type: "sum"
|
|
140
|
-
* })
|
|
141
|
-
*/
|
|
142
|
-
createUsageEventSummary(request, requestOptions) {
|
|
143
|
-
return core.HttpResponsePromise.fromPromise(this.__createUsageEventSummary(request, requestOptions));
|
|
144
|
-
}
|
|
145
|
-
__createUsageEventSummary(request, requestOptions) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
var _a, _b, _c;
|
|
148
|
-
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
149
|
-
const _response = yield core.fetcher({
|
|
150
|
-
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LarkEnvironment.Default, "usage-events/summary"),
|
|
151
|
-
method: "POST",
|
|
152
|
-
headers: _headers,
|
|
153
|
-
contentType: "application/json",
|
|
154
|
-
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
155
|
-
requestType: "json",
|
|
156
|
-
body: request,
|
|
157
|
-
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
158
|
-
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
159
|
-
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
160
|
-
});
|
|
161
|
-
if (_response.ok) {
|
|
162
|
-
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
163
|
-
}
|
|
164
|
-
if (_response.error.reason === "status-code") {
|
|
165
|
-
switch (_response.error.statusCode) {
|
|
166
|
-
case 422:
|
|
167
|
-
throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
168
|
-
default:
|
|
169
|
-
throw new errors.LarkError({
|
|
170
|
-
statusCode: _response.error.statusCode,
|
|
171
|
-
body: _response.error.body,
|
|
172
|
-
rawResponse: _response.rawResponse,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
switch (_response.error.reason) {
|
|
177
|
-
case "non-json":
|
|
178
|
-
throw new errors.LarkError({
|
|
179
|
-
statusCode: _response.error.statusCode,
|
|
180
|
-
body: _response.error.rawBody,
|
|
181
|
-
rawResponse: _response.rawResponse,
|
|
182
|
-
});
|
|
183
|
-
case "timeout":
|
|
184
|
-
throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /usage-events/summary.");
|
|
185
|
-
case "unknown":
|
|
186
|
-
throw new errors.LarkError({
|
|
187
|
-
message: _response.error.errorMessage,
|
|
188
|
-
rawResponse: _response.rawResponse,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
128
|
_getCustomAuthorizationHeaders() {
|
|
194
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
130
|
const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
* {
|
|
7
|
-
* idempotency_key: "
|
|
8
|
-
* event_name: "
|
|
9
|
-
* subject_id: "
|
|
7
|
+
* idempotency_key: "6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
|
|
8
|
+
* event_name: "compute_hours",
|
|
9
|
+
* subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
10
|
+
* timestamp: "2025-10-31T20:29:47Z",
|
|
10
11
|
* data: {
|
|
11
|
-
* "
|
|
12
|
+
* "compute_hours": 100,
|
|
13
|
+
* "instance_type": "t2.micro",
|
|
14
|
+
* "region": "us-east-1"
|
|
12
15
|
* }
|
|
13
16
|
* }
|
|
14
17
|
*/
|
|
@@ -26,6 +29,6 @@ export interface CreateUsageEventRequest {
|
|
|
26
29
|
}
|
|
27
30
|
export declare namespace CreateUsageEventRequest {
|
|
28
31
|
namespace Data {
|
|
29
|
-
type Value = string | number
|
|
32
|
+
type Value = string | number;
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
import * as Lark from "../index.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The aggregation function used to compute the value of the pricing metric.
|
|
7
|
+
*/
|
|
8
|
+
export type Aggregation = Lark.Aggregation.Count | Lark.Aggregation.Last | Lark.Aggregation.Max | Lark.Aggregation.Sum;
|
|
6
9
|
export declare namespace Aggregation {
|
|
7
10
|
interface Count extends Lark.CountAggregationPricingMetricResource {
|
|
8
11
|
aggregation_type: "count";
|
|
9
12
|
}
|
|
13
|
+
interface Last extends Lark.LastAggregationPricingMetricResource {
|
|
14
|
+
aggregation_type: "last";
|
|
15
|
+
}
|
|
16
|
+
interface Max extends Lark.MaxAggregationPricingMetricResource {
|
|
17
|
+
aggregation_type: "max";
|
|
18
|
+
}
|
|
10
19
|
interface Sum extends Lark.SumAggregationPricingMetricResource {
|
|
11
20
|
aggregation_type: "sum";
|
|
12
21
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
export interface BillingStateResponse {
|
|
5
|
+
/** Whether the subject has an active subscription. */
|
|
5
6
|
has_active_subscription: boolean;
|
|
7
|
+
/** Whether the subject has exceeded the included usage (if any) on a usage-based rate they are subscribed to. */
|
|
6
8
|
has_overage_for_usage: boolean;
|
|
7
9
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Custom aggregation for use cases not supported by the other aggregation types. Please email team@uselark.ai to enable this feature.
|
|
6
|
+
*/
|
|
7
|
+
export interface CustomAggregationPricingMetricInterface {
|
|
8
|
+
/** Custom expression to compute the pricing metric. Please email team@uselark.ai to enable this feature. */
|
|
9
|
+
custom_expression: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Computes the last value of the `value_field` over all usage events with the specified `event_name`.
|
|
6
|
+
*/
|
|
7
|
+
export interface LastAggregationPricingMetricInterface {
|
|
8
|
+
/** Field to get the last value of. */
|
|
9
|
+
value_field: string;
|
|
10
|
+
}
|