mistralai 1.0.3__py3-none-any.whl → 1.2.0__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.
- mistralai/__init__.py +4 -0
- mistralai/_hooks/sdkhooks.py +23 -4
- mistralai/_hooks/types.py +27 -9
- mistralai/_version.py +12 -0
- mistralai/agents.py +334 -164
- mistralai/basesdk.py +90 -5
- mistralai/batch.py +17 -0
- mistralai/chat.py +316 -166
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +79 -55
- mistralai/files.py +487 -194
- mistralai/fim.py +206 -132
- mistralai/fine_tuning.py +3 -2
- mistralai/jobs.py +392 -263
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +593 -50
- mistralai/models/agentscompletionrequest.py +70 -17
- mistralai/models/agentscompletionstreamrequest.py +72 -17
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +15 -5
- mistralai/models/assistantmessage.py +22 -10
- mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
- mistralai/models/batcherror.py +17 -0
- mistralai/models/batchjobin.py +58 -0
- mistralai/models/batchjobout.py +117 -0
- mistralai/models/batchjobsout.py +30 -0
- mistralai/models/batchjobstatus.py +15 -0
- mistralai/models/chatclassificationrequest.py +104 -0
- mistralai/models/chatcompletionchoice.py +13 -6
- mistralai/models/chatcompletionrequest.py +86 -21
- mistralai/models/chatcompletionresponse.py +8 -4
- mistralai/models/chatcompletionstreamrequest.py +88 -21
- mistralai/models/checkpointout.py +4 -3
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +12 -5
- mistralai/models/completionevent.py +2 -3
- mistralai/models/completionresponsestreamchoice.py +22 -8
- mistralai/models/contentchunk.py +13 -10
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
- mistralai/models/deletefileout.py +4 -3
- mistralai/models/deletemodelout.py +5 -4
- mistralai/models/deltamessage.py +23 -11
- mistralai/models/detailedjobout.py +70 -12
- mistralai/models/embeddingrequest.py +14 -9
- mistralai/models/embeddingresponse.py +7 -3
- mistralai/models/embeddingresponsedata.py +5 -4
- mistralai/models/eventout.py +11 -6
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +5 -5
- mistralai/models/files_api_routes_download_fileop.py +16 -0
- mistralai/models/files_api_routes_list_filesop.py +96 -0
- mistralai/models/files_api_routes_retrieve_fileop.py +5 -5
- mistralai/models/files_api_routes_upload_fileop.py +33 -14
- mistralai/models/fileschema.py +22 -15
- mistralai/models/fimcompletionrequest.py +44 -16
- mistralai/models/fimcompletionresponse.py +8 -4
- mistralai/models/fimcompletionstreamrequest.py +44 -16
- mistralai/models/finetuneablemodel.py +7 -1
- mistralai/models/ftmodelcapabilitiesout.py +6 -4
- mistralai/models/ftmodelcard.py +121 -0
- mistralai/models/ftmodelout.py +39 -9
- mistralai/models/function.py +5 -4
- mistralai/models/functioncall.py +4 -3
- mistralai/models/functionname.py +17 -0
- mistralai/models/githubrepositoryin.py +24 -7
- mistralai/models/githubrepositoryout.py +24 -7
- mistralai/models/httpvalidationerror.py +1 -3
- mistralai/models/imageurl.py +47 -0
- mistralai/models/imageurlchunk.py +38 -0
- mistralai/models/jobin.py +24 -7
- mistralai/models/jobmetadataout.py +32 -8
- mistralai/models/jobout.py +65 -12
- mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
- mistralai/models/jobsout.py +13 -5
- mistralai/models/legacyjobmetadataout.py +55 -9
- mistralai/models/listfilesout.py +7 -3
- mistralai/models/metricout.py +12 -8
- mistralai/models/modelcapabilities.py +9 -4
- mistralai/models/modellist.py +21 -7
- mistralai/models/responseformat.py +7 -8
- mistralai/models/responseformats.py +8 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
- mistralai/models/retrievefileout.py +25 -15
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +14 -5
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +10 -9
- mistralai/models/textchunk.py +14 -5
- mistralai/models/tool.py +10 -9
- mistralai/models/toolcall.py +10 -8
- mistralai/models/toolchoice.py +29 -0
- mistralai/models/toolchoiceenum.py +7 -0
- mistralai/models/toolmessage.py +13 -6
- mistralai/models/tooltypes.py +8 -0
- mistralai/models/trainingfile.py +4 -4
- mistralai/models/trainingparameters.py +34 -8
- mistralai/models/trainingparametersin.py +36 -10
- mistralai/models/unarchiveftmodelout.py +15 -5
- mistralai/models/updateftmodelin.py +9 -6
- mistralai/models/uploadfileout.py +22 -15
- mistralai/models/usageinfo.py +4 -3
- mistralai/models/usermessage.py +42 -10
- mistralai/models/validationerror.py +5 -3
- mistralai/models/wandbintegration.py +23 -7
- mistralai/models/wandbintegrationout.py +23 -8
- mistralai/models_.py +416 -294
- mistralai/sdk.py +31 -19
- mistralai/sdkconfiguration.py +9 -11
- mistralai/utils/__init__.py +14 -1
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/logger.py +4 -1
- mistralai/utils/retries.py +2 -1
- mistralai/utils/security.py +13 -6
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
- mistralai-1.2.0.dist-info/RECORD +276 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_hooks/sdkhooks.py +23 -4
- mistralai_azure/_hooks/types.py +27 -9
- mistralai_azure/_version.py +12 -0
- mistralai_azure/basesdk.py +91 -6
- mistralai_azure/chat.py +308 -166
- mistralai_azure/models/__init__.py +164 -16
- mistralai_azure/models/assistantmessage.py +29 -11
- mistralai_azure/models/chatcompletionchoice.py +15 -6
- mistralai_azure/models/chatcompletionrequest.py +94 -22
- mistralai_azure/models/chatcompletionresponse.py +8 -4
- mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
- mistralai_azure/models/completionchunk.py +12 -5
- mistralai_azure/models/completionevent.py +2 -3
- mistralai_azure/models/completionresponsestreamchoice.py +19 -8
- mistralai_azure/models/contentchunk.py +4 -11
- mistralai_azure/models/deltamessage.py +30 -12
- mistralai_azure/models/function.py +5 -4
- mistralai_azure/models/functioncall.py +4 -3
- mistralai_azure/models/functionname.py +17 -0
- mistralai_azure/models/httpvalidationerror.py +1 -3
- mistralai_azure/models/responseformat.py +7 -8
- mistralai_azure/models/responseformats.py +8 -0
- mistralai_azure/models/security.py +13 -5
- mistralai_azure/models/systemmessage.py +10 -9
- mistralai_azure/models/textchunk.py +14 -5
- mistralai_azure/models/tool.py +10 -9
- mistralai_azure/models/toolcall.py +10 -8
- mistralai_azure/models/toolchoice.py +29 -0
- mistralai_azure/models/toolchoiceenum.py +7 -0
- mistralai_azure/models/toolmessage.py +20 -7
- mistralai_azure/models/tooltypes.py +8 -0
- mistralai_azure/models/usageinfo.py +4 -3
- mistralai_azure/models/usermessage.py +42 -10
- mistralai_azure/models/validationerror.py +5 -3
- mistralai_azure/sdkconfiguration.py +9 -11
- mistralai_azure/utils/__init__.py +16 -3
- mistralai_azure/utils/annotations.py +13 -2
- mistralai_azure/utils/forms.py +10 -9
- mistralai_azure/utils/headers.py +8 -8
- mistralai_azure/utils/logger.py +6 -0
- mistralai_azure/utils/queryparams.py +16 -14
- mistralai_azure/utils/retries.py +2 -1
- mistralai_azure/utils/security.py +12 -6
- mistralai_azure/utils/serializers.py +42 -8
- mistralai_azure/utils/url.py +13 -8
- mistralai_azure/utils/values.py +6 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_hooks/sdkhooks.py +23 -4
- mistralai_gcp/_hooks/types.py +27 -9
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/basesdk.py +91 -6
- mistralai_gcp/chat.py +308 -166
- mistralai_gcp/fim.py +198 -132
- mistralai_gcp/models/__init__.py +186 -18
- mistralai_gcp/models/assistantmessage.py +29 -11
- mistralai_gcp/models/chatcompletionchoice.py +15 -6
- mistralai_gcp/models/chatcompletionrequest.py +91 -22
- mistralai_gcp/models/chatcompletionresponse.py +8 -4
- mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
- mistralai_gcp/models/completionchunk.py +12 -5
- mistralai_gcp/models/completionevent.py +2 -3
- mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
- mistralai_gcp/models/contentchunk.py +4 -11
- mistralai_gcp/models/deltamessage.py +30 -12
- mistralai_gcp/models/fimcompletionrequest.py +51 -17
- mistralai_gcp/models/fimcompletionresponse.py +8 -4
- mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
- mistralai_gcp/models/function.py +5 -4
- mistralai_gcp/models/functioncall.py +4 -3
- mistralai_gcp/models/functionname.py +17 -0
- mistralai_gcp/models/httpvalidationerror.py +1 -3
- mistralai_gcp/models/responseformat.py +7 -8
- mistralai_gcp/models/responseformats.py +8 -0
- mistralai_gcp/models/security.py +13 -5
- mistralai_gcp/models/systemmessage.py +10 -9
- mistralai_gcp/models/textchunk.py +14 -5
- mistralai_gcp/models/tool.py +10 -9
- mistralai_gcp/models/toolcall.py +10 -8
- mistralai_gcp/models/toolchoice.py +29 -0
- mistralai_gcp/models/toolchoiceenum.py +7 -0
- mistralai_gcp/models/toolmessage.py +20 -7
- mistralai_gcp/models/tooltypes.py +8 -0
- mistralai_gcp/models/usageinfo.py +4 -3
- mistralai_gcp/models/usermessage.py +42 -10
- mistralai_gcp/models/validationerror.py +5 -3
- mistralai_gcp/sdk.py +6 -7
- mistralai_gcp/sdkconfiguration.py +9 -11
- mistralai_gcp/utils/__init__.py +16 -3
- mistralai_gcp/utils/annotations.py +13 -2
- mistralai_gcp/utils/forms.py +10 -9
- mistralai_gcp/utils/headers.py +8 -8
- mistralai_gcp/utils/logger.py +6 -0
- mistralai_gcp/utils/queryparams.py +16 -14
- mistralai_gcp/utils/retries.py +2 -1
- mistralai_gcp/utils/security.py +12 -6
- mistralai_gcp/utils/serializers.py +42 -8
- mistralai_gcp/utils/url.py +13 -8
- mistralai_gcp/utils/values.py +6 -0
- mistralai-1.0.3.dist-info/RECORD +0 -236
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
mistralai/files.py
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
|
+
import httpx
|
|
4
5
|
from mistralai import models, utils
|
|
5
6
|
from mistralai._hooks import HookContext
|
|
6
7
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
8
|
from mistralai.utils import get_security_from_env
|
|
8
|
-
from typing import Optional, Union
|
|
9
|
+
from typing import List, Optional, Union
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
class Files(BaseSDK):
|
|
11
13
|
r"""Files API"""
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
def upload(
|
|
15
|
-
self,
|
|
16
|
+
self,
|
|
17
|
+
*,
|
|
16
18
|
file: Union[models.File, models.FileTypedDict],
|
|
19
|
+
purpose: Optional[models.FilePurpose] = None,
|
|
17
20
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
18
21
|
server_url: Optional[str] = None,
|
|
19
22
|
timeout_ms: Optional[int] = None,
|
|
@@ -27,6 +30,7 @@ class Files(BaseSDK):
|
|
|
27
30
|
Please contact us if you need to increase these storage limits.
|
|
28
31
|
|
|
29
32
|
:param file: The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such: ```bash file=@path/to/your/file.jsonl;filename=custom_name.jsonl ``` Otherwise, you can just keep the original file name: ```bash file=@path/to/your/file.jsonl ```
|
|
33
|
+
:param purpose:
|
|
30
34
|
:param retries: Override the default retry configuration for this method
|
|
31
35
|
:param server_url: Override the default server URL for this method
|
|
32
36
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -35,14 +39,15 @@ class Files(BaseSDK):
|
|
|
35
39
|
url_variables = None
|
|
36
40
|
if timeout_ms is None:
|
|
37
41
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
38
|
-
|
|
42
|
+
|
|
39
43
|
if server_url is not None:
|
|
40
44
|
base_url = server_url
|
|
41
|
-
|
|
45
|
+
|
|
42
46
|
request = models.FilesAPIRoutesUploadFileMultiPartBodyParams(
|
|
43
47
|
file=utils.get_pydantic_model(file, models.File),
|
|
48
|
+
purpose=purpose,
|
|
44
49
|
)
|
|
45
|
-
|
|
50
|
+
|
|
46
51
|
req = self.build_request(
|
|
47
52
|
method="POST",
|
|
48
53
|
path="/v1/files",
|
|
@@ -55,44 +60,59 @@ class Files(BaseSDK):
|
|
|
55
60
|
user_agent_header="user-agent",
|
|
56
61
|
accept_header_value="application/json",
|
|
57
62
|
security=self.sdk_configuration.security,
|
|
58
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
63
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
64
|
+
request,
|
|
65
|
+
False,
|
|
66
|
+
False,
|
|
67
|
+
"multipart",
|
|
68
|
+
models.FilesAPIRoutesUploadFileMultiPartBodyParams,
|
|
69
|
+
),
|
|
59
70
|
timeout_ms=timeout_ms,
|
|
60
71
|
)
|
|
61
|
-
|
|
72
|
+
|
|
62
73
|
if retries == UNSET:
|
|
63
74
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
64
75
|
retries = self.sdk_configuration.retry_config
|
|
65
76
|
|
|
66
77
|
retry_config = None
|
|
67
78
|
if isinstance(retries, utils.RetryConfig):
|
|
68
|
-
retry_config = (retries, [
|
|
69
|
-
|
|
70
|
-
"500",
|
|
71
|
-
"502",
|
|
72
|
-
"503",
|
|
73
|
-
"504"
|
|
74
|
-
])
|
|
75
|
-
|
|
79
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
80
|
+
|
|
76
81
|
http_res = self.do_request(
|
|
77
|
-
hook_ctx=HookContext(
|
|
82
|
+
hook_ctx=HookContext(
|
|
83
|
+
operation_id="files_api_routes_upload_file",
|
|
84
|
+
oauth2_scopes=[],
|
|
85
|
+
security_source=get_security_from_env(
|
|
86
|
+
self.sdk_configuration.security, models.Security
|
|
87
|
+
),
|
|
88
|
+
),
|
|
78
89
|
request=req,
|
|
79
|
-
error_status_codes=["4XX","5XX"],
|
|
80
|
-
retry_config=retry_config
|
|
90
|
+
error_status_codes=["4XX", "5XX"],
|
|
91
|
+
retry_config=retry_config,
|
|
81
92
|
)
|
|
82
|
-
|
|
93
|
+
|
|
83
94
|
if utils.match_response(http_res, "200", "application/json"):
|
|
84
95
|
return utils.unmarshal_json(http_res.text, Optional[models.UploadFileOut])
|
|
85
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
97
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
98
|
+
raise models.SDKError(
|
|
99
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
100
|
+
)
|
|
101
|
+
|
|
88
102
|
content_type = http_res.headers.get("Content-Type")
|
|
89
|
-
|
|
103
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
104
|
+
raise models.SDKError(
|
|
105
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
106
|
+
http_res.status_code,
|
|
107
|
+
http_res_text,
|
|
108
|
+
http_res,
|
|
109
|
+
)
|
|
90
110
|
|
|
91
|
-
|
|
92
|
-
|
|
93
111
|
async def upload_async(
|
|
94
|
-
self,
|
|
112
|
+
self,
|
|
113
|
+
*,
|
|
95
114
|
file: Union[models.File, models.FileTypedDict],
|
|
115
|
+
purpose: Optional[models.FilePurpose] = None,
|
|
96
116
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
97
117
|
server_url: Optional[str] = None,
|
|
98
118
|
timeout_ms: Optional[int] = None,
|
|
@@ -106,6 +126,7 @@ class Files(BaseSDK):
|
|
|
106
126
|
Please contact us if you need to increase these storage limits.
|
|
107
127
|
|
|
108
128
|
:param file: The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such: ```bash file=@path/to/your/file.jsonl;filename=custom_name.jsonl ``` Otherwise, you can just keep the original file name: ```bash file=@path/to/your/file.jsonl ```
|
|
129
|
+
:param purpose:
|
|
109
130
|
:param retries: Override the default retry configuration for this method
|
|
110
131
|
:param server_url: Override the default server URL for this method
|
|
111
132
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -114,15 +135,16 @@ class Files(BaseSDK):
|
|
|
114
135
|
url_variables = None
|
|
115
136
|
if timeout_ms is None:
|
|
116
137
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
117
|
-
|
|
138
|
+
|
|
118
139
|
if server_url is not None:
|
|
119
140
|
base_url = server_url
|
|
120
|
-
|
|
141
|
+
|
|
121
142
|
request = models.FilesAPIRoutesUploadFileMultiPartBodyParams(
|
|
122
143
|
file=utils.get_pydantic_model(file, models.File),
|
|
144
|
+
purpose=purpose,
|
|
123
145
|
)
|
|
124
|
-
|
|
125
|
-
req = self.
|
|
146
|
+
|
|
147
|
+
req = self.build_request_async(
|
|
126
148
|
method="POST",
|
|
127
149
|
path="/v1/files",
|
|
128
150
|
base_url=base_url,
|
|
@@ -134,43 +156,63 @@ class Files(BaseSDK):
|
|
|
134
156
|
user_agent_header="user-agent",
|
|
135
157
|
accept_header_value="application/json",
|
|
136
158
|
security=self.sdk_configuration.security,
|
|
137
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
159
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
160
|
+
request,
|
|
161
|
+
False,
|
|
162
|
+
False,
|
|
163
|
+
"multipart",
|
|
164
|
+
models.FilesAPIRoutesUploadFileMultiPartBodyParams,
|
|
165
|
+
),
|
|
138
166
|
timeout_ms=timeout_ms,
|
|
139
167
|
)
|
|
140
|
-
|
|
168
|
+
|
|
141
169
|
if retries == UNSET:
|
|
142
170
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
143
171
|
retries = self.sdk_configuration.retry_config
|
|
144
172
|
|
|
145
173
|
retry_config = None
|
|
146
174
|
if isinstance(retries, utils.RetryConfig):
|
|
147
|
-
retry_config = (retries, [
|
|
148
|
-
|
|
149
|
-
"500",
|
|
150
|
-
"502",
|
|
151
|
-
"503",
|
|
152
|
-
"504"
|
|
153
|
-
])
|
|
154
|
-
|
|
175
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
176
|
+
|
|
155
177
|
http_res = await self.do_request_async(
|
|
156
|
-
hook_ctx=HookContext(
|
|
178
|
+
hook_ctx=HookContext(
|
|
179
|
+
operation_id="files_api_routes_upload_file",
|
|
180
|
+
oauth2_scopes=[],
|
|
181
|
+
security_source=get_security_from_env(
|
|
182
|
+
self.sdk_configuration.security, models.Security
|
|
183
|
+
),
|
|
184
|
+
),
|
|
157
185
|
request=req,
|
|
158
|
-
error_status_codes=["4XX","5XX"],
|
|
159
|
-
retry_config=retry_config
|
|
186
|
+
error_status_codes=["4XX", "5XX"],
|
|
187
|
+
retry_config=retry_config,
|
|
160
188
|
)
|
|
161
|
-
|
|
189
|
+
|
|
162
190
|
if utils.match_response(http_res, "200", "application/json"):
|
|
163
191
|
return utils.unmarshal_json(http_res.text, Optional[models.UploadFileOut])
|
|
164
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
165
|
-
|
|
166
|
-
|
|
192
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
193
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
194
|
+
raise models.SDKError(
|
|
195
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
196
|
+
)
|
|
197
|
+
|
|
167
198
|
content_type = http_res.headers.get("Content-Type")
|
|
168
|
-
|
|
199
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
200
|
+
raise models.SDKError(
|
|
201
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
202
|
+
http_res.status_code,
|
|
203
|
+
http_res_text,
|
|
204
|
+
http_res,
|
|
205
|
+
)
|
|
169
206
|
|
|
170
|
-
|
|
171
|
-
|
|
172
207
|
def list(
|
|
173
|
-
self,
|
|
208
|
+
self,
|
|
209
|
+
*,
|
|
210
|
+
page: Optional[int] = 0,
|
|
211
|
+
page_size: Optional[int] = 100,
|
|
212
|
+
sample_type: OptionalNullable[List[models.SampleType]] = UNSET,
|
|
213
|
+
source: OptionalNullable[List[models.Source]] = UNSET,
|
|
214
|
+
search: OptionalNullable[str] = UNSET,
|
|
215
|
+
purpose: OptionalNullable[models.FilePurpose] = UNSET,
|
|
174
216
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
175
217
|
server_url: Optional[str] = None,
|
|
176
218
|
timeout_ms: Optional[int] = None,
|
|
@@ -179,6 +221,12 @@ class Files(BaseSDK):
|
|
|
179
221
|
|
|
180
222
|
Returns a list of files that belong to the user's organization.
|
|
181
223
|
|
|
224
|
+
:param page:
|
|
225
|
+
:param page_size:
|
|
226
|
+
:param sample_type:
|
|
227
|
+
:param source:
|
|
228
|
+
:param search:
|
|
229
|
+
:param purpose:
|
|
182
230
|
:param retries: Override the default retry configuration for this method
|
|
183
231
|
:param server_url: Override the default server URL for this method
|
|
184
232
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -187,15 +235,25 @@ class Files(BaseSDK):
|
|
|
187
235
|
url_variables = None
|
|
188
236
|
if timeout_ms is None:
|
|
189
237
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
190
|
-
|
|
238
|
+
|
|
191
239
|
if server_url is not None:
|
|
192
240
|
base_url = server_url
|
|
241
|
+
|
|
242
|
+
request = models.FilesAPIRoutesListFilesRequest(
|
|
243
|
+
page=page,
|
|
244
|
+
page_size=page_size,
|
|
245
|
+
sample_type=sample_type,
|
|
246
|
+
source=source,
|
|
247
|
+
search=search,
|
|
248
|
+
purpose=purpose,
|
|
249
|
+
)
|
|
250
|
+
|
|
193
251
|
req = self.build_request(
|
|
194
252
|
method="GET",
|
|
195
253
|
path="/v1/files",
|
|
196
254
|
base_url=base_url,
|
|
197
255
|
url_variables=url_variables,
|
|
198
|
-
request=
|
|
256
|
+
request=request,
|
|
199
257
|
request_body_required=False,
|
|
200
258
|
request_has_path_params=False,
|
|
201
259
|
request_has_query_params=True,
|
|
@@ -204,40 +262,54 @@ class Files(BaseSDK):
|
|
|
204
262
|
security=self.sdk_configuration.security,
|
|
205
263
|
timeout_ms=timeout_ms,
|
|
206
264
|
)
|
|
207
|
-
|
|
265
|
+
|
|
208
266
|
if retries == UNSET:
|
|
209
267
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
210
268
|
retries = self.sdk_configuration.retry_config
|
|
211
269
|
|
|
212
270
|
retry_config = None
|
|
213
271
|
if isinstance(retries, utils.RetryConfig):
|
|
214
|
-
retry_config = (retries, [
|
|
215
|
-
|
|
216
|
-
"500",
|
|
217
|
-
"502",
|
|
218
|
-
"503",
|
|
219
|
-
"504"
|
|
220
|
-
])
|
|
221
|
-
|
|
272
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
273
|
+
|
|
222
274
|
http_res = self.do_request(
|
|
223
|
-
hook_ctx=HookContext(
|
|
275
|
+
hook_ctx=HookContext(
|
|
276
|
+
operation_id="files_api_routes_list_files",
|
|
277
|
+
oauth2_scopes=[],
|
|
278
|
+
security_source=get_security_from_env(
|
|
279
|
+
self.sdk_configuration.security, models.Security
|
|
280
|
+
),
|
|
281
|
+
),
|
|
224
282
|
request=req,
|
|
225
|
-
error_status_codes=["4XX","5XX"],
|
|
226
|
-
retry_config=retry_config
|
|
283
|
+
error_status_codes=["4XX", "5XX"],
|
|
284
|
+
retry_config=retry_config,
|
|
227
285
|
)
|
|
228
|
-
|
|
286
|
+
|
|
229
287
|
if utils.match_response(http_res, "200", "application/json"):
|
|
230
288
|
return utils.unmarshal_json(http_res.text, Optional[models.ListFilesOut])
|
|
231
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
232
|
-
|
|
233
|
-
|
|
289
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
290
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
291
|
+
raise models.SDKError(
|
|
292
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
293
|
+
)
|
|
294
|
+
|
|
234
295
|
content_type = http_res.headers.get("Content-Type")
|
|
235
|
-
|
|
296
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
297
|
+
raise models.SDKError(
|
|
298
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
299
|
+
http_res.status_code,
|
|
300
|
+
http_res_text,
|
|
301
|
+
http_res,
|
|
302
|
+
)
|
|
236
303
|
|
|
237
|
-
|
|
238
|
-
|
|
239
304
|
async def list_async(
|
|
240
|
-
self,
|
|
305
|
+
self,
|
|
306
|
+
*,
|
|
307
|
+
page: Optional[int] = 0,
|
|
308
|
+
page_size: Optional[int] = 100,
|
|
309
|
+
sample_type: OptionalNullable[List[models.SampleType]] = UNSET,
|
|
310
|
+
source: OptionalNullable[List[models.Source]] = UNSET,
|
|
311
|
+
search: OptionalNullable[str] = UNSET,
|
|
312
|
+
purpose: OptionalNullable[models.FilePurpose] = UNSET,
|
|
241
313
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
242
314
|
server_url: Optional[str] = None,
|
|
243
315
|
timeout_ms: Optional[int] = None,
|
|
@@ -246,6 +318,12 @@ class Files(BaseSDK):
|
|
|
246
318
|
|
|
247
319
|
Returns a list of files that belong to the user's organization.
|
|
248
320
|
|
|
321
|
+
:param page:
|
|
322
|
+
:param page_size:
|
|
323
|
+
:param sample_type:
|
|
324
|
+
:param source:
|
|
325
|
+
:param search:
|
|
326
|
+
:param purpose:
|
|
249
327
|
:param retries: Override the default retry configuration for this method
|
|
250
328
|
:param server_url: Override the default server URL for this method
|
|
251
329
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -254,15 +332,25 @@ class Files(BaseSDK):
|
|
|
254
332
|
url_variables = None
|
|
255
333
|
if timeout_ms is None:
|
|
256
334
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
257
|
-
|
|
335
|
+
|
|
258
336
|
if server_url is not None:
|
|
259
337
|
base_url = server_url
|
|
260
|
-
|
|
338
|
+
|
|
339
|
+
request = models.FilesAPIRoutesListFilesRequest(
|
|
340
|
+
page=page,
|
|
341
|
+
page_size=page_size,
|
|
342
|
+
sample_type=sample_type,
|
|
343
|
+
source=source,
|
|
344
|
+
search=search,
|
|
345
|
+
purpose=purpose,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
req = self.build_request_async(
|
|
261
349
|
method="GET",
|
|
262
350
|
path="/v1/files",
|
|
263
351
|
base_url=base_url,
|
|
264
352
|
url_variables=url_variables,
|
|
265
|
-
request=
|
|
353
|
+
request=request,
|
|
266
354
|
request_body_required=False,
|
|
267
355
|
request_has_path_params=False,
|
|
268
356
|
request_has_query_params=True,
|
|
@@ -271,40 +359,48 @@ class Files(BaseSDK):
|
|
|
271
359
|
security=self.sdk_configuration.security,
|
|
272
360
|
timeout_ms=timeout_ms,
|
|
273
361
|
)
|
|
274
|
-
|
|
362
|
+
|
|
275
363
|
if retries == UNSET:
|
|
276
364
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
277
365
|
retries = self.sdk_configuration.retry_config
|
|
278
366
|
|
|
279
367
|
retry_config = None
|
|
280
368
|
if isinstance(retries, utils.RetryConfig):
|
|
281
|
-
retry_config = (retries, [
|
|
282
|
-
|
|
283
|
-
"500",
|
|
284
|
-
"502",
|
|
285
|
-
"503",
|
|
286
|
-
"504"
|
|
287
|
-
])
|
|
288
|
-
|
|
369
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
370
|
+
|
|
289
371
|
http_res = await self.do_request_async(
|
|
290
|
-
hook_ctx=HookContext(
|
|
372
|
+
hook_ctx=HookContext(
|
|
373
|
+
operation_id="files_api_routes_list_files",
|
|
374
|
+
oauth2_scopes=[],
|
|
375
|
+
security_source=get_security_from_env(
|
|
376
|
+
self.sdk_configuration.security, models.Security
|
|
377
|
+
),
|
|
378
|
+
),
|
|
291
379
|
request=req,
|
|
292
|
-
error_status_codes=["4XX","5XX"],
|
|
293
|
-
retry_config=retry_config
|
|
380
|
+
error_status_codes=["4XX", "5XX"],
|
|
381
|
+
retry_config=retry_config,
|
|
294
382
|
)
|
|
295
|
-
|
|
383
|
+
|
|
296
384
|
if utils.match_response(http_res, "200", "application/json"):
|
|
297
385
|
return utils.unmarshal_json(http_res.text, Optional[models.ListFilesOut])
|
|
298
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
299
|
-
|
|
300
|
-
|
|
386
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
387
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
388
|
+
raise models.SDKError(
|
|
389
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
390
|
+
)
|
|
391
|
+
|
|
301
392
|
content_type = http_res.headers.get("Content-Type")
|
|
302
|
-
|
|
393
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
394
|
+
raise models.SDKError(
|
|
395
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
396
|
+
http_res.status_code,
|
|
397
|
+
http_res_text,
|
|
398
|
+
http_res,
|
|
399
|
+
)
|
|
303
400
|
|
|
304
|
-
|
|
305
|
-
|
|
306
401
|
def retrieve(
|
|
307
|
-
self,
|
|
402
|
+
self,
|
|
403
|
+
*,
|
|
308
404
|
file_id: str,
|
|
309
405
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
310
406
|
server_url: Optional[str] = None,
|
|
@@ -314,7 +410,7 @@ class Files(BaseSDK):
|
|
|
314
410
|
|
|
315
411
|
Returns information about a specific file.
|
|
316
412
|
|
|
317
|
-
:param file_id:
|
|
413
|
+
:param file_id:
|
|
318
414
|
:param retries: Override the default retry configuration for this method
|
|
319
415
|
:param server_url: Override the default server URL for this method
|
|
320
416
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -323,14 +419,14 @@ class Files(BaseSDK):
|
|
|
323
419
|
url_variables = None
|
|
324
420
|
if timeout_ms is None:
|
|
325
421
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
326
|
-
|
|
422
|
+
|
|
327
423
|
if server_url is not None:
|
|
328
424
|
base_url = server_url
|
|
329
|
-
|
|
425
|
+
|
|
330
426
|
request = models.FilesAPIRoutesRetrieveFileRequest(
|
|
331
427
|
file_id=file_id,
|
|
332
428
|
)
|
|
333
|
-
|
|
429
|
+
|
|
334
430
|
req = self.build_request(
|
|
335
431
|
method="GET",
|
|
336
432
|
path="/v1/files/{file_id}",
|
|
@@ -345,40 +441,48 @@ class Files(BaseSDK):
|
|
|
345
441
|
security=self.sdk_configuration.security,
|
|
346
442
|
timeout_ms=timeout_ms,
|
|
347
443
|
)
|
|
348
|
-
|
|
444
|
+
|
|
349
445
|
if retries == UNSET:
|
|
350
446
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
351
447
|
retries = self.sdk_configuration.retry_config
|
|
352
448
|
|
|
353
449
|
retry_config = None
|
|
354
450
|
if isinstance(retries, utils.RetryConfig):
|
|
355
|
-
retry_config = (retries, [
|
|
356
|
-
|
|
357
|
-
"500",
|
|
358
|
-
"502",
|
|
359
|
-
"503",
|
|
360
|
-
"504"
|
|
361
|
-
])
|
|
362
|
-
|
|
451
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
452
|
+
|
|
363
453
|
http_res = self.do_request(
|
|
364
|
-
hook_ctx=HookContext(
|
|
454
|
+
hook_ctx=HookContext(
|
|
455
|
+
operation_id="files_api_routes_retrieve_file",
|
|
456
|
+
oauth2_scopes=[],
|
|
457
|
+
security_source=get_security_from_env(
|
|
458
|
+
self.sdk_configuration.security, models.Security
|
|
459
|
+
),
|
|
460
|
+
),
|
|
365
461
|
request=req,
|
|
366
|
-
error_status_codes=["4XX","5XX"],
|
|
367
|
-
retry_config=retry_config
|
|
462
|
+
error_status_codes=["4XX", "5XX"],
|
|
463
|
+
retry_config=retry_config,
|
|
368
464
|
)
|
|
369
|
-
|
|
465
|
+
|
|
370
466
|
if utils.match_response(http_res, "200", "application/json"):
|
|
371
467
|
return utils.unmarshal_json(http_res.text, Optional[models.RetrieveFileOut])
|
|
372
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
373
|
-
|
|
374
|
-
|
|
468
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
469
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
470
|
+
raise models.SDKError(
|
|
471
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
472
|
+
)
|
|
473
|
+
|
|
375
474
|
content_type = http_res.headers.get("Content-Type")
|
|
376
|
-
|
|
475
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
476
|
+
raise models.SDKError(
|
|
477
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
478
|
+
http_res.status_code,
|
|
479
|
+
http_res_text,
|
|
480
|
+
http_res,
|
|
481
|
+
)
|
|
377
482
|
|
|
378
|
-
|
|
379
|
-
|
|
380
483
|
async def retrieve_async(
|
|
381
|
-
self,
|
|
484
|
+
self,
|
|
485
|
+
*,
|
|
382
486
|
file_id: str,
|
|
383
487
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
384
488
|
server_url: Optional[str] = None,
|
|
@@ -388,7 +492,7 @@ class Files(BaseSDK):
|
|
|
388
492
|
|
|
389
493
|
Returns information about a specific file.
|
|
390
494
|
|
|
391
|
-
:param file_id:
|
|
495
|
+
:param file_id:
|
|
392
496
|
:param retries: Override the default retry configuration for this method
|
|
393
497
|
:param server_url: Override the default server URL for this method
|
|
394
498
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -397,15 +501,15 @@ class Files(BaseSDK):
|
|
|
397
501
|
url_variables = None
|
|
398
502
|
if timeout_ms is None:
|
|
399
503
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
400
|
-
|
|
504
|
+
|
|
401
505
|
if server_url is not None:
|
|
402
506
|
base_url = server_url
|
|
403
|
-
|
|
507
|
+
|
|
404
508
|
request = models.FilesAPIRoutesRetrieveFileRequest(
|
|
405
509
|
file_id=file_id,
|
|
406
510
|
)
|
|
407
|
-
|
|
408
|
-
req = self.
|
|
511
|
+
|
|
512
|
+
req = self.build_request_async(
|
|
409
513
|
method="GET",
|
|
410
514
|
path="/v1/files/{file_id}",
|
|
411
515
|
base_url=base_url,
|
|
@@ -419,40 +523,48 @@ class Files(BaseSDK):
|
|
|
419
523
|
security=self.sdk_configuration.security,
|
|
420
524
|
timeout_ms=timeout_ms,
|
|
421
525
|
)
|
|
422
|
-
|
|
526
|
+
|
|
423
527
|
if retries == UNSET:
|
|
424
528
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
425
529
|
retries = self.sdk_configuration.retry_config
|
|
426
530
|
|
|
427
531
|
retry_config = None
|
|
428
532
|
if isinstance(retries, utils.RetryConfig):
|
|
429
|
-
retry_config = (retries, [
|
|
430
|
-
|
|
431
|
-
"500",
|
|
432
|
-
"502",
|
|
433
|
-
"503",
|
|
434
|
-
"504"
|
|
435
|
-
])
|
|
436
|
-
|
|
533
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
534
|
+
|
|
437
535
|
http_res = await self.do_request_async(
|
|
438
|
-
hook_ctx=HookContext(
|
|
536
|
+
hook_ctx=HookContext(
|
|
537
|
+
operation_id="files_api_routes_retrieve_file",
|
|
538
|
+
oauth2_scopes=[],
|
|
539
|
+
security_source=get_security_from_env(
|
|
540
|
+
self.sdk_configuration.security, models.Security
|
|
541
|
+
),
|
|
542
|
+
),
|
|
439
543
|
request=req,
|
|
440
|
-
error_status_codes=["4XX","5XX"],
|
|
441
|
-
retry_config=retry_config
|
|
544
|
+
error_status_codes=["4XX", "5XX"],
|
|
545
|
+
retry_config=retry_config,
|
|
442
546
|
)
|
|
443
|
-
|
|
547
|
+
|
|
444
548
|
if utils.match_response(http_res, "200", "application/json"):
|
|
445
549
|
return utils.unmarshal_json(http_res.text, Optional[models.RetrieveFileOut])
|
|
446
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
447
|
-
|
|
448
|
-
|
|
550
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
551
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
552
|
+
raise models.SDKError(
|
|
553
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
554
|
+
)
|
|
555
|
+
|
|
449
556
|
content_type = http_res.headers.get("Content-Type")
|
|
450
|
-
|
|
557
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
558
|
+
raise models.SDKError(
|
|
559
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
560
|
+
http_res.status_code,
|
|
561
|
+
http_res_text,
|
|
562
|
+
http_res,
|
|
563
|
+
)
|
|
451
564
|
|
|
452
|
-
|
|
453
|
-
|
|
454
565
|
def delete(
|
|
455
|
-
self,
|
|
566
|
+
self,
|
|
567
|
+
*,
|
|
456
568
|
file_id: str,
|
|
457
569
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
458
570
|
server_url: Optional[str] = None,
|
|
@@ -462,7 +574,7 @@ class Files(BaseSDK):
|
|
|
462
574
|
|
|
463
575
|
Delete a file.
|
|
464
576
|
|
|
465
|
-
:param file_id:
|
|
577
|
+
:param file_id:
|
|
466
578
|
:param retries: Override the default retry configuration for this method
|
|
467
579
|
:param server_url: Override the default server URL for this method
|
|
468
580
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -471,14 +583,14 @@ class Files(BaseSDK):
|
|
|
471
583
|
url_variables = None
|
|
472
584
|
if timeout_ms is None:
|
|
473
585
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
474
|
-
|
|
586
|
+
|
|
475
587
|
if server_url is not None:
|
|
476
588
|
base_url = server_url
|
|
477
|
-
|
|
589
|
+
|
|
478
590
|
request = models.FilesAPIRoutesDeleteFileRequest(
|
|
479
591
|
file_id=file_id,
|
|
480
592
|
)
|
|
481
|
-
|
|
593
|
+
|
|
482
594
|
req = self.build_request(
|
|
483
595
|
method="DELETE",
|
|
484
596
|
path="/v1/files/{file_id}",
|
|
@@ -493,40 +605,48 @@ class Files(BaseSDK):
|
|
|
493
605
|
security=self.sdk_configuration.security,
|
|
494
606
|
timeout_ms=timeout_ms,
|
|
495
607
|
)
|
|
496
|
-
|
|
608
|
+
|
|
497
609
|
if retries == UNSET:
|
|
498
610
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
499
611
|
retries = self.sdk_configuration.retry_config
|
|
500
612
|
|
|
501
613
|
retry_config = None
|
|
502
614
|
if isinstance(retries, utils.RetryConfig):
|
|
503
|
-
retry_config = (retries, [
|
|
504
|
-
|
|
505
|
-
"500",
|
|
506
|
-
"502",
|
|
507
|
-
"503",
|
|
508
|
-
"504"
|
|
509
|
-
])
|
|
510
|
-
|
|
615
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
616
|
+
|
|
511
617
|
http_res = self.do_request(
|
|
512
|
-
hook_ctx=HookContext(
|
|
618
|
+
hook_ctx=HookContext(
|
|
619
|
+
operation_id="files_api_routes_delete_file",
|
|
620
|
+
oauth2_scopes=[],
|
|
621
|
+
security_source=get_security_from_env(
|
|
622
|
+
self.sdk_configuration.security, models.Security
|
|
623
|
+
),
|
|
624
|
+
),
|
|
513
625
|
request=req,
|
|
514
|
-
error_status_codes=["4XX","5XX"],
|
|
515
|
-
retry_config=retry_config
|
|
626
|
+
error_status_codes=["4XX", "5XX"],
|
|
627
|
+
retry_config=retry_config,
|
|
516
628
|
)
|
|
517
|
-
|
|
629
|
+
|
|
518
630
|
if utils.match_response(http_res, "200", "application/json"):
|
|
519
631
|
return utils.unmarshal_json(http_res.text, Optional[models.DeleteFileOut])
|
|
520
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
521
|
-
|
|
522
|
-
|
|
632
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
633
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
634
|
+
raise models.SDKError(
|
|
635
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
636
|
+
)
|
|
637
|
+
|
|
523
638
|
content_type = http_res.headers.get("Content-Type")
|
|
524
|
-
|
|
639
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
640
|
+
raise models.SDKError(
|
|
641
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
642
|
+
http_res.status_code,
|
|
643
|
+
http_res_text,
|
|
644
|
+
http_res,
|
|
645
|
+
)
|
|
525
646
|
|
|
526
|
-
|
|
527
|
-
|
|
528
647
|
async def delete_async(
|
|
529
|
-
self,
|
|
648
|
+
self,
|
|
649
|
+
*,
|
|
530
650
|
file_id: str,
|
|
531
651
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
532
652
|
server_url: Optional[str] = None,
|
|
@@ -536,7 +656,7 @@ class Files(BaseSDK):
|
|
|
536
656
|
|
|
537
657
|
Delete a file.
|
|
538
658
|
|
|
539
|
-
:param file_id:
|
|
659
|
+
:param file_id:
|
|
540
660
|
:param retries: Override the default retry configuration for this method
|
|
541
661
|
:param server_url: Override the default server URL for this method
|
|
542
662
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -545,15 +665,15 @@ class Files(BaseSDK):
|
|
|
545
665
|
url_variables = None
|
|
546
666
|
if timeout_ms is None:
|
|
547
667
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
548
|
-
|
|
668
|
+
|
|
549
669
|
if server_url is not None:
|
|
550
670
|
base_url = server_url
|
|
551
|
-
|
|
671
|
+
|
|
552
672
|
request = models.FilesAPIRoutesDeleteFileRequest(
|
|
553
673
|
file_id=file_id,
|
|
554
674
|
)
|
|
555
|
-
|
|
556
|
-
req = self.
|
|
675
|
+
|
|
676
|
+
req = self.build_request_async(
|
|
557
677
|
method="DELETE",
|
|
558
678
|
path="/v1/files/{file_id}",
|
|
559
679
|
base_url=base_url,
|
|
@@ -567,34 +687,207 @@ class Files(BaseSDK):
|
|
|
567
687
|
security=self.sdk_configuration.security,
|
|
568
688
|
timeout_ms=timeout_ms,
|
|
569
689
|
)
|
|
570
|
-
|
|
690
|
+
|
|
571
691
|
if retries == UNSET:
|
|
572
692
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
573
693
|
retries = self.sdk_configuration.retry_config
|
|
574
694
|
|
|
575
695
|
retry_config = None
|
|
576
696
|
if isinstance(retries, utils.RetryConfig):
|
|
577
|
-
retry_config = (retries, [
|
|
578
|
-
|
|
579
|
-
"500",
|
|
580
|
-
"502",
|
|
581
|
-
"503",
|
|
582
|
-
"504"
|
|
583
|
-
])
|
|
584
|
-
|
|
697
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
698
|
+
|
|
585
699
|
http_res = await self.do_request_async(
|
|
586
|
-
hook_ctx=HookContext(
|
|
700
|
+
hook_ctx=HookContext(
|
|
701
|
+
operation_id="files_api_routes_delete_file",
|
|
702
|
+
oauth2_scopes=[],
|
|
703
|
+
security_source=get_security_from_env(
|
|
704
|
+
self.sdk_configuration.security, models.Security
|
|
705
|
+
),
|
|
706
|
+
),
|
|
587
707
|
request=req,
|
|
588
|
-
error_status_codes=["4XX","5XX"],
|
|
589
|
-
retry_config=retry_config
|
|
708
|
+
error_status_codes=["4XX", "5XX"],
|
|
709
|
+
retry_config=retry_config,
|
|
590
710
|
)
|
|
591
|
-
|
|
711
|
+
|
|
592
712
|
if utils.match_response(http_res, "200", "application/json"):
|
|
593
713
|
return utils.unmarshal_json(http_res.text, Optional[models.DeleteFileOut])
|
|
594
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
595
|
-
|
|
596
|
-
|
|
714
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
715
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
716
|
+
raise models.SDKError(
|
|
717
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
718
|
+
)
|
|
719
|
+
|
|
720
|
+
content_type = http_res.headers.get("Content-Type")
|
|
721
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
722
|
+
raise models.SDKError(
|
|
723
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
724
|
+
http_res.status_code,
|
|
725
|
+
http_res_text,
|
|
726
|
+
http_res,
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
def download(
|
|
730
|
+
self,
|
|
731
|
+
*,
|
|
732
|
+
file_id: str,
|
|
733
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
734
|
+
server_url: Optional[str] = None,
|
|
735
|
+
timeout_ms: Optional[int] = None,
|
|
736
|
+
) -> Optional[httpx.Response]:
|
|
737
|
+
r"""Download File
|
|
738
|
+
|
|
739
|
+
Download a file
|
|
740
|
+
|
|
741
|
+
:param file_id:
|
|
742
|
+
:param retries: Override the default retry configuration for this method
|
|
743
|
+
:param server_url: Override the default server URL for this method
|
|
744
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
745
|
+
"""
|
|
746
|
+
base_url = None
|
|
747
|
+
url_variables = None
|
|
748
|
+
if timeout_ms is None:
|
|
749
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
750
|
+
|
|
751
|
+
if server_url is not None:
|
|
752
|
+
base_url = server_url
|
|
753
|
+
|
|
754
|
+
request = models.FilesAPIRoutesDownloadFileRequest(
|
|
755
|
+
file_id=file_id,
|
|
756
|
+
)
|
|
757
|
+
|
|
758
|
+
req = self.build_request(
|
|
759
|
+
method="GET",
|
|
760
|
+
path="/v1/files/{file_id}/content",
|
|
761
|
+
base_url=base_url,
|
|
762
|
+
url_variables=url_variables,
|
|
763
|
+
request=request,
|
|
764
|
+
request_body_required=False,
|
|
765
|
+
request_has_path_params=True,
|
|
766
|
+
request_has_query_params=True,
|
|
767
|
+
user_agent_header="user-agent",
|
|
768
|
+
accept_header_value="application/octet-stream",
|
|
769
|
+
security=self.sdk_configuration.security,
|
|
770
|
+
timeout_ms=timeout_ms,
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
if retries == UNSET:
|
|
774
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
775
|
+
retries = self.sdk_configuration.retry_config
|
|
776
|
+
|
|
777
|
+
retry_config = None
|
|
778
|
+
if isinstance(retries, utils.RetryConfig):
|
|
779
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
780
|
+
|
|
781
|
+
http_res = self.do_request(
|
|
782
|
+
hook_ctx=HookContext(
|
|
783
|
+
operation_id="files_api_routes_download_file",
|
|
784
|
+
oauth2_scopes=[],
|
|
785
|
+
security_source=get_security_from_env(
|
|
786
|
+
self.sdk_configuration.security, models.Security
|
|
787
|
+
),
|
|
788
|
+
),
|
|
789
|
+
request=req,
|
|
790
|
+
error_status_codes=["4XX", "5XX"],
|
|
791
|
+
stream=True,
|
|
792
|
+
retry_config=retry_config,
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
if utils.match_response(http_res, "200", "application/octet-stream"):
|
|
796
|
+
return http_res
|
|
797
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
798
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
799
|
+
raise models.SDKError(
|
|
800
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
801
|
+
)
|
|
802
|
+
|
|
597
803
|
content_type = http_res.headers.get("Content-Type")
|
|
598
|
-
|
|
804
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
805
|
+
raise models.SDKError(
|
|
806
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
807
|
+
http_res.status_code,
|
|
808
|
+
http_res_text,
|
|
809
|
+
http_res,
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
async def download_async(
|
|
813
|
+
self,
|
|
814
|
+
*,
|
|
815
|
+
file_id: str,
|
|
816
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
817
|
+
server_url: Optional[str] = None,
|
|
818
|
+
timeout_ms: Optional[int] = None,
|
|
819
|
+
) -> Optional[httpx.Response]:
|
|
820
|
+
r"""Download File
|
|
599
821
|
|
|
600
|
-
|
|
822
|
+
Download a file
|
|
823
|
+
|
|
824
|
+
:param file_id:
|
|
825
|
+
:param retries: Override the default retry configuration for this method
|
|
826
|
+
:param server_url: Override the default server URL for this method
|
|
827
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
828
|
+
"""
|
|
829
|
+
base_url = None
|
|
830
|
+
url_variables = None
|
|
831
|
+
if timeout_ms is None:
|
|
832
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
833
|
+
|
|
834
|
+
if server_url is not None:
|
|
835
|
+
base_url = server_url
|
|
836
|
+
|
|
837
|
+
request = models.FilesAPIRoutesDownloadFileRequest(
|
|
838
|
+
file_id=file_id,
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
req = self.build_request_async(
|
|
842
|
+
method="GET",
|
|
843
|
+
path="/v1/files/{file_id}/content",
|
|
844
|
+
base_url=base_url,
|
|
845
|
+
url_variables=url_variables,
|
|
846
|
+
request=request,
|
|
847
|
+
request_body_required=False,
|
|
848
|
+
request_has_path_params=True,
|
|
849
|
+
request_has_query_params=True,
|
|
850
|
+
user_agent_header="user-agent",
|
|
851
|
+
accept_header_value="application/octet-stream",
|
|
852
|
+
security=self.sdk_configuration.security,
|
|
853
|
+
timeout_ms=timeout_ms,
|
|
854
|
+
)
|
|
855
|
+
|
|
856
|
+
if retries == UNSET:
|
|
857
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
858
|
+
retries = self.sdk_configuration.retry_config
|
|
859
|
+
|
|
860
|
+
retry_config = None
|
|
861
|
+
if isinstance(retries, utils.RetryConfig):
|
|
862
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
863
|
+
|
|
864
|
+
http_res = await self.do_request_async(
|
|
865
|
+
hook_ctx=HookContext(
|
|
866
|
+
operation_id="files_api_routes_download_file",
|
|
867
|
+
oauth2_scopes=[],
|
|
868
|
+
security_source=get_security_from_env(
|
|
869
|
+
self.sdk_configuration.security, models.Security
|
|
870
|
+
),
|
|
871
|
+
),
|
|
872
|
+
request=req,
|
|
873
|
+
error_status_codes=["4XX", "5XX"],
|
|
874
|
+
stream=True,
|
|
875
|
+
retry_config=retry_config,
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
if utils.match_response(http_res, "200", "application/octet-stream"):
|
|
879
|
+
return http_res
|
|
880
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
881
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
882
|
+
raise models.SDKError(
|
|
883
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
884
|
+
)
|
|
885
|
+
|
|
886
|
+
content_type = http_res.headers.get("Content-Type")
|
|
887
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
888
|
+
raise models.SDKError(
|
|
889
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
890
|
+
http_res.status_code,
|
|
891
|
+
http_res_text,
|
|
892
|
+
http_res,
|
|
893
|
+
)
|