lark-billing 0.0.7__py3-none-any.whl → 0.0.8__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.

Files changed (46) hide show
  1. lark/__init__.py +42 -28
  2. lark/checkout/client.py +26 -8
  3. lark/checkout/raw_client.py +18 -6
  4. lark/client.py +19 -0
  5. lark/core/client_wrapper.py +2 -2
  6. lark/core/http_sse/__init__.py +42 -0
  7. lark/core/http_sse/_api.py +112 -0
  8. lark/core/http_sse/_decoders.py +61 -0
  9. lark/core/http_sse/_exceptions.py +7 -0
  10. lark/core/http_sse/_models.py +17 -0
  11. lark/core/pydantic_utilities.py +3 -1
  12. lark/invoices/__init__.py +4 -0
  13. lark/invoices/client.py +136 -0
  14. lark/invoices/raw_client.py +147 -0
  15. lark/pricing_metrics/client.py +69 -0
  16. lark/pricing_metrics/raw_client.py +101 -0
  17. lark/rate_cards/__init__.py +15 -3
  18. lark/rate_cards/client.py +10 -10
  19. lark/rate_cards/raw_client.py +14 -14
  20. lark/rate_cards/types/__init__.py +12 -2
  21. lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +30 -0
  22. lark/subjects/client.py +16 -18
  23. lark/subjects/raw_client.py +14 -8
  24. lark/subscriptions/client.py +192 -8
  25. lark/subscriptions/raw_client.py +254 -4
  26. lark/types/__init__.py +31 -32
  27. lark/types/aggregation.py +1 -43
  28. lark/types/{create_fixed_rate_interface.py → create_fixed_rate_request.py} +1 -1
  29. lark/types/{create_simple_usage_based_rate_interface.py → create_simple_usage_based_rate_request.py} +5 -3
  30. lark/types/create_subject_response.py +29 -6
  31. lark/types/{custom_pricing_metric_resource.py → invoice_line_item_resource.py} +6 -2
  32. lark/types/invoice_resource.py +31 -0
  33. lark/types/invoice_status.py +5 -0
  34. lark/types/{max_aggregation_pricing_metric_resource.py → list_invoices_response.py} +4 -2
  35. lark/types/list_pricing_metrics_response.py +21 -0
  36. lark/types/period_resource.py +23 -0
  37. lark/types/{last_aggregation_pricing_metric_resource.py → pricing_metric_resource.py} +7 -2
  38. lark/types/rate_card_resource_usage_based_rates_item.py +0 -1
  39. lark/types/simple_usage_based_rate_interface.py +0 -5
  40. lark/types/subject_resource.py +29 -6
  41. lark/types/subscription_resource.py +6 -3
  42. lark/types/subscription_status.py +5 -0
  43. {lark_billing-0.0.7.dist-info → lark_billing-0.0.8.dist-info}/METADATA +4 -3
  44. {lark_billing-0.0.7.dist-info → lark_billing-0.0.8.dist-info}/RECORD +45 -32
  45. lark/types/status.py +0 -5
  46. {lark_billing-0.0.7.dist-info → lark_billing-0.0.8.dist-info}/WHEEL +0 -0
@@ -7,8 +7,14 @@ from importlib import import_module
7
7
 
8
8
  if typing.TYPE_CHECKING:
9
9
  from .create_rate_card_request_billing_interval import CreateRateCardRequestBillingInterval
10
+ from .create_rate_card_request_usage_based_rates_item import (
11
+ CreateRateCardRequestUsageBasedRatesItem,
12
+ CreateRateCardRequestUsageBasedRatesItem_Simple,
13
+ )
10
14
  _dynamic_imports: typing.Dict[str, str] = {
11
- "CreateRateCardRequestBillingInterval": ".create_rate_card_request_billing_interval"
15
+ "CreateRateCardRequestBillingInterval": ".create_rate_card_request_billing_interval",
16
+ "CreateRateCardRequestUsageBasedRatesItem": ".create_rate_card_request_usage_based_rates_item",
17
+ "CreateRateCardRequestUsageBasedRatesItem_Simple": ".create_rate_card_request_usage_based_rates_item",
12
18
  }
13
19
 
14
20
 
@@ -33,4 +39,8 @@ def __dir__():
33
39
  return sorted(lazy_attrs)
34
40
 
35
41
 
36
- __all__ = ["CreateRateCardRequestBillingInterval"]
42
+ __all__ = [
43
+ "CreateRateCardRequestBillingInterval",
44
+ "CreateRateCardRequestUsageBasedRatesItem",
45
+ "CreateRateCardRequestUsageBasedRatesItem_Simple",
46
+ ]
@@ -0,0 +1,30 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import pydantic
8
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
9
+ from ...types.price import Price
10
+
11
+
12
+ class CreateRateCardRequestUsageBasedRatesItem_Simple(UniversalBaseModel):
13
+ usage_based_rate_type: typing.Literal["simple"] = "simple"
14
+ name: typing.Optional[str] = None
15
+ description: typing.Optional[str] = None
16
+ price: Price
17
+ included_units: typing.Optional[int] = None
18
+ pricing_metric_id: str
19
+
20
+ if IS_PYDANTIC_V2:
21
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
22
+ else:
23
+
24
+ class Config:
25
+ frozen = True
26
+ smart_union = True
27
+ extra = pydantic.Extra.allow
28
+
29
+
30
+ CreateRateCardRequestUsageBasedRatesItem = CreateRateCardRequestUsageBasedRatesItem_Simple
lark/subjects/client.py CHANGED
@@ -78,12 +78,16 @@ class SubjectsClient:
78
78
  Parameters
79
79
  ----------
80
80
  external_id : typing.Optional[str]
81
+ 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.
81
82
 
82
83
  name : typing.Optional[str]
84
+ The name of the subject. Used for display in the dashboard.
83
85
 
84
86
  email : typing.Optional[str]
87
+ The email of the subject. Must be a valid email address.
85
88
 
86
89
  metadata : typing.Optional[typing.Dict[str, str]]
90
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
87
91
 
88
92
  request_options : typing.Optional[RequestOptions]
89
93
  Request-specific configuration.
@@ -141,7 +145,6 @@ class SubjectsClient:
141
145
  self,
142
146
  subject_id: str,
143
147
  *,
144
- external_id: typing.Optional[str] = OMIT,
145
148
  name: typing.Optional[str] = OMIT,
146
149
  email: typing.Optional[str] = OMIT,
147
150
  metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
@@ -152,13 +155,14 @@ class SubjectsClient:
152
155
  ----------
153
156
  subject_id : str
154
157
 
155
- external_id : typing.Optional[str]
156
-
157
158
  name : typing.Optional[str]
159
+ The name of the subject. Used for display in the dashboard.
158
160
 
159
161
  email : typing.Optional[str]
162
+ The email of the subject. Must be a valid email address.
160
163
 
161
164
  metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
165
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
162
166
 
163
167
  request_options : typing.Optional[RequestOptions]
164
168
  Request-specific configuration.
@@ -180,12 +184,7 @@ class SubjectsClient:
180
184
  )
181
185
  """
182
186
  _response = self._raw_client.update_subject(
183
- subject_id,
184
- external_id=external_id,
185
- name=name,
186
- email=email,
187
- metadata=metadata,
188
- request_options=request_options,
187
+ subject_id, name=name, email=email, metadata=metadata, request_options=request_options
189
188
  )
190
189
  return _response.data
191
190
 
@@ -293,12 +292,16 @@ class AsyncSubjectsClient:
293
292
  Parameters
294
293
  ----------
295
294
  external_id : typing.Optional[str]
295
+ 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.
296
296
 
297
297
  name : typing.Optional[str]
298
+ The name of the subject. Used for display in the dashboard.
298
299
 
299
300
  email : typing.Optional[str]
301
+ The email of the subject. Must be a valid email address.
300
302
 
301
303
  metadata : typing.Optional[typing.Dict[str, str]]
304
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
302
305
 
303
306
  request_options : typing.Optional[RequestOptions]
304
307
  Request-specific configuration.
@@ -372,7 +375,6 @@ class AsyncSubjectsClient:
372
375
  self,
373
376
  subject_id: str,
374
377
  *,
375
- external_id: typing.Optional[str] = OMIT,
376
378
  name: typing.Optional[str] = OMIT,
377
379
  email: typing.Optional[str] = OMIT,
378
380
  metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
@@ -383,13 +385,14 @@ class AsyncSubjectsClient:
383
385
  ----------
384
386
  subject_id : str
385
387
 
386
- external_id : typing.Optional[str]
387
-
388
388
  name : typing.Optional[str]
389
+ The name of the subject. Used for display in the dashboard.
389
390
 
390
391
  email : typing.Optional[str]
392
+ The email of the subject. Must be a valid email address.
391
393
 
392
394
  metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
395
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
393
396
 
394
397
  request_options : typing.Optional[RequestOptions]
395
398
  Request-specific configuration.
@@ -419,12 +422,7 @@ class AsyncSubjectsClient:
419
422
  asyncio.run(main())
420
423
  """
421
424
  _response = await self._raw_client.update_subject(
422
- subject_id,
423
- external_id=external_id,
424
- name=name,
425
- email=email,
426
- metadata=metadata,
427
- request_options=request_options,
425
+ subject_id, name=name, email=email, metadata=metadata, request_options=request_options
428
426
  )
429
427
  return _response.data
430
428
 
@@ -93,12 +93,16 @@ class RawSubjectsClient:
93
93
  Parameters
94
94
  ----------
95
95
  external_id : typing.Optional[str]
96
+ 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.
96
97
 
97
98
  name : typing.Optional[str]
99
+ The name of the subject. Used for display in the dashboard.
98
100
 
99
101
  email : typing.Optional[str]
102
+ The email of the subject. Must be a valid email address.
100
103
 
101
104
  metadata : typing.Optional[typing.Dict[str, str]]
105
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
102
106
 
103
107
  request_options : typing.Optional[RequestOptions]
104
108
  Request-specific configuration.
@@ -200,7 +204,6 @@ class RawSubjectsClient:
200
204
  self,
201
205
  subject_id: str,
202
206
  *,
203
- external_id: typing.Optional[str] = OMIT,
204
207
  name: typing.Optional[str] = OMIT,
205
208
  email: typing.Optional[str] = OMIT,
206
209
  metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
@@ -211,13 +214,14 @@ class RawSubjectsClient:
211
214
  ----------
212
215
  subject_id : str
213
216
 
214
- external_id : typing.Optional[str]
215
-
216
217
  name : typing.Optional[str]
218
+ The name of the subject. Used for display in the dashboard.
217
219
 
218
220
  email : typing.Optional[str]
221
+ The email of the subject. Must be a valid email address.
219
222
 
220
223
  metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
224
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
221
225
 
222
226
  request_options : typing.Optional[RequestOptions]
223
227
  Request-specific configuration.
@@ -231,7 +235,6 @@ class RawSubjectsClient:
231
235
  f"subjects/{jsonable_encoder(subject_id)}",
232
236
  method="PUT",
233
237
  json={
234
- "external_id": external_id,
235
238
  "name": name,
236
239
  "email": email,
237
240
  "metadata": metadata,
@@ -392,12 +395,16 @@ class AsyncRawSubjectsClient:
392
395
  Parameters
393
396
  ----------
394
397
  external_id : typing.Optional[str]
398
+ 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.
395
399
 
396
400
  name : typing.Optional[str]
401
+ The name of the subject. Used for display in the dashboard.
397
402
 
398
403
  email : typing.Optional[str]
404
+ The email of the subject. Must be a valid email address.
399
405
 
400
406
  metadata : typing.Optional[typing.Dict[str, str]]
407
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
401
408
 
402
409
  request_options : typing.Optional[RequestOptions]
403
410
  Request-specific configuration.
@@ -499,7 +506,6 @@ class AsyncRawSubjectsClient:
499
506
  self,
500
507
  subject_id: str,
501
508
  *,
502
- external_id: typing.Optional[str] = OMIT,
503
509
  name: typing.Optional[str] = OMIT,
504
510
  email: typing.Optional[str] = OMIT,
505
511
  metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
@@ -510,13 +516,14 @@ class AsyncRawSubjectsClient:
510
516
  ----------
511
517
  subject_id : str
512
518
 
513
- external_id : typing.Optional[str]
514
-
515
519
  name : typing.Optional[str]
520
+ The name of the subject. Used for display in the dashboard.
516
521
 
517
522
  email : typing.Optional[str]
523
+ The email of the subject. Must be a valid email address.
518
524
 
519
525
  metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
526
+ Additional metadata about the subject. You may use this to store any custom data about the subject.
520
527
 
521
528
  request_options : typing.Optional[RequestOptions]
522
529
  Request-specific configuration.
@@ -530,7 +537,6 @@ class AsyncRawSubjectsClient:
530
537
  f"subjects/{jsonable_encoder(subject_id)}",
531
538
  method="PUT",
532
539
  json={
533
- "external_id": external_id,
534
540
  "name": name,
535
541
  "email": email,
536
542
  "metadata": metadata,
@@ -77,17 +77,20 @@ class SubscriptionsClient:
77
77
  *,
78
78
  rate_card_id: str,
79
79
  subject_id: str,
80
- metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
80
+ metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
81
81
  request_options: typing.Optional[RequestOptions] = None,
82
82
  ) -> SubscriptionResource:
83
83
  """
84
84
  Parameters
85
85
  ----------
86
86
  rate_card_id : str
87
+ The ID of the rate card to use for the subscription.
87
88
 
88
89
  subject_id : str
90
+ The ID of the subject to create the subscription for.
89
91
 
90
- metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
92
+ metadata : typing.Optional[typing.Dict[str, str]]
93
+ Additional metadata about the subscription. You may use this to store any custom data about the subscription.
91
94
 
92
95
  request_options : typing.Optional[RequestOptions]
93
96
  Request-specific configuration.
@@ -105,8 +108,8 @@ class SubscriptionsClient:
105
108
  api_key="YOUR_API_KEY",
106
109
  )
107
110
  client.subscriptions.create_subscription(
108
- rate_card_id="rate_card_id",
109
- subject_id="subject_id",
111
+ rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
112
+ subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
110
113
  )
111
114
  """
112
115
  _response = self._raw_client.create_subscription(
@@ -144,6 +147,87 @@ class SubscriptionsClient:
144
147
  _response = self._raw_client.get_subscription(subscription_id, request_options=request_options)
145
148
  return _response.data
146
149
 
150
+ def cancel_subscription(
151
+ self,
152
+ subscription_id: str,
153
+ *,
154
+ reason: typing.Optional[str] = OMIT,
155
+ cancel_at_end_of_cycle: typing.Optional[bool] = OMIT,
156
+ request_options: typing.Optional[RequestOptions] = None,
157
+ ) -> SubscriptionResource:
158
+ """
159
+ Parameters
160
+ ----------
161
+ subscription_id : str
162
+
163
+ reason : typing.Optional[str]
164
+ The reason for cancelling the subscription.
165
+
166
+ cancel_at_end_of_cycle : typing.Optional[bool]
167
+ Whether to cancel the subscription at end of cycle.
168
+
169
+ request_options : typing.Optional[RequestOptions]
170
+ Request-specific configuration.
171
+
172
+ Returns
173
+ -------
174
+ SubscriptionResource
175
+ Successful Response
176
+
177
+ Examples
178
+ --------
179
+ from lark import Lark
180
+
181
+ client = Lark(
182
+ api_key="YOUR_API_KEY",
183
+ )
184
+ client.subscriptions.cancel_subscription(
185
+ subscription_id="subscription_id",
186
+ )
187
+ """
188
+ _response = self._raw_client.cancel_subscription(
189
+ subscription_id,
190
+ reason=reason,
191
+ cancel_at_end_of_cycle=cancel_at_end_of_cycle,
192
+ request_options=request_options,
193
+ )
194
+ return _response.data
195
+
196
+ def change_subscription_rate_card(
197
+ self, subscription_id: str, *, rate_card_id: str, request_options: typing.Optional[RequestOptions] = None
198
+ ) -> SubscriptionResource:
199
+ """
200
+ Parameters
201
+ ----------
202
+ subscription_id : str
203
+
204
+ rate_card_id : str
205
+
206
+ request_options : typing.Optional[RequestOptions]
207
+ Request-specific configuration.
208
+
209
+ Returns
210
+ -------
211
+ SubscriptionResource
212
+ Successful Response
213
+
214
+ Examples
215
+ --------
216
+ from lark import Lark
217
+
218
+ client = Lark(
219
+ api_key="YOUR_API_KEY",
220
+ )
221
+ client.subscriptions.change_subscription_rate_card(
222
+ subscription_id="subscription_id",
223
+ rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
224
+ )
225
+ """
226
+ _response = self._raw_client.change_subscription_rate_card(
227
+ subscription_id, rate_card_id=rate_card_id, request_options=request_options
228
+ )
229
+ return _response.data
230
+
147
231
 
148
232
  class AsyncSubscriptionsClient:
149
233
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -218,17 +302,20 @@ class AsyncSubscriptionsClient:
218
302
  *,
219
303
  rate_card_id: str,
220
304
  subject_id: str,
221
- metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
305
+ metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
222
306
  request_options: typing.Optional[RequestOptions] = None,
223
307
  ) -> SubscriptionResource:
224
308
  """
225
309
  Parameters
226
310
  ----------
227
311
  rate_card_id : str
312
+ The ID of the rate card to use for the subscription.
228
313
 
229
314
  subject_id : str
315
+ The ID of the subject to create the subscription for.
230
316
 
231
- metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
317
+ metadata : typing.Optional[typing.Dict[str, str]]
318
+ Additional metadata about the subscription. You may use this to store any custom data about the subscription.
232
319
 
233
320
  request_options : typing.Optional[RequestOptions]
234
321
  Request-specific configuration.
@@ -251,8 +338,8 @@ class AsyncSubscriptionsClient:
251
338
 
252
339
  async def main() -> None:
253
340
  await client.subscriptions.create_subscription(
254
- rate_card_id="rate_card_id",
255
- subject_id="subject_id",
341
+ rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
342
+ subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
256
343
  )
257
344
 
258
345
 
@@ -300,3 +387,100 @@ class AsyncSubscriptionsClient:
300
387
  """
301
388
  _response = await self._raw_client.get_subscription(subscription_id, request_options=request_options)
302
389
  return _response.data
390
+
391
+ async def cancel_subscription(
392
+ self,
393
+ subscription_id: str,
394
+ *,
395
+ reason: typing.Optional[str] = OMIT,
396
+ cancel_at_end_of_cycle: typing.Optional[bool] = OMIT,
397
+ request_options: typing.Optional[RequestOptions] = None,
398
+ ) -> SubscriptionResource:
399
+ """
400
+ Parameters
401
+ ----------
402
+ subscription_id : str
403
+
404
+ reason : typing.Optional[str]
405
+ The reason for cancelling the subscription.
406
+
407
+ cancel_at_end_of_cycle : typing.Optional[bool]
408
+ Whether to cancel the subscription at end of cycle.
409
+
410
+ request_options : typing.Optional[RequestOptions]
411
+ Request-specific configuration.
412
+
413
+ Returns
414
+ -------
415
+ SubscriptionResource
416
+ Successful Response
417
+
418
+ Examples
419
+ --------
420
+ import asyncio
421
+
422
+ from lark import AsyncLark
423
+
424
+ client = AsyncLark(
425
+ api_key="YOUR_API_KEY",
426
+ )
427
+
428
+
429
+ async def main() -> None:
430
+ await client.subscriptions.cancel_subscription(
431
+ subscription_id="subscription_id",
432
+ )
433
+
434
+
435
+ asyncio.run(main())
436
+ """
437
+ _response = await self._raw_client.cancel_subscription(
438
+ subscription_id,
439
+ reason=reason,
440
+ cancel_at_end_of_cycle=cancel_at_end_of_cycle,
441
+ request_options=request_options,
442
+ )
443
+ return _response.data
444
+
445
+ async def change_subscription_rate_card(
446
+ self, subscription_id: str, *, rate_card_id: str, request_options: typing.Optional[RequestOptions] = None
447
+ ) -> SubscriptionResource:
448
+ """
449
+ Parameters
450
+ ----------
451
+ subscription_id : str
452
+
453
+ rate_card_id : str
454
+
455
+ request_options : typing.Optional[RequestOptions]
456
+ Request-specific configuration.
457
+
458
+ Returns
459
+ -------
460
+ SubscriptionResource
461
+ Successful Response
462
+
463
+ Examples
464
+ --------
465
+ import asyncio
466
+
467
+ from lark import AsyncLark
468
+
469
+ client = AsyncLark(
470
+ api_key="YOUR_API_KEY",
471
+ )
472
+
473
+
474
+ async def main() -> None:
475
+ await client.subscriptions.change_subscription_rate_card(
476
+ subscription_id="subscription_id",
477
+ rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
478
+ )
479
+
480
+
481
+ asyncio.run(main())
482
+ """
483
+ _response = await self._raw_client.change_subscription_rate_card(
484
+ subscription_id, rate_card_id=rate_card_id, request_options=request_options
485
+ )
486
+ return _response.data