lark-billing 0.0.8__py3-none-any.whl → 0.1.0__py3-none-any.whl
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.
Potentially problematic release.
This version of lark-billing might be problematic. Click here for more details.
- lark/__init__.py +41 -16
- lark/checkout/client.py +8 -4
- lark/checkout/raw_client.py +4 -0
- lark/core/client_wrapper.py +2 -2
- lark/customer_portal/client.py +4 -2
- lark/customer_portal/raw_client.py +2 -0
- lark/pricing_metrics/__init__.py +19 -2
- lark/pricing_metrics/client.py +148 -22
- lark/pricing_metrics/raw_client.py +159 -20
- lark/pricing_metrics/types/__init__.py +14 -1
- lark/pricing_metrics/types/pricing_metric_aggregation.py +69 -1
- lark/rate_cards/client.py +74 -12
- lark/rate_cards/raw_client.py +24 -14
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +1 -1
- lark/subjects/client.py +12 -2
- lark/subscriptions/client.py +4 -2
- lark/subscriptions/raw_client.py +2 -0
- lark/types/__init__.py +23 -13
- lark/types/aggregation.py +45 -1
- lark/types/amount.py +4 -1
- lark/types/billing_state_response.py +9 -2
- lark/types/count_aggregation_pricing_metric_interface.py +4 -0
- lark/types/create_customer_portal_session_response.py +9 -2
- lark/types/create_fixed_rate_request.py +10 -2
- lark/types/create_simple_usage_based_rate_request.py +15 -3
- lark/types/create_subscription_checkout_session_response.py +14 -3
- lark/types/custom_aggregation_pricing_metric_interface.py +26 -0
- lark/types/fixed_rate_interface.py +1 -1
- lark/types/invoice_resource.py +34 -9
- lark/types/last_aggregation_pricing_metric_interface.py +26 -0
- lark/types/{get_pricing_metric_response.py → last_aggregation_pricing_metric_resource.py} +5 -7
- lark/types/{create_usage_event_summary_response.py → max_aggregation_pricing_metric_interface.py} +9 -6
- lark/types/{create_pricing_metric_response.py → max_aggregation_pricing_metric_resource.py} +5 -7
- lark/types/period.py +3 -2
- lark/types/pricing_metric_resource.py +24 -5
- lark/types/pricing_metric_summary_resource.py +43 -0
- lark/types/rate_card_resource.py +36 -7
- lark/types/rate_card_resource_usage_based_rates_item.py +1 -1
- lark/types/simple_usage_based_rate_interface.py +1 -1
- lark/types/subscription_resource.py +39 -8
- lark/types/sum_aggregation_pricing_metric_interface.py +4 -0
- lark/types/sum_aggregation_pricing_metric_resource.py +4 -1
- lark/usage_events/__init__.py +3 -3
- lark/usage_events/client.py +40 -131
- lark/usage_events/raw_client.py +21 -147
- lark/usage_events/types/__init__.py +3 -5
- lark/{types/value.py → usage_events/types/create_usage_event_request_data_value.py} +1 -1
- {lark_billing-0.0.8.dist-info → lark_billing-0.1.0.dist-info}/METADATA +5 -5
- {lark_billing-0.0.8.dist-info → lark_billing-0.1.0.dist-info}/RECORD +50 -48
- lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +0 -5
- {lark_billing-0.0.8.dist-info → lark_billing-0.1.0.dist-info}/WHEEL +0 -0
|
@@ -11,10 +11,11 @@ from ..core.pydantic_utilities import parse_obj_as
|
|
|
11
11
|
from ..core.request_options import RequestOptions
|
|
12
12
|
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
13
13
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
14
|
-
from ..types.create_pricing_metric_response import CreatePricingMetricResponse
|
|
15
|
-
from ..types.get_pricing_metric_response import GetPricingMetricResponse
|
|
16
14
|
from ..types.http_validation_error import HttpValidationError
|
|
17
15
|
from ..types.list_pricing_metrics_response import ListPricingMetricsResponse
|
|
16
|
+
from ..types.period import Period
|
|
17
|
+
from ..types.pricing_metric_resource import PricingMetricResource
|
|
18
|
+
from ..types.pricing_metric_summary_resource import PricingMetricSummaryResource
|
|
18
19
|
from .types.pricing_metric_aggregation import PricingMetricAggregation
|
|
19
20
|
|
|
20
21
|
# this is used as the default value for optional parameters
|
|
@@ -83,25 +84,28 @@ class RawPricingMetricsClient:
|
|
|
83
84
|
aggregation: PricingMetricAggregation,
|
|
84
85
|
unit: str,
|
|
85
86
|
request_options: typing.Optional[RequestOptions] = None,
|
|
86
|
-
) -> HttpResponse[
|
|
87
|
+
) -> HttpResponse[PricingMetricResource]:
|
|
87
88
|
"""
|
|
88
89
|
Parameters
|
|
89
90
|
----------
|
|
90
91
|
name : str
|
|
92
|
+
The name of the pricing metric.
|
|
91
93
|
|
|
92
94
|
event_name : str
|
|
95
|
+
The name of the event that the pricing metric is computed on.
|
|
93
96
|
|
|
94
97
|
aggregation : PricingMetricAggregation
|
|
98
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
95
99
|
|
|
96
100
|
unit : str
|
|
97
|
-
Unit of measurement for the pricing metric
|
|
101
|
+
Unit of measurement for the pricing metric.
|
|
98
102
|
|
|
99
103
|
request_options : typing.Optional[RequestOptions]
|
|
100
104
|
Request-specific configuration.
|
|
101
105
|
|
|
102
106
|
Returns
|
|
103
107
|
-------
|
|
104
|
-
HttpResponse[
|
|
108
|
+
HttpResponse[PricingMetricResource]
|
|
105
109
|
Successful Response
|
|
106
110
|
"""
|
|
107
111
|
_response = self._client_wrapper.httpx_client.request(
|
|
@@ -124,9 +128,9 @@ class RawPricingMetricsClient:
|
|
|
124
128
|
try:
|
|
125
129
|
if 200 <= _response.status_code < 300:
|
|
126
130
|
_data = typing.cast(
|
|
127
|
-
|
|
131
|
+
PricingMetricResource,
|
|
128
132
|
parse_obj_as(
|
|
129
|
-
type_=
|
|
133
|
+
type_=PricingMetricResource, # type: ignore
|
|
130
134
|
object_=_response.json(),
|
|
131
135
|
),
|
|
132
136
|
)
|
|
@@ -149,7 +153,7 @@ class RawPricingMetricsClient:
|
|
|
149
153
|
|
|
150
154
|
def get_pricing_metric(
|
|
151
155
|
self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
152
|
-
) -> HttpResponse[
|
|
156
|
+
) -> HttpResponse[PricingMetricResource]:
|
|
153
157
|
"""
|
|
154
158
|
Parameters
|
|
155
159
|
----------
|
|
@@ -160,7 +164,7 @@ class RawPricingMetricsClient:
|
|
|
160
164
|
|
|
161
165
|
Returns
|
|
162
166
|
-------
|
|
163
|
-
HttpResponse[
|
|
167
|
+
HttpResponse[PricingMetricResource]
|
|
164
168
|
Successful Response
|
|
165
169
|
"""
|
|
166
170
|
_response = self._client_wrapper.httpx_client.request(
|
|
@@ -171,9 +175,75 @@ class RawPricingMetricsClient:
|
|
|
171
175
|
try:
|
|
172
176
|
if 200 <= _response.status_code < 300:
|
|
173
177
|
_data = typing.cast(
|
|
174
|
-
|
|
178
|
+
PricingMetricResource,
|
|
175
179
|
parse_obj_as(
|
|
176
|
-
type_=
|
|
180
|
+
type_=PricingMetricResource, # type: ignore
|
|
181
|
+
object_=_response.json(),
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
return HttpResponse(response=_response, data=_data)
|
|
185
|
+
if _response.status_code == 422:
|
|
186
|
+
raise UnprocessableEntityError(
|
|
187
|
+
headers=dict(_response.headers),
|
|
188
|
+
body=typing.cast(
|
|
189
|
+
HttpValidationError,
|
|
190
|
+
parse_obj_as(
|
|
191
|
+
type_=HttpValidationError, # type: ignore
|
|
192
|
+
object_=_response.json(),
|
|
193
|
+
),
|
|
194
|
+
),
|
|
195
|
+
)
|
|
196
|
+
_response_json = _response.json()
|
|
197
|
+
except JSONDecodeError:
|
|
198
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
199
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
200
|
+
|
|
201
|
+
def create_pricing_metric_summary(
|
|
202
|
+
self,
|
|
203
|
+
pricing_metric_id: str,
|
|
204
|
+
*,
|
|
205
|
+
subject_id: str,
|
|
206
|
+
period: Period,
|
|
207
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
208
|
+
) -> HttpResponse[PricingMetricSummaryResource]:
|
|
209
|
+
"""
|
|
210
|
+
Parameters
|
|
211
|
+
----------
|
|
212
|
+
pricing_metric_id : str
|
|
213
|
+
|
|
214
|
+
subject_id : str
|
|
215
|
+
The ID of the subject that the summary should be computed for.
|
|
216
|
+
|
|
217
|
+
period : Period
|
|
218
|
+
The period that the summary should be computed over.
|
|
219
|
+
|
|
220
|
+
request_options : typing.Optional[RequestOptions]
|
|
221
|
+
Request-specific configuration.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
HttpResponse[PricingMetricSummaryResource]
|
|
226
|
+
Successful Response
|
|
227
|
+
"""
|
|
228
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
229
|
+
f"pricing-metrics/{jsonable_encoder(pricing_metric_id)}/summary",
|
|
230
|
+
method="POST",
|
|
231
|
+
json={
|
|
232
|
+
"subject_id": subject_id,
|
|
233
|
+
"period": convert_and_respect_annotation_metadata(object_=period, annotation=Period, direction="write"),
|
|
234
|
+
},
|
|
235
|
+
headers={
|
|
236
|
+
"content-type": "application/json",
|
|
237
|
+
},
|
|
238
|
+
request_options=request_options,
|
|
239
|
+
omit=OMIT,
|
|
240
|
+
)
|
|
241
|
+
try:
|
|
242
|
+
if 200 <= _response.status_code < 300:
|
|
243
|
+
_data = typing.cast(
|
|
244
|
+
PricingMetricSummaryResource,
|
|
245
|
+
parse_obj_as(
|
|
246
|
+
type_=PricingMetricSummaryResource, # type: ignore
|
|
177
247
|
object_=_response.json(),
|
|
178
248
|
),
|
|
179
249
|
)
|
|
@@ -257,25 +327,28 @@ class AsyncRawPricingMetricsClient:
|
|
|
257
327
|
aggregation: PricingMetricAggregation,
|
|
258
328
|
unit: str,
|
|
259
329
|
request_options: typing.Optional[RequestOptions] = None,
|
|
260
|
-
) -> AsyncHttpResponse[
|
|
330
|
+
) -> AsyncHttpResponse[PricingMetricResource]:
|
|
261
331
|
"""
|
|
262
332
|
Parameters
|
|
263
333
|
----------
|
|
264
334
|
name : str
|
|
335
|
+
The name of the pricing metric.
|
|
265
336
|
|
|
266
337
|
event_name : str
|
|
338
|
+
The name of the event that the pricing metric is computed on.
|
|
267
339
|
|
|
268
340
|
aggregation : PricingMetricAggregation
|
|
341
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
269
342
|
|
|
270
343
|
unit : str
|
|
271
|
-
Unit of measurement for the pricing metric
|
|
344
|
+
Unit of measurement for the pricing metric.
|
|
272
345
|
|
|
273
346
|
request_options : typing.Optional[RequestOptions]
|
|
274
347
|
Request-specific configuration.
|
|
275
348
|
|
|
276
349
|
Returns
|
|
277
350
|
-------
|
|
278
|
-
AsyncHttpResponse[
|
|
351
|
+
AsyncHttpResponse[PricingMetricResource]
|
|
279
352
|
Successful Response
|
|
280
353
|
"""
|
|
281
354
|
_response = await self._client_wrapper.httpx_client.request(
|
|
@@ -298,9 +371,9 @@ class AsyncRawPricingMetricsClient:
|
|
|
298
371
|
try:
|
|
299
372
|
if 200 <= _response.status_code < 300:
|
|
300
373
|
_data = typing.cast(
|
|
301
|
-
|
|
374
|
+
PricingMetricResource,
|
|
302
375
|
parse_obj_as(
|
|
303
|
-
type_=
|
|
376
|
+
type_=PricingMetricResource, # type: ignore
|
|
304
377
|
object_=_response.json(),
|
|
305
378
|
),
|
|
306
379
|
)
|
|
@@ -323,7 +396,7 @@ class AsyncRawPricingMetricsClient:
|
|
|
323
396
|
|
|
324
397
|
async def get_pricing_metric(
|
|
325
398
|
self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
326
|
-
) -> AsyncHttpResponse[
|
|
399
|
+
) -> AsyncHttpResponse[PricingMetricResource]:
|
|
327
400
|
"""
|
|
328
401
|
Parameters
|
|
329
402
|
----------
|
|
@@ -334,7 +407,7 @@ class AsyncRawPricingMetricsClient:
|
|
|
334
407
|
|
|
335
408
|
Returns
|
|
336
409
|
-------
|
|
337
|
-
AsyncHttpResponse[
|
|
410
|
+
AsyncHttpResponse[PricingMetricResource]
|
|
338
411
|
Successful Response
|
|
339
412
|
"""
|
|
340
413
|
_response = await self._client_wrapper.httpx_client.request(
|
|
@@ -345,9 +418,75 @@ class AsyncRawPricingMetricsClient:
|
|
|
345
418
|
try:
|
|
346
419
|
if 200 <= _response.status_code < 300:
|
|
347
420
|
_data = typing.cast(
|
|
348
|
-
|
|
421
|
+
PricingMetricResource,
|
|
422
|
+
parse_obj_as(
|
|
423
|
+
type_=PricingMetricResource, # type: ignore
|
|
424
|
+
object_=_response.json(),
|
|
425
|
+
),
|
|
426
|
+
)
|
|
427
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
428
|
+
if _response.status_code == 422:
|
|
429
|
+
raise UnprocessableEntityError(
|
|
430
|
+
headers=dict(_response.headers),
|
|
431
|
+
body=typing.cast(
|
|
432
|
+
HttpValidationError,
|
|
433
|
+
parse_obj_as(
|
|
434
|
+
type_=HttpValidationError, # type: ignore
|
|
435
|
+
object_=_response.json(),
|
|
436
|
+
),
|
|
437
|
+
),
|
|
438
|
+
)
|
|
439
|
+
_response_json = _response.json()
|
|
440
|
+
except JSONDecodeError:
|
|
441
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
442
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
443
|
+
|
|
444
|
+
async def create_pricing_metric_summary(
|
|
445
|
+
self,
|
|
446
|
+
pricing_metric_id: str,
|
|
447
|
+
*,
|
|
448
|
+
subject_id: str,
|
|
449
|
+
period: Period,
|
|
450
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
451
|
+
) -> AsyncHttpResponse[PricingMetricSummaryResource]:
|
|
452
|
+
"""
|
|
453
|
+
Parameters
|
|
454
|
+
----------
|
|
455
|
+
pricing_metric_id : str
|
|
456
|
+
|
|
457
|
+
subject_id : str
|
|
458
|
+
The ID of the subject that the summary should be computed for.
|
|
459
|
+
|
|
460
|
+
period : Period
|
|
461
|
+
The period that the summary should be computed over.
|
|
462
|
+
|
|
463
|
+
request_options : typing.Optional[RequestOptions]
|
|
464
|
+
Request-specific configuration.
|
|
465
|
+
|
|
466
|
+
Returns
|
|
467
|
+
-------
|
|
468
|
+
AsyncHttpResponse[PricingMetricSummaryResource]
|
|
469
|
+
Successful Response
|
|
470
|
+
"""
|
|
471
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
472
|
+
f"pricing-metrics/{jsonable_encoder(pricing_metric_id)}/summary",
|
|
473
|
+
method="POST",
|
|
474
|
+
json={
|
|
475
|
+
"subject_id": subject_id,
|
|
476
|
+
"period": convert_and_respect_annotation_metadata(object_=period, annotation=Period, direction="write"),
|
|
477
|
+
},
|
|
478
|
+
headers={
|
|
479
|
+
"content-type": "application/json",
|
|
480
|
+
},
|
|
481
|
+
request_options=request_options,
|
|
482
|
+
omit=OMIT,
|
|
483
|
+
)
|
|
484
|
+
try:
|
|
485
|
+
if 200 <= _response.status_code < 300:
|
|
486
|
+
_data = typing.cast(
|
|
487
|
+
PricingMetricSummaryResource,
|
|
349
488
|
parse_obj_as(
|
|
350
|
-
type_=
|
|
489
|
+
type_=PricingMetricSummaryResource, # type: ignore
|
|
351
490
|
object_=_response.json(),
|
|
352
491
|
),
|
|
353
492
|
)
|
|
@@ -9,11 +9,17 @@ if typing.TYPE_CHECKING:
|
|
|
9
9
|
from .pricing_metric_aggregation import (
|
|
10
10
|
PricingMetricAggregation,
|
|
11
11
|
PricingMetricAggregation_Count,
|
|
12
|
+
PricingMetricAggregation_Custom,
|
|
13
|
+
PricingMetricAggregation_Last,
|
|
14
|
+
PricingMetricAggregation_Max,
|
|
12
15
|
PricingMetricAggregation_Sum,
|
|
13
16
|
)
|
|
14
17
|
_dynamic_imports: typing.Dict[str, str] = {
|
|
15
18
|
"PricingMetricAggregation": ".pricing_metric_aggregation",
|
|
16
19
|
"PricingMetricAggregation_Count": ".pricing_metric_aggregation",
|
|
20
|
+
"PricingMetricAggregation_Custom": ".pricing_metric_aggregation",
|
|
21
|
+
"PricingMetricAggregation_Last": ".pricing_metric_aggregation",
|
|
22
|
+
"PricingMetricAggregation_Max": ".pricing_metric_aggregation",
|
|
17
23
|
"PricingMetricAggregation_Sum": ".pricing_metric_aggregation",
|
|
18
24
|
}
|
|
19
25
|
|
|
@@ -39,4 +45,11 @@ def __dir__():
|
|
|
39
45
|
return sorted(lazy_attrs)
|
|
40
46
|
|
|
41
47
|
|
|
42
|
-
__all__ = [
|
|
48
|
+
__all__ = [
|
|
49
|
+
"PricingMetricAggregation",
|
|
50
|
+
"PricingMetricAggregation_Count",
|
|
51
|
+
"PricingMetricAggregation_Custom",
|
|
52
|
+
"PricingMetricAggregation_Last",
|
|
53
|
+
"PricingMetricAggregation_Max",
|
|
54
|
+
"PricingMetricAggregation_Sum",
|
|
55
|
+
]
|
|
@@ -9,6 +9,10 @@ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class PricingMetricAggregation_Count(UniversalBaseModel):
|
|
12
|
+
"""
|
|
13
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
14
|
+
"""
|
|
15
|
+
|
|
12
16
|
aggregation_type: typing.Literal["count"] = "count"
|
|
13
17
|
|
|
14
18
|
if IS_PYDANTIC_V2:
|
|
@@ -21,7 +25,65 @@ class PricingMetricAggregation_Count(UniversalBaseModel):
|
|
|
21
25
|
extra = pydantic.Extra.allow
|
|
22
26
|
|
|
23
27
|
|
|
28
|
+
class PricingMetricAggregation_Custom(UniversalBaseModel):
|
|
29
|
+
"""
|
|
30
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
aggregation_type: typing.Literal["custom"] = "custom"
|
|
34
|
+
custom_expression: str
|
|
35
|
+
|
|
36
|
+
if IS_PYDANTIC_V2:
|
|
37
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
38
|
+
else:
|
|
39
|
+
|
|
40
|
+
class Config:
|
|
41
|
+
frozen = True
|
|
42
|
+
smart_union = True
|
|
43
|
+
extra = pydantic.Extra.allow
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class PricingMetricAggregation_Last(UniversalBaseModel):
|
|
47
|
+
"""
|
|
48
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
aggregation_type: typing.Literal["last"] = "last"
|
|
52
|
+
value_field: str
|
|
53
|
+
|
|
54
|
+
if IS_PYDANTIC_V2:
|
|
55
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
56
|
+
else:
|
|
57
|
+
|
|
58
|
+
class Config:
|
|
59
|
+
frozen = True
|
|
60
|
+
smart_union = True
|
|
61
|
+
extra = pydantic.Extra.allow
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class PricingMetricAggregation_Max(UniversalBaseModel):
|
|
65
|
+
"""
|
|
66
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
aggregation_type: typing.Literal["max"] = "max"
|
|
70
|
+
value_field: str
|
|
71
|
+
|
|
72
|
+
if IS_PYDANTIC_V2:
|
|
73
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
74
|
+
else:
|
|
75
|
+
|
|
76
|
+
class Config:
|
|
77
|
+
frozen = True
|
|
78
|
+
smart_union = True
|
|
79
|
+
extra = pydantic.Extra.allow
|
|
80
|
+
|
|
81
|
+
|
|
24
82
|
class PricingMetricAggregation_Sum(UniversalBaseModel):
|
|
83
|
+
"""
|
|
84
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
85
|
+
"""
|
|
86
|
+
|
|
25
87
|
aggregation_type: typing.Literal["sum"] = "sum"
|
|
26
88
|
value_field: str
|
|
27
89
|
|
|
@@ -35,4 +97,10 @@ class PricingMetricAggregation_Sum(UniversalBaseModel):
|
|
|
35
97
|
extra = pydantic.Extra.allow
|
|
36
98
|
|
|
37
99
|
|
|
38
|
-
PricingMetricAggregation = typing.Union[
|
|
100
|
+
PricingMetricAggregation = typing.Union[
|
|
101
|
+
PricingMetricAggregation_Count,
|
|
102
|
+
PricingMetricAggregation_Custom,
|
|
103
|
+
PricingMetricAggregation_Last,
|
|
104
|
+
PricingMetricAggregation_Max,
|
|
105
|
+
PricingMetricAggregation_Sum,
|
|
106
|
+
]
|
lark/rate_cards/client.py
CHANGED
|
@@ -66,8 +66,8 @@ class RateCardsClient:
|
|
|
66
66
|
name: str,
|
|
67
67
|
billing_interval: CreateRateCardRequestBillingInterval,
|
|
68
68
|
description: typing.Optional[str] = OMIT,
|
|
69
|
-
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
70
69
|
fixed_rates: typing.Optional[typing.Sequence[CreateFixedRateRequest]] = OMIT,
|
|
70
|
+
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
71
71
|
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
72
72
|
request_options: typing.Optional[RequestOptions] = None,
|
|
73
73
|
) -> RateCardResource:
|
|
@@ -75,14 +75,19 @@ class RateCardsClient:
|
|
|
75
75
|
Parameters
|
|
76
76
|
----------
|
|
77
77
|
name : str
|
|
78
|
+
The name of the rate card displayed to the customer.
|
|
78
79
|
|
|
79
80
|
billing_interval : CreateRateCardRequestBillingInterval
|
|
81
|
+
How often the customer will be billed for this rate card.
|
|
80
82
|
|
|
81
83
|
description : typing.Optional[str]
|
|
82
|
-
|
|
83
|
-
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
84
|
+
The description of the rate card displayed to the customer.
|
|
84
85
|
|
|
85
86
|
fixed_rates : typing.Optional[typing.Sequence[CreateFixedRateRequest]]
|
|
87
|
+
The fixed rates of the rate card. These are billed at the start of each billing cycle.
|
|
88
|
+
|
|
89
|
+
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
90
|
+
The usage based rates of the rate card. These are billed at the end of each billing cycle.
|
|
86
91
|
|
|
87
92
|
metadata : typing.Optional[typing.Dict[str, str]]
|
|
88
93
|
|
|
@@ -96,22 +101,48 @@ class RateCardsClient:
|
|
|
96
101
|
|
|
97
102
|
Examples
|
|
98
103
|
--------
|
|
99
|
-
from lark import Lark
|
|
104
|
+
from lark import Amount, CreateFixedRateRequest, Lark, Price_Flat
|
|
105
|
+
from lark.rate_cards import CreateRateCardRequestUsageBasedRatesItem_Simple
|
|
100
106
|
|
|
101
107
|
client = Lark(
|
|
102
108
|
api_key="YOUR_API_KEY",
|
|
103
109
|
)
|
|
104
110
|
client.rate_cards.create_rate_card(
|
|
105
|
-
name="
|
|
111
|
+
name="Pro Plan",
|
|
112
|
+
description="For production applications with moderate usage.",
|
|
106
113
|
billing_interval="monthly",
|
|
114
|
+
fixed_rates=[
|
|
115
|
+
CreateFixedRateRequest(
|
|
116
|
+
name="Base Rate",
|
|
117
|
+
price=Price_Flat(
|
|
118
|
+
amount=Amount(
|
|
119
|
+
value="2500",
|
|
120
|
+
currency_code="usd",
|
|
121
|
+
),
|
|
122
|
+
),
|
|
123
|
+
)
|
|
124
|
+
],
|
|
125
|
+
usage_based_rates=[
|
|
126
|
+
CreateRateCardRequestUsageBasedRatesItem_Simple(
|
|
127
|
+
name="name",
|
|
128
|
+
price=Price_Flat(
|
|
129
|
+
amount=Amount(
|
|
130
|
+
value="2500",
|
|
131
|
+
currency_code="usd",
|
|
132
|
+
),
|
|
133
|
+
),
|
|
134
|
+
pricing_metric_id="pricing_metric_id",
|
|
135
|
+
)
|
|
136
|
+
],
|
|
137
|
+
metadata={"key": "value"},
|
|
107
138
|
)
|
|
108
139
|
"""
|
|
109
140
|
_response = self._raw_client.create_rate_card(
|
|
110
141
|
name=name,
|
|
111
142
|
billing_interval=billing_interval,
|
|
112
143
|
description=description,
|
|
113
|
-
usage_based_rates=usage_based_rates,
|
|
114
144
|
fixed_rates=fixed_rates,
|
|
145
|
+
usage_based_rates=usage_based_rates,
|
|
115
146
|
metadata=metadata,
|
|
116
147
|
request_options=request_options,
|
|
117
148
|
)
|
|
@@ -207,8 +238,8 @@ class AsyncRateCardsClient:
|
|
|
207
238
|
name: str,
|
|
208
239
|
billing_interval: CreateRateCardRequestBillingInterval,
|
|
209
240
|
description: typing.Optional[str] = OMIT,
|
|
210
|
-
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
211
241
|
fixed_rates: typing.Optional[typing.Sequence[CreateFixedRateRequest]] = OMIT,
|
|
242
|
+
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
212
243
|
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
213
244
|
request_options: typing.Optional[RequestOptions] = None,
|
|
214
245
|
) -> RateCardResource:
|
|
@@ -216,14 +247,19 @@ class AsyncRateCardsClient:
|
|
|
216
247
|
Parameters
|
|
217
248
|
----------
|
|
218
249
|
name : str
|
|
250
|
+
The name of the rate card displayed to the customer.
|
|
219
251
|
|
|
220
252
|
billing_interval : CreateRateCardRequestBillingInterval
|
|
253
|
+
How often the customer will be billed for this rate card.
|
|
221
254
|
|
|
222
255
|
description : typing.Optional[str]
|
|
223
|
-
|
|
224
|
-
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
256
|
+
The description of the rate card displayed to the customer.
|
|
225
257
|
|
|
226
258
|
fixed_rates : typing.Optional[typing.Sequence[CreateFixedRateRequest]]
|
|
259
|
+
The fixed rates of the rate card. These are billed at the start of each billing cycle.
|
|
260
|
+
|
|
261
|
+
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
262
|
+
The usage based rates of the rate card. These are billed at the end of each billing cycle.
|
|
227
263
|
|
|
228
264
|
metadata : typing.Optional[typing.Dict[str, str]]
|
|
229
265
|
|
|
@@ -239,7 +275,8 @@ class AsyncRateCardsClient:
|
|
|
239
275
|
--------
|
|
240
276
|
import asyncio
|
|
241
277
|
|
|
242
|
-
from lark import AsyncLark
|
|
278
|
+
from lark import Amount, AsyncLark, CreateFixedRateRequest, Price_Flat
|
|
279
|
+
from lark.rate_cards import CreateRateCardRequestUsageBasedRatesItem_Simple
|
|
243
280
|
|
|
244
281
|
client = AsyncLark(
|
|
245
282
|
api_key="YOUR_API_KEY",
|
|
@@ -248,8 +285,33 @@ class AsyncRateCardsClient:
|
|
|
248
285
|
|
|
249
286
|
async def main() -> None:
|
|
250
287
|
await client.rate_cards.create_rate_card(
|
|
251
|
-
name="
|
|
288
|
+
name="Pro Plan",
|
|
289
|
+
description="For production applications with moderate usage.",
|
|
252
290
|
billing_interval="monthly",
|
|
291
|
+
fixed_rates=[
|
|
292
|
+
CreateFixedRateRequest(
|
|
293
|
+
name="Base Rate",
|
|
294
|
+
price=Price_Flat(
|
|
295
|
+
amount=Amount(
|
|
296
|
+
value="2500",
|
|
297
|
+
currency_code="usd",
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
)
|
|
301
|
+
],
|
|
302
|
+
usage_based_rates=[
|
|
303
|
+
CreateRateCardRequestUsageBasedRatesItem_Simple(
|
|
304
|
+
name="name",
|
|
305
|
+
price=Price_Flat(
|
|
306
|
+
amount=Amount(
|
|
307
|
+
value="2500",
|
|
308
|
+
currency_code="usd",
|
|
309
|
+
),
|
|
310
|
+
),
|
|
311
|
+
pricing_metric_id="pricing_metric_id",
|
|
312
|
+
)
|
|
313
|
+
],
|
|
314
|
+
metadata={"key": "value"},
|
|
253
315
|
)
|
|
254
316
|
|
|
255
317
|
|
|
@@ -259,8 +321,8 @@ class AsyncRateCardsClient:
|
|
|
259
321
|
name=name,
|
|
260
322
|
billing_interval=billing_interval,
|
|
261
323
|
description=description,
|
|
262
|
-
usage_based_rates=usage_based_rates,
|
|
263
324
|
fixed_rates=fixed_rates,
|
|
325
|
+
usage_based_rates=usage_based_rates,
|
|
264
326
|
metadata=metadata,
|
|
265
327
|
request_options=request_options,
|
|
266
328
|
)
|
lark/rate_cards/raw_client.py
CHANGED
|
@@ -82,8 +82,8 @@ class RawRateCardsClient:
|
|
|
82
82
|
name: str,
|
|
83
83
|
billing_interval: CreateRateCardRequestBillingInterval,
|
|
84
84
|
description: typing.Optional[str] = OMIT,
|
|
85
|
-
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
86
85
|
fixed_rates: typing.Optional[typing.Sequence[CreateFixedRateRequest]] = OMIT,
|
|
86
|
+
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
87
87
|
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
88
88
|
request_options: typing.Optional[RequestOptions] = None,
|
|
89
89
|
) -> HttpResponse[RateCardResource]:
|
|
@@ -91,14 +91,19 @@ class RawRateCardsClient:
|
|
|
91
91
|
Parameters
|
|
92
92
|
----------
|
|
93
93
|
name : str
|
|
94
|
+
The name of the rate card displayed to the customer.
|
|
94
95
|
|
|
95
96
|
billing_interval : CreateRateCardRequestBillingInterval
|
|
97
|
+
How often the customer will be billed for this rate card.
|
|
96
98
|
|
|
97
99
|
description : typing.Optional[str]
|
|
98
|
-
|
|
99
|
-
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
100
|
+
The description of the rate card displayed to the customer.
|
|
100
101
|
|
|
101
102
|
fixed_rates : typing.Optional[typing.Sequence[CreateFixedRateRequest]]
|
|
103
|
+
The fixed rates of the rate card. These are billed at the start of each billing cycle.
|
|
104
|
+
|
|
105
|
+
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
106
|
+
The usage based rates of the rate card. These are billed at the end of each billing cycle.
|
|
102
107
|
|
|
103
108
|
metadata : typing.Optional[typing.Dict[str, str]]
|
|
104
109
|
|
|
@@ -116,15 +121,15 @@ class RawRateCardsClient:
|
|
|
116
121
|
json={
|
|
117
122
|
"name": name,
|
|
118
123
|
"description": description,
|
|
124
|
+
"billing_interval": billing_interval,
|
|
125
|
+
"fixed_rates": convert_and_respect_annotation_metadata(
|
|
126
|
+
object_=fixed_rates, annotation=typing.Sequence[CreateFixedRateRequest], direction="write"
|
|
127
|
+
),
|
|
119
128
|
"usage_based_rates": convert_and_respect_annotation_metadata(
|
|
120
129
|
object_=usage_based_rates,
|
|
121
130
|
annotation=typing.Sequence[CreateRateCardRequestUsageBasedRatesItem],
|
|
122
131
|
direction="write",
|
|
123
132
|
),
|
|
124
|
-
"fixed_rates": convert_and_respect_annotation_metadata(
|
|
125
|
-
object_=fixed_rates, annotation=typing.Sequence[CreateFixedRateRequest], direction="write"
|
|
126
|
-
),
|
|
127
|
-
"billing_interval": billing_interval,
|
|
128
133
|
"metadata": metadata,
|
|
129
134
|
},
|
|
130
135
|
headers={
|
|
@@ -267,8 +272,8 @@ class AsyncRawRateCardsClient:
|
|
|
267
272
|
name: str,
|
|
268
273
|
billing_interval: CreateRateCardRequestBillingInterval,
|
|
269
274
|
description: typing.Optional[str] = OMIT,
|
|
270
|
-
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
271
275
|
fixed_rates: typing.Optional[typing.Sequence[CreateFixedRateRequest]] = OMIT,
|
|
276
|
+
usage_based_rates: typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]] = OMIT,
|
|
272
277
|
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
273
278
|
request_options: typing.Optional[RequestOptions] = None,
|
|
274
279
|
) -> AsyncHttpResponse[RateCardResource]:
|
|
@@ -276,14 +281,19 @@ class AsyncRawRateCardsClient:
|
|
|
276
281
|
Parameters
|
|
277
282
|
----------
|
|
278
283
|
name : str
|
|
284
|
+
The name of the rate card displayed to the customer.
|
|
279
285
|
|
|
280
286
|
billing_interval : CreateRateCardRequestBillingInterval
|
|
287
|
+
How often the customer will be billed for this rate card.
|
|
281
288
|
|
|
282
289
|
description : typing.Optional[str]
|
|
283
|
-
|
|
284
|
-
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
290
|
+
The description of the rate card displayed to the customer.
|
|
285
291
|
|
|
286
292
|
fixed_rates : typing.Optional[typing.Sequence[CreateFixedRateRequest]]
|
|
293
|
+
The fixed rates of the rate card. These are billed at the start of each billing cycle.
|
|
294
|
+
|
|
295
|
+
usage_based_rates : typing.Optional[typing.Sequence[CreateRateCardRequestUsageBasedRatesItem]]
|
|
296
|
+
The usage based rates of the rate card. These are billed at the end of each billing cycle.
|
|
287
297
|
|
|
288
298
|
metadata : typing.Optional[typing.Dict[str, str]]
|
|
289
299
|
|
|
@@ -301,15 +311,15 @@ class AsyncRawRateCardsClient:
|
|
|
301
311
|
json={
|
|
302
312
|
"name": name,
|
|
303
313
|
"description": description,
|
|
314
|
+
"billing_interval": billing_interval,
|
|
315
|
+
"fixed_rates": convert_and_respect_annotation_metadata(
|
|
316
|
+
object_=fixed_rates, annotation=typing.Sequence[CreateFixedRateRequest], direction="write"
|
|
317
|
+
),
|
|
304
318
|
"usage_based_rates": convert_and_respect_annotation_metadata(
|
|
305
319
|
object_=usage_based_rates,
|
|
306
320
|
annotation=typing.Sequence[CreateRateCardRequestUsageBasedRatesItem],
|
|
307
321
|
direction="write",
|
|
308
322
|
),
|
|
309
|
-
"fixed_rates": convert_and_respect_annotation_metadata(
|
|
310
|
-
object_=fixed_rates, annotation=typing.Sequence[CreateFixedRateRequest], direction="write"
|
|
311
|
-
),
|
|
312
|
-
"billing_interval": billing_interval,
|
|
313
323
|
"metadata": metadata,
|
|
314
324
|
},
|
|
315
325
|
headers={
|