Imports

The ImportsClient class provides methods to import files from a connected account into the platform as assets and to review past imports. For the end-to-end workflow, see the Data connectors page.

Methods

Import files

Description: This method imports one or more files from the connected provider account into the platform as assets. Each newly imported file creates an asset in the processing status and is downloaded asynchronously. If you import a file that was already imported through this account, the platform returns the existing asset with its current status, which may be ready, without downloading the file again. The response returns one entry per requested file, in request order.

Function signature and example:

1def import_files(
2 self,
3 connection_id: str,
4 *,
5 items: typing.Sequence[ImportFilesRequestItemsItem],
6 request_options: typing.Optional[RequestOptions] = None,
7) -> ImportResult:

Parameters

NameTypeRequiredDescription
connection_idstrYesThe unique identifier of the connection to import through.
itemstyping.Sequence
[ImportFiles
RequestItemsItem]
YesThe files to import. Provide an array of one item for a single import, or multiple items for a batch import. A maximum of 100 items can be imported per request. Each source_id must be unique within a request.
request_optionstyping.
Optional
[RequestOptions]
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

The ImportFilesRequestItemsItem class contains the following property:

NameTypeRequiredDescription
source_idstrYesThe identifier of the file at the provider. For Google Drive, this is the Drive file identifier.

Return value

Returns an ImportResult object. The ImportResult class contains the following properties:

NameTypeDescription
idstrThe unique identifier of the import created for this request.
has_failuresboolWhether any item was rejected before an asset was created. When true, inspect the error object of each item to identify the rejected ones.
itemstyping.List
[ImportItem]
One entry per requested file, in request order.

The ImportItem class contains the following properties:

NameTypeDescription
source_idstrThe identifier of the file at the provider. For Google Drive, this is the Drive file identifier.
asset_idstrThe unique identifier of the asset created for this file. Absent when the item was rejected before an asset was created.
statusImportItemStatusThe status of the asset. Values: processing, ready, failed. Absent when the item was rejected before an asset was created, in which case an error object is present.
errorImportItemErrorDetails of the rejection. Present when the item was rejected before an asset was created, in which case the status field is absent.

The ImportItemError class contains the following properties:

NameTypeDescription
codestrA string representing the code associated with the error. See the Error codes page for details. Possible values include source_unavailable, source_not_authorized, unsupported_media_type, video_filesize_too_large, audio_filesize_too_large, and media_filesize_too_large.
messagestrA human-readable string describing the error, intended to be suitable for display in a user interface.

API Reference

Import files.

List imports

Description: This method returns a list of the imports for the specified connection. The platform returns the imports sorted by creation date, with the newest at the top of the list. Each import in the list is a summary that omits the items array. To see the status of each file, use the retrieve_import method.

Function signature and example:

1def list_imports(
2 self,
3 connection_id: str,
4 *,
5 page: typing.Optional[int] = None,
6 page_limit: typing.Optional[int] = None,
7 request_options: typing.Optional[RequestOptions] = None,
8) -> ListImportsResponse:

Parameters

NameTypeRequiredDescription
connection_idstrYesThe unique identifier of the connection to list imports for.
pagetyping.
Optional[int]
NoA number that identifies the page to retrieve. Default: 1.
page_limittyping.
Optional[int]
NoThe number of items to return on each page. Default: 10. Max: 50.
request_optionstyping.
Optional
[RequestOptions]
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a ListImportsResponse object. The ListImportsResponse class contains the following properties:

NameTypeDescription
datatyping.List
[Import]
An array containing the imports.
page_infoPageInfoAn object that provides information about pagination. Contains the page, limit_per_page, total_page, and total_results fields.

The Import class contains the following properties:

NameTypeDescription
idstrThe unique identifier of the import.
connection_idstrThe unique identifier of the connection the files were imported through.
providerImportProviderThe data connector provider. Values: google_drive.
custom_idstrThe label you supplied when creating the connection, copied when the import was created. Present only when a value is set for the custom_id field.
item_countintThe number of files requested in this import. If an imported asset is later deleted, it is omitted from the items array in the Retrieve an import response, so the items array can contain fewer entries than item_count.
created_atdatetimeThe date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the import was created.

API Reference

List imports.

Retrieve an import

Description: This method retrieves a single import, including the current status of each asset in the import.

Function signature and example:

1def retrieve_import(
2 self,
3 connection_id: str,
4 import_id: str,
5 *,
6 request_options: typing.Optional[RequestOptions] = None,
7) -> ImportDetail:

Parameters

NameTypeRequiredDescription
connection_idstrYesThe unique identifier of the connection the import belongs to.
import_idstrYesThe unique identifier of the import to retrieve.
request_optionstyping.
Optional
[RequestOptions]
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns an ImportDetail object. The ImportDetail class contains all the properties of the Import object (see List imports), plus the following:

NameTypeDescription
itemstyping.List
[ImportItem]
One entry per imported file, with the current status of its asset. For the properties of each ImportItem object, see Import files.

API Reference

Retrieve an import.