lark-billing 0.0.6__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 (154) hide show
  1. lark/__init__.py +92 -369
  2. lark/checkout/client.py +20 -79
  3. lark/checkout/raw_client.py +18 -102
  4. lark/client.py +112 -27
  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/{types/credit_grant.py → core/http_sse/_exceptions.py} +4 -2
  10. lark/core/http_sse/_models.py +17 -0
  11. lark/core/pydantic_utilities.py +3 -1
  12. lark/{feature_access → customer_access}/client.py +30 -24
  13. lark/{feature_access → customer_access}/raw_client.py +22 -17
  14. lark/{types/rate_card.py → customer_portal/__init__.py} +1 -2
  15. lark/customer_portal/client.py +115 -0
  16. lark/customer_portal/raw_client.py +134 -0
  17. lark/environment.py +7 -0
  18. lark/{types/dimension.py → invoices/__init__.py} +1 -2
  19. lark/invoices/client.py +136 -0
  20. lark/invoices/raw_client.py +147 -0
  21. lark/pricing_metrics/__init__.py +38 -0
  22. lark/pricing_metrics/client.py +288 -0
  23. lark/pricing_metrics/raw_client.py +369 -0
  24. lark/pricing_metrics/types/__init__.py +42 -0
  25. lark/{types/credit_grant_resource_input_schedule.py → pricing_metrics/types/pricing_metric_aggregation.py} +7 -8
  26. lark/rate_cards/__init__.py +0 -15
  27. lark/rate_cards/client.py +30 -542
  28. lark/rate_cards/raw_client.py +34 -370
  29. lark/rate_cards/types/__init__.py +0 -17
  30. lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +3 -29
  31. lark/subjects/client.py +18 -54
  32. lark/subjects/raw_client.py +14 -24
  33. lark/subscriptions/client.py +104 -80
  34. lark/subscriptions/raw_client.py +186 -53
  35. lark/types/__init__.py +63 -379
  36. lark/types/aggregation.py +1 -43
  37. lark/types/amount.py +5 -1
  38. lark/types/{credit_grant_date_time_expiration_interface.py → billing_state_response.py} +3 -2
  39. lark/types/{credit_grant_schedule_one_time_resource.py → count_aggregation_pricing_metric_resource.py} +1 -1
  40. lark/types/{create_dimension_interface.py → create_customer_portal_session_response.py} +3 -3
  41. lark/types/{create_dimension_coordinate_interface.py → create_fixed_rate_request.py} +5 -3
  42. lark/types/{pricing_metric_interface.py → create_pricing_metric_response.py} +2 -5
  43. lark/types/{create_simple_usage_based_rate_interface.py → create_simple_usage_based_rate_request.py} +6 -9
  44. lark/types/create_subject_response.py +30 -6
  45. lark/types/create_subscription_checkout_session_response.py +1 -2
  46. lark/types/create_usage_event_summary_response.py +1 -1
  47. lark/types/fixed_rate_interface.py +0 -6
  48. lark/types/{create_pricing_metric_interface.py → get_pricing_metric_response.py} +3 -5
  49. lark/types/{complete_subscription_checkout_response.py → invoice_line_item_resource.py} +4 -2
  50. lark/types/invoice_resource.py +31 -0
  51. lark/types/invoice_status.py +5 -0
  52. lark/types/{check_feature_access_response.py → list_invoices_response.py} +4 -4
  53. lark/types/{check_feature_access_request.py → list_pricing_metrics_response.py} +4 -7
  54. lark/types/package_price.py +2 -2
  55. lark/types/package_price_input_rounding_behavior.py +5 -0
  56. lark/types/package_price_output_rounding_behavior.py +5 -0
  57. lark/types/period_resource.py +23 -0
  58. lark/types/price.py +39 -1
  59. lark/types/pricing_metric_resource.py +24 -0
  60. lark/types/rate_card_resource.py +0 -6
  61. lark/types/rate_card_resource_usage_based_rates_item.py +2 -29
  62. lark/types/simple_usage_based_rate_interface.py +1 -7
  63. lark/types/subject_resource.py +30 -6
  64. lark/types/subscription_resource.py +6 -4
  65. lark/types/subscription_status.py +5 -0
  66. lark/types/{credit_grant_date_time_expiration_resource.py → sum_aggregation_pricing_metric_resource.py} +2 -2
  67. lark/types/{subject.py → value.py} +1 -1
  68. lark/usage_events/client.py +8 -21
  69. lark/usage_events/raw_client.py +6 -6
  70. {lark_billing-0.0.6.dist-info → lark_billing-0.0.8.dist-info}/METADATA +4 -3
  71. lark_billing-0.0.8.dist-info/RECORD +107 -0
  72. lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +0 -58
  73. lark/rate_cards/types/create_rate_card_version_request_version_type.py +0 -5
  74. lark/types/create_credit_grant_interface.py +0 -27
  75. lark/types/create_credit_grant_interface_expiration.py +0 -27
  76. lark/types/create_credit_pool_request.py +0 -5
  77. lark/types/create_dimensional_usage_based_rate_interface.py +0 -32
  78. lark/types/create_fixed_rate_interface.py +0 -28
  79. lark/types/create_pricing_matrix_cell_interface.py +0 -22
  80. lark/types/create_pricing_matrix_interface.py +0 -20
  81. lark/types/create_pricing_plan_request.py +0 -5
  82. lark/types/create_rate_card_response.py +0 -36
  83. lark/types/create_rate_card_response_billing_interval.py +0 -5
  84. lark/types/create_rate_card_response_usage_based_rates_item.py +0 -58
  85. lark/types/create_rate_card_version_response.py +0 -36
  86. lark/types/create_rate_card_version_response_billing_interval.py +0 -5
  87. lark/types/create_rate_card_version_response_usage_based_rates_item.py +0 -59
  88. lark/types/credit_grant_duration_expiration_interface.py +0 -21
  89. lark/types/credit_grant_duration_expiration_resource.py +0 -21
  90. lark/types/credit_grant_interface.py +0 -28
  91. lark/types/credit_grant_interface_input_expiration.py +0 -27
  92. lark/types/credit_grant_interface_output_expiration.py +0 -43
  93. lark/types/credit_grant_interface_output_schedule.py +0 -41
  94. lark/types/credit_grant_resource.py +0 -28
  95. lark/types/credit_grant_resource_input_expiration.py +0 -27
  96. lark/types/credit_grant_resource_output_expiration.py +0 -43
  97. lark/types/credit_grant_resource_output_schedule.py +0 -39
  98. lark/types/credit_grant_schedule.py +0 -5
  99. lark/types/credit_grant_schedule_one_time_interface.py +0 -19
  100. lark/types/credit_grant_schedule_rate_cycle_start_interface.py +0 -19
  101. lark/types/credit_grant_schedule_rate_cycle_start_resource.py +0 -17
  102. lark/types/credit_grant_subject_granting_config_interface.py +0 -20
  103. lark/types/credit_pool.py +0 -5
  104. lark/types/credit_pool_rollover_config.py +0 -5
  105. lark/types/custom_aggregation_pricing_metric_interface.py +0 -22
  106. lark/types/custom_pricing_metric.py +0 -5
  107. lark/types/custom_unit.py +0 -5
  108. lark/types/custom_unit_amount.py +0 -5
  109. lark/types/dimension_coordinate.py +0 -5
  110. lark/types/dimension_coordinate_interface.py +0 -20
  111. lark/types/dimension_coordinate_set.py +0 -5
  112. lark/types/dimension_interface.py +0 -20
  113. lark/types/dimensional_rate_matrix.py +0 -5
  114. lark/types/dimensional_rate_matrix_cell.py +0 -5
  115. lark/types/dimensional_usage_based_rate.py +0 -5
  116. lark/types/dimensional_usage_based_rate_input.py +0 -5
  117. lark/types/dimensional_usage_based_rate_interface.py +0 -33
  118. lark/types/feature_access_resource.py +0 -21
  119. lark/types/get_rate_card_response.py +0 -36
  120. lark/types/get_rate_card_response_billing_interval.py +0 -5
  121. lark/types/get_rate_card_response_usage_based_rates_item.py +0 -58
  122. lark/types/grant_credits_request.py +0 -5
  123. lark/types/last_aggregation_pricing_metric_interface.py +0 -22
  124. lark/types/license_based_rate.py +0 -5
  125. lark/types/license_based_rate_input.py +0 -5
  126. lark/types/max_aggregation_pricing_metric_interface.py +0 -22
  127. lark/types/monetary_amount.py +0 -5
  128. lark/types/package_price_rounding_behavior.py +0 -5
  129. lark/types/package_price_wrapper.py +0 -5
  130. lark/types/pricing_matrix_cell_interface.py +0 -22
  131. lark/types/pricing_matrix_interface.py +0 -20
  132. lark/types/pricing_metric.py +0 -5
  133. lark/types/pricing_plan.py +0 -5
  134. lark/types/pricing_plan_subscription.py +0 -5
  135. lark/types/pricing_tier.py +0 -5
  136. lark/types/rate_card_version.py +0 -5
  137. lark/types/rate_card_version_input.py +0 -5
  138. lark/types/simple_usage_based_rate.py +0 -5
  139. lark/types/simple_usage_based_rate_input.py +0 -5
  140. lark/types/status.py +0 -5
  141. lark/types/subject_granting_config.py +0 -5
  142. lark/types/subject_granting_config_resource.py +0 -20
  143. lark/types/tiered_price.py +0 -5
  144. lark/types/tiered_price_wrapper.py +0 -5
  145. lark/types/unit.py +0 -5
  146. lark/types/update_pricing_plan_request.py +0 -5
  147. lark/types/update_rate_card_request.py +0 -5
  148. lark/types/update_subscription_request.py +0 -5
  149. lark/types/usage_based_rate.py +0 -5
  150. lark/types/usage_based_rate_input.py +0 -5
  151. lark/types/usage_unit.py +0 -5
  152. lark_billing-0.0.6.dist-info/RECORD +0 -167
  153. /lark/{feature_access → customer_access}/__init__.py +0 -0
  154. {lark_billing-0.0.6.dist-info → lark_billing-0.0.8.dist-info}/WHEEL +0 -0
@@ -0,0 +1,288 @@
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.create_pricing_metric_response import CreatePricingMetricResponse
8
+ from ..types.get_pricing_metric_response import GetPricingMetricResponse
9
+ from ..types.list_pricing_metrics_response import ListPricingMetricsResponse
10
+ from .raw_client import AsyncRawPricingMetricsClient, RawPricingMetricsClient
11
+ from .types.pricing_metric_aggregation import PricingMetricAggregation
12
+
13
+ # this is used as the default value for optional parameters
14
+ OMIT = typing.cast(typing.Any, ...)
15
+
16
+
17
+ class PricingMetricsClient:
18
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
19
+ self._raw_client = RawPricingMetricsClient(client_wrapper=client_wrapper)
20
+
21
+ @property
22
+ def with_raw_response(self) -> RawPricingMetricsClient:
23
+ """
24
+ Retrieves a raw implementation of this client that returns raw responses.
25
+
26
+ Returns
27
+ -------
28
+ RawPricingMetricsClient
29
+ """
30
+ return self._raw_client
31
+
32
+ def list_pricing_metrics(
33
+ self, *, limit: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
34
+ ) -> ListPricingMetricsResponse:
35
+ """
36
+ Parameters
37
+ ----------
38
+ limit : typing.Optional[int]
39
+
40
+ request_options : typing.Optional[RequestOptions]
41
+ Request-specific configuration.
42
+
43
+ Returns
44
+ -------
45
+ ListPricingMetricsResponse
46
+ Successful Response
47
+
48
+ Examples
49
+ --------
50
+ from lark import Lark
51
+
52
+ client = Lark(
53
+ api_key="YOUR_API_KEY",
54
+ )
55
+ client.pricing_metrics.list_pricing_metrics(
56
+ limit=1,
57
+ )
58
+ """
59
+ _response = self._raw_client.list_pricing_metrics(limit=limit, request_options=request_options)
60
+ return _response.data
61
+
62
+ def create_pricing_metric(
63
+ self,
64
+ *,
65
+ name: str,
66
+ event_name: str,
67
+ aggregation: PricingMetricAggregation,
68
+ unit: str,
69
+ request_options: typing.Optional[RequestOptions] = None,
70
+ ) -> CreatePricingMetricResponse:
71
+ """
72
+ Parameters
73
+ ----------
74
+ name : str
75
+
76
+ event_name : str
77
+
78
+ aggregation : PricingMetricAggregation
79
+
80
+ unit : str
81
+ Unit of measurement for the pricing metric
82
+
83
+ request_options : typing.Optional[RequestOptions]
84
+ Request-specific configuration.
85
+
86
+ Returns
87
+ -------
88
+ CreatePricingMetricResponse
89
+ Successful Response
90
+
91
+ Examples
92
+ --------
93
+ from lark import Lark
94
+ from lark.pricing_metrics import PricingMetricAggregation_Count
95
+
96
+ client = Lark(
97
+ api_key="YOUR_API_KEY",
98
+ )
99
+ client.pricing_metrics.create_pricing_metric(
100
+ name="name",
101
+ event_name="event_name",
102
+ aggregation=PricingMetricAggregation_Count(),
103
+ unit="unit",
104
+ )
105
+ """
106
+ _response = self._raw_client.create_pricing_metric(
107
+ name=name, event_name=event_name, aggregation=aggregation, unit=unit, request_options=request_options
108
+ )
109
+ return _response.data
110
+
111
+ def get_pricing_metric(
112
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
113
+ ) -> GetPricingMetricResponse:
114
+ """
115
+ Parameters
116
+ ----------
117
+ pricing_metric_id : str
118
+
119
+ request_options : typing.Optional[RequestOptions]
120
+ Request-specific configuration.
121
+
122
+ Returns
123
+ -------
124
+ GetPricingMetricResponse
125
+ Successful Response
126
+
127
+ Examples
128
+ --------
129
+ from lark import Lark
130
+
131
+ client = Lark(
132
+ api_key="YOUR_API_KEY",
133
+ )
134
+ client.pricing_metrics.get_pricing_metric(
135
+ pricing_metric_id="pricing_metric_id",
136
+ )
137
+ """
138
+ _response = self._raw_client.get_pricing_metric(pricing_metric_id, request_options=request_options)
139
+ return _response.data
140
+
141
+
142
+ class AsyncPricingMetricsClient:
143
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
144
+ self._raw_client = AsyncRawPricingMetricsClient(client_wrapper=client_wrapper)
145
+
146
+ @property
147
+ def with_raw_response(self) -> AsyncRawPricingMetricsClient:
148
+ """
149
+ Retrieves a raw implementation of this client that returns raw responses.
150
+
151
+ Returns
152
+ -------
153
+ AsyncRawPricingMetricsClient
154
+ """
155
+ return self._raw_client
156
+
157
+ async def list_pricing_metrics(
158
+ self, *, limit: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
159
+ ) -> ListPricingMetricsResponse:
160
+ """
161
+ Parameters
162
+ ----------
163
+ limit : typing.Optional[int]
164
+
165
+ request_options : typing.Optional[RequestOptions]
166
+ Request-specific configuration.
167
+
168
+ Returns
169
+ -------
170
+ ListPricingMetricsResponse
171
+ Successful Response
172
+
173
+ Examples
174
+ --------
175
+ import asyncio
176
+
177
+ from lark import AsyncLark
178
+
179
+ client = AsyncLark(
180
+ api_key="YOUR_API_KEY",
181
+ )
182
+
183
+
184
+ async def main() -> None:
185
+ await client.pricing_metrics.list_pricing_metrics(
186
+ limit=1,
187
+ )
188
+
189
+
190
+ asyncio.run(main())
191
+ """
192
+ _response = await self._raw_client.list_pricing_metrics(limit=limit, request_options=request_options)
193
+ return _response.data
194
+
195
+ async def create_pricing_metric(
196
+ self,
197
+ *,
198
+ name: str,
199
+ event_name: str,
200
+ aggregation: PricingMetricAggregation,
201
+ unit: str,
202
+ request_options: typing.Optional[RequestOptions] = None,
203
+ ) -> CreatePricingMetricResponse:
204
+ """
205
+ Parameters
206
+ ----------
207
+ name : str
208
+
209
+ event_name : str
210
+
211
+ aggregation : PricingMetricAggregation
212
+
213
+ unit : str
214
+ Unit of measurement for the pricing metric
215
+
216
+ request_options : typing.Optional[RequestOptions]
217
+ Request-specific configuration.
218
+
219
+ Returns
220
+ -------
221
+ CreatePricingMetricResponse
222
+ Successful Response
223
+
224
+ Examples
225
+ --------
226
+ import asyncio
227
+
228
+ from lark import AsyncLark
229
+ from lark.pricing_metrics import PricingMetricAggregation_Count
230
+
231
+ client = AsyncLark(
232
+ api_key="YOUR_API_KEY",
233
+ )
234
+
235
+
236
+ async def main() -> None:
237
+ await client.pricing_metrics.create_pricing_metric(
238
+ name="name",
239
+ event_name="event_name",
240
+ aggregation=PricingMetricAggregation_Count(),
241
+ unit="unit",
242
+ )
243
+
244
+
245
+ asyncio.run(main())
246
+ """
247
+ _response = await self._raw_client.create_pricing_metric(
248
+ name=name, event_name=event_name, aggregation=aggregation, unit=unit, request_options=request_options
249
+ )
250
+ return _response.data
251
+
252
+ async def get_pricing_metric(
253
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
254
+ ) -> GetPricingMetricResponse:
255
+ """
256
+ Parameters
257
+ ----------
258
+ pricing_metric_id : str
259
+
260
+ request_options : typing.Optional[RequestOptions]
261
+ Request-specific configuration.
262
+
263
+ Returns
264
+ -------
265
+ GetPricingMetricResponse
266
+ Successful Response
267
+
268
+ Examples
269
+ --------
270
+ import asyncio
271
+
272
+ from lark import AsyncLark
273
+
274
+ client = AsyncLark(
275
+ api_key="YOUR_API_KEY",
276
+ )
277
+
278
+
279
+ async def main() -> None:
280
+ await client.pricing_metrics.get_pricing_metric(
281
+ pricing_metric_id="pricing_metric_id",
282
+ )
283
+
284
+
285
+ asyncio.run(main())
286
+ """
287
+ _response = await self._raw_client.get_pricing_metric(pricing_metric_id, request_options=request_options)
288
+ return _response.data
@@ -0,0 +1,369 @@
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 ..core.serialization import convert_and_respect_annotation_metadata
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
+ from ..types.http_validation_error import HttpValidationError
17
+ from ..types.list_pricing_metrics_response import ListPricingMetricsResponse
18
+ from .types.pricing_metric_aggregation import PricingMetricAggregation
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class RawPricingMetricsClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+
28
+ def list_pricing_metrics(
29
+ self, *, limit: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
30
+ ) -> HttpResponse[ListPricingMetricsResponse]:
31
+ """
32
+ Parameters
33
+ ----------
34
+ limit : typing.Optional[int]
35
+
36
+ request_options : typing.Optional[RequestOptions]
37
+ Request-specific configuration.
38
+
39
+ Returns
40
+ -------
41
+ HttpResponse[ListPricingMetricsResponse]
42
+ Successful Response
43
+ """
44
+ _response = self._client_wrapper.httpx_client.request(
45
+ "pricing-metrics",
46
+ method="GET",
47
+ params={
48
+ "limit": limit,
49
+ },
50
+ request_options=request_options,
51
+ )
52
+ try:
53
+ if 200 <= _response.status_code < 300:
54
+ _data = typing.cast(
55
+ ListPricingMetricsResponse,
56
+ parse_obj_as(
57
+ type_=ListPricingMetricsResponse, # type: ignore
58
+ object_=_response.json(),
59
+ ),
60
+ )
61
+ return HttpResponse(response=_response, data=_data)
62
+ if _response.status_code == 422:
63
+ raise UnprocessableEntityError(
64
+ headers=dict(_response.headers),
65
+ body=typing.cast(
66
+ HttpValidationError,
67
+ parse_obj_as(
68
+ type_=HttpValidationError, # type: ignore
69
+ object_=_response.json(),
70
+ ),
71
+ ),
72
+ )
73
+ _response_json = _response.json()
74
+ except JSONDecodeError:
75
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
76
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
77
+
78
+ def create_pricing_metric(
79
+ self,
80
+ *,
81
+ name: str,
82
+ event_name: str,
83
+ aggregation: PricingMetricAggregation,
84
+ unit: str,
85
+ request_options: typing.Optional[RequestOptions] = None,
86
+ ) -> HttpResponse[CreatePricingMetricResponse]:
87
+ """
88
+ Parameters
89
+ ----------
90
+ name : str
91
+
92
+ event_name : str
93
+
94
+ aggregation : PricingMetricAggregation
95
+
96
+ unit : str
97
+ Unit of measurement for the pricing metric
98
+
99
+ request_options : typing.Optional[RequestOptions]
100
+ Request-specific configuration.
101
+
102
+ Returns
103
+ -------
104
+ HttpResponse[CreatePricingMetricResponse]
105
+ Successful Response
106
+ """
107
+ _response = self._client_wrapper.httpx_client.request(
108
+ "pricing-metrics",
109
+ method="POST",
110
+ json={
111
+ "name": name,
112
+ "event_name": event_name,
113
+ "aggregation": convert_and_respect_annotation_metadata(
114
+ object_=aggregation, annotation=PricingMetricAggregation, direction="write"
115
+ ),
116
+ "unit": unit,
117
+ },
118
+ headers={
119
+ "content-type": "application/json",
120
+ },
121
+ request_options=request_options,
122
+ omit=OMIT,
123
+ )
124
+ try:
125
+ if 200 <= _response.status_code < 300:
126
+ _data = typing.cast(
127
+ CreatePricingMetricResponse,
128
+ parse_obj_as(
129
+ type_=CreatePricingMetricResponse, # type: ignore
130
+ object_=_response.json(),
131
+ ),
132
+ )
133
+ return HttpResponse(response=_response, data=_data)
134
+ if _response.status_code == 422:
135
+ raise UnprocessableEntityError(
136
+ headers=dict(_response.headers),
137
+ body=typing.cast(
138
+ HttpValidationError,
139
+ parse_obj_as(
140
+ type_=HttpValidationError, # type: ignore
141
+ object_=_response.json(),
142
+ ),
143
+ ),
144
+ )
145
+ _response_json = _response.json()
146
+ except JSONDecodeError:
147
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
148
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
149
+
150
+ def get_pricing_metric(
151
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
152
+ ) -> HttpResponse[GetPricingMetricResponse]:
153
+ """
154
+ Parameters
155
+ ----------
156
+ pricing_metric_id : str
157
+
158
+ request_options : typing.Optional[RequestOptions]
159
+ Request-specific configuration.
160
+
161
+ Returns
162
+ -------
163
+ HttpResponse[GetPricingMetricResponse]
164
+ Successful Response
165
+ """
166
+ _response = self._client_wrapper.httpx_client.request(
167
+ f"pricing-metrics/{jsonable_encoder(pricing_metric_id)}",
168
+ method="GET",
169
+ request_options=request_options,
170
+ )
171
+ try:
172
+ if 200 <= _response.status_code < 300:
173
+ _data = typing.cast(
174
+ GetPricingMetricResponse,
175
+ parse_obj_as(
176
+ type_=GetPricingMetricResponse, # type: ignore
177
+ object_=_response.json(),
178
+ ),
179
+ )
180
+ return HttpResponse(response=_response, data=_data)
181
+ if _response.status_code == 422:
182
+ raise UnprocessableEntityError(
183
+ headers=dict(_response.headers),
184
+ body=typing.cast(
185
+ HttpValidationError,
186
+ parse_obj_as(
187
+ type_=HttpValidationError, # type: ignore
188
+ object_=_response.json(),
189
+ ),
190
+ ),
191
+ )
192
+ _response_json = _response.json()
193
+ except JSONDecodeError:
194
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
195
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
196
+
197
+
198
+ class AsyncRawPricingMetricsClient:
199
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
200
+ self._client_wrapper = client_wrapper
201
+
202
+ async def list_pricing_metrics(
203
+ self, *, limit: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
204
+ ) -> AsyncHttpResponse[ListPricingMetricsResponse]:
205
+ """
206
+ Parameters
207
+ ----------
208
+ limit : typing.Optional[int]
209
+
210
+ request_options : typing.Optional[RequestOptions]
211
+ Request-specific configuration.
212
+
213
+ Returns
214
+ -------
215
+ AsyncHttpResponse[ListPricingMetricsResponse]
216
+ Successful Response
217
+ """
218
+ _response = await self._client_wrapper.httpx_client.request(
219
+ "pricing-metrics",
220
+ method="GET",
221
+ params={
222
+ "limit": limit,
223
+ },
224
+ request_options=request_options,
225
+ )
226
+ try:
227
+ if 200 <= _response.status_code < 300:
228
+ _data = typing.cast(
229
+ ListPricingMetricsResponse,
230
+ parse_obj_as(
231
+ type_=ListPricingMetricsResponse, # type: ignore
232
+ object_=_response.json(),
233
+ ),
234
+ )
235
+ return AsyncHttpResponse(response=_response, data=_data)
236
+ if _response.status_code == 422:
237
+ raise UnprocessableEntityError(
238
+ headers=dict(_response.headers),
239
+ body=typing.cast(
240
+ HttpValidationError,
241
+ parse_obj_as(
242
+ type_=HttpValidationError, # type: ignore
243
+ object_=_response.json(),
244
+ ),
245
+ ),
246
+ )
247
+ _response_json = _response.json()
248
+ except JSONDecodeError:
249
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
250
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
251
+
252
+ async def create_pricing_metric(
253
+ self,
254
+ *,
255
+ name: str,
256
+ event_name: str,
257
+ aggregation: PricingMetricAggregation,
258
+ unit: str,
259
+ request_options: typing.Optional[RequestOptions] = None,
260
+ ) -> AsyncHttpResponse[CreatePricingMetricResponse]:
261
+ """
262
+ Parameters
263
+ ----------
264
+ name : str
265
+
266
+ event_name : str
267
+
268
+ aggregation : PricingMetricAggregation
269
+
270
+ unit : str
271
+ Unit of measurement for the pricing metric
272
+
273
+ request_options : typing.Optional[RequestOptions]
274
+ Request-specific configuration.
275
+
276
+ Returns
277
+ -------
278
+ AsyncHttpResponse[CreatePricingMetricResponse]
279
+ Successful Response
280
+ """
281
+ _response = await self._client_wrapper.httpx_client.request(
282
+ "pricing-metrics",
283
+ method="POST",
284
+ json={
285
+ "name": name,
286
+ "event_name": event_name,
287
+ "aggregation": convert_and_respect_annotation_metadata(
288
+ object_=aggregation, annotation=PricingMetricAggregation, direction="write"
289
+ ),
290
+ "unit": unit,
291
+ },
292
+ headers={
293
+ "content-type": "application/json",
294
+ },
295
+ request_options=request_options,
296
+ omit=OMIT,
297
+ )
298
+ try:
299
+ if 200 <= _response.status_code < 300:
300
+ _data = typing.cast(
301
+ CreatePricingMetricResponse,
302
+ parse_obj_as(
303
+ type_=CreatePricingMetricResponse, # type: ignore
304
+ object_=_response.json(),
305
+ ),
306
+ )
307
+ return AsyncHttpResponse(response=_response, data=_data)
308
+ if _response.status_code == 422:
309
+ raise UnprocessableEntityError(
310
+ headers=dict(_response.headers),
311
+ body=typing.cast(
312
+ HttpValidationError,
313
+ parse_obj_as(
314
+ type_=HttpValidationError, # type: ignore
315
+ object_=_response.json(),
316
+ ),
317
+ ),
318
+ )
319
+ _response_json = _response.json()
320
+ except JSONDecodeError:
321
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
322
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
323
+
324
+ async def get_pricing_metric(
325
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
326
+ ) -> AsyncHttpResponse[GetPricingMetricResponse]:
327
+ """
328
+ Parameters
329
+ ----------
330
+ pricing_metric_id : str
331
+
332
+ request_options : typing.Optional[RequestOptions]
333
+ Request-specific configuration.
334
+
335
+ Returns
336
+ -------
337
+ AsyncHttpResponse[GetPricingMetricResponse]
338
+ Successful Response
339
+ """
340
+ _response = await self._client_wrapper.httpx_client.request(
341
+ f"pricing-metrics/{jsonable_encoder(pricing_metric_id)}",
342
+ method="GET",
343
+ request_options=request_options,
344
+ )
345
+ try:
346
+ if 200 <= _response.status_code < 300:
347
+ _data = typing.cast(
348
+ GetPricingMetricResponse,
349
+ parse_obj_as(
350
+ type_=GetPricingMetricResponse, # type: ignore
351
+ object_=_response.json(),
352
+ ),
353
+ )
354
+ return AsyncHttpResponse(response=_response, data=_data)
355
+ if _response.status_code == 422:
356
+ raise UnprocessableEntityError(
357
+ headers=dict(_response.headers),
358
+ body=typing.cast(
359
+ HttpValidationError,
360
+ parse_obj_as(
361
+ type_=HttpValidationError, # type: ignore
362
+ object_=_response.json(),
363
+ ),
364
+ ),
365
+ )
366
+ _response_json = _response.json()
367
+ except JSONDecodeError:
368
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
369
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,42 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .pricing_metric_aggregation import (
10
+ PricingMetricAggregation,
11
+ PricingMetricAggregation_Count,
12
+ PricingMetricAggregation_Sum,
13
+ )
14
+ _dynamic_imports: typing.Dict[str, str] = {
15
+ "PricingMetricAggregation": ".pricing_metric_aggregation",
16
+ "PricingMetricAggregation_Count": ".pricing_metric_aggregation",
17
+ "PricingMetricAggregation_Sum": ".pricing_metric_aggregation",
18
+ }
19
+
20
+
21
+ def __getattr__(attr_name: str) -> typing.Any:
22
+ module_name = _dynamic_imports.get(attr_name)
23
+ if module_name is None:
24
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
25
+ try:
26
+ module = import_module(module_name, __package__)
27
+ if module_name == f".{attr_name}":
28
+ return module
29
+ else:
30
+ return getattr(module, attr_name)
31
+ except ImportError as e:
32
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
33
+ except AttributeError as e:
34
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
35
+
36
+
37
+ def __dir__():
38
+ lazy_attrs = list(_dynamic_imports.keys())
39
+ return sorted(lazy_attrs)
40
+
41
+
42
+ __all__ = ["PricingMetricAggregation", "PricingMetricAggregation_Count", "PricingMetricAggregation_Sum"]