lark-billing 0.0.6__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 (167) hide show
  1. lark/__init__.py +522 -0
  2. lark/checkout/__init__.py +4 -0
  3. lark/checkout/client.py +214 -0
  4. lark/checkout/raw_client.py +252 -0
  5. lark/client.py +240 -0
  6. lark/core/__init__.py +105 -0
  7. lark/core/api_error.py +23 -0
  8. lark/core/client_wrapper.py +79 -0
  9. lark/core/datetime_utils.py +28 -0
  10. lark/core/file.py +67 -0
  11. lark/core/force_multipart.py +18 -0
  12. lark/core/http_client.py +543 -0
  13. lark/core/http_response.py +55 -0
  14. lark/core/jsonable_encoder.py +100 -0
  15. lark/core/pydantic_utilities.py +258 -0
  16. lark/core/query_encoder.py +58 -0
  17. lark/core/remove_none_from_dict.py +11 -0
  18. lark/core/request_options.py +35 -0
  19. lark/core/serialization.py +276 -0
  20. lark/errors/__init__.py +34 -0
  21. lark/errors/unprocessable_entity_error.py +11 -0
  22. lark/feature_access/__init__.py +4 -0
  23. lark/feature_access/client.py +102 -0
  24. lark/feature_access/raw_client.py +113 -0
  25. lark/py.typed +0 -0
  26. lark/rate_cards/__init__.py +61 -0
  27. lark/rate_cards/client.py +817 -0
  28. lark/rate_cards/raw_client.py +728 -0
  29. lark/rate_cards/types/__init__.py +63 -0
  30. lark/rate_cards/types/create_rate_card_request_billing_interval.py +5 -0
  31. lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +56 -0
  32. lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +58 -0
  33. lark/rate_cards/types/create_rate_card_version_request_version_type.py +5 -0
  34. lark/subjects/__init__.py +4 -0
  35. lark/subjects/client.py +501 -0
  36. lark/subjects/raw_client.py +633 -0
  37. lark/subscriptions/__init__.py +4 -0
  38. lark/subscriptions/client.py +462 -0
  39. lark/subscriptions/raw_client.py +495 -0
  40. lark/types/__init__.py +493 -0
  41. lark/types/aggregation.py +80 -0
  42. lark/types/amount.py +20 -0
  43. lark/types/check_feature_access_request.py +24 -0
  44. lark/types/check_feature_access_response.py +21 -0
  45. lark/types/complete_subscription_checkout_response.py +21 -0
  46. lark/types/count_aggregation_pricing_metric_interface.py +17 -0
  47. lark/types/create_credit_grant_interface.py +27 -0
  48. lark/types/create_credit_grant_interface_expiration.py +27 -0
  49. lark/types/create_credit_pool_request.py +5 -0
  50. lark/types/create_dimension_coordinate_interface.py +20 -0
  51. lark/types/create_dimension_interface.py +20 -0
  52. lark/types/create_dimensional_usage_based_rate_interface.py +32 -0
  53. lark/types/create_fixed_rate_interface.py +28 -0
  54. lark/types/create_pricing_matrix_cell_interface.py +22 -0
  55. lark/types/create_pricing_matrix_interface.py +20 -0
  56. lark/types/create_pricing_metric_interface.py +26 -0
  57. lark/types/create_pricing_plan_request.py +5 -0
  58. lark/types/create_rate_card_response.py +36 -0
  59. lark/types/create_rate_card_response_billing_interval.py +5 -0
  60. lark/types/create_rate_card_response_usage_based_rates_item.py +58 -0
  61. lark/types/create_rate_card_version_response.py +36 -0
  62. lark/types/create_rate_card_version_response_billing_interval.py +5 -0
  63. lark/types/create_rate_card_version_response_usage_based_rates_item.py +59 -0
  64. lark/types/create_simple_usage_based_rate_interface.py +30 -0
  65. lark/types/create_subject_response.py +24 -0
  66. lark/types/create_subscription_checkout_session_response.py +23 -0
  67. lark/types/create_usage_event_summary_response.py +23 -0
  68. lark/types/credit_grant.py +5 -0
  69. lark/types/credit_grant_date_time_expiration_interface.py +19 -0
  70. lark/types/credit_grant_date_time_expiration_resource.py +19 -0
  71. lark/types/credit_grant_duration_expiration_interface.py +21 -0
  72. lark/types/credit_grant_duration_expiration_resource.py +21 -0
  73. lark/types/credit_grant_interface.py +28 -0
  74. lark/types/credit_grant_interface_input_expiration.py +27 -0
  75. lark/types/credit_grant_interface_output_expiration.py +43 -0
  76. lark/types/credit_grant_interface_output_schedule.py +41 -0
  77. lark/types/credit_grant_resource.py +28 -0
  78. lark/types/credit_grant_resource_input_expiration.py +27 -0
  79. lark/types/credit_grant_resource_input_schedule.py +39 -0
  80. lark/types/credit_grant_resource_output_expiration.py +43 -0
  81. lark/types/credit_grant_resource_output_schedule.py +39 -0
  82. lark/types/credit_grant_schedule.py +5 -0
  83. lark/types/credit_grant_schedule_one_time_interface.py +19 -0
  84. lark/types/credit_grant_schedule_one_time_resource.py +17 -0
  85. lark/types/credit_grant_schedule_rate_cycle_start_interface.py +19 -0
  86. lark/types/credit_grant_schedule_rate_cycle_start_resource.py +17 -0
  87. lark/types/credit_grant_subject_granting_config_interface.py +20 -0
  88. lark/types/credit_pool.py +5 -0
  89. lark/types/credit_pool_rollover_config.py +5 -0
  90. lark/types/custom_aggregation_pricing_metric_interface.py +22 -0
  91. lark/types/custom_pricing_metric.py +5 -0
  92. lark/types/custom_unit.py +5 -0
  93. lark/types/custom_unit_amount.py +5 -0
  94. lark/types/dimension.py +5 -0
  95. lark/types/dimension_coordinate.py +5 -0
  96. lark/types/dimension_coordinate_interface.py +20 -0
  97. lark/types/dimension_coordinate_set.py +5 -0
  98. lark/types/dimension_interface.py +20 -0
  99. lark/types/dimensional_rate_matrix.py +5 -0
  100. lark/types/dimensional_rate_matrix_cell.py +5 -0
  101. lark/types/dimensional_usage_based_rate.py +5 -0
  102. lark/types/dimensional_usage_based_rate_input.py +5 -0
  103. lark/types/dimensional_usage_based_rate_interface.py +33 -0
  104. lark/types/feature_access_resource.py +21 -0
  105. lark/types/fixed_rate_interface.py +29 -0
  106. lark/types/flat_price.py +24 -0
  107. lark/types/get_rate_card_response.py +36 -0
  108. lark/types/get_rate_card_response_billing_interval.py +5 -0
  109. lark/types/get_rate_card_response_usage_based_rates_item.py +58 -0
  110. lark/types/grant_credits_request.py +5 -0
  111. lark/types/http_validation_error.py +20 -0
  112. lark/types/last_aggregation_pricing_metric_interface.py +22 -0
  113. lark/types/license_based_rate.py +5 -0
  114. lark/types/license_based_rate_input.py +5 -0
  115. lark/types/list_rate_cards_response.py +21 -0
  116. lark/types/list_subjects_response.py +21 -0
  117. lark/types/list_subscriptions_response.py +21 -0
  118. lark/types/max_aggregation_pricing_metric_interface.py +22 -0
  119. lark/types/monetary_amount.py +5 -0
  120. lark/types/package_price.py +27 -0
  121. lark/types/package_price_rounding_behavior.py +5 -0
  122. lark/types/package_price_wrapper.py +5 -0
  123. lark/types/period.py +22 -0
  124. lark/types/price.py +5 -0
  125. lark/types/pricing_matrix_cell_interface.py +22 -0
  126. lark/types/pricing_matrix_interface.py +20 -0
  127. lark/types/pricing_metric.py +5 -0
  128. lark/types/pricing_metric_interface.py +27 -0
  129. lark/types/pricing_plan.py +5 -0
  130. lark/types/pricing_plan_subscription.py +5 -0
  131. lark/types/pricing_tier.py +5 -0
  132. lark/types/rate_card.py +5 -0
  133. lark/types/rate_card_resource.py +36 -0
  134. lark/types/rate_card_resource_billing_interval.py +5 -0
  135. lark/types/rate_card_resource_usage_based_rates_item.py +58 -0
  136. lark/types/rate_card_version.py +5 -0
  137. lark/types/rate_card_version_input.py +5 -0
  138. lark/types/simple_usage_based_rate.py +5 -0
  139. lark/types/simple_usage_based_rate_input.py +5 -0
  140. lark/types/simple_usage_based_rate_interface.py +31 -0
  141. lark/types/status.py +5 -0
  142. lark/types/subject.py +5 -0
  143. lark/types/subject_granting_config.py +5 -0
  144. lark/types/subject_granting_config_resource.py +20 -0
  145. lark/types/subject_resource.py +24 -0
  146. lark/types/subscription_resource.py +28 -0
  147. lark/types/sum_aggregation_pricing_metric_interface.py +22 -0
  148. lark/types/tiered_price.py +5 -0
  149. lark/types/tiered_price_wrapper.py +5 -0
  150. lark/types/unit.py +5 -0
  151. lark/types/update_pricing_plan_request.py +5 -0
  152. lark/types/update_rate_card_request.py +5 -0
  153. lark/types/update_subscription_request.py +5 -0
  154. lark/types/usage_based_rate.py +5 -0
  155. lark/types/usage_based_rate_input.py +5 -0
  156. lark/types/usage_unit.py +5 -0
  157. lark/types/validation_error.py +22 -0
  158. lark/types/validation_error_loc_item.py +5 -0
  159. lark/usage_events/__init__.py +34 -0
  160. lark/usage_events/client.py +293 -0
  161. lark/usage_events/raw_client.py +318 -0
  162. lark/usage_events/types/__init__.py +36 -0
  163. lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +5 -0
  164. lark/version.py +3 -0
  165. lark_billing-0.0.6.dist-info/METADATA +188 -0
  166. lark_billing-0.0.6.dist-info/RECORD +167 -0
  167. lark_billing-0.0.6.dist-info/WHEEL +4 -0
@@ -0,0 +1,214 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.complete_subscription_checkout_response import CompleteSubscriptionCheckoutResponse
8
+ from ..types.create_subscription_checkout_session_response import CreateSubscriptionCheckoutSessionResponse
9
+ from .raw_client import AsyncRawCheckoutClient, RawCheckoutClient
10
+
11
+ # this is used as the default value for optional parameters
12
+ OMIT = typing.cast(typing.Any, ...)
13
+
14
+
15
+ class CheckoutClient:
16
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
17
+ self._raw_client = RawCheckoutClient(client_wrapper=client_wrapper)
18
+
19
+ @property
20
+ def with_raw_response(self) -> RawCheckoutClient:
21
+ """
22
+ Retrieves a raw implementation of this client that returns raw responses.
23
+
24
+ Returns
25
+ -------
26
+ RawCheckoutClient
27
+ """
28
+ return self._raw_client
29
+
30
+ def create_subscription_checkout_session(
31
+ self,
32
+ *,
33
+ subject_id: str,
34
+ rate_card_id: str,
35
+ rate_card_overrides: typing.Optional[typing.Dict[str, str]] = OMIT,
36
+ request_options: typing.Optional[RequestOptions] = None,
37
+ ) -> CreateSubscriptionCheckoutSessionResponse:
38
+ """
39
+ Parameters
40
+ ----------
41
+ subject_id : str
42
+
43
+ rate_card_id : str
44
+
45
+ rate_card_overrides : typing.Optional[typing.Dict[str, str]]
46
+
47
+ request_options : typing.Optional[RequestOptions]
48
+ Request-specific configuration.
49
+
50
+ Returns
51
+ -------
52
+ CreateSubscriptionCheckoutSessionResponse
53
+ Successful Response
54
+
55
+ Examples
56
+ --------
57
+ from lark import Lark
58
+
59
+ client = Lark(
60
+ api_key="YOUR_API_KEY",
61
+ base_url="https://yourhost.com/path/to/api",
62
+ )
63
+ client.checkout.create_subscription_checkout_session(
64
+ subject_id="subject_id",
65
+ rate_card_id="rate_card_id",
66
+ )
67
+ """
68
+ _response = self._raw_client.create_subscription_checkout_session(
69
+ subject_id=subject_id,
70
+ rate_card_id=rate_card_id,
71
+ rate_card_overrides=rate_card_overrides,
72
+ request_options=request_options,
73
+ )
74
+ return _response.data
75
+
76
+ def complete_subscription_checkout(
77
+ self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
78
+ ) -> CompleteSubscriptionCheckoutResponse:
79
+ """
80
+ Parameters
81
+ ----------
82
+ checkout_id : str
83
+
84
+ request_options : typing.Optional[RequestOptions]
85
+ Request-specific configuration.
86
+
87
+ Returns
88
+ -------
89
+ CompleteSubscriptionCheckoutResponse
90
+ Successful Response
91
+
92
+ Examples
93
+ --------
94
+ from lark import Lark
95
+
96
+ client = Lark(
97
+ api_key="YOUR_API_KEY",
98
+ base_url="https://yourhost.com/path/to/api",
99
+ )
100
+ client.checkout.complete_subscription_checkout(
101
+ checkout_id="checkout_id",
102
+ )
103
+ """
104
+ _response = self._raw_client.complete_subscription_checkout(checkout_id, request_options=request_options)
105
+ return _response.data
106
+
107
+
108
+ class AsyncCheckoutClient:
109
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
110
+ self._raw_client = AsyncRawCheckoutClient(client_wrapper=client_wrapper)
111
+
112
+ @property
113
+ def with_raw_response(self) -> AsyncRawCheckoutClient:
114
+ """
115
+ Retrieves a raw implementation of this client that returns raw responses.
116
+
117
+ Returns
118
+ -------
119
+ AsyncRawCheckoutClient
120
+ """
121
+ return self._raw_client
122
+
123
+ async def create_subscription_checkout_session(
124
+ self,
125
+ *,
126
+ subject_id: str,
127
+ rate_card_id: str,
128
+ rate_card_overrides: typing.Optional[typing.Dict[str, str]] = OMIT,
129
+ request_options: typing.Optional[RequestOptions] = None,
130
+ ) -> CreateSubscriptionCheckoutSessionResponse:
131
+ """
132
+ Parameters
133
+ ----------
134
+ subject_id : str
135
+
136
+ rate_card_id : str
137
+
138
+ rate_card_overrides : typing.Optional[typing.Dict[str, str]]
139
+
140
+ request_options : typing.Optional[RequestOptions]
141
+ Request-specific configuration.
142
+
143
+ Returns
144
+ -------
145
+ CreateSubscriptionCheckoutSessionResponse
146
+ Successful Response
147
+
148
+ Examples
149
+ --------
150
+ import asyncio
151
+
152
+ from lark import AsyncLark
153
+
154
+ client = AsyncLark(
155
+ api_key="YOUR_API_KEY",
156
+ base_url="https://yourhost.com/path/to/api",
157
+ )
158
+
159
+
160
+ async def main() -> None:
161
+ await client.checkout.create_subscription_checkout_session(
162
+ subject_id="subject_id",
163
+ rate_card_id="rate_card_id",
164
+ )
165
+
166
+
167
+ asyncio.run(main())
168
+ """
169
+ _response = await self._raw_client.create_subscription_checkout_session(
170
+ subject_id=subject_id,
171
+ rate_card_id=rate_card_id,
172
+ rate_card_overrides=rate_card_overrides,
173
+ request_options=request_options,
174
+ )
175
+ return _response.data
176
+
177
+ async def complete_subscription_checkout(
178
+ self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
179
+ ) -> CompleteSubscriptionCheckoutResponse:
180
+ """
181
+ Parameters
182
+ ----------
183
+ checkout_id : str
184
+
185
+ request_options : typing.Optional[RequestOptions]
186
+ Request-specific configuration.
187
+
188
+ Returns
189
+ -------
190
+ CompleteSubscriptionCheckoutResponse
191
+ Successful Response
192
+
193
+ Examples
194
+ --------
195
+ import asyncio
196
+
197
+ from lark import AsyncLark
198
+
199
+ client = AsyncLark(
200
+ api_key="YOUR_API_KEY",
201
+ base_url="https://yourhost.com/path/to/api",
202
+ )
203
+
204
+
205
+ async def main() -> None:
206
+ await client.checkout.complete_subscription_checkout(
207
+ checkout_id="checkout_id",
208
+ )
209
+
210
+
211
+ asyncio.run(main())
212
+ """
213
+ _response = await self._raw_client.complete_subscription_checkout(checkout_id, request_options=request_options)
214
+ return _response.data
@@ -0,0 +1,252 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
13
+ from ..types.complete_subscription_checkout_response import CompleteSubscriptionCheckoutResponse
14
+ from ..types.create_subscription_checkout_session_response import CreateSubscriptionCheckoutSessionResponse
15
+ from ..types.http_validation_error import HttpValidationError
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class RawCheckoutClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._client_wrapper = client_wrapper
24
+
25
+ def create_subscription_checkout_session(
26
+ self,
27
+ *,
28
+ subject_id: str,
29
+ rate_card_id: str,
30
+ rate_card_overrides: typing.Optional[typing.Dict[str, str]] = OMIT,
31
+ request_options: typing.Optional[RequestOptions] = None,
32
+ ) -> HttpResponse[CreateSubscriptionCheckoutSessionResponse]:
33
+ """
34
+ Parameters
35
+ ----------
36
+ subject_id : str
37
+
38
+ rate_card_id : str
39
+
40
+ rate_card_overrides : typing.Optional[typing.Dict[str, str]]
41
+
42
+ request_options : typing.Optional[RequestOptions]
43
+ Request-specific configuration.
44
+
45
+ Returns
46
+ -------
47
+ HttpResponse[CreateSubscriptionCheckoutSessionResponse]
48
+ Successful Response
49
+ """
50
+ _response = self._client_wrapper.httpx_client.request(
51
+ "checkout",
52
+ method="POST",
53
+ json={
54
+ "subject_id": subject_id,
55
+ "rate_card_id": rate_card_id,
56
+ "rate_card_overrides": rate_card_overrides,
57
+ },
58
+ headers={
59
+ "content-type": "application/json",
60
+ },
61
+ request_options=request_options,
62
+ omit=OMIT,
63
+ )
64
+ try:
65
+ if 200 <= _response.status_code < 300:
66
+ _data = typing.cast(
67
+ CreateSubscriptionCheckoutSessionResponse,
68
+ parse_obj_as(
69
+ type_=CreateSubscriptionCheckoutSessionResponse, # type: ignore
70
+ object_=_response.json(),
71
+ ),
72
+ )
73
+ return HttpResponse(response=_response, data=_data)
74
+ if _response.status_code == 422:
75
+ raise UnprocessableEntityError(
76
+ headers=dict(_response.headers),
77
+ body=typing.cast(
78
+ HttpValidationError,
79
+ parse_obj_as(
80
+ type_=HttpValidationError, # type: ignore
81
+ object_=_response.json(),
82
+ ),
83
+ ),
84
+ )
85
+ _response_json = _response.json()
86
+ except JSONDecodeError:
87
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
88
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
89
+
90
+ def complete_subscription_checkout(
91
+ self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
92
+ ) -> HttpResponse[CompleteSubscriptionCheckoutResponse]:
93
+ """
94
+ Parameters
95
+ ----------
96
+ checkout_id : str
97
+
98
+ request_options : typing.Optional[RequestOptions]
99
+ Request-specific configuration.
100
+
101
+ Returns
102
+ -------
103
+ HttpResponse[CompleteSubscriptionCheckoutResponse]
104
+ Successful Response
105
+ """
106
+ _response = self._client_wrapper.httpx_client.request(
107
+ f"checkout/{jsonable_encoder(checkout_id)}/complete",
108
+ method="POST",
109
+ request_options=request_options,
110
+ )
111
+ try:
112
+ if 200 <= _response.status_code < 300:
113
+ _data = typing.cast(
114
+ CompleteSubscriptionCheckoutResponse,
115
+ parse_obj_as(
116
+ type_=CompleteSubscriptionCheckoutResponse, # type: ignore
117
+ object_=_response.json(),
118
+ ),
119
+ )
120
+ return HttpResponse(response=_response, data=_data)
121
+ if _response.status_code == 422:
122
+ raise UnprocessableEntityError(
123
+ headers=dict(_response.headers),
124
+ body=typing.cast(
125
+ HttpValidationError,
126
+ parse_obj_as(
127
+ type_=HttpValidationError, # type: ignore
128
+ object_=_response.json(),
129
+ ),
130
+ ),
131
+ )
132
+ _response_json = _response.json()
133
+ except JSONDecodeError:
134
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
135
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
136
+
137
+
138
+ class AsyncRawCheckoutClient:
139
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
140
+ self._client_wrapper = client_wrapper
141
+
142
+ async def create_subscription_checkout_session(
143
+ self,
144
+ *,
145
+ subject_id: str,
146
+ rate_card_id: str,
147
+ rate_card_overrides: typing.Optional[typing.Dict[str, str]] = OMIT,
148
+ request_options: typing.Optional[RequestOptions] = None,
149
+ ) -> AsyncHttpResponse[CreateSubscriptionCheckoutSessionResponse]:
150
+ """
151
+ Parameters
152
+ ----------
153
+ subject_id : str
154
+
155
+ rate_card_id : str
156
+
157
+ rate_card_overrides : typing.Optional[typing.Dict[str, str]]
158
+
159
+ request_options : typing.Optional[RequestOptions]
160
+ Request-specific configuration.
161
+
162
+ Returns
163
+ -------
164
+ AsyncHttpResponse[CreateSubscriptionCheckoutSessionResponse]
165
+ Successful Response
166
+ """
167
+ _response = await self._client_wrapper.httpx_client.request(
168
+ "checkout",
169
+ method="POST",
170
+ json={
171
+ "subject_id": subject_id,
172
+ "rate_card_id": rate_card_id,
173
+ "rate_card_overrides": rate_card_overrides,
174
+ },
175
+ headers={
176
+ "content-type": "application/json",
177
+ },
178
+ request_options=request_options,
179
+ omit=OMIT,
180
+ )
181
+ try:
182
+ if 200 <= _response.status_code < 300:
183
+ _data = typing.cast(
184
+ CreateSubscriptionCheckoutSessionResponse,
185
+ parse_obj_as(
186
+ type_=CreateSubscriptionCheckoutSessionResponse, # type: ignore
187
+ object_=_response.json(),
188
+ ),
189
+ )
190
+ return AsyncHttpResponse(response=_response, data=_data)
191
+ if _response.status_code == 422:
192
+ raise UnprocessableEntityError(
193
+ headers=dict(_response.headers),
194
+ body=typing.cast(
195
+ HttpValidationError,
196
+ parse_obj_as(
197
+ type_=HttpValidationError, # type: ignore
198
+ object_=_response.json(),
199
+ ),
200
+ ),
201
+ )
202
+ _response_json = _response.json()
203
+ except JSONDecodeError:
204
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
205
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
206
+
207
+ async def complete_subscription_checkout(
208
+ self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
209
+ ) -> AsyncHttpResponse[CompleteSubscriptionCheckoutResponse]:
210
+ """
211
+ Parameters
212
+ ----------
213
+ checkout_id : str
214
+
215
+ request_options : typing.Optional[RequestOptions]
216
+ Request-specific configuration.
217
+
218
+ Returns
219
+ -------
220
+ AsyncHttpResponse[CompleteSubscriptionCheckoutResponse]
221
+ Successful Response
222
+ """
223
+ _response = await self._client_wrapper.httpx_client.request(
224
+ f"checkout/{jsonable_encoder(checkout_id)}/complete",
225
+ method="POST",
226
+ request_options=request_options,
227
+ )
228
+ try:
229
+ if 200 <= _response.status_code < 300:
230
+ _data = typing.cast(
231
+ CompleteSubscriptionCheckoutResponse,
232
+ parse_obj_as(
233
+ type_=CompleteSubscriptionCheckoutResponse, # type: ignore
234
+ object_=_response.json(),
235
+ ),
236
+ )
237
+ return AsyncHttpResponse(response=_response, data=_data)
238
+ if _response.status_code == 422:
239
+ raise UnprocessableEntityError(
240
+ headers=dict(_response.headers),
241
+ body=typing.cast(
242
+ HttpValidationError,
243
+ parse_obj_as(
244
+ type_=HttpValidationError, # type: ignore
245
+ object_=_response.json(),
246
+ ),
247
+ ),
248
+ )
249
+ _response_json = _response.json()
250
+ except JSONDecodeError:
251
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
252
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
lark/client.py ADDED
@@ -0,0 +1,240 @@
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 httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from .checkout.client import AsyncCheckoutClient, CheckoutClient
12
+ from .feature_access.client import AsyncFeatureAccessClient, FeatureAccessClient
13
+ from .rate_cards.client import AsyncRateCardsClient, RateCardsClient
14
+ from .subjects.client import AsyncSubjectsClient, SubjectsClient
15
+ from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient
16
+ from .usage_events.client import AsyncUsageEventsClient, UsageEventsClient
17
+
18
+
19
+ class Lark:
20
+ """
21
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
22
+
23
+ Parameters
24
+ ----------
25
+ base_url : str
26
+ The base url to use for requests from the client.
27
+
28
+ api_key : str
29
+ headers : typing.Optional[typing.Dict[str, str]]
30
+ Additional headers to send with every request.
31
+
32
+ timeout : typing.Optional[float]
33
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
34
+
35
+ follow_redirects : typing.Optional[bool]
36
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
37
+
38
+ httpx_client : typing.Optional[httpx.Client]
39
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
40
+
41
+ Examples
42
+ --------
43
+ from lark import Lark
44
+
45
+ client = Lark(
46
+ api_key="YOUR_API_KEY",
47
+ base_url="https://yourhost.com/path/to/api",
48
+ )
49
+ """
50
+
51
+ def __init__(
52
+ self,
53
+ *,
54
+ base_url: str,
55
+ api_key: str,
56
+ headers: typing.Optional[typing.Dict[str, str]] = None,
57
+ timeout: typing.Optional[float] = None,
58
+ follow_redirects: typing.Optional[bool] = True,
59
+ httpx_client: typing.Optional[httpx.Client] = None,
60
+ ):
61
+ _defaulted_timeout = (
62
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
63
+ )
64
+ self._client_wrapper = SyncClientWrapper(
65
+ base_url=base_url,
66
+ api_key=api_key,
67
+ headers=headers,
68
+ httpx_client=httpx_client
69
+ if httpx_client is not None
70
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
71
+ if follow_redirects is not None
72
+ else httpx.Client(timeout=_defaulted_timeout),
73
+ timeout=_defaulted_timeout,
74
+ )
75
+ self._checkout: typing.Optional[CheckoutClient] = None
76
+ self._rate_cards: typing.Optional[RateCardsClient] = None
77
+ self._usage_events: typing.Optional[UsageEventsClient] = None
78
+ self._subscriptions: typing.Optional[SubscriptionsClient] = None
79
+ self._feature_access: typing.Optional[FeatureAccessClient] = None
80
+ self._subjects: typing.Optional[SubjectsClient] = None
81
+
82
+ @property
83
+ def checkout(self):
84
+ if self._checkout is None:
85
+ from .checkout.client import CheckoutClient # noqa: E402
86
+
87
+ self._checkout = CheckoutClient(client_wrapper=self._client_wrapper)
88
+ return self._checkout
89
+
90
+ @property
91
+ def rate_cards(self):
92
+ if self._rate_cards is None:
93
+ from .rate_cards.client import RateCardsClient # noqa: E402
94
+
95
+ self._rate_cards = RateCardsClient(client_wrapper=self._client_wrapper)
96
+ return self._rate_cards
97
+
98
+ @property
99
+ def usage_events(self):
100
+ if self._usage_events is None:
101
+ from .usage_events.client import UsageEventsClient # noqa: E402
102
+
103
+ self._usage_events = UsageEventsClient(client_wrapper=self._client_wrapper)
104
+ return self._usage_events
105
+
106
+ @property
107
+ def subscriptions(self):
108
+ if self._subscriptions is None:
109
+ from .subscriptions.client import SubscriptionsClient # noqa: E402
110
+
111
+ self._subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper)
112
+ return self._subscriptions
113
+
114
+ @property
115
+ def feature_access(self):
116
+ if self._feature_access is None:
117
+ from .feature_access.client import FeatureAccessClient # noqa: E402
118
+
119
+ self._feature_access = FeatureAccessClient(client_wrapper=self._client_wrapper)
120
+ return self._feature_access
121
+
122
+ @property
123
+ def subjects(self):
124
+ if self._subjects is None:
125
+ from .subjects.client import SubjectsClient # noqa: E402
126
+
127
+ self._subjects = SubjectsClient(client_wrapper=self._client_wrapper)
128
+ return self._subjects
129
+
130
+
131
+ class AsyncLark:
132
+ """
133
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
134
+
135
+ Parameters
136
+ ----------
137
+ base_url : str
138
+ The base url to use for requests from the client.
139
+
140
+ api_key : str
141
+ headers : typing.Optional[typing.Dict[str, str]]
142
+ Additional headers to send with every request.
143
+
144
+ timeout : typing.Optional[float]
145
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
146
+
147
+ follow_redirects : typing.Optional[bool]
148
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
149
+
150
+ httpx_client : typing.Optional[httpx.AsyncClient]
151
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
152
+
153
+ Examples
154
+ --------
155
+ from lark import AsyncLark
156
+
157
+ client = AsyncLark(
158
+ api_key="YOUR_API_KEY",
159
+ base_url="https://yourhost.com/path/to/api",
160
+ )
161
+ """
162
+
163
+ def __init__(
164
+ self,
165
+ *,
166
+ base_url: str,
167
+ api_key: str,
168
+ headers: typing.Optional[typing.Dict[str, str]] = None,
169
+ timeout: typing.Optional[float] = None,
170
+ follow_redirects: typing.Optional[bool] = True,
171
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
172
+ ):
173
+ _defaulted_timeout = (
174
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
175
+ )
176
+ self._client_wrapper = AsyncClientWrapper(
177
+ base_url=base_url,
178
+ api_key=api_key,
179
+ headers=headers,
180
+ httpx_client=httpx_client
181
+ if httpx_client is not None
182
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
183
+ if follow_redirects is not None
184
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
185
+ timeout=_defaulted_timeout,
186
+ )
187
+ self._checkout: typing.Optional[AsyncCheckoutClient] = None
188
+ self._rate_cards: typing.Optional[AsyncRateCardsClient] = None
189
+ self._usage_events: typing.Optional[AsyncUsageEventsClient] = None
190
+ self._subscriptions: typing.Optional[AsyncSubscriptionsClient] = None
191
+ self._feature_access: typing.Optional[AsyncFeatureAccessClient] = None
192
+ self._subjects: typing.Optional[AsyncSubjectsClient] = None
193
+
194
+ @property
195
+ def checkout(self):
196
+ if self._checkout is None:
197
+ from .checkout.client import AsyncCheckoutClient # noqa: E402
198
+
199
+ self._checkout = AsyncCheckoutClient(client_wrapper=self._client_wrapper)
200
+ return self._checkout
201
+
202
+ @property
203
+ def rate_cards(self):
204
+ if self._rate_cards is None:
205
+ from .rate_cards.client import AsyncRateCardsClient # noqa: E402
206
+
207
+ self._rate_cards = AsyncRateCardsClient(client_wrapper=self._client_wrapper)
208
+ return self._rate_cards
209
+
210
+ @property
211
+ def usage_events(self):
212
+ if self._usage_events is None:
213
+ from .usage_events.client import AsyncUsageEventsClient # noqa: E402
214
+
215
+ self._usage_events = AsyncUsageEventsClient(client_wrapper=self._client_wrapper)
216
+ return self._usage_events
217
+
218
+ @property
219
+ def subscriptions(self):
220
+ if self._subscriptions is None:
221
+ from .subscriptions.client import AsyncSubscriptionsClient # noqa: E402
222
+
223
+ self._subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper)
224
+ return self._subscriptions
225
+
226
+ @property
227
+ def feature_access(self):
228
+ if self._feature_access is None:
229
+ from .feature_access.client import AsyncFeatureAccessClient # noqa: E402
230
+
231
+ self._feature_access = AsyncFeatureAccessClient(client_wrapper=self._client_wrapper)
232
+ return self._feature_access
233
+
234
+ @property
235
+ def subjects(self):
236
+ if self._subjects is None:
237
+ from .subjects.client import AsyncSubjectsClient # noqa: E402
238
+
239
+ self._subjects = AsyncSubjectsClient(client_wrapper=self._client_wrapper)
240
+ return self._subjects