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.
- lark/__init__.py +522 -0
- lark/checkout/__init__.py +4 -0
- lark/checkout/client.py +214 -0
- lark/checkout/raw_client.py +252 -0
- lark/client.py +240 -0
- lark/core/__init__.py +105 -0
- lark/core/api_error.py +23 -0
- lark/core/client_wrapper.py +79 -0
- lark/core/datetime_utils.py +28 -0
- lark/core/file.py +67 -0
- lark/core/force_multipart.py +18 -0
- lark/core/http_client.py +543 -0
- lark/core/http_response.py +55 -0
- lark/core/jsonable_encoder.py +100 -0
- lark/core/pydantic_utilities.py +258 -0
- lark/core/query_encoder.py +58 -0
- lark/core/remove_none_from_dict.py +11 -0
- lark/core/request_options.py +35 -0
- lark/core/serialization.py +276 -0
- lark/errors/__init__.py +34 -0
- lark/errors/unprocessable_entity_error.py +11 -0
- lark/feature_access/__init__.py +4 -0
- lark/feature_access/client.py +102 -0
- lark/feature_access/raw_client.py +113 -0
- lark/py.typed +0 -0
- lark/rate_cards/__init__.py +61 -0
- lark/rate_cards/client.py +817 -0
- lark/rate_cards/raw_client.py +728 -0
- lark/rate_cards/types/__init__.py +63 -0
- lark/rate_cards/types/create_rate_card_request_billing_interval.py +5 -0
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +56 -0
- lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +58 -0
- lark/rate_cards/types/create_rate_card_version_request_version_type.py +5 -0
- lark/subjects/__init__.py +4 -0
- lark/subjects/client.py +501 -0
- lark/subjects/raw_client.py +633 -0
- lark/subscriptions/__init__.py +4 -0
- lark/subscriptions/client.py +462 -0
- lark/subscriptions/raw_client.py +495 -0
- lark/types/__init__.py +493 -0
- lark/types/aggregation.py +80 -0
- lark/types/amount.py +20 -0
- lark/types/check_feature_access_request.py +24 -0
- lark/types/check_feature_access_response.py +21 -0
- lark/types/complete_subscription_checkout_response.py +21 -0
- lark/types/count_aggregation_pricing_metric_interface.py +17 -0
- lark/types/create_credit_grant_interface.py +27 -0
- lark/types/create_credit_grant_interface_expiration.py +27 -0
- lark/types/create_credit_pool_request.py +5 -0
- lark/types/create_dimension_coordinate_interface.py +20 -0
- lark/types/create_dimension_interface.py +20 -0
- lark/types/create_dimensional_usage_based_rate_interface.py +32 -0
- lark/types/create_fixed_rate_interface.py +28 -0
- lark/types/create_pricing_matrix_cell_interface.py +22 -0
- lark/types/create_pricing_matrix_interface.py +20 -0
- lark/types/create_pricing_metric_interface.py +26 -0
- lark/types/create_pricing_plan_request.py +5 -0
- lark/types/create_rate_card_response.py +36 -0
- lark/types/create_rate_card_response_billing_interval.py +5 -0
- lark/types/create_rate_card_response_usage_based_rates_item.py +58 -0
- lark/types/create_rate_card_version_response.py +36 -0
- lark/types/create_rate_card_version_response_billing_interval.py +5 -0
- lark/types/create_rate_card_version_response_usage_based_rates_item.py +59 -0
- lark/types/create_simple_usage_based_rate_interface.py +30 -0
- lark/types/create_subject_response.py +24 -0
- lark/types/create_subscription_checkout_session_response.py +23 -0
- lark/types/create_usage_event_summary_response.py +23 -0
- lark/types/credit_grant.py +5 -0
- lark/types/credit_grant_date_time_expiration_interface.py +19 -0
- lark/types/credit_grant_date_time_expiration_resource.py +19 -0
- lark/types/credit_grant_duration_expiration_interface.py +21 -0
- lark/types/credit_grant_duration_expiration_resource.py +21 -0
- lark/types/credit_grant_interface.py +28 -0
- lark/types/credit_grant_interface_input_expiration.py +27 -0
- lark/types/credit_grant_interface_output_expiration.py +43 -0
- lark/types/credit_grant_interface_output_schedule.py +41 -0
- lark/types/credit_grant_resource.py +28 -0
- lark/types/credit_grant_resource_input_expiration.py +27 -0
- lark/types/credit_grant_resource_input_schedule.py +39 -0
- lark/types/credit_grant_resource_output_expiration.py +43 -0
- lark/types/credit_grant_resource_output_schedule.py +39 -0
- lark/types/credit_grant_schedule.py +5 -0
- lark/types/credit_grant_schedule_one_time_interface.py +19 -0
- lark/types/credit_grant_schedule_one_time_resource.py +17 -0
- lark/types/credit_grant_schedule_rate_cycle_start_interface.py +19 -0
- lark/types/credit_grant_schedule_rate_cycle_start_resource.py +17 -0
- lark/types/credit_grant_subject_granting_config_interface.py +20 -0
- lark/types/credit_pool.py +5 -0
- lark/types/credit_pool_rollover_config.py +5 -0
- lark/types/custom_aggregation_pricing_metric_interface.py +22 -0
- lark/types/custom_pricing_metric.py +5 -0
- lark/types/custom_unit.py +5 -0
- lark/types/custom_unit_amount.py +5 -0
- lark/types/dimension.py +5 -0
- lark/types/dimension_coordinate.py +5 -0
- lark/types/dimension_coordinate_interface.py +20 -0
- lark/types/dimension_coordinate_set.py +5 -0
- lark/types/dimension_interface.py +20 -0
- lark/types/dimensional_rate_matrix.py +5 -0
- lark/types/dimensional_rate_matrix_cell.py +5 -0
- lark/types/dimensional_usage_based_rate.py +5 -0
- lark/types/dimensional_usage_based_rate_input.py +5 -0
- lark/types/dimensional_usage_based_rate_interface.py +33 -0
- lark/types/feature_access_resource.py +21 -0
- lark/types/fixed_rate_interface.py +29 -0
- lark/types/flat_price.py +24 -0
- lark/types/get_rate_card_response.py +36 -0
- lark/types/get_rate_card_response_billing_interval.py +5 -0
- lark/types/get_rate_card_response_usage_based_rates_item.py +58 -0
- lark/types/grant_credits_request.py +5 -0
- lark/types/http_validation_error.py +20 -0
- lark/types/last_aggregation_pricing_metric_interface.py +22 -0
- lark/types/license_based_rate.py +5 -0
- lark/types/license_based_rate_input.py +5 -0
- lark/types/list_rate_cards_response.py +21 -0
- lark/types/list_subjects_response.py +21 -0
- lark/types/list_subscriptions_response.py +21 -0
- lark/types/max_aggregation_pricing_metric_interface.py +22 -0
- lark/types/monetary_amount.py +5 -0
- lark/types/package_price.py +27 -0
- lark/types/package_price_rounding_behavior.py +5 -0
- lark/types/package_price_wrapper.py +5 -0
- lark/types/period.py +22 -0
- lark/types/price.py +5 -0
- lark/types/pricing_matrix_cell_interface.py +22 -0
- lark/types/pricing_matrix_interface.py +20 -0
- lark/types/pricing_metric.py +5 -0
- lark/types/pricing_metric_interface.py +27 -0
- lark/types/pricing_plan.py +5 -0
- lark/types/pricing_plan_subscription.py +5 -0
- lark/types/pricing_tier.py +5 -0
- lark/types/rate_card.py +5 -0
- lark/types/rate_card_resource.py +36 -0
- lark/types/rate_card_resource_billing_interval.py +5 -0
- lark/types/rate_card_resource_usage_based_rates_item.py +58 -0
- lark/types/rate_card_version.py +5 -0
- lark/types/rate_card_version_input.py +5 -0
- lark/types/simple_usage_based_rate.py +5 -0
- lark/types/simple_usage_based_rate_input.py +5 -0
- lark/types/simple_usage_based_rate_interface.py +31 -0
- lark/types/status.py +5 -0
- lark/types/subject.py +5 -0
- lark/types/subject_granting_config.py +5 -0
- lark/types/subject_granting_config_resource.py +20 -0
- lark/types/subject_resource.py +24 -0
- lark/types/subscription_resource.py +28 -0
- lark/types/sum_aggregation_pricing_metric_interface.py +22 -0
- lark/types/tiered_price.py +5 -0
- lark/types/tiered_price_wrapper.py +5 -0
- lark/types/unit.py +5 -0
- lark/types/update_pricing_plan_request.py +5 -0
- lark/types/update_rate_card_request.py +5 -0
- lark/types/update_subscription_request.py +5 -0
- lark/types/usage_based_rate.py +5 -0
- lark/types/usage_based_rate_input.py +5 -0
- lark/types/usage_unit.py +5 -0
- lark/types/validation_error.py +22 -0
- lark/types/validation_error_loc_item.py +5 -0
- lark/usage_events/__init__.py +34 -0
- lark/usage_events/client.py +293 -0
- lark/usage_events/raw_client.py +318 -0
- lark/usage_events/types/__init__.py +36 -0
- lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +5 -0
- lark/version.py +3 -0
- lark_billing-0.0.6.dist-info/METADATA +188 -0
- lark_billing-0.0.6.dist-info/RECORD +167 -0
- lark_billing-0.0.6.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,633 @@
|
|
|
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.create_subject_response import CreateSubjectResponse
|
|
14
|
+
from ..types.http_validation_error import HttpValidationError
|
|
15
|
+
from ..types.list_subjects_response import ListSubjectsResponse
|
|
16
|
+
from ..types.subject_resource import SubjectResource
|
|
17
|
+
|
|
18
|
+
# this is used as the default value for optional parameters
|
|
19
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RawSubjectsClient:
|
|
23
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
+
self._client_wrapper = client_wrapper
|
|
25
|
+
|
|
26
|
+
def list_subjects(
|
|
27
|
+
self,
|
|
28
|
+
*,
|
|
29
|
+
limit: typing.Optional[int] = None,
|
|
30
|
+
offset: typing.Optional[int] = None,
|
|
31
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
32
|
+
) -> HttpResponse[ListSubjectsResponse]:
|
|
33
|
+
"""
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
limit : typing.Optional[int]
|
|
37
|
+
|
|
38
|
+
offset : typing.Optional[int]
|
|
39
|
+
|
|
40
|
+
request_options : typing.Optional[RequestOptions]
|
|
41
|
+
Request-specific configuration.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
HttpResponse[ListSubjectsResponse]
|
|
46
|
+
Successful Response
|
|
47
|
+
"""
|
|
48
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
49
|
+
"subjects",
|
|
50
|
+
method="GET",
|
|
51
|
+
params={
|
|
52
|
+
"limit": limit,
|
|
53
|
+
"offset": offset,
|
|
54
|
+
},
|
|
55
|
+
request_options=request_options,
|
|
56
|
+
)
|
|
57
|
+
try:
|
|
58
|
+
if 200 <= _response.status_code < 300:
|
|
59
|
+
_data = typing.cast(
|
|
60
|
+
ListSubjectsResponse,
|
|
61
|
+
parse_obj_as(
|
|
62
|
+
type_=ListSubjectsResponse, # type: ignore
|
|
63
|
+
object_=_response.json(),
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
return HttpResponse(response=_response, data=_data)
|
|
67
|
+
if _response.status_code == 422:
|
|
68
|
+
raise UnprocessableEntityError(
|
|
69
|
+
headers=dict(_response.headers),
|
|
70
|
+
body=typing.cast(
|
|
71
|
+
HttpValidationError,
|
|
72
|
+
parse_obj_as(
|
|
73
|
+
type_=HttpValidationError, # type: ignore
|
|
74
|
+
object_=_response.json(),
|
|
75
|
+
),
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
_response_json = _response.json()
|
|
79
|
+
except JSONDecodeError:
|
|
80
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
81
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
82
|
+
|
|
83
|
+
def create_subject(
|
|
84
|
+
self,
|
|
85
|
+
*,
|
|
86
|
+
external_id: typing.Optional[str] = OMIT,
|
|
87
|
+
name: typing.Optional[str] = OMIT,
|
|
88
|
+
email: typing.Optional[str] = OMIT,
|
|
89
|
+
parent_subject_id: typing.Optional[str] = OMIT,
|
|
90
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
91
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
92
|
+
) -> HttpResponse[CreateSubjectResponse]:
|
|
93
|
+
"""
|
|
94
|
+
Parameters
|
|
95
|
+
----------
|
|
96
|
+
external_id : typing.Optional[str]
|
|
97
|
+
|
|
98
|
+
name : typing.Optional[str]
|
|
99
|
+
|
|
100
|
+
email : typing.Optional[str]
|
|
101
|
+
|
|
102
|
+
parent_subject_id : typing.Optional[str]
|
|
103
|
+
|
|
104
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
105
|
+
|
|
106
|
+
request_options : typing.Optional[RequestOptions]
|
|
107
|
+
Request-specific configuration.
|
|
108
|
+
|
|
109
|
+
Returns
|
|
110
|
+
-------
|
|
111
|
+
HttpResponse[CreateSubjectResponse]
|
|
112
|
+
Successful Response
|
|
113
|
+
"""
|
|
114
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
115
|
+
"subjects",
|
|
116
|
+
method="POST",
|
|
117
|
+
json={
|
|
118
|
+
"external_id": external_id,
|
|
119
|
+
"name": name,
|
|
120
|
+
"email": email,
|
|
121
|
+
"parent_subject_id": parent_subject_id,
|
|
122
|
+
"metadata": metadata,
|
|
123
|
+
},
|
|
124
|
+
headers={
|
|
125
|
+
"content-type": "application/json",
|
|
126
|
+
},
|
|
127
|
+
request_options=request_options,
|
|
128
|
+
omit=OMIT,
|
|
129
|
+
)
|
|
130
|
+
try:
|
|
131
|
+
if 200 <= _response.status_code < 300:
|
|
132
|
+
_data = typing.cast(
|
|
133
|
+
CreateSubjectResponse,
|
|
134
|
+
parse_obj_as(
|
|
135
|
+
type_=CreateSubjectResponse, # type: ignore
|
|
136
|
+
object_=_response.json(),
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
return HttpResponse(response=_response, data=_data)
|
|
140
|
+
if _response.status_code == 422:
|
|
141
|
+
raise UnprocessableEntityError(
|
|
142
|
+
headers=dict(_response.headers),
|
|
143
|
+
body=typing.cast(
|
|
144
|
+
HttpValidationError,
|
|
145
|
+
parse_obj_as(
|
|
146
|
+
type_=HttpValidationError, # type: ignore
|
|
147
|
+
object_=_response.json(),
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
)
|
|
151
|
+
_response_json = _response.json()
|
|
152
|
+
except JSONDecodeError:
|
|
153
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
154
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
155
|
+
|
|
156
|
+
def get_subject(
|
|
157
|
+
self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
158
|
+
) -> HttpResponse[SubjectResource]:
|
|
159
|
+
"""
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
subject_id : str
|
|
163
|
+
|
|
164
|
+
request_options : typing.Optional[RequestOptions]
|
|
165
|
+
Request-specific configuration.
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
HttpResponse[SubjectResource]
|
|
170
|
+
Successful Response
|
|
171
|
+
"""
|
|
172
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
173
|
+
f"subjects/{jsonable_encoder(subject_id)}",
|
|
174
|
+
method="GET",
|
|
175
|
+
request_options=request_options,
|
|
176
|
+
)
|
|
177
|
+
try:
|
|
178
|
+
if 200 <= _response.status_code < 300:
|
|
179
|
+
_data = typing.cast(
|
|
180
|
+
SubjectResource,
|
|
181
|
+
parse_obj_as(
|
|
182
|
+
type_=SubjectResource, # type: ignore
|
|
183
|
+
object_=_response.json(),
|
|
184
|
+
),
|
|
185
|
+
)
|
|
186
|
+
return HttpResponse(response=_response, data=_data)
|
|
187
|
+
if _response.status_code == 422:
|
|
188
|
+
raise UnprocessableEntityError(
|
|
189
|
+
headers=dict(_response.headers),
|
|
190
|
+
body=typing.cast(
|
|
191
|
+
HttpValidationError,
|
|
192
|
+
parse_obj_as(
|
|
193
|
+
type_=HttpValidationError, # type: ignore
|
|
194
|
+
object_=_response.json(),
|
|
195
|
+
),
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
_response_json = _response.json()
|
|
199
|
+
except JSONDecodeError:
|
|
200
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
201
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
202
|
+
|
|
203
|
+
def update_subject(
|
|
204
|
+
self,
|
|
205
|
+
subject_id: str,
|
|
206
|
+
*,
|
|
207
|
+
external_id: typing.Optional[str] = OMIT,
|
|
208
|
+
name: typing.Optional[str] = OMIT,
|
|
209
|
+
email: typing.Optional[str] = OMIT,
|
|
210
|
+
parent_subject_id: typing.Optional[str] = OMIT,
|
|
211
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
212
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
213
|
+
) -> HttpResponse[SubjectResource]:
|
|
214
|
+
"""
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
subject_id : str
|
|
218
|
+
|
|
219
|
+
external_id : typing.Optional[str]
|
|
220
|
+
|
|
221
|
+
name : typing.Optional[str]
|
|
222
|
+
|
|
223
|
+
email : typing.Optional[str]
|
|
224
|
+
|
|
225
|
+
parent_subject_id : typing.Optional[str]
|
|
226
|
+
|
|
227
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
228
|
+
|
|
229
|
+
request_options : typing.Optional[RequestOptions]
|
|
230
|
+
Request-specific configuration.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
HttpResponse[SubjectResource]
|
|
235
|
+
Successful Response
|
|
236
|
+
"""
|
|
237
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
238
|
+
f"subjects/{jsonable_encoder(subject_id)}",
|
|
239
|
+
method="PUT",
|
|
240
|
+
json={
|
|
241
|
+
"external_id": external_id,
|
|
242
|
+
"name": name,
|
|
243
|
+
"email": email,
|
|
244
|
+
"parent_subject_id": parent_subject_id,
|
|
245
|
+
"metadata": metadata,
|
|
246
|
+
},
|
|
247
|
+
headers={
|
|
248
|
+
"content-type": "application/json",
|
|
249
|
+
},
|
|
250
|
+
request_options=request_options,
|
|
251
|
+
omit=OMIT,
|
|
252
|
+
)
|
|
253
|
+
try:
|
|
254
|
+
if 200 <= _response.status_code < 300:
|
|
255
|
+
_data = typing.cast(
|
|
256
|
+
SubjectResource,
|
|
257
|
+
parse_obj_as(
|
|
258
|
+
type_=SubjectResource, # type: ignore
|
|
259
|
+
object_=_response.json(),
|
|
260
|
+
),
|
|
261
|
+
)
|
|
262
|
+
return HttpResponse(response=_response, data=_data)
|
|
263
|
+
if _response.status_code == 422:
|
|
264
|
+
raise UnprocessableEntityError(
|
|
265
|
+
headers=dict(_response.headers),
|
|
266
|
+
body=typing.cast(
|
|
267
|
+
HttpValidationError,
|
|
268
|
+
parse_obj_as(
|
|
269
|
+
type_=HttpValidationError, # type: ignore
|
|
270
|
+
object_=_response.json(),
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
)
|
|
274
|
+
_response_json = _response.json()
|
|
275
|
+
except JSONDecodeError:
|
|
276
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
277
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
278
|
+
|
|
279
|
+
def delete_subject(
|
|
280
|
+
self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
281
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
282
|
+
"""
|
|
283
|
+
Parameters
|
|
284
|
+
----------
|
|
285
|
+
subject_id : str
|
|
286
|
+
|
|
287
|
+
request_options : typing.Optional[RequestOptions]
|
|
288
|
+
Request-specific configuration.
|
|
289
|
+
|
|
290
|
+
Returns
|
|
291
|
+
-------
|
|
292
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
293
|
+
Successful Response
|
|
294
|
+
"""
|
|
295
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
296
|
+
f"subjects/{jsonable_encoder(subject_id)}",
|
|
297
|
+
method="DELETE",
|
|
298
|
+
request_options=request_options,
|
|
299
|
+
)
|
|
300
|
+
try:
|
|
301
|
+
if _response is None or not _response.text.strip():
|
|
302
|
+
return HttpResponse(response=_response, data=None)
|
|
303
|
+
if 200 <= _response.status_code < 300:
|
|
304
|
+
_data = typing.cast(
|
|
305
|
+
typing.Optional[typing.Any],
|
|
306
|
+
parse_obj_as(
|
|
307
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
308
|
+
object_=_response.json(),
|
|
309
|
+
),
|
|
310
|
+
)
|
|
311
|
+
return HttpResponse(response=_response, data=_data)
|
|
312
|
+
if _response.status_code == 422:
|
|
313
|
+
raise UnprocessableEntityError(
|
|
314
|
+
headers=dict(_response.headers),
|
|
315
|
+
body=typing.cast(
|
|
316
|
+
HttpValidationError,
|
|
317
|
+
parse_obj_as(
|
|
318
|
+
type_=HttpValidationError, # type: ignore
|
|
319
|
+
object_=_response.json(),
|
|
320
|
+
),
|
|
321
|
+
),
|
|
322
|
+
)
|
|
323
|
+
_response_json = _response.json()
|
|
324
|
+
except JSONDecodeError:
|
|
325
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
326
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class AsyncRawSubjectsClient:
|
|
330
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
331
|
+
self._client_wrapper = client_wrapper
|
|
332
|
+
|
|
333
|
+
async def list_subjects(
|
|
334
|
+
self,
|
|
335
|
+
*,
|
|
336
|
+
limit: typing.Optional[int] = None,
|
|
337
|
+
offset: typing.Optional[int] = None,
|
|
338
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
339
|
+
) -> AsyncHttpResponse[ListSubjectsResponse]:
|
|
340
|
+
"""
|
|
341
|
+
Parameters
|
|
342
|
+
----------
|
|
343
|
+
limit : typing.Optional[int]
|
|
344
|
+
|
|
345
|
+
offset : typing.Optional[int]
|
|
346
|
+
|
|
347
|
+
request_options : typing.Optional[RequestOptions]
|
|
348
|
+
Request-specific configuration.
|
|
349
|
+
|
|
350
|
+
Returns
|
|
351
|
+
-------
|
|
352
|
+
AsyncHttpResponse[ListSubjectsResponse]
|
|
353
|
+
Successful Response
|
|
354
|
+
"""
|
|
355
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
356
|
+
"subjects",
|
|
357
|
+
method="GET",
|
|
358
|
+
params={
|
|
359
|
+
"limit": limit,
|
|
360
|
+
"offset": offset,
|
|
361
|
+
},
|
|
362
|
+
request_options=request_options,
|
|
363
|
+
)
|
|
364
|
+
try:
|
|
365
|
+
if 200 <= _response.status_code < 300:
|
|
366
|
+
_data = typing.cast(
|
|
367
|
+
ListSubjectsResponse,
|
|
368
|
+
parse_obj_as(
|
|
369
|
+
type_=ListSubjectsResponse, # type: ignore
|
|
370
|
+
object_=_response.json(),
|
|
371
|
+
),
|
|
372
|
+
)
|
|
373
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
374
|
+
if _response.status_code == 422:
|
|
375
|
+
raise UnprocessableEntityError(
|
|
376
|
+
headers=dict(_response.headers),
|
|
377
|
+
body=typing.cast(
|
|
378
|
+
HttpValidationError,
|
|
379
|
+
parse_obj_as(
|
|
380
|
+
type_=HttpValidationError, # type: ignore
|
|
381
|
+
object_=_response.json(),
|
|
382
|
+
),
|
|
383
|
+
),
|
|
384
|
+
)
|
|
385
|
+
_response_json = _response.json()
|
|
386
|
+
except JSONDecodeError:
|
|
387
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
388
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
389
|
+
|
|
390
|
+
async def create_subject(
|
|
391
|
+
self,
|
|
392
|
+
*,
|
|
393
|
+
external_id: typing.Optional[str] = OMIT,
|
|
394
|
+
name: typing.Optional[str] = OMIT,
|
|
395
|
+
email: typing.Optional[str] = OMIT,
|
|
396
|
+
parent_subject_id: typing.Optional[str] = OMIT,
|
|
397
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
398
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
399
|
+
) -> AsyncHttpResponse[CreateSubjectResponse]:
|
|
400
|
+
"""
|
|
401
|
+
Parameters
|
|
402
|
+
----------
|
|
403
|
+
external_id : typing.Optional[str]
|
|
404
|
+
|
|
405
|
+
name : typing.Optional[str]
|
|
406
|
+
|
|
407
|
+
email : typing.Optional[str]
|
|
408
|
+
|
|
409
|
+
parent_subject_id : typing.Optional[str]
|
|
410
|
+
|
|
411
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
412
|
+
|
|
413
|
+
request_options : typing.Optional[RequestOptions]
|
|
414
|
+
Request-specific configuration.
|
|
415
|
+
|
|
416
|
+
Returns
|
|
417
|
+
-------
|
|
418
|
+
AsyncHttpResponse[CreateSubjectResponse]
|
|
419
|
+
Successful Response
|
|
420
|
+
"""
|
|
421
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
422
|
+
"subjects",
|
|
423
|
+
method="POST",
|
|
424
|
+
json={
|
|
425
|
+
"external_id": external_id,
|
|
426
|
+
"name": name,
|
|
427
|
+
"email": email,
|
|
428
|
+
"parent_subject_id": parent_subject_id,
|
|
429
|
+
"metadata": metadata,
|
|
430
|
+
},
|
|
431
|
+
headers={
|
|
432
|
+
"content-type": "application/json",
|
|
433
|
+
},
|
|
434
|
+
request_options=request_options,
|
|
435
|
+
omit=OMIT,
|
|
436
|
+
)
|
|
437
|
+
try:
|
|
438
|
+
if 200 <= _response.status_code < 300:
|
|
439
|
+
_data = typing.cast(
|
|
440
|
+
CreateSubjectResponse,
|
|
441
|
+
parse_obj_as(
|
|
442
|
+
type_=CreateSubjectResponse, # type: ignore
|
|
443
|
+
object_=_response.json(),
|
|
444
|
+
),
|
|
445
|
+
)
|
|
446
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
447
|
+
if _response.status_code == 422:
|
|
448
|
+
raise UnprocessableEntityError(
|
|
449
|
+
headers=dict(_response.headers),
|
|
450
|
+
body=typing.cast(
|
|
451
|
+
HttpValidationError,
|
|
452
|
+
parse_obj_as(
|
|
453
|
+
type_=HttpValidationError, # type: ignore
|
|
454
|
+
object_=_response.json(),
|
|
455
|
+
),
|
|
456
|
+
),
|
|
457
|
+
)
|
|
458
|
+
_response_json = _response.json()
|
|
459
|
+
except JSONDecodeError:
|
|
460
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
461
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
462
|
+
|
|
463
|
+
async def get_subject(
|
|
464
|
+
self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
465
|
+
) -> AsyncHttpResponse[SubjectResource]:
|
|
466
|
+
"""
|
|
467
|
+
Parameters
|
|
468
|
+
----------
|
|
469
|
+
subject_id : str
|
|
470
|
+
|
|
471
|
+
request_options : typing.Optional[RequestOptions]
|
|
472
|
+
Request-specific configuration.
|
|
473
|
+
|
|
474
|
+
Returns
|
|
475
|
+
-------
|
|
476
|
+
AsyncHttpResponse[SubjectResource]
|
|
477
|
+
Successful Response
|
|
478
|
+
"""
|
|
479
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
480
|
+
f"subjects/{jsonable_encoder(subject_id)}",
|
|
481
|
+
method="GET",
|
|
482
|
+
request_options=request_options,
|
|
483
|
+
)
|
|
484
|
+
try:
|
|
485
|
+
if 200 <= _response.status_code < 300:
|
|
486
|
+
_data = typing.cast(
|
|
487
|
+
SubjectResource,
|
|
488
|
+
parse_obj_as(
|
|
489
|
+
type_=SubjectResource, # type: ignore
|
|
490
|
+
object_=_response.json(),
|
|
491
|
+
),
|
|
492
|
+
)
|
|
493
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
494
|
+
if _response.status_code == 422:
|
|
495
|
+
raise UnprocessableEntityError(
|
|
496
|
+
headers=dict(_response.headers),
|
|
497
|
+
body=typing.cast(
|
|
498
|
+
HttpValidationError,
|
|
499
|
+
parse_obj_as(
|
|
500
|
+
type_=HttpValidationError, # type: ignore
|
|
501
|
+
object_=_response.json(),
|
|
502
|
+
),
|
|
503
|
+
),
|
|
504
|
+
)
|
|
505
|
+
_response_json = _response.json()
|
|
506
|
+
except JSONDecodeError:
|
|
507
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
508
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
509
|
+
|
|
510
|
+
async def update_subject(
|
|
511
|
+
self,
|
|
512
|
+
subject_id: str,
|
|
513
|
+
*,
|
|
514
|
+
external_id: typing.Optional[str] = OMIT,
|
|
515
|
+
name: typing.Optional[str] = OMIT,
|
|
516
|
+
email: typing.Optional[str] = OMIT,
|
|
517
|
+
parent_subject_id: typing.Optional[str] = OMIT,
|
|
518
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
519
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
520
|
+
) -> AsyncHttpResponse[SubjectResource]:
|
|
521
|
+
"""
|
|
522
|
+
Parameters
|
|
523
|
+
----------
|
|
524
|
+
subject_id : str
|
|
525
|
+
|
|
526
|
+
external_id : typing.Optional[str]
|
|
527
|
+
|
|
528
|
+
name : typing.Optional[str]
|
|
529
|
+
|
|
530
|
+
email : typing.Optional[str]
|
|
531
|
+
|
|
532
|
+
parent_subject_id : typing.Optional[str]
|
|
533
|
+
|
|
534
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
535
|
+
|
|
536
|
+
request_options : typing.Optional[RequestOptions]
|
|
537
|
+
Request-specific configuration.
|
|
538
|
+
|
|
539
|
+
Returns
|
|
540
|
+
-------
|
|
541
|
+
AsyncHttpResponse[SubjectResource]
|
|
542
|
+
Successful Response
|
|
543
|
+
"""
|
|
544
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
545
|
+
f"subjects/{jsonable_encoder(subject_id)}",
|
|
546
|
+
method="PUT",
|
|
547
|
+
json={
|
|
548
|
+
"external_id": external_id,
|
|
549
|
+
"name": name,
|
|
550
|
+
"email": email,
|
|
551
|
+
"parent_subject_id": parent_subject_id,
|
|
552
|
+
"metadata": metadata,
|
|
553
|
+
},
|
|
554
|
+
headers={
|
|
555
|
+
"content-type": "application/json",
|
|
556
|
+
},
|
|
557
|
+
request_options=request_options,
|
|
558
|
+
omit=OMIT,
|
|
559
|
+
)
|
|
560
|
+
try:
|
|
561
|
+
if 200 <= _response.status_code < 300:
|
|
562
|
+
_data = typing.cast(
|
|
563
|
+
SubjectResource,
|
|
564
|
+
parse_obj_as(
|
|
565
|
+
type_=SubjectResource, # type: ignore
|
|
566
|
+
object_=_response.json(),
|
|
567
|
+
),
|
|
568
|
+
)
|
|
569
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
570
|
+
if _response.status_code == 422:
|
|
571
|
+
raise UnprocessableEntityError(
|
|
572
|
+
headers=dict(_response.headers),
|
|
573
|
+
body=typing.cast(
|
|
574
|
+
HttpValidationError,
|
|
575
|
+
parse_obj_as(
|
|
576
|
+
type_=HttpValidationError, # type: ignore
|
|
577
|
+
object_=_response.json(),
|
|
578
|
+
),
|
|
579
|
+
),
|
|
580
|
+
)
|
|
581
|
+
_response_json = _response.json()
|
|
582
|
+
except JSONDecodeError:
|
|
583
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
584
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
585
|
+
|
|
586
|
+
async def delete_subject(
|
|
587
|
+
self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
588
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
589
|
+
"""
|
|
590
|
+
Parameters
|
|
591
|
+
----------
|
|
592
|
+
subject_id : str
|
|
593
|
+
|
|
594
|
+
request_options : typing.Optional[RequestOptions]
|
|
595
|
+
Request-specific configuration.
|
|
596
|
+
|
|
597
|
+
Returns
|
|
598
|
+
-------
|
|
599
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
600
|
+
Successful Response
|
|
601
|
+
"""
|
|
602
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
603
|
+
f"subjects/{jsonable_encoder(subject_id)}",
|
|
604
|
+
method="DELETE",
|
|
605
|
+
request_options=request_options,
|
|
606
|
+
)
|
|
607
|
+
try:
|
|
608
|
+
if _response is None or not _response.text.strip():
|
|
609
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
610
|
+
if 200 <= _response.status_code < 300:
|
|
611
|
+
_data = typing.cast(
|
|
612
|
+
typing.Optional[typing.Any],
|
|
613
|
+
parse_obj_as(
|
|
614
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
615
|
+
object_=_response.json(),
|
|
616
|
+
),
|
|
617
|
+
)
|
|
618
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
619
|
+
if _response.status_code == 422:
|
|
620
|
+
raise UnprocessableEntityError(
|
|
621
|
+
headers=dict(_response.headers),
|
|
622
|
+
body=typing.cast(
|
|
623
|
+
HttpValidationError,
|
|
624
|
+
parse_obj_as(
|
|
625
|
+
type_=HttpValidationError, # type: ignore
|
|
626
|
+
object_=_response.json(),
|
|
627
|
+
),
|
|
628
|
+
),
|
|
629
|
+
)
|
|
630
|
+
_response_json = _response.json()
|
|
631
|
+
except JSONDecodeError:
|
|
632
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
633
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|