lark-billing 0.0.6__py3-none-any.whl → 0.0.7__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 (141) hide show
  1. lark/__init__.py +69 -360
  2. lark/checkout/client.py +8 -85
  3. lark/checkout/raw_client.py +6 -102
  4. lark/client.py +93 -27
  5. lark/core/client_wrapper.py +2 -2
  6. lark/{feature_access → customer_access}/client.py +30 -24
  7. lark/{feature_access → customer_access}/raw_client.py +22 -17
  8. lark/{types/rate_card.py → customer_portal/__init__.py} +1 -2
  9. lark/customer_portal/client.py +115 -0
  10. lark/customer_portal/raw_client.py +134 -0
  11. lark/environment.py +7 -0
  12. lark/pricing_metrics/__init__.py +38 -0
  13. lark/pricing_metrics/client.py +219 -0
  14. lark/pricing_metrics/raw_client.py +268 -0
  15. lark/pricing_metrics/types/__init__.py +42 -0
  16. lark/{types/credit_grant_resource_input_schedule.py → pricing_metrics/types/pricing_metric_aggregation.py} +7 -8
  17. lark/rate_cards/__init__.py +3 -30
  18. lark/rate_cards/client.py +28 -540
  19. lark/rate_cards/raw_client.py +32 -368
  20. lark/rate_cards/types/__init__.py +2 -29
  21. lark/subjects/client.py +2 -36
  22. lark/subjects/raw_client.py +0 -16
  23. lark/subscriptions/client.py +24 -184
  24. lark/subscriptions/raw_client.py +18 -135
  25. lark/types/__init__.py +41 -356
  26. lark/types/amount.py +5 -1
  27. lark/types/{create_dimension_coordinate_interface.py → billing_state_response.py} +3 -3
  28. lark/types/{credit_grant_schedule_one_time_resource.py → count_aggregation_pricing_metric_resource.py} +1 -1
  29. lark/types/{create_dimension_interface.py → create_customer_portal_session_response.py} +3 -3
  30. lark/types/create_fixed_rate_interface.py +1 -7
  31. lark/types/{pricing_metric_interface.py → create_pricing_metric_response.py} +2 -5
  32. lark/types/create_simple_usage_based_rate_interface.py +3 -8
  33. lark/types/create_subject_response.py +2 -1
  34. lark/types/create_subscription_checkout_session_response.py +1 -2
  35. lark/types/create_usage_event_summary_response.py +1 -1
  36. lark/types/{credit_grant_schedule_rate_cycle_start_resource.py → custom_pricing_metric_resource.py} +3 -1
  37. lark/types/fixed_rate_interface.py +0 -6
  38. lark/types/{create_pricing_metric_interface.py → get_pricing_metric_response.py} +3 -5
  39. lark/types/{credit_grant_schedule_one_time_interface.py → last_aggregation_pricing_metric_resource.py} +2 -2
  40. lark/types/{credit_grant_date_time_expiration_resource.py → max_aggregation_pricing_metric_resource.py} +2 -2
  41. lark/types/package_price.py +2 -2
  42. lark/types/package_price_input_rounding_behavior.py +5 -0
  43. lark/types/package_price_output_rounding_behavior.py +5 -0
  44. lark/types/price.py +39 -1
  45. lark/types/rate_card_resource.py +0 -6
  46. lark/types/rate_card_resource_usage_based_rates_item.py +2 -28
  47. lark/types/simple_usage_based_rate_interface.py +1 -2
  48. lark/types/status.py +1 -1
  49. lark/types/subject_resource.py +2 -1
  50. lark/types/subscription_resource.py +0 -1
  51. lark/types/{credit_grant_date_time_expiration_interface.py → sum_aggregation_pricing_metric_resource.py} +2 -2
  52. lark/types/{subject.py → value.py} +1 -1
  53. lark/usage_events/client.py +8 -21
  54. lark/usage_events/raw_client.py +6 -6
  55. {lark_billing-0.0.6.dist-info → lark_billing-0.0.7.dist-info}/METADATA +3 -3
  56. lark_billing-0.0.7.dist-info/RECORD +94 -0
  57. lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +0 -56
  58. lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +0 -58
  59. lark/rate_cards/types/create_rate_card_version_request_version_type.py +0 -5
  60. lark/types/check_feature_access_request.py +0 -24
  61. lark/types/check_feature_access_response.py +0 -21
  62. lark/types/complete_subscription_checkout_response.py +0 -21
  63. lark/types/create_credit_grant_interface.py +0 -27
  64. lark/types/create_credit_grant_interface_expiration.py +0 -27
  65. lark/types/create_credit_pool_request.py +0 -5
  66. lark/types/create_dimensional_usage_based_rate_interface.py +0 -32
  67. lark/types/create_pricing_matrix_cell_interface.py +0 -22
  68. lark/types/create_pricing_matrix_interface.py +0 -20
  69. lark/types/create_pricing_plan_request.py +0 -5
  70. lark/types/create_rate_card_response.py +0 -36
  71. lark/types/create_rate_card_response_billing_interval.py +0 -5
  72. lark/types/create_rate_card_response_usage_based_rates_item.py +0 -58
  73. lark/types/create_rate_card_version_response.py +0 -36
  74. lark/types/create_rate_card_version_response_billing_interval.py +0 -5
  75. lark/types/create_rate_card_version_response_usage_based_rates_item.py +0 -59
  76. lark/types/credit_grant.py +0 -5
  77. lark/types/credit_grant_duration_expiration_interface.py +0 -21
  78. lark/types/credit_grant_duration_expiration_resource.py +0 -21
  79. lark/types/credit_grant_interface.py +0 -28
  80. lark/types/credit_grant_interface_input_expiration.py +0 -27
  81. lark/types/credit_grant_interface_output_expiration.py +0 -43
  82. lark/types/credit_grant_interface_output_schedule.py +0 -41
  83. lark/types/credit_grant_resource.py +0 -28
  84. lark/types/credit_grant_resource_input_expiration.py +0 -27
  85. lark/types/credit_grant_resource_output_expiration.py +0 -43
  86. lark/types/credit_grant_resource_output_schedule.py +0 -39
  87. lark/types/credit_grant_schedule.py +0 -5
  88. lark/types/credit_grant_schedule_rate_cycle_start_interface.py +0 -19
  89. lark/types/credit_grant_subject_granting_config_interface.py +0 -20
  90. lark/types/credit_pool.py +0 -5
  91. lark/types/credit_pool_rollover_config.py +0 -5
  92. lark/types/custom_aggregation_pricing_metric_interface.py +0 -22
  93. lark/types/custom_pricing_metric.py +0 -5
  94. lark/types/custom_unit.py +0 -5
  95. lark/types/custom_unit_amount.py +0 -5
  96. lark/types/dimension.py +0 -5
  97. lark/types/dimension_coordinate.py +0 -5
  98. lark/types/dimension_coordinate_interface.py +0 -20
  99. lark/types/dimension_coordinate_set.py +0 -5
  100. lark/types/dimension_interface.py +0 -20
  101. lark/types/dimensional_rate_matrix.py +0 -5
  102. lark/types/dimensional_rate_matrix_cell.py +0 -5
  103. lark/types/dimensional_usage_based_rate.py +0 -5
  104. lark/types/dimensional_usage_based_rate_input.py +0 -5
  105. lark/types/dimensional_usage_based_rate_interface.py +0 -33
  106. lark/types/feature_access_resource.py +0 -21
  107. lark/types/get_rate_card_response.py +0 -36
  108. lark/types/get_rate_card_response_billing_interval.py +0 -5
  109. lark/types/get_rate_card_response_usage_based_rates_item.py +0 -58
  110. lark/types/grant_credits_request.py +0 -5
  111. lark/types/last_aggregation_pricing_metric_interface.py +0 -22
  112. lark/types/license_based_rate.py +0 -5
  113. lark/types/license_based_rate_input.py +0 -5
  114. lark/types/max_aggregation_pricing_metric_interface.py +0 -22
  115. lark/types/monetary_amount.py +0 -5
  116. lark/types/package_price_rounding_behavior.py +0 -5
  117. lark/types/package_price_wrapper.py +0 -5
  118. lark/types/pricing_matrix_cell_interface.py +0 -22
  119. lark/types/pricing_matrix_interface.py +0 -20
  120. lark/types/pricing_metric.py +0 -5
  121. lark/types/pricing_plan.py +0 -5
  122. lark/types/pricing_plan_subscription.py +0 -5
  123. lark/types/pricing_tier.py +0 -5
  124. lark/types/rate_card_version.py +0 -5
  125. lark/types/rate_card_version_input.py +0 -5
  126. lark/types/simple_usage_based_rate.py +0 -5
  127. lark/types/simple_usage_based_rate_input.py +0 -5
  128. lark/types/subject_granting_config.py +0 -5
  129. lark/types/subject_granting_config_resource.py +0 -20
  130. lark/types/tiered_price.py +0 -5
  131. lark/types/tiered_price_wrapper.py +0 -5
  132. lark/types/unit.py +0 -5
  133. lark/types/update_pricing_plan_request.py +0 -5
  134. lark/types/update_rate_card_request.py +0 -5
  135. lark/types/update_subscription_request.py +0 -5
  136. lark/types/usage_based_rate.py +0 -5
  137. lark/types/usage_based_rate_input.py +0 -5
  138. lark/types/usage_unit.py +0 -5
  139. lark_billing-0.0.6.dist-info/RECORD +0 -167
  140. /lark/{feature_access → customer_access}/__init__.py +0 -0
  141. {lark_billing-0.0.6.dist-info → lark_billing-0.0.7.dist-info}/WHEEL +0 -0
@@ -0,0 +1,219 @@
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 .raw_client import AsyncRawPricingMetricsClient, RawPricingMetricsClient
10
+ from .types.pricing_metric_aggregation import PricingMetricAggregation
11
+
12
+ # this is used as the default value for optional parameters
13
+ OMIT = typing.cast(typing.Any, ...)
14
+
15
+
16
+ class PricingMetricsClient:
17
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
18
+ self._raw_client = RawPricingMetricsClient(client_wrapper=client_wrapper)
19
+
20
+ @property
21
+ def with_raw_response(self) -> RawPricingMetricsClient:
22
+ """
23
+ Retrieves a raw implementation of this client that returns raw responses.
24
+
25
+ Returns
26
+ -------
27
+ RawPricingMetricsClient
28
+ """
29
+ return self._raw_client
30
+
31
+ def create_pricing_metric(
32
+ self,
33
+ *,
34
+ name: str,
35
+ event_name: str,
36
+ aggregation: PricingMetricAggregation,
37
+ unit: str,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ) -> CreatePricingMetricResponse:
40
+ """
41
+ Parameters
42
+ ----------
43
+ name : str
44
+
45
+ event_name : str
46
+
47
+ aggregation : PricingMetricAggregation
48
+
49
+ unit : str
50
+ Unit of measurement for the pricing metric
51
+
52
+ request_options : typing.Optional[RequestOptions]
53
+ Request-specific configuration.
54
+
55
+ Returns
56
+ -------
57
+ CreatePricingMetricResponse
58
+ Successful Response
59
+
60
+ Examples
61
+ --------
62
+ from lark import Lark
63
+ from lark.pricing_metrics import PricingMetricAggregation_Count
64
+
65
+ client = Lark(
66
+ api_key="YOUR_API_KEY",
67
+ )
68
+ client.pricing_metrics.create_pricing_metric(
69
+ name="name",
70
+ event_name="event_name",
71
+ aggregation=PricingMetricAggregation_Count(),
72
+ unit="unit",
73
+ )
74
+ """
75
+ _response = self._raw_client.create_pricing_metric(
76
+ name=name, event_name=event_name, aggregation=aggregation, unit=unit, request_options=request_options
77
+ )
78
+ return _response.data
79
+
80
+ def get_pricing_metric(
81
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
82
+ ) -> GetPricingMetricResponse:
83
+ """
84
+ Parameters
85
+ ----------
86
+ pricing_metric_id : str
87
+
88
+ request_options : typing.Optional[RequestOptions]
89
+ Request-specific configuration.
90
+
91
+ Returns
92
+ -------
93
+ GetPricingMetricResponse
94
+ Successful Response
95
+
96
+ Examples
97
+ --------
98
+ from lark import Lark
99
+
100
+ client = Lark(
101
+ api_key="YOUR_API_KEY",
102
+ )
103
+ client.pricing_metrics.get_pricing_metric(
104
+ pricing_metric_id="pricing_metric_id",
105
+ )
106
+ """
107
+ _response = self._raw_client.get_pricing_metric(pricing_metric_id, request_options=request_options)
108
+ return _response.data
109
+
110
+
111
+ class AsyncPricingMetricsClient:
112
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
113
+ self._raw_client = AsyncRawPricingMetricsClient(client_wrapper=client_wrapper)
114
+
115
+ @property
116
+ def with_raw_response(self) -> AsyncRawPricingMetricsClient:
117
+ """
118
+ Retrieves a raw implementation of this client that returns raw responses.
119
+
120
+ Returns
121
+ -------
122
+ AsyncRawPricingMetricsClient
123
+ """
124
+ return self._raw_client
125
+
126
+ async def create_pricing_metric(
127
+ self,
128
+ *,
129
+ name: str,
130
+ event_name: str,
131
+ aggregation: PricingMetricAggregation,
132
+ unit: str,
133
+ request_options: typing.Optional[RequestOptions] = None,
134
+ ) -> CreatePricingMetricResponse:
135
+ """
136
+ Parameters
137
+ ----------
138
+ name : str
139
+
140
+ event_name : str
141
+
142
+ aggregation : PricingMetricAggregation
143
+
144
+ unit : str
145
+ Unit of measurement for the pricing metric
146
+
147
+ request_options : typing.Optional[RequestOptions]
148
+ Request-specific configuration.
149
+
150
+ Returns
151
+ -------
152
+ CreatePricingMetricResponse
153
+ Successful Response
154
+
155
+ Examples
156
+ --------
157
+ import asyncio
158
+
159
+ from lark import AsyncLark
160
+ from lark.pricing_metrics import PricingMetricAggregation_Count
161
+
162
+ client = AsyncLark(
163
+ api_key="YOUR_API_KEY",
164
+ )
165
+
166
+
167
+ async def main() -> None:
168
+ await client.pricing_metrics.create_pricing_metric(
169
+ name="name",
170
+ event_name="event_name",
171
+ aggregation=PricingMetricAggregation_Count(),
172
+ unit="unit",
173
+ )
174
+
175
+
176
+ asyncio.run(main())
177
+ """
178
+ _response = await self._raw_client.create_pricing_metric(
179
+ name=name, event_name=event_name, aggregation=aggregation, unit=unit, request_options=request_options
180
+ )
181
+ return _response.data
182
+
183
+ async def get_pricing_metric(
184
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
185
+ ) -> GetPricingMetricResponse:
186
+ """
187
+ Parameters
188
+ ----------
189
+ pricing_metric_id : str
190
+
191
+ request_options : typing.Optional[RequestOptions]
192
+ Request-specific configuration.
193
+
194
+ Returns
195
+ -------
196
+ GetPricingMetricResponse
197
+ Successful Response
198
+
199
+ Examples
200
+ --------
201
+ import asyncio
202
+
203
+ from lark import AsyncLark
204
+
205
+ client = AsyncLark(
206
+ api_key="YOUR_API_KEY",
207
+ )
208
+
209
+
210
+ async def main() -> None:
211
+ await client.pricing_metrics.get_pricing_metric(
212
+ pricing_metric_id="pricing_metric_id",
213
+ )
214
+
215
+
216
+ asyncio.run(main())
217
+ """
218
+ _response = await self._raw_client.get_pricing_metric(pricing_metric_id, request_options=request_options)
219
+ return _response.data
@@ -0,0 +1,268 @@
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.pricing_metric_aggregation import PricingMetricAggregation
18
+
19
+ # this is used as the default value for optional parameters
20
+ OMIT = typing.cast(typing.Any, ...)
21
+
22
+
23
+ class RawPricingMetricsClient:
24
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
25
+ self._client_wrapper = client_wrapper
26
+
27
+ def create_pricing_metric(
28
+ self,
29
+ *,
30
+ name: str,
31
+ event_name: str,
32
+ aggregation: PricingMetricAggregation,
33
+ unit: str,
34
+ request_options: typing.Optional[RequestOptions] = None,
35
+ ) -> HttpResponse[CreatePricingMetricResponse]:
36
+ """
37
+ Parameters
38
+ ----------
39
+ name : str
40
+
41
+ event_name : str
42
+
43
+ aggregation : PricingMetricAggregation
44
+
45
+ unit : str
46
+ Unit of measurement for the pricing metric
47
+
48
+ request_options : typing.Optional[RequestOptions]
49
+ Request-specific configuration.
50
+
51
+ Returns
52
+ -------
53
+ HttpResponse[CreatePricingMetricResponse]
54
+ Successful Response
55
+ """
56
+ _response = self._client_wrapper.httpx_client.request(
57
+ "pricing-metrics",
58
+ method="POST",
59
+ json={
60
+ "name": name,
61
+ "event_name": event_name,
62
+ "aggregation": convert_and_respect_annotation_metadata(
63
+ object_=aggregation, annotation=PricingMetricAggregation, direction="write"
64
+ ),
65
+ "unit": unit,
66
+ },
67
+ headers={
68
+ "content-type": "application/json",
69
+ },
70
+ request_options=request_options,
71
+ omit=OMIT,
72
+ )
73
+ try:
74
+ if 200 <= _response.status_code < 300:
75
+ _data = typing.cast(
76
+ CreatePricingMetricResponse,
77
+ parse_obj_as(
78
+ type_=CreatePricingMetricResponse, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ )
82
+ return HttpResponse(response=_response, data=_data)
83
+ if _response.status_code == 422:
84
+ raise UnprocessableEntityError(
85
+ headers=dict(_response.headers),
86
+ body=typing.cast(
87
+ HttpValidationError,
88
+ parse_obj_as(
89
+ type_=HttpValidationError, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ ),
93
+ )
94
+ _response_json = _response.json()
95
+ except JSONDecodeError:
96
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
97
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
98
+
99
+ def get_pricing_metric(
100
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
101
+ ) -> HttpResponse[GetPricingMetricResponse]:
102
+ """
103
+ Parameters
104
+ ----------
105
+ pricing_metric_id : str
106
+
107
+ request_options : typing.Optional[RequestOptions]
108
+ Request-specific configuration.
109
+
110
+ Returns
111
+ -------
112
+ HttpResponse[GetPricingMetricResponse]
113
+ Successful Response
114
+ """
115
+ _response = self._client_wrapper.httpx_client.request(
116
+ f"pricing-metrics/{jsonable_encoder(pricing_metric_id)}",
117
+ method="GET",
118
+ request_options=request_options,
119
+ )
120
+ try:
121
+ if 200 <= _response.status_code < 300:
122
+ _data = typing.cast(
123
+ GetPricingMetricResponse,
124
+ parse_obj_as(
125
+ type_=GetPricingMetricResponse, # type: ignore
126
+ object_=_response.json(),
127
+ ),
128
+ )
129
+ return HttpResponse(response=_response, data=_data)
130
+ if _response.status_code == 422:
131
+ raise UnprocessableEntityError(
132
+ headers=dict(_response.headers),
133
+ body=typing.cast(
134
+ HttpValidationError,
135
+ parse_obj_as(
136
+ type_=HttpValidationError, # type: ignore
137
+ object_=_response.json(),
138
+ ),
139
+ ),
140
+ )
141
+ _response_json = _response.json()
142
+ except JSONDecodeError:
143
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
144
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
145
+
146
+
147
+ class AsyncRawPricingMetricsClient:
148
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
149
+ self._client_wrapper = client_wrapper
150
+
151
+ async def create_pricing_metric(
152
+ self,
153
+ *,
154
+ name: str,
155
+ event_name: str,
156
+ aggregation: PricingMetricAggregation,
157
+ unit: str,
158
+ request_options: typing.Optional[RequestOptions] = None,
159
+ ) -> AsyncHttpResponse[CreatePricingMetricResponse]:
160
+ """
161
+ Parameters
162
+ ----------
163
+ name : str
164
+
165
+ event_name : str
166
+
167
+ aggregation : PricingMetricAggregation
168
+
169
+ unit : str
170
+ Unit of measurement for the pricing metric
171
+
172
+ request_options : typing.Optional[RequestOptions]
173
+ Request-specific configuration.
174
+
175
+ Returns
176
+ -------
177
+ AsyncHttpResponse[CreatePricingMetricResponse]
178
+ Successful Response
179
+ """
180
+ _response = await self._client_wrapper.httpx_client.request(
181
+ "pricing-metrics",
182
+ method="POST",
183
+ json={
184
+ "name": name,
185
+ "event_name": event_name,
186
+ "aggregation": convert_and_respect_annotation_metadata(
187
+ object_=aggregation, annotation=PricingMetricAggregation, direction="write"
188
+ ),
189
+ "unit": unit,
190
+ },
191
+ headers={
192
+ "content-type": "application/json",
193
+ },
194
+ request_options=request_options,
195
+ omit=OMIT,
196
+ )
197
+ try:
198
+ if 200 <= _response.status_code < 300:
199
+ _data = typing.cast(
200
+ CreatePricingMetricResponse,
201
+ parse_obj_as(
202
+ type_=CreatePricingMetricResponse, # type: ignore
203
+ object_=_response.json(),
204
+ ),
205
+ )
206
+ return AsyncHttpResponse(response=_response, data=_data)
207
+ if _response.status_code == 422:
208
+ raise UnprocessableEntityError(
209
+ headers=dict(_response.headers),
210
+ body=typing.cast(
211
+ HttpValidationError,
212
+ parse_obj_as(
213
+ type_=HttpValidationError, # type: ignore
214
+ object_=_response.json(),
215
+ ),
216
+ ),
217
+ )
218
+ _response_json = _response.json()
219
+ except JSONDecodeError:
220
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
221
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
222
+
223
+ async def get_pricing_metric(
224
+ self, pricing_metric_id: str, *, request_options: typing.Optional[RequestOptions] = None
225
+ ) -> AsyncHttpResponse[GetPricingMetricResponse]:
226
+ """
227
+ Parameters
228
+ ----------
229
+ pricing_metric_id : str
230
+
231
+ request_options : typing.Optional[RequestOptions]
232
+ Request-specific configuration.
233
+
234
+ Returns
235
+ -------
236
+ AsyncHttpResponse[GetPricingMetricResponse]
237
+ Successful Response
238
+ """
239
+ _response = await self._client_wrapper.httpx_client.request(
240
+ f"pricing-metrics/{jsonable_encoder(pricing_metric_id)}",
241
+ method="GET",
242
+ request_options=request_options,
243
+ )
244
+ try:
245
+ if 200 <= _response.status_code < 300:
246
+ _data = typing.cast(
247
+ GetPricingMetricResponse,
248
+ parse_obj_as(
249
+ type_=GetPricingMetricResponse, # type: ignore
250
+ object_=_response.json(),
251
+ ),
252
+ )
253
+ return AsyncHttpResponse(response=_response, data=_data)
254
+ if _response.status_code == 422:
255
+ raise UnprocessableEntityError(
256
+ headers=dict(_response.headers),
257
+ body=typing.cast(
258
+ HttpValidationError,
259
+ parse_obj_as(
260
+ type_=HttpValidationError, # type: ignore
261
+ object_=_response.json(),
262
+ ),
263
+ ),
264
+ )
265
+ _response_json = _response.json()
266
+ except JSONDecodeError:
267
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
268
+ 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"]
@@ -5,11 +5,11 @@ from __future__ import annotations
5
5
  import typing
6
6
 
7
7
  import pydantic
8
- from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
9
9
 
10
10
 
11
- class CreditGrantResourceInputSchedule_OneTime(UniversalBaseModel):
12
- schedule_type: typing.Literal["one_time"] = "one_time"
11
+ class PricingMetricAggregation_Count(UniversalBaseModel):
12
+ aggregation_type: typing.Literal["count"] = "count"
13
13
 
14
14
  if IS_PYDANTIC_V2:
15
15
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -21,8 +21,9 @@ class CreditGrantResourceInputSchedule_OneTime(UniversalBaseModel):
21
21
  extra = pydantic.Extra.allow
22
22
 
23
23
 
24
- class CreditGrantResourceInputSchedule_RateCycleStart(UniversalBaseModel):
25
- schedule_type: typing.Literal["rate_cycle_start"] = "rate_cycle_start"
24
+ class PricingMetricAggregation_Sum(UniversalBaseModel):
25
+ aggregation_type: typing.Literal["sum"] = "sum"
26
+ value_field: str
26
27
 
27
28
  if IS_PYDANTIC_V2:
28
29
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -34,6 +35,4 @@ class CreditGrantResourceInputSchedule_RateCycleStart(UniversalBaseModel):
34
35
  extra = pydantic.Extra.allow
35
36
 
36
37
 
37
- CreditGrantResourceInputSchedule = typing.Union[
38
- CreditGrantResourceInputSchedule_OneTime, CreditGrantResourceInputSchedule_RateCycleStart
39
- ]
38
+ PricingMetricAggregation = typing.Union[PricingMetricAggregation_Count, PricingMetricAggregation_Sum]
@@ -6,26 +6,8 @@ import typing
6
6
  from importlib import import_module
7
7
 
8
8
  if typing.TYPE_CHECKING:
9
- from .types import (
10
- CreateRateCardRequestBillingInterval,
11
- CreateRateCardRequestUsageBasedRatesItem,
12
- CreateRateCardRequestUsageBasedRatesItem_Dimensional,
13
- CreateRateCardRequestUsageBasedRatesItem_Simple,
14
- CreateRateCardVersionRequestUsageBasedRatesItem,
15
- CreateRateCardVersionRequestUsageBasedRatesItem_Dimensional,
16
- CreateRateCardVersionRequestUsageBasedRatesItem_Simple,
17
- CreateRateCardVersionRequestVersionType,
18
- )
19
- _dynamic_imports: typing.Dict[str, str] = {
20
- "CreateRateCardRequestBillingInterval": ".types",
21
- "CreateRateCardRequestUsageBasedRatesItem": ".types",
22
- "CreateRateCardRequestUsageBasedRatesItem_Dimensional": ".types",
23
- "CreateRateCardRequestUsageBasedRatesItem_Simple": ".types",
24
- "CreateRateCardVersionRequestUsageBasedRatesItem": ".types",
25
- "CreateRateCardVersionRequestUsageBasedRatesItem_Dimensional": ".types",
26
- "CreateRateCardVersionRequestUsageBasedRatesItem_Simple": ".types",
27
- "CreateRateCardVersionRequestVersionType": ".types",
28
- }
9
+ from .types import CreateRateCardRequestBillingInterval
10
+ _dynamic_imports: typing.Dict[str, str] = {"CreateRateCardRequestBillingInterval": ".types"}
29
11
 
30
12
 
31
13
  def __getattr__(attr_name: str) -> typing.Any:
@@ -49,13 +31,4 @@ def __dir__():
49
31
  return sorted(lazy_attrs)
50
32
 
51
33
 
52
- __all__ = [
53
- "CreateRateCardRequestBillingInterval",
54
- "CreateRateCardRequestUsageBasedRatesItem",
55
- "CreateRateCardRequestUsageBasedRatesItem_Dimensional",
56
- "CreateRateCardRequestUsageBasedRatesItem_Simple",
57
- "CreateRateCardVersionRequestUsageBasedRatesItem",
58
- "CreateRateCardVersionRequestUsageBasedRatesItem_Dimensional",
59
- "CreateRateCardVersionRequestUsageBasedRatesItem_Simple",
60
- "CreateRateCardVersionRequestVersionType",
61
- ]
34
+ __all__ = ["CreateRateCardRequestBillingInterval"]