phenoml 0.0.1__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 phenoml might be problematic. Click here for more details.
- phenoml/__init__.py +30 -0
- phenoml/agent/__init__.py +58 -0
- phenoml/agent/client.py +820 -0
- phenoml/agent/errors/__init__.py +11 -0
- phenoml/agent/errors/bad_request_error.py +10 -0
- phenoml/agent/errors/forbidden_error.py +10 -0
- phenoml/agent/errors/internal_server_error.py +10 -0
- phenoml/agent/errors/not_found_error.py +10 -0
- phenoml/agent/errors/unauthorized_error.py +10 -0
- phenoml/agent/prompts/__init__.py +7 -0
- phenoml/agent/prompts/client.py +707 -0
- phenoml/agent/prompts/raw_client.py +1345 -0
- phenoml/agent/prompts/types/__init__.py +8 -0
- phenoml/agent/prompts/types/prompts_delete_response.py +20 -0
- phenoml/agent/prompts/types/prompts_list_response.py +22 -0
- phenoml/agent/raw_client.py +1501 -0
- phenoml/agent/types/__init__.py +45 -0
- phenoml/agent/types/agent_chat_response.py +33 -0
- phenoml/agent/types/agent_create_request_provider.py +13 -0
- phenoml/agent/types/agent_create_request_provider_item.py +7 -0
- phenoml/agent/types/agent_delete_response.py +20 -0
- phenoml/agent/types/agent_fhir_config.py +31 -0
- phenoml/agent/types/agent_list_response.py +22 -0
- phenoml/agent/types/agent_prompts_response.py +22 -0
- phenoml/agent/types/agent_response.py +22 -0
- phenoml/agent/types/agent_template.py +56 -0
- phenoml/agent/types/agent_template_provider.py +13 -0
- phenoml/agent/types/agent_template_provider_item.py +5 -0
- phenoml/agent/types/agent_update_request_provider.py +13 -0
- phenoml/agent/types/agent_update_request_provider_item.py +7 -0
- phenoml/agent/types/chat_fhir_client_config.py +31 -0
- phenoml/agent/types/json_patch.py +7 -0
- phenoml/agent/types/json_patch_operation.py +36 -0
- phenoml/agent/types/json_patch_operation_op.py +5 -0
- phenoml/agent/types/prompt_template.py +52 -0
- phenoml/agent/types/success_response.py +20 -0
- phenoml/authtoken/__init__.py +17 -0
- phenoml/authtoken/auth/__init__.py +7 -0
- phenoml/authtoken/auth/client.py +129 -0
- phenoml/authtoken/auth/raw_client.py +173 -0
- phenoml/authtoken/auth/types/__init__.py +7 -0
- phenoml/authtoken/auth/types/auth_generate_token_response.py +22 -0
- phenoml/authtoken/client.py +39 -0
- phenoml/authtoken/errors/__init__.py +8 -0
- phenoml/authtoken/errors/bad_request_error.py +10 -0
- phenoml/authtoken/errors/unauthorized_error.py +10 -0
- phenoml/authtoken/raw_client.py +13 -0
- phenoml/authtoken/types/__init__.py +8 -0
- phenoml/authtoken/types/bad_request_error_body.py +21 -0
- phenoml/authtoken/types/unauthorized_error_body.py +21 -0
- phenoml/client.py +168 -0
- phenoml/cohort/__init__.py +8 -0
- phenoml/cohort/client.py +113 -0
- phenoml/cohort/errors/__init__.py +9 -0
- phenoml/cohort/errors/bad_request_error.py +10 -0
- phenoml/cohort/errors/internal_server_error.py +10 -0
- phenoml/cohort/errors/unauthorized_error.py +10 -0
- phenoml/cohort/raw_client.py +185 -0
- phenoml/cohort/types/__init__.py +8 -0
- phenoml/cohort/types/cohort_response.py +33 -0
- phenoml/cohort/types/search_concept.py +37 -0
- phenoml/construe/__init__.py +45 -0
- phenoml/construe/client.py +399 -0
- phenoml/construe/errors/__init__.py +11 -0
- phenoml/construe/errors/bad_request_error.py +10 -0
- phenoml/construe/errors/conflict_error.py +10 -0
- phenoml/construe/errors/failed_dependency_error.py +10 -0
- phenoml/construe/errors/internal_server_error.py +10 -0
- phenoml/construe/errors/unauthorized_error.py +10 -0
- phenoml/construe/raw_client.py +706 -0
- phenoml/construe/types/__init__.py +41 -0
- phenoml/construe/types/bad_request_error_body.py +27 -0
- phenoml/construe/types/construe_cohort_request_config.py +37 -0
- phenoml/construe/types/construe_cohort_response.py +33 -0
- phenoml/construe/types/construe_cohort_response_queries_item.py +49 -0
- phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +31 -0
- phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py +32 -0
- phenoml/construe/types/construe_upload_code_system_response.py +19 -0
- phenoml/construe/types/extract_codes_result.py +22 -0
- phenoml/construe/types/extract_request_config.py +23 -0
- phenoml/construe/types/extract_request_config_chunking_method.py +5 -0
- phenoml/construe/types/extract_request_system.py +37 -0
- phenoml/construe/types/extracted_code_result.py +41 -0
- phenoml/construe/types/internal_server_error_body.py +27 -0
- phenoml/construe/types/unauthorized_error_body.py +27 -0
- phenoml/construe/types/upload_request_format.py +5 -0
- phenoml/core/__init__.py +52 -0
- phenoml/core/api_error.py +23 -0
- phenoml/core/client_wrapper.py +85 -0
- phenoml/core/datetime_utils.py +28 -0
- phenoml/core/file.py +67 -0
- phenoml/core/force_multipart.py +16 -0
- phenoml/core/http_client.py +543 -0
- phenoml/core/http_response.py +55 -0
- phenoml/core/jsonable_encoder.py +100 -0
- phenoml/core/pydantic_utilities.py +255 -0
- phenoml/core/query_encoder.py +58 -0
- phenoml/core/remove_none_from_dict.py +11 -0
- phenoml/core/request_options.py +35 -0
- phenoml/core/serialization.py +276 -0
- phenoml/environment.py +7 -0
- phenoml/lang2fhir/__init__.py +27 -0
- phenoml/lang2fhir/client.py +430 -0
- phenoml/lang2fhir/errors/__init__.py +11 -0
- phenoml/lang2fhir/errors/bad_request_error.py +10 -0
- phenoml/lang2fhir/errors/failed_dependency_error.py +10 -0
- phenoml/lang2fhir/errors/forbidden_error.py +10 -0
- phenoml/lang2fhir/errors/internal_server_error.py +10 -0
- phenoml/lang2fhir/errors/unauthorized_error.py +10 -0
- phenoml/lang2fhir/raw_client.py +788 -0
- phenoml/lang2fhir/types/__init__.py +19 -0
- phenoml/lang2fhir/types/create_request_resource.py +25 -0
- phenoml/lang2fhir/types/document_request_file_type.py +7 -0
- phenoml/lang2fhir/types/document_request_resource.py +5 -0
- phenoml/lang2fhir/types/fhir_resource.py +5 -0
- phenoml/lang2fhir/types/lang2fhir_upload_profile_response.py +23 -0
- phenoml/lang2fhir/types/search_response.py +33 -0
- phenoml/py.typed +0 -0
- phenoml/tools/__init__.py +33 -0
- phenoml/tools/client.py +392 -0
- phenoml/tools/errors/__init__.py +11 -0
- phenoml/tools/errors/bad_request_error.py +10 -0
- phenoml/tools/errors/failed_dependency_error.py +10 -0
- phenoml/tools/errors/forbidden_error.py +10 -0
- phenoml/tools/errors/internal_server_error.py +10 -0
- phenoml/tools/errors/unauthorized_error.py +10 -0
- phenoml/tools/raw_client.py +745 -0
- phenoml/tools/types/__init__.py +25 -0
- phenoml/tools/types/cohort_request_provider.py +5 -0
- phenoml/tools/types/cohort_response.py +49 -0
- phenoml/tools/types/fhir_client_config.py +31 -0
- phenoml/tools/types/lang2fhir_and_create_request_provider.py +7 -0
- phenoml/tools/types/lang2fhir_and_create_request_resource.py +25 -0
- phenoml/tools/types/lang2fhir_and_create_response.py +33 -0
- phenoml/tools/types/lang2fhir_and_search_request_provider.py +7 -0
- phenoml/tools/types/lang2fhir_and_search_response.py +40 -0
- phenoml/tools/types/search_concept.py +41 -0
- phenoml/version.py +3 -0
- phenoml/wrapper_client.py +123 -0
- phenoml-0.0.1.dist-info/LICENSE +21 -0
- phenoml-0.0.1.dist-info/METADATA +192 -0
- phenoml-0.0.1.dist-info/RECORD +143 -0
- phenoml-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,1345 @@
|
|
|
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.bad_request_error import BadRequestError
|
|
14
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
15
|
+
from ..errors.internal_server_error import InternalServerError
|
|
16
|
+
from ..errors.not_found_error import NotFoundError
|
|
17
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
18
|
+
from ..types.agent_prompts_response import AgentPromptsResponse
|
|
19
|
+
from ..types.json_patch import JsonPatch
|
|
20
|
+
from ..types.success_response import SuccessResponse
|
|
21
|
+
from .types.prompts_delete_response import PromptsDeleteResponse
|
|
22
|
+
from .types.prompts_list_response import PromptsListResponse
|
|
23
|
+
|
|
24
|
+
# this is used as the default value for optional parameters
|
|
25
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RawPromptsClient:
|
|
29
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
30
|
+
self._client_wrapper = client_wrapper
|
|
31
|
+
|
|
32
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[PromptsListResponse]:
|
|
33
|
+
"""
|
|
34
|
+
Retrieves a list of agent prompts belonging to the authenticated user
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
HttpResponse[PromptsListResponse]
|
|
44
|
+
Prompts retrieved successfully
|
|
45
|
+
"""
|
|
46
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
47
|
+
"agent/prompts",
|
|
48
|
+
method="GET",
|
|
49
|
+
request_options=request_options,
|
|
50
|
+
)
|
|
51
|
+
try:
|
|
52
|
+
if 200 <= _response.status_code < 300:
|
|
53
|
+
_data = typing.cast(
|
|
54
|
+
PromptsListResponse,
|
|
55
|
+
parse_obj_as(
|
|
56
|
+
type_=PromptsListResponse, # type: ignore
|
|
57
|
+
object_=_response.json(),
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
return HttpResponse(response=_response, data=_data)
|
|
61
|
+
if _response.status_code == 401:
|
|
62
|
+
raise UnauthorizedError(
|
|
63
|
+
headers=dict(_response.headers),
|
|
64
|
+
body=typing.cast(
|
|
65
|
+
typing.Optional[typing.Any],
|
|
66
|
+
parse_obj_as(
|
|
67
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
68
|
+
object_=_response.json(),
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
if _response.status_code == 403:
|
|
73
|
+
raise ForbiddenError(
|
|
74
|
+
headers=dict(_response.headers),
|
|
75
|
+
body=typing.cast(
|
|
76
|
+
typing.Optional[typing.Any],
|
|
77
|
+
parse_obj_as(
|
|
78
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
if _response.status_code == 500:
|
|
84
|
+
raise InternalServerError(
|
|
85
|
+
headers=dict(_response.headers),
|
|
86
|
+
body=typing.cast(
|
|
87
|
+
typing.Optional[typing.Any],
|
|
88
|
+
parse_obj_as(
|
|
89
|
+
type_=typing.Optional[typing.Any], # 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 create(
|
|
100
|
+
self,
|
|
101
|
+
*,
|
|
102
|
+
name: str,
|
|
103
|
+
content: str,
|
|
104
|
+
is_active: bool,
|
|
105
|
+
description: typing.Optional[str] = OMIT,
|
|
106
|
+
is_default: typing.Optional[bool] = OMIT,
|
|
107
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
108
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
109
|
+
) -> HttpResponse[AgentPromptsResponse]:
|
|
110
|
+
"""
|
|
111
|
+
Creates a new agent prompt
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
name : str
|
|
116
|
+
Prompt name
|
|
117
|
+
|
|
118
|
+
content : str
|
|
119
|
+
Prompt content
|
|
120
|
+
|
|
121
|
+
is_active : bool
|
|
122
|
+
Whether the prompt is active
|
|
123
|
+
|
|
124
|
+
description : typing.Optional[str]
|
|
125
|
+
Prompt description
|
|
126
|
+
|
|
127
|
+
is_default : typing.Optional[bool]
|
|
128
|
+
Whether this is a default prompt
|
|
129
|
+
|
|
130
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
131
|
+
Tags for categorizing the prompt
|
|
132
|
+
|
|
133
|
+
request_options : typing.Optional[RequestOptions]
|
|
134
|
+
Request-specific configuration.
|
|
135
|
+
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
HttpResponse[AgentPromptsResponse]
|
|
139
|
+
Prompt created successfully
|
|
140
|
+
"""
|
|
141
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
142
|
+
"agent/prompts",
|
|
143
|
+
method="POST",
|
|
144
|
+
json={
|
|
145
|
+
"name": name,
|
|
146
|
+
"description": description,
|
|
147
|
+
"content": content,
|
|
148
|
+
"is_default": is_default,
|
|
149
|
+
"is_active": is_active,
|
|
150
|
+
"tags": tags,
|
|
151
|
+
},
|
|
152
|
+
headers={
|
|
153
|
+
"content-type": "application/json",
|
|
154
|
+
},
|
|
155
|
+
request_options=request_options,
|
|
156
|
+
omit=OMIT,
|
|
157
|
+
)
|
|
158
|
+
try:
|
|
159
|
+
if 200 <= _response.status_code < 300:
|
|
160
|
+
_data = typing.cast(
|
|
161
|
+
AgentPromptsResponse,
|
|
162
|
+
parse_obj_as(
|
|
163
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
164
|
+
object_=_response.json(),
|
|
165
|
+
),
|
|
166
|
+
)
|
|
167
|
+
return HttpResponse(response=_response, data=_data)
|
|
168
|
+
if _response.status_code == 400:
|
|
169
|
+
raise BadRequestError(
|
|
170
|
+
headers=dict(_response.headers),
|
|
171
|
+
body=typing.cast(
|
|
172
|
+
typing.Optional[typing.Any],
|
|
173
|
+
parse_obj_as(
|
|
174
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
175
|
+
object_=_response.json(),
|
|
176
|
+
),
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
if _response.status_code == 401:
|
|
180
|
+
raise UnauthorizedError(
|
|
181
|
+
headers=dict(_response.headers),
|
|
182
|
+
body=typing.cast(
|
|
183
|
+
typing.Optional[typing.Any],
|
|
184
|
+
parse_obj_as(
|
|
185
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
186
|
+
object_=_response.json(),
|
|
187
|
+
),
|
|
188
|
+
),
|
|
189
|
+
)
|
|
190
|
+
if _response.status_code == 403:
|
|
191
|
+
raise ForbiddenError(
|
|
192
|
+
headers=dict(_response.headers),
|
|
193
|
+
body=typing.cast(
|
|
194
|
+
typing.Optional[typing.Any],
|
|
195
|
+
parse_obj_as(
|
|
196
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
197
|
+
object_=_response.json(),
|
|
198
|
+
),
|
|
199
|
+
),
|
|
200
|
+
)
|
|
201
|
+
if _response.status_code == 500:
|
|
202
|
+
raise InternalServerError(
|
|
203
|
+
headers=dict(_response.headers),
|
|
204
|
+
body=typing.cast(
|
|
205
|
+
typing.Optional[typing.Any],
|
|
206
|
+
parse_obj_as(
|
|
207
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
208
|
+
object_=_response.json(),
|
|
209
|
+
),
|
|
210
|
+
),
|
|
211
|
+
)
|
|
212
|
+
_response_json = _response.json()
|
|
213
|
+
except JSONDecodeError:
|
|
214
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
215
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
216
|
+
|
|
217
|
+
def get(
|
|
218
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
219
|
+
) -> HttpResponse[AgentPromptsResponse]:
|
|
220
|
+
"""
|
|
221
|
+
Retrieves a specific prompt by its ID
|
|
222
|
+
|
|
223
|
+
Parameters
|
|
224
|
+
----------
|
|
225
|
+
id : str
|
|
226
|
+
Prompt ID
|
|
227
|
+
|
|
228
|
+
request_options : typing.Optional[RequestOptions]
|
|
229
|
+
Request-specific configuration.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
HttpResponse[AgentPromptsResponse]
|
|
234
|
+
Prompt retrieved successfully
|
|
235
|
+
"""
|
|
236
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
237
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
238
|
+
method="GET",
|
|
239
|
+
request_options=request_options,
|
|
240
|
+
)
|
|
241
|
+
try:
|
|
242
|
+
if 200 <= _response.status_code < 300:
|
|
243
|
+
_data = typing.cast(
|
|
244
|
+
AgentPromptsResponse,
|
|
245
|
+
parse_obj_as(
|
|
246
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
247
|
+
object_=_response.json(),
|
|
248
|
+
),
|
|
249
|
+
)
|
|
250
|
+
return HttpResponse(response=_response, data=_data)
|
|
251
|
+
if _response.status_code == 401:
|
|
252
|
+
raise UnauthorizedError(
|
|
253
|
+
headers=dict(_response.headers),
|
|
254
|
+
body=typing.cast(
|
|
255
|
+
typing.Optional[typing.Any],
|
|
256
|
+
parse_obj_as(
|
|
257
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
258
|
+
object_=_response.json(),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
)
|
|
262
|
+
if _response.status_code == 403:
|
|
263
|
+
raise ForbiddenError(
|
|
264
|
+
headers=dict(_response.headers),
|
|
265
|
+
body=typing.cast(
|
|
266
|
+
typing.Optional[typing.Any],
|
|
267
|
+
parse_obj_as(
|
|
268
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
269
|
+
object_=_response.json(),
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
)
|
|
273
|
+
if _response.status_code == 404:
|
|
274
|
+
raise NotFoundError(
|
|
275
|
+
headers=dict(_response.headers),
|
|
276
|
+
body=typing.cast(
|
|
277
|
+
typing.Optional[typing.Any],
|
|
278
|
+
parse_obj_as(
|
|
279
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
280
|
+
object_=_response.json(),
|
|
281
|
+
),
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
if _response.status_code == 500:
|
|
285
|
+
raise InternalServerError(
|
|
286
|
+
headers=dict(_response.headers),
|
|
287
|
+
body=typing.cast(
|
|
288
|
+
typing.Optional[typing.Any],
|
|
289
|
+
parse_obj_as(
|
|
290
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
291
|
+
object_=_response.json(),
|
|
292
|
+
),
|
|
293
|
+
),
|
|
294
|
+
)
|
|
295
|
+
_response_json = _response.json()
|
|
296
|
+
except JSONDecodeError:
|
|
297
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
298
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
299
|
+
|
|
300
|
+
def update(
|
|
301
|
+
self,
|
|
302
|
+
id: str,
|
|
303
|
+
*,
|
|
304
|
+
name: typing.Optional[str] = OMIT,
|
|
305
|
+
description: typing.Optional[str] = OMIT,
|
|
306
|
+
content: typing.Optional[str] = OMIT,
|
|
307
|
+
is_default: typing.Optional[bool] = OMIT,
|
|
308
|
+
is_active: typing.Optional[bool] = OMIT,
|
|
309
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
310
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
311
|
+
) -> HttpResponse[AgentPromptsResponse]:
|
|
312
|
+
"""
|
|
313
|
+
Updates an existing prompt
|
|
314
|
+
|
|
315
|
+
Parameters
|
|
316
|
+
----------
|
|
317
|
+
id : str
|
|
318
|
+
Prompt ID
|
|
319
|
+
|
|
320
|
+
name : typing.Optional[str]
|
|
321
|
+
Prompt name
|
|
322
|
+
|
|
323
|
+
description : typing.Optional[str]
|
|
324
|
+
Prompt description
|
|
325
|
+
|
|
326
|
+
content : typing.Optional[str]
|
|
327
|
+
Prompt content
|
|
328
|
+
|
|
329
|
+
is_default : typing.Optional[bool]
|
|
330
|
+
Whether this is a default prompt
|
|
331
|
+
|
|
332
|
+
is_active : typing.Optional[bool]
|
|
333
|
+
Whether the prompt is active
|
|
334
|
+
|
|
335
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
336
|
+
Tags for categorizing the prompt
|
|
337
|
+
|
|
338
|
+
request_options : typing.Optional[RequestOptions]
|
|
339
|
+
Request-specific configuration.
|
|
340
|
+
|
|
341
|
+
Returns
|
|
342
|
+
-------
|
|
343
|
+
HttpResponse[AgentPromptsResponse]
|
|
344
|
+
Prompt updated successfully
|
|
345
|
+
"""
|
|
346
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
347
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
348
|
+
method="PUT",
|
|
349
|
+
json={
|
|
350
|
+
"name": name,
|
|
351
|
+
"description": description,
|
|
352
|
+
"content": content,
|
|
353
|
+
"is_default": is_default,
|
|
354
|
+
"is_active": is_active,
|
|
355
|
+
"tags": tags,
|
|
356
|
+
},
|
|
357
|
+
headers={
|
|
358
|
+
"content-type": "application/json",
|
|
359
|
+
},
|
|
360
|
+
request_options=request_options,
|
|
361
|
+
omit=OMIT,
|
|
362
|
+
)
|
|
363
|
+
try:
|
|
364
|
+
if 200 <= _response.status_code < 300:
|
|
365
|
+
_data = typing.cast(
|
|
366
|
+
AgentPromptsResponse,
|
|
367
|
+
parse_obj_as(
|
|
368
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
369
|
+
object_=_response.json(),
|
|
370
|
+
),
|
|
371
|
+
)
|
|
372
|
+
return HttpResponse(response=_response, data=_data)
|
|
373
|
+
if _response.status_code == 400:
|
|
374
|
+
raise BadRequestError(
|
|
375
|
+
headers=dict(_response.headers),
|
|
376
|
+
body=typing.cast(
|
|
377
|
+
typing.Optional[typing.Any],
|
|
378
|
+
parse_obj_as(
|
|
379
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
380
|
+
object_=_response.json(),
|
|
381
|
+
),
|
|
382
|
+
),
|
|
383
|
+
)
|
|
384
|
+
if _response.status_code == 401:
|
|
385
|
+
raise UnauthorizedError(
|
|
386
|
+
headers=dict(_response.headers),
|
|
387
|
+
body=typing.cast(
|
|
388
|
+
typing.Optional[typing.Any],
|
|
389
|
+
parse_obj_as(
|
|
390
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
391
|
+
object_=_response.json(),
|
|
392
|
+
),
|
|
393
|
+
),
|
|
394
|
+
)
|
|
395
|
+
if _response.status_code == 403:
|
|
396
|
+
raise ForbiddenError(
|
|
397
|
+
headers=dict(_response.headers),
|
|
398
|
+
body=typing.cast(
|
|
399
|
+
typing.Optional[typing.Any],
|
|
400
|
+
parse_obj_as(
|
|
401
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
402
|
+
object_=_response.json(),
|
|
403
|
+
),
|
|
404
|
+
),
|
|
405
|
+
)
|
|
406
|
+
if _response.status_code == 404:
|
|
407
|
+
raise NotFoundError(
|
|
408
|
+
headers=dict(_response.headers),
|
|
409
|
+
body=typing.cast(
|
|
410
|
+
typing.Optional[typing.Any],
|
|
411
|
+
parse_obj_as(
|
|
412
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
413
|
+
object_=_response.json(),
|
|
414
|
+
),
|
|
415
|
+
),
|
|
416
|
+
)
|
|
417
|
+
if _response.status_code == 500:
|
|
418
|
+
raise InternalServerError(
|
|
419
|
+
headers=dict(_response.headers),
|
|
420
|
+
body=typing.cast(
|
|
421
|
+
typing.Optional[typing.Any],
|
|
422
|
+
parse_obj_as(
|
|
423
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
424
|
+
object_=_response.json(),
|
|
425
|
+
),
|
|
426
|
+
),
|
|
427
|
+
)
|
|
428
|
+
_response_json = _response.json()
|
|
429
|
+
except JSONDecodeError:
|
|
430
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
431
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
432
|
+
|
|
433
|
+
def delete(
|
|
434
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
435
|
+
) -> HttpResponse[PromptsDeleteResponse]:
|
|
436
|
+
"""
|
|
437
|
+
Soft deletes a prompt by setting is_active to false
|
|
438
|
+
|
|
439
|
+
Parameters
|
|
440
|
+
----------
|
|
441
|
+
id : str
|
|
442
|
+
Prompt ID
|
|
443
|
+
|
|
444
|
+
request_options : typing.Optional[RequestOptions]
|
|
445
|
+
Request-specific configuration.
|
|
446
|
+
|
|
447
|
+
Returns
|
|
448
|
+
-------
|
|
449
|
+
HttpResponse[PromptsDeleteResponse]
|
|
450
|
+
Prompt deleted successfully
|
|
451
|
+
"""
|
|
452
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
453
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
454
|
+
method="DELETE",
|
|
455
|
+
request_options=request_options,
|
|
456
|
+
)
|
|
457
|
+
try:
|
|
458
|
+
if 200 <= _response.status_code < 300:
|
|
459
|
+
_data = typing.cast(
|
|
460
|
+
PromptsDeleteResponse,
|
|
461
|
+
parse_obj_as(
|
|
462
|
+
type_=PromptsDeleteResponse, # type: ignore
|
|
463
|
+
object_=_response.json(),
|
|
464
|
+
),
|
|
465
|
+
)
|
|
466
|
+
return HttpResponse(response=_response, data=_data)
|
|
467
|
+
if _response.status_code == 401:
|
|
468
|
+
raise UnauthorizedError(
|
|
469
|
+
headers=dict(_response.headers),
|
|
470
|
+
body=typing.cast(
|
|
471
|
+
typing.Optional[typing.Any],
|
|
472
|
+
parse_obj_as(
|
|
473
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
474
|
+
object_=_response.json(),
|
|
475
|
+
),
|
|
476
|
+
),
|
|
477
|
+
)
|
|
478
|
+
if _response.status_code == 403:
|
|
479
|
+
raise ForbiddenError(
|
|
480
|
+
headers=dict(_response.headers),
|
|
481
|
+
body=typing.cast(
|
|
482
|
+
typing.Optional[typing.Any],
|
|
483
|
+
parse_obj_as(
|
|
484
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
485
|
+
object_=_response.json(),
|
|
486
|
+
),
|
|
487
|
+
),
|
|
488
|
+
)
|
|
489
|
+
if _response.status_code == 404:
|
|
490
|
+
raise NotFoundError(
|
|
491
|
+
headers=dict(_response.headers),
|
|
492
|
+
body=typing.cast(
|
|
493
|
+
typing.Optional[typing.Any],
|
|
494
|
+
parse_obj_as(
|
|
495
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
496
|
+
object_=_response.json(),
|
|
497
|
+
),
|
|
498
|
+
),
|
|
499
|
+
)
|
|
500
|
+
if _response.status_code == 500:
|
|
501
|
+
raise InternalServerError(
|
|
502
|
+
headers=dict(_response.headers),
|
|
503
|
+
body=typing.cast(
|
|
504
|
+
typing.Optional[typing.Any],
|
|
505
|
+
parse_obj_as(
|
|
506
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
507
|
+
object_=_response.json(),
|
|
508
|
+
),
|
|
509
|
+
),
|
|
510
|
+
)
|
|
511
|
+
_response_json = _response.json()
|
|
512
|
+
except JSONDecodeError:
|
|
513
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
514
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
515
|
+
|
|
516
|
+
def patch(
|
|
517
|
+
self, id: str, *, request: JsonPatch, request_options: typing.Optional[RequestOptions] = None
|
|
518
|
+
) -> HttpResponse[AgentPromptsResponse]:
|
|
519
|
+
"""
|
|
520
|
+
Patches an existing prompt
|
|
521
|
+
|
|
522
|
+
Parameters
|
|
523
|
+
----------
|
|
524
|
+
id : str
|
|
525
|
+
Agent Prompt ID
|
|
526
|
+
|
|
527
|
+
request : JsonPatch
|
|
528
|
+
|
|
529
|
+
request_options : typing.Optional[RequestOptions]
|
|
530
|
+
Request-specific configuration.
|
|
531
|
+
|
|
532
|
+
Returns
|
|
533
|
+
-------
|
|
534
|
+
HttpResponse[AgentPromptsResponse]
|
|
535
|
+
Prompt patched successfully
|
|
536
|
+
"""
|
|
537
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
538
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
539
|
+
method="PATCH",
|
|
540
|
+
json=convert_and_respect_annotation_metadata(object_=request, annotation=JsonPatch, direction="write"),
|
|
541
|
+
headers={
|
|
542
|
+
"content-type": "application/json+patch",
|
|
543
|
+
},
|
|
544
|
+
request_options=request_options,
|
|
545
|
+
omit=OMIT,
|
|
546
|
+
)
|
|
547
|
+
try:
|
|
548
|
+
if 200 <= _response.status_code < 300:
|
|
549
|
+
_data = typing.cast(
|
|
550
|
+
AgentPromptsResponse,
|
|
551
|
+
parse_obj_as(
|
|
552
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
553
|
+
object_=_response.json(),
|
|
554
|
+
),
|
|
555
|
+
)
|
|
556
|
+
return HttpResponse(response=_response, data=_data)
|
|
557
|
+
if _response.status_code == 400:
|
|
558
|
+
raise BadRequestError(
|
|
559
|
+
headers=dict(_response.headers),
|
|
560
|
+
body=typing.cast(
|
|
561
|
+
typing.Optional[typing.Any],
|
|
562
|
+
parse_obj_as(
|
|
563
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
564
|
+
object_=_response.json(),
|
|
565
|
+
),
|
|
566
|
+
),
|
|
567
|
+
)
|
|
568
|
+
if _response.status_code == 401:
|
|
569
|
+
raise UnauthorizedError(
|
|
570
|
+
headers=dict(_response.headers),
|
|
571
|
+
body=typing.cast(
|
|
572
|
+
typing.Optional[typing.Any],
|
|
573
|
+
parse_obj_as(
|
|
574
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
575
|
+
object_=_response.json(),
|
|
576
|
+
),
|
|
577
|
+
),
|
|
578
|
+
)
|
|
579
|
+
if _response.status_code == 403:
|
|
580
|
+
raise ForbiddenError(
|
|
581
|
+
headers=dict(_response.headers),
|
|
582
|
+
body=typing.cast(
|
|
583
|
+
typing.Optional[typing.Any],
|
|
584
|
+
parse_obj_as(
|
|
585
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
586
|
+
object_=_response.json(),
|
|
587
|
+
),
|
|
588
|
+
),
|
|
589
|
+
)
|
|
590
|
+
if _response.status_code == 404:
|
|
591
|
+
raise NotFoundError(
|
|
592
|
+
headers=dict(_response.headers),
|
|
593
|
+
body=typing.cast(
|
|
594
|
+
typing.Optional[typing.Any],
|
|
595
|
+
parse_obj_as(
|
|
596
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
597
|
+
object_=_response.json(),
|
|
598
|
+
),
|
|
599
|
+
),
|
|
600
|
+
)
|
|
601
|
+
if _response.status_code == 500:
|
|
602
|
+
raise InternalServerError(
|
|
603
|
+
headers=dict(_response.headers),
|
|
604
|
+
body=typing.cast(
|
|
605
|
+
typing.Optional[typing.Any],
|
|
606
|
+
parse_obj_as(
|
|
607
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
608
|
+
object_=_response.json(),
|
|
609
|
+
),
|
|
610
|
+
),
|
|
611
|
+
)
|
|
612
|
+
_response_json = _response.json()
|
|
613
|
+
except JSONDecodeError:
|
|
614
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
615
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
616
|
+
|
|
617
|
+
def load_defaults(
|
|
618
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
619
|
+
) -> HttpResponse[SuccessResponse]:
|
|
620
|
+
"""
|
|
621
|
+
Loads default agent prompts for the authenticated user
|
|
622
|
+
|
|
623
|
+
Parameters
|
|
624
|
+
----------
|
|
625
|
+
request_options : typing.Optional[RequestOptions]
|
|
626
|
+
Request-specific configuration.
|
|
627
|
+
|
|
628
|
+
Returns
|
|
629
|
+
-------
|
|
630
|
+
HttpResponse[SuccessResponse]
|
|
631
|
+
Default prompts loaded successfully
|
|
632
|
+
"""
|
|
633
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
634
|
+
"agent/prompts/load-defaults",
|
|
635
|
+
method="POST",
|
|
636
|
+
request_options=request_options,
|
|
637
|
+
)
|
|
638
|
+
try:
|
|
639
|
+
if 200 <= _response.status_code < 300:
|
|
640
|
+
_data = typing.cast(
|
|
641
|
+
SuccessResponse,
|
|
642
|
+
parse_obj_as(
|
|
643
|
+
type_=SuccessResponse, # type: ignore
|
|
644
|
+
object_=_response.json(),
|
|
645
|
+
),
|
|
646
|
+
)
|
|
647
|
+
return HttpResponse(response=_response, data=_data)
|
|
648
|
+
if _response.status_code == 401:
|
|
649
|
+
raise UnauthorizedError(
|
|
650
|
+
headers=dict(_response.headers),
|
|
651
|
+
body=typing.cast(
|
|
652
|
+
typing.Optional[typing.Any],
|
|
653
|
+
parse_obj_as(
|
|
654
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
655
|
+
object_=_response.json(),
|
|
656
|
+
),
|
|
657
|
+
),
|
|
658
|
+
)
|
|
659
|
+
if _response.status_code == 403:
|
|
660
|
+
raise ForbiddenError(
|
|
661
|
+
headers=dict(_response.headers),
|
|
662
|
+
body=typing.cast(
|
|
663
|
+
typing.Optional[typing.Any],
|
|
664
|
+
parse_obj_as(
|
|
665
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
666
|
+
object_=_response.json(),
|
|
667
|
+
),
|
|
668
|
+
),
|
|
669
|
+
)
|
|
670
|
+
if _response.status_code == 500:
|
|
671
|
+
raise InternalServerError(
|
|
672
|
+
headers=dict(_response.headers),
|
|
673
|
+
body=typing.cast(
|
|
674
|
+
typing.Optional[typing.Any],
|
|
675
|
+
parse_obj_as(
|
|
676
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
677
|
+
object_=_response.json(),
|
|
678
|
+
),
|
|
679
|
+
),
|
|
680
|
+
)
|
|
681
|
+
_response_json = _response.json()
|
|
682
|
+
except JSONDecodeError:
|
|
683
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
684
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
class AsyncRawPromptsClient:
|
|
688
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
689
|
+
self._client_wrapper = client_wrapper
|
|
690
|
+
|
|
691
|
+
async def list(
|
|
692
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
693
|
+
) -> AsyncHttpResponse[PromptsListResponse]:
|
|
694
|
+
"""
|
|
695
|
+
Retrieves a list of agent prompts belonging to the authenticated user
|
|
696
|
+
|
|
697
|
+
Parameters
|
|
698
|
+
----------
|
|
699
|
+
request_options : typing.Optional[RequestOptions]
|
|
700
|
+
Request-specific configuration.
|
|
701
|
+
|
|
702
|
+
Returns
|
|
703
|
+
-------
|
|
704
|
+
AsyncHttpResponse[PromptsListResponse]
|
|
705
|
+
Prompts retrieved successfully
|
|
706
|
+
"""
|
|
707
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
708
|
+
"agent/prompts",
|
|
709
|
+
method="GET",
|
|
710
|
+
request_options=request_options,
|
|
711
|
+
)
|
|
712
|
+
try:
|
|
713
|
+
if 200 <= _response.status_code < 300:
|
|
714
|
+
_data = typing.cast(
|
|
715
|
+
PromptsListResponse,
|
|
716
|
+
parse_obj_as(
|
|
717
|
+
type_=PromptsListResponse, # type: ignore
|
|
718
|
+
object_=_response.json(),
|
|
719
|
+
),
|
|
720
|
+
)
|
|
721
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
722
|
+
if _response.status_code == 401:
|
|
723
|
+
raise UnauthorizedError(
|
|
724
|
+
headers=dict(_response.headers),
|
|
725
|
+
body=typing.cast(
|
|
726
|
+
typing.Optional[typing.Any],
|
|
727
|
+
parse_obj_as(
|
|
728
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
729
|
+
object_=_response.json(),
|
|
730
|
+
),
|
|
731
|
+
),
|
|
732
|
+
)
|
|
733
|
+
if _response.status_code == 403:
|
|
734
|
+
raise ForbiddenError(
|
|
735
|
+
headers=dict(_response.headers),
|
|
736
|
+
body=typing.cast(
|
|
737
|
+
typing.Optional[typing.Any],
|
|
738
|
+
parse_obj_as(
|
|
739
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
740
|
+
object_=_response.json(),
|
|
741
|
+
),
|
|
742
|
+
),
|
|
743
|
+
)
|
|
744
|
+
if _response.status_code == 500:
|
|
745
|
+
raise InternalServerError(
|
|
746
|
+
headers=dict(_response.headers),
|
|
747
|
+
body=typing.cast(
|
|
748
|
+
typing.Optional[typing.Any],
|
|
749
|
+
parse_obj_as(
|
|
750
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
751
|
+
object_=_response.json(),
|
|
752
|
+
),
|
|
753
|
+
),
|
|
754
|
+
)
|
|
755
|
+
_response_json = _response.json()
|
|
756
|
+
except JSONDecodeError:
|
|
757
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
758
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
759
|
+
|
|
760
|
+
async def create(
|
|
761
|
+
self,
|
|
762
|
+
*,
|
|
763
|
+
name: str,
|
|
764
|
+
content: str,
|
|
765
|
+
is_active: bool,
|
|
766
|
+
description: typing.Optional[str] = OMIT,
|
|
767
|
+
is_default: typing.Optional[bool] = OMIT,
|
|
768
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
769
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
770
|
+
) -> AsyncHttpResponse[AgentPromptsResponse]:
|
|
771
|
+
"""
|
|
772
|
+
Creates a new agent prompt
|
|
773
|
+
|
|
774
|
+
Parameters
|
|
775
|
+
----------
|
|
776
|
+
name : str
|
|
777
|
+
Prompt name
|
|
778
|
+
|
|
779
|
+
content : str
|
|
780
|
+
Prompt content
|
|
781
|
+
|
|
782
|
+
is_active : bool
|
|
783
|
+
Whether the prompt is active
|
|
784
|
+
|
|
785
|
+
description : typing.Optional[str]
|
|
786
|
+
Prompt description
|
|
787
|
+
|
|
788
|
+
is_default : typing.Optional[bool]
|
|
789
|
+
Whether this is a default prompt
|
|
790
|
+
|
|
791
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
792
|
+
Tags for categorizing the prompt
|
|
793
|
+
|
|
794
|
+
request_options : typing.Optional[RequestOptions]
|
|
795
|
+
Request-specific configuration.
|
|
796
|
+
|
|
797
|
+
Returns
|
|
798
|
+
-------
|
|
799
|
+
AsyncHttpResponse[AgentPromptsResponse]
|
|
800
|
+
Prompt created successfully
|
|
801
|
+
"""
|
|
802
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
803
|
+
"agent/prompts",
|
|
804
|
+
method="POST",
|
|
805
|
+
json={
|
|
806
|
+
"name": name,
|
|
807
|
+
"description": description,
|
|
808
|
+
"content": content,
|
|
809
|
+
"is_default": is_default,
|
|
810
|
+
"is_active": is_active,
|
|
811
|
+
"tags": tags,
|
|
812
|
+
},
|
|
813
|
+
headers={
|
|
814
|
+
"content-type": "application/json",
|
|
815
|
+
},
|
|
816
|
+
request_options=request_options,
|
|
817
|
+
omit=OMIT,
|
|
818
|
+
)
|
|
819
|
+
try:
|
|
820
|
+
if 200 <= _response.status_code < 300:
|
|
821
|
+
_data = typing.cast(
|
|
822
|
+
AgentPromptsResponse,
|
|
823
|
+
parse_obj_as(
|
|
824
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
825
|
+
object_=_response.json(),
|
|
826
|
+
),
|
|
827
|
+
)
|
|
828
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
829
|
+
if _response.status_code == 400:
|
|
830
|
+
raise BadRequestError(
|
|
831
|
+
headers=dict(_response.headers),
|
|
832
|
+
body=typing.cast(
|
|
833
|
+
typing.Optional[typing.Any],
|
|
834
|
+
parse_obj_as(
|
|
835
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
836
|
+
object_=_response.json(),
|
|
837
|
+
),
|
|
838
|
+
),
|
|
839
|
+
)
|
|
840
|
+
if _response.status_code == 401:
|
|
841
|
+
raise UnauthorizedError(
|
|
842
|
+
headers=dict(_response.headers),
|
|
843
|
+
body=typing.cast(
|
|
844
|
+
typing.Optional[typing.Any],
|
|
845
|
+
parse_obj_as(
|
|
846
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
847
|
+
object_=_response.json(),
|
|
848
|
+
),
|
|
849
|
+
),
|
|
850
|
+
)
|
|
851
|
+
if _response.status_code == 403:
|
|
852
|
+
raise ForbiddenError(
|
|
853
|
+
headers=dict(_response.headers),
|
|
854
|
+
body=typing.cast(
|
|
855
|
+
typing.Optional[typing.Any],
|
|
856
|
+
parse_obj_as(
|
|
857
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
858
|
+
object_=_response.json(),
|
|
859
|
+
),
|
|
860
|
+
),
|
|
861
|
+
)
|
|
862
|
+
if _response.status_code == 500:
|
|
863
|
+
raise InternalServerError(
|
|
864
|
+
headers=dict(_response.headers),
|
|
865
|
+
body=typing.cast(
|
|
866
|
+
typing.Optional[typing.Any],
|
|
867
|
+
parse_obj_as(
|
|
868
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
869
|
+
object_=_response.json(),
|
|
870
|
+
),
|
|
871
|
+
),
|
|
872
|
+
)
|
|
873
|
+
_response_json = _response.json()
|
|
874
|
+
except JSONDecodeError:
|
|
875
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
876
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
877
|
+
|
|
878
|
+
async def get(
|
|
879
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
880
|
+
) -> AsyncHttpResponse[AgentPromptsResponse]:
|
|
881
|
+
"""
|
|
882
|
+
Retrieves a specific prompt by its ID
|
|
883
|
+
|
|
884
|
+
Parameters
|
|
885
|
+
----------
|
|
886
|
+
id : str
|
|
887
|
+
Prompt ID
|
|
888
|
+
|
|
889
|
+
request_options : typing.Optional[RequestOptions]
|
|
890
|
+
Request-specific configuration.
|
|
891
|
+
|
|
892
|
+
Returns
|
|
893
|
+
-------
|
|
894
|
+
AsyncHttpResponse[AgentPromptsResponse]
|
|
895
|
+
Prompt retrieved successfully
|
|
896
|
+
"""
|
|
897
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
898
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
899
|
+
method="GET",
|
|
900
|
+
request_options=request_options,
|
|
901
|
+
)
|
|
902
|
+
try:
|
|
903
|
+
if 200 <= _response.status_code < 300:
|
|
904
|
+
_data = typing.cast(
|
|
905
|
+
AgentPromptsResponse,
|
|
906
|
+
parse_obj_as(
|
|
907
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
908
|
+
object_=_response.json(),
|
|
909
|
+
),
|
|
910
|
+
)
|
|
911
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
912
|
+
if _response.status_code == 401:
|
|
913
|
+
raise UnauthorizedError(
|
|
914
|
+
headers=dict(_response.headers),
|
|
915
|
+
body=typing.cast(
|
|
916
|
+
typing.Optional[typing.Any],
|
|
917
|
+
parse_obj_as(
|
|
918
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
919
|
+
object_=_response.json(),
|
|
920
|
+
),
|
|
921
|
+
),
|
|
922
|
+
)
|
|
923
|
+
if _response.status_code == 403:
|
|
924
|
+
raise ForbiddenError(
|
|
925
|
+
headers=dict(_response.headers),
|
|
926
|
+
body=typing.cast(
|
|
927
|
+
typing.Optional[typing.Any],
|
|
928
|
+
parse_obj_as(
|
|
929
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
930
|
+
object_=_response.json(),
|
|
931
|
+
),
|
|
932
|
+
),
|
|
933
|
+
)
|
|
934
|
+
if _response.status_code == 404:
|
|
935
|
+
raise NotFoundError(
|
|
936
|
+
headers=dict(_response.headers),
|
|
937
|
+
body=typing.cast(
|
|
938
|
+
typing.Optional[typing.Any],
|
|
939
|
+
parse_obj_as(
|
|
940
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
941
|
+
object_=_response.json(),
|
|
942
|
+
),
|
|
943
|
+
),
|
|
944
|
+
)
|
|
945
|
+
if _response.status_code == 500:
|
|
946
|
+
raise InternalServerError(
|
|
947
|
+
headers=dict(_response.headers),
|
|
948
|
+
body=typing.cast(
|
|
949
|
+
typing.Optional[typing.Any],
|
|
950
|
+
parse_obj_as(
|
|
951
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
952
|
+
object_=_response.json(),
|
|
953
|
+
),
|
|
954
|
+
),
|
|
955
|
+
)
|
|
956
|
+
_response_json = _response.json()
|
|
957
|
+
except JSONDecodeError:
|
|
958
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
959
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
960
|
+
|
|
961
|
+
async def update(
|
|
962
|
+
self,
|
|
963
|
+
id: str,
|
|
964
|
+
*,
|
|
965
|
+
name: typing.Optional[str] = OMIT,
|
|
966
|
+
description: typing.Optional[str] = OMIT,
|
|
967
|
+
content: typing.Optional[str] = OMIT,
|
|
968
|
+
is_default: typing.Optional[bool] = OMIT,
|
|
969
|
+
is_active: typing.Optional[bool] = OMIT,
|
|
970
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
971
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
972
|
+
) -> AsyncHttpResponse[AgentPromptsResponse]:
|
|
973
|
+
"""
|
|
974
|
+
Updates an existing prompt
|
|
975
|
+
|
|
976
|
+
Parameters
|
|
977
|
+
----------
|
|
978
|
+
id : str
|
|
979
|
+
Prompt ID
|
|
980
|
+
|
|
981
|
+
name : typing.Optional[str]
|
|
982
|
+
Prompt name
|
|
983
|
+
|
|
984
|
+
description : typing.Optional[str]
|
|
985
|
+
Prompt description
|
|
986
|
+
|
|
987
|
+
content : typing.Optional[str]
|
|
988
|
+
Prompt content
|
|
989
|
+
|
|
990
|
+
is_default : typing.Optional[bool]
|
|
991
|
+
Whether this is a default prompt
|
|
992
|
+
|
|
993
|
+
is_active : typing.Optional[bool]
|
|
994
|
+
Whether the prompt is active
|
|
995
|
+
|
|
996
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
997
|
+
Tags for categorizing the prompt
|
|
998
|
+
|
|
999
|
+
request_options : typing.Optional[RequestOptions]
|
|
1000
|
+
Request-specific configuration.
|
|
1001
|
+
|
|
1002
|
+
Returns
|
|
1003
|
+
-------
|
|
1004
|
+
AsyncHttpResponse[AgentPromptsResponse]
|
|
1005
|
+
Prompt updated successfully
|
|
1006
|
+
"""
|
|
1007
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1008
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
1009
|
+
method="PUT",
|
|
1010
|
+
json={
|
|
1011
|
+
"name": name,
|
|
1012
|
+
"description": description,
|
|
1013
|
+
"content": content,
|
|
1014
|
+
"is_default": is_default,
|
|
1015
|
+
"is_active": is_active,
|
|
1016
|
+
"tags": tags,
|
|
1017
|
+
},
|
|
1018
|
+
headers={
|
|
1019
|
+
"content-type": "application/json",
|
|
1020
|
+
},
|
|
1021
|
+
request_options=request_options,
|
|
1022
|
+
omit=OMIT,
|
|
1023
|
+
)
|
|
1024
|
+
try:
|
|
1025
|
+
if 200 <= _response.status_code < 300:
|
|
1026
|
+
_data = typing.cast(
|
|
1027
|
+
AgentPromptsResponse,
|
|
1028
|
+
parse_obj_as(
|
|
1029
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
1030
|
+
object_=_response.json(),
|
|
1031
|
+
),
|
|
1032
|
+
)
|
|
1033
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1034
|
+
if _response.status_code == 400:
|
|
1035
|
+
raise BadRequestError(
|
|
1036
|
+
headers=dict(_response.headers),
|
|
1037
|
+
body=typing.cast(
|
|
1038
|
+
typing.Optional[typing.Any],
|
|
1039
|
+
parse_obj_as(
|
|
1040
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1041
|
+
object_=_response.json(),
|
|
1042
|
+
),
|
|
1043
|
+
),
|
|
1044
|
+
)
|
|
1045
|
+
if _response.status_code == 401:
|
|
1046
|
+
raise UnauthorizedError(
|
|
1047
|
+
headers=dict(_response.headers),
|
|
1048
|
+
body=typing.cast(
|
|
1049
|
+
typing.Optional[typing.Any],
|
|
1050
|
+
parse_obj_as(
|
|
1051
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1052
|
+
object_=_response.json(),
|
|
1053
|
+
),
|
|
1054
|
+
),
|
|
1055
|
+
)
|
|
1056
|
+
if _response.status_code == 403:
|
|
1057
|
+
raise ForbiddenError(
|
|
1058
|
+
headers=dict(_response.headers),
|
|
1059
|
+
body=typing.cast(
|
|
1060
|
+
typing.Optional[typing.Any],
|
|
1061
|
+
parse_obj_as(
|
|
1062
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1063
|
+
object_=_response.json(),
|
|
1064
|
+
),
|
|
1065
|
+
),
|
|
1066
|
+
)
|
|
1067
|
+
if _response.status_code == 404:
|
|
1068
|
+
raise NotFoundError(
|
|
1069
|
+
headers=dict(_response.headers),
|
|
1070
|
+
body=typing.cast(
|
|
1071
|
+
typing.Optional[typing.Any],
|
|
1072
|
+
parse_obj_as(
|
|
1073
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1074
|
+
object_=_response.json(),
|
|
1075
|
+
),
|
|
1076
|
+
),
|
|
1077
|
+
)
|
|
1078
|
+
if _response.status_code == 500:
|
|
1079
|
+
raise InternalServerError(
|
|
1080
|
+
headers=dict(_response.headers),
|
|
1081
|
+
body=typing.cast(
|
|
1082
|
+
typing.Optional[typing.Any],
|
|
1083
|
+
parse_obj_as(
|
|
1084
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1085
|
+
object_=_response.json(),
|
|
1086
|
+
),
|
|
1087
|
+
),
|
|
1088
|
+
)
|
|
1089
|
+
_response_json = _response.json()
|
|
1090
|
+
except JSONDecodeError:
|
|
1091
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1092
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1093
|
+
|
|
1094
|
+
async def delete(
|
|
1095
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1096
|
+
) -> AsyncHttpResponse[PromptsDeleteResponse]:
|
|
1097
|
+
"""
|
|
1098
|
+
Soft deletes a prompt by setting is_active to false
|
|
1099
|
+
|
|
1100
|
+
Parameters
|
|
1101
|
+
----------
|
|
1102
|
+
id : str
|
|
1103
|
+
Prompt ID
|
|
1104
|
+
|
|
1105
|
+
request_options : typing.Optional[RequestOptions]
|
|
1106
|
+
Request-specific configuration.
|
|
1107
|
+
|
|
1108
|
+
Returns
|
|
1109
|
+
-------
|
|
1110
|
+
AsyncHttpResponse[PromptsDeleteResponse]
|
|
1111
|
+
Prompt deleted successfully
|
|
1112
|
+
"""
|
|
1113
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1114
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
1115
|
+
method="DELETE",
|
|
1116
|
+
request_options=request_options,
|
|
1117
|
+
)
|
|
1118
|
+
try:
|
|
1119
|
+
if 200 <= _response.status_code < 300:
|
|
1120
|
+
_data = typing.cast(
|
|
1121
|
+
PromptsDeleteResponse,
|
|
1122
|
+
parse_obj_as(
|
|
1123
|
+
type_=PromptsDeleteResponse, # type: ignore
|
|
1124
|
+
object_=_response.json(),
|
|
1125
|
+
),
|
|
1126
|
+
)
|
|
1127
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1128
|
+
if _response.status_code == 401:
|
|
1129
|
+
raise UnauthorizedError(
|
|
1130
|
+
headers=dict(_response.headers),
|
|
1131
|
+
body=typing.cast(
|
|
1132
|
+
typing.Optional[typing.Any],
|
|
1133
|
+
parse_obj_as(
|
|
1134
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1135
|
+
object_=_response.json(),
|
|
1136
|
+
),
|
|
1137
|
+
),
|
|
1138
|
+
)
|
|
1139
|
+
if _response.status_code == 403:
|
|
1140
|
+
raise ForbiddenError(
|
|
1141
|
+
headers=dict(_response.headers),
|
|
1142
|
+
body=typing.cast(
|
|
1143
|
+
typing.Optional[typing.Any],
|
|
1144
|
+
parse_obj_as(
|
|
1145
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1146
|
+
object_=_response.json(),
|
|
1147
|
+
),
|
|
1148
|
+
),
|
|
1149
|
+
)
|
|
1150
|
+
if _response.status_code == 404:
|
|
1151
|
+
raise NotFoundError(
|
|
1152
|
+
headers=dict(_response.headers),
|
|
1153
|
+
body=typing.cast(
|
|
1154
|
+
typing.Optional[typing.Any],
|
|
1155
|
+
parse_obj_as(
|
|
1156
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1157
|
+
object_=_response.json(),
|
|
1158
|
+
),
|
|
1159
|
+
),
|
|
1160
|
+
)
|
|
1161
|
+
if _response.status_code == 500:
|
|
1162
|
+
raise InternalServerError(
|
|
1163
|
+
headers=dict(_response.headers),
|
|
1164
|
+
body=typing.cast(
|
|
1165
|
+
typing.Optional[typing.Any],
|
|
1166
|
+
parse_obj_as(
|
|
1167
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1168
|
+
object_=_response.json(),
|
|
1169
|
+
),
|
|
1170
|
+
),
|
|
1171
|
+
)
|
|
1172
|
+
_response_json = _response.json()
|
|
1173
|
+
except JSONDecodeError:
|
|
1174
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1175
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1176
|
+
|
|
1177
|
+
async def patch(
|
|
1178
|
+
self, id: str, *, request: JsonPatch, request_options: typing.Optional[RequestOptions] = None
|
|
1179
|
+
) -> AsyncHttpResponse[AgentPromptsResponse]:
|
|
1180
|
+
"""
|
|
1181
|
+
Patches an existing prompt
|
|
1182
|
+
|
|
1183
|
+
Parameters
|
|
1184
|
+
----------
|
|
1185
|
+
id : str
|
|
1186
|
+
Agent Prompt ID
|
|
1187
|
+
|
|
1188
|
+
request : JsonPatch
|
|
1189
|
+
|
|
1190
|
+
request_options : typing.Optional[RequestOptions]
|
|
1191
|
+
Request-specific configuration.
|
|
1192
|
+
|
|
1193
|
+
Returns
|
|
1194
|
+
-------
|
|
1195
|
+
AsyncHttpResponse[AgentPromptsResponse]
|
|
1196
|
+
Prompt patched successfully
|
|
1197
|
+
"""
|
|
1198
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1199
|
+
f"agent/prompts/{jsonable_encoder(id)}",
|
|
1200
|
+
method="PATCH",
|
|
1201
|
+
json=convert_and_respect_annotation_metadata(object_=request, annotation=JsonPatch, direction="write"),
|
|
1202
|
+
headers={
|
|
1203
|
+
"content-type": "application/json+patch",
|
|
1204
|
+
},
|
|
1205
|
+
request_options=request_options,
|
|
1206
|
+
omit=OMIT,
|
|
1207
|
+
)
|
|
1208
|
+
try:
|
|
1209
|
+
if 200 <= _response.status_code < 300:
|
|
1210
|
+
_data = typing.cast(
|
|
1211
|
+
AgentPromptsResponse,
|
|
1212
|
+
parse_obj_as(
|
|
1213
|
+
type_=AgentPromptsResponse, # type: ignore
|
|
1214
|
+
object_=_response.json(),
|
|
1215
|
+
),
|
|
1216
|
+
)
|
|
1217
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1218
|
+
if _response.status_code == 400:
|
|
1219
|
+
raise BadRequestError(
|
|
1220
|
+
headers=dict(_response.headers),
|
|
1221
|
+
body=typing.cast(
|
|
1222
|
+
typing.Optional[typing.Any],
|
|
1223
|
+
parse_obj_as(
|
|
1224
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1225
|
+
object_=_response.json(),
|
|
1226
|
+
),
|
|
1227
|
+
),
|
|
1228
|
+
)
|
|
1229
|
+
if _response.status_code == 401:
|
|
1230
|
+
raise UnauthorizedError(
|
|
1231
|
+
headers=dict(_response.headers),
|
|
1232
|
+
body=typing.cast(
|
|
1233
|
+
typing.Optional[typing.Any],
|
|
1234
|
+
parse_obj_as(
|
|
1235
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1236
|
+
object_=_response.json(),
|
|
1237
|
+
),
|
|
1238
|
+
),
|
|
1239
|
+
)
|
|
1240
|
+
if _response.status_code == 403:
|
|
1241
|
+
raise ForbiddenError(
|
|
1242
|
+
headers=dict(_response.headers),
|
|
1243
|
+
body=typing.cast(
|
|
1244
|
+
typing.Optional[typing.Any],
|
|
1245
|
+
parse_obj_as(
|
|
1246
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1247
|
+
object_=_response.json(),
|
|
1248
|
+
),
|
|
1249
|
+
),
|
|
1250
|
+
)
|
|
1251
|
+
if _response.status_code == 404:
|
|
1252
|
+
raise NotFoundError(
|
|
1253
|
+
headers=dict(_response.headers),
|
|
1254
|
+
body=typing.cast(
|
|
1255
|
+
typing.Optional[typing.Any],
|
|
1256
|
+
parse_obj_as(
|
|
1257
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1258
|
+
object_=_response.json(),
|
|
1259
|
+
),
|
|
1260
|
+
),
|
|
1261
|
+
)
|
|
1262
|
+
if _response.status_code == 500:
|
|
1263
|
+
raise InternalServerError(
|
|
1264
|
+
headers=dict(_response.headers),
|
|
1265
|
+
body=typing.cast(
|
|
1266
|
+
typing.Optional[typing.Any],
|
|
1267
|
+
parse_obj_as(
|
|
1268
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1269
|
+
object_=_response.json(),
|
|
1270
|
+
),
|
|
1271
|
+
),
|
|
1272
|
+
)
|
|
1273
|
+
_response_json = _response.json()
|
|
1274
|
+
except JSONDecodeError:
|
|
1275
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1276
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1277
|
+
|
|
1278
|
+
async def load_defaults(
|
|
1279
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1280
|
+
) -> AsyncHttpResponse[SuccessResponse]:
|
|
1281
|
+
"""
|
|
1282
|
+
Loads default agent prompts for the authenticated user
|
|
1283
|
+
|
|
1284
|
+
Parameters
|
|
1285
|
+
----------
|
|
1286
|
+
request_options : typing.Optional[RequestOptions]
|
|
1287
|
+
Request-specific configuration.
|
|
1288
|
+
|
|
1289
|
+
Returns
|
|
1290
|
+
-------
|
|
1291
|
+
AsyncHttpResponse[SuccessResponse]
|
|
1292
|
+
Default prompts loaded successfully
|
|
1293
|
+
"""
|
|
1294
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1295
|
+
"agent/prompts/load-defaults",
|
|
1296
|
+
method="POST",
|
|
1297
|
+
request_options=request_options,
|
|
1298
|
+
)
|
|
1299
|
+
try:
|
|
1300
|
+
if 200 <= _response.status_code < 300:
|
|
1301
|
+
_data = typing.cast(
|
|
1302
|
+
SuccessResponse,
|
|
1303
|
+
parse_obj_as(
|
|
1304
|
+
type_=SuccessResponse, # type: ignore
|
|
1305
|
+
object_=_response.json(),
|
|
1306
|
+
),
|
|
1307
|
+
)
|
|
1308
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1309
|
+
if _response.status_code == 401:
|
|
1310
|
+
raise UnauthorizedError(
|
|
1311
|
+
headers=dict(_response.headers),
|
|
1312
|
+
body=typing.cast(
|
|
1313
|
+
typing.Optional[typing.Any],
|
|
1314
|
+
parse_obj_as(
|
|
1315
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1316
|
+
object_=_response.json(),
|
|
1317
|
+
),
|
|
1318
|
+
),
|
|
1319
|
+
)
|
|
1320
|
+
if _response.status_code == 403:
|
|
1321
|
+
raise ForbiddenError(
|
|
1322
|
+
headers=dict(_response.headers),
|
|
1323
|
+
body=typing.cast(
|
|
1324
|
+
typing.Optional[typing.Any],
|
|
1325
|
+
parse_obj_as(
|
|
1326
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1327
|
+
object_=_response.json(),
|
|
1328
|
+
),
|
|
1329
|
+
),
|
|
1330
|
+
)
|
|
1331
|
+
if _response.status_code == 500:
|
|
1332
|
+
raise InternalServerError(
|
|
1333
|
+
headers=dict(_response.headers),
|
|
1334
|
+
body=typing.cast(
|
|
1335
|
+
typing.Optional[typing.Any],
|
|
1336
|
+
parse_obj_as(
|
|
1337
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1338
|
+
object_=_response.json(),
|
|
1339
|
+
),
|
|
1340
|
+
),
|
|
1341
|
+
)
|
|
1342
|
+
_response_json = _response.json()
|
|
1343
|
+
except JSONDecodeError:
|
|
1344
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1345
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|