|
2 | 2 |
|
3 | 3 | import typing |
4 | 4 |
|
| 5 | +from .. import core |
5 | 6 | from ..common.types.custom_metadata_value import CustomMetadataValue |
6 | 7 | from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
7 | 8 | from ..core.request_options import RequestOptions |
@@ -119,6 +120,88 @@ def upload_document_contents( |
119 | 120 | ) |
120 | 121 | return _response.data |
121 | 122 |
|
| 123 | + def upload_file( |
| 124 | + self, |
| 125 | + *, |
| 126 | + file: core.File, |
| 127 | + upload_as_user_email: str, |
| 128 | + document_external_id: str, |
| 129 | + document_name: typing.Optional[str] = OMIT, |
| 130 | + allowed_users_email_addresses: typing.Optional[str] = OMIT, |
| 131 | + document_external_url: typing.Optional[str] = OMIT, |
| 132 | + custom_metadata: typing.Optional[str] = OMIT, |
| 133 | + collection_id: typing.Optional[str] = OMIT, |
| 134 | + force_update: typing.Optional[str] = OMIT, |
| 135 | + internal_public: typing.Optional[str] = OMIT, |
| 136 | + source_system_updated: typing.Optional[str] = OMIT, |
| 137 | + await_vector_store_sync: typing.Optional[str] = OMIT, |
| 138 | + request_options: typing.Optional[RequestOptions] = None, |
| 139 | + ) -> UploadDocumentResponse: |
| 140 | + """ |
| 141 | + Upload a file (PDF, Word, Excel, CSV, PowerPoint) to Credal. Unlike uploadDocumentContents which requires pre-parsed text, this endpoint accepts actual file uploads and automatically parses them using Credal's parsing service. |
| 142 | +
|
| 143 | + Parameters |
| 144 | + ---------- |
| 145 | + file : core.File |
| 146 | + See core.File for more documentation |
| 147 | +
|
| 148 | + upload_as_user_email : str |
| 149 | + [Legacy] The user on behalf of whom the document should be uploaded. In most cases, this can simply be the email of the developer making the API call. This field will be removed in the future in favor of purely specifying permissions via allowedUsersEmailAddresses. |
| 150 | +
|
| 151 | + document_external_id : str |
| 152 | + The external ID of the document. This is typically the ID as it exists in its original external system. Uploads to the same external ID will update the document in Credal. |
| 153 | +
|
| 154 | + document_name : typing.Optional[str] |
| 155 | + The name of the document you want to upload. If not provided, the original filename will be used. |
| 156 | +
|
| 157 | + allowed_users_email_addresses : typing.Optional[str] |
| 158 | + Users allowed to access the document. Can be provided as a JSON array string (e.g., ["[email protected]","[email protected]"]) or comma-separated list (e.g., "[email protected],[email protected]"). Unlike Credal's out of the box connectors which reconcile various permissions models from 3rd party software, for custom uploads the caller is responsible for specifying who can access the document and currently flattening groups if applicable. Documents can also be marked as internal public. |
| 159 | +
|
| 160 | + document_external_url : typing.Optional[str] |
| 161 | + The external URL of the document you want to upload. If provided Credal will link to this URL. |
| 162 | +
|
| 163 | + custom_metadata : typing.Optional[str] |
| 164 | + Optional JSON string representing any custom metadata for this document (e.g., '{"key1":"value1","key2":"value2"}'). |
| 165 | +
|
| 166 | + collection_id : typing.Optional[str] |
| 167 | + If specified, the document will also be added to the provided document collection. This operation is eventually consistent, meaning the document does not immediately start appearing in searches of that collection due to an asynchronous embedding process. To achieve strong consistency use the `awaitVectorStoreSync` parameter. |
| 168 | +
|
| 169 | + force_update : typing.Optional[str] |
| 170 | + If set to "true", document contents will be re-uploaded and re-embedded even if the document already exists in Credal. |
| 171 | +
|
| 172 | + internal_public : typing.Optional[str] |
| 173 | + If set to "true", document will be accessible to everyone within the organization of the uploader. |
| 174 | +
|
| 175 | + source_system_updated : typing.Optional[str] |
| 176 | + ISO 8601 date string indicating when the document was last updated in the source system (e.g., "2025-11-03T21:15:00Z"). |
| 177 | +
|
| 178 | + await_vector_store_sync : typing.Optional[str] |
| 179 | + Document uploads are eventually consistent by default. If set to "true" the API will wait for the vector store to be updated before returning. This is useful if you want to ensure that the document is immediately searchable after this call returns. |
| 180 | +
|
| 181 | + request_options : typing.Optional[RequestOptions] |
| 182 | + Request-specific configuration. |
| 183 | +
|
| 184 | + Returns |
| 185 | + ------- |
| 186 | + UploadDocumentResponse |
| 187 | + """ |
| 188 | + _response = self._raw_client.upload_file( |
| 189 | + file=file, |
| 190 | + upload_as_user_email=upload_as_user_email, |
| 191 | + document_external_id=document_external_id, |
| 192 | + document_name=document_name, |
| 193 | + allowed_users_email_addresses=allowed_users_email_addresses, |
| 194 | + document_external_url=document_external_url, |
| 195 | + custom_metadata=custom_metadata, |
| 196 | + collection_id=collection_id, |
| 197 | + force_update=force_update, |
| 198 | + internal_public=internal_public, |
| 199 | + source_system_updated=source_system_updated, |
| 200 | + await_vector_store_sync=await_vector_store_sync, |
| 201 | + request_options=request_options, |
| 202 | + ) |
| 203 | + return _response.data |
| 204 | + |
122 | 205 | def sync_source_by_url( |
123 | 206 | self, *, upload_as_user_email: str, source_url: str, request_options: typing.Optional[RequestOptions] = None |
124 | 207 | ) -> SyncSourceByUrlResponse: |
@@ -326,6 +409,88 @@ async def main() -> None: |
326 | 409 | ) |
327 | 410 | return _response.data |
328 | 411 |
|
| 412 | + async def upload_file( |
| 413 | + self, |
| 414 | + *, |
| 415 | + file: core.File, |
| 416 | + upload_as_user_email: str, |
| 417 | + document_external_id: str, |
| 418 | + document_name: typing.Optional[str] = OMIT, |
| 419 | + allowed_users_email_addresses: typing.Optional[str] = OMIT, |
| 420 | + document_external_url: typing.Optional[str] = OMIT, |
| 421 | + custom_metadata: typing.Optional[str] = OMIT, |
| 422 | + collection_id: typing.Optional[str] = OMIT, |
| 423 | + force_update: typing.Optional[str] = OMIT, |
| 424 | + internal_public: typing.Optional[str] = OMIT, |
| 425 | + source_system_updated: typing.Optional[str] = OMIT, |
| 426 | + await_vector_store_sync: typing.Optional[str] = OMIT, |
| 427 | + request_options: typing.Optional[RequestOptions] = None, |
| 428 | + ) -> UploadDocumentResponse: |
| 429 | + """ |
| 430 | + Upload a file (PDF, Word, Excel, CSV, PowerPoint) to Credal. Unlike uploadDocumentContents which requires pre-parsed text, this endpoint accepts actual file uploads and automatically parses them using Credal's parsing service. |
| 431 | +
|
| 432 | + Parameters |
| 433 | + ---------- |
| 434 | + file : core.File |
| 435 | + See core.File for more documentation |
| 436 | +
|
| 437 | + upload_as_user_email : str |
| 438 | + [Legacy] The user on behalf of whom the document should be uploaded. In most cases, this can simply be the email of the developer making the API call. This field will be removed in the future in favor of purely specifying permissions via allowedUsersEmailAddresses. |
| 439 | +
|
| 440 | + document_external_id : str |
| 441 | + The external ID of the document. This is typically the ID as it exists in its original external system. Uploads to the same external ID will update the document in Credal. |
| 442 | +
|
| 443 | + document_name : typing.Optional[str] |
| 444 | + The name of the document you want to upload. If not provided, the original filename will be used. |
| 445 | +
|
| 446 | + allowed_users_email_addresses : typing.Optional[str] |
| 447 | + Users allowed to access the document. Can be provided as a JSON array string (e.g., ["[email protected]","[email protected]"]) or comma-separated list (e.g., "[email protected],[email protected]"). Unlike Credal's out of the box connectors which reconcile various permissions models from 3rd party software, for custom uploads the caller is responsible for specifying who can access the document and currently flattening groups if applicable. Documents can also be marked as internal public. |
| 448 | +
|
| 449 | + document_external_url : typing.Optional[str] |
| 450 | + The external URL of the document you want to upload. If provided Credal will link to this URL. |
| 451 | +
|
| 452 | + custom_metadata : typing.Optional[str] |
| 453 | + Optional JSON string representing any custom metadata for this document (e.g., '{"key1":"value1","key2":"value2"}'). |
| 454 | +
|
| 455 | + collection_id : typing.Optional[str] |
| 456 | + If specified, the document will also be added to the provided document collection. This operation is eventually consistent, meaning the document does not immediately start appearing in searches of that collection due to an asynchronous embedding process. To achieve strong consistency use the `awaitVectorStoreSync` parameter. |
| 457 | +
|
| 458 | + force_update : typing.Optional[str] |
| 459 | + If set to "true", document contents will be re-uploaded and re-embedded even if the document already exists in Credal. |
| 460 | +
|
| 461 | + internal_public : typing.Optional[str] |
| 462 | + If set to "true", document will be accessible to everyone within the organization of the uploader. |
| 463 | +
|
| 464 | + source_system_updated : typing.Optional[str] |
| 465 | + ISO 8601 date string indicating when the document was last updated in the source system (e.g., "2025-11-03T21:15:00Z"). |
| 466 | +
|
| 467 | + await_vector_store_sync : typing.Optional[str] |
| 468 | + Document uploads are eventually consistent by default. If set to "true" the API will wait for the vector store to be updated before returning. This is useful if you want to ensure that the document is immediately searchable after this call returns. |
| 469 | +
|
| 470 | + request_options : typing.Optional[RequestOptions] |
| 471 | + Request-specific configuration. |
| 472 | +
|
| 473 | + Returns |
| 474 | + ------- |
| 475 | + UploadDocumentResponse |
| 476 | + """ |
| 477 | + _response = await self._raw_client.upload_file( |
| 478 | + file=file, |
| 479 | + upload_as_user_email=upload_as_user_email, |
| 480 | + document_external_id=document_external_id, |
| 481 | + document_name=document_name, |
| 482 | + allowed_users_email_addresses=allowed_users_email_addresses, |
| 483 | + document_external_url=document_external_url, |
| 484 | + custom_metadata=custom_metadata, |
| 485 | + collection_id=collection_id, |
| 486 | + force_update=force_update, |
| 487 | + internal_public=internal_public, |
| 488 | + source_system_updated=source_system_updated, |
| 489 | + await_vector_store_sync=await_vector_store_sync, |
| 490 | + request_options=request_options, |
| 491 | + ) |
| 492 | + return _response.data |
| 493 | + |
329 | 494 | async def sync_source_by_url( |
330 | 495 | self, *, upload_as_user_email: str, source_url: str, request_options: typing.Optional[RequestOptions] = None |
331 | 496 | ) -> SyncSourceByUrlResponse: |
|
0 commit comments