List files metadata
- async AsyncCogniteClient.files.list(
- name: str | None = None,
- mime_type: str | None = None,
- metadata: dict[str, str] | None = None,
- asset_ids: Sequence[int] | None = None,
- asset_external_ids: SequenceNotStr[str] | None = None,
- asset_subtree_ids: int | Sequence[int] | None = None,
- asset_subtree_external_ids: str | SequenceNotStr[str] | None = None,
- data_set_ids: int | Sequence[int] | None = None,
- data_set_external_ids: str | SequenceNotStr[str] | None = None,
- labels: LabelFilter | None = None,
- geo_location: GeoLocationFilter | None = None,
- source: str | None = None,
- created_time: dict[str, Any] | TimestampRange | None = None,
- last_updated_time: dict[str, Any] | TimestampRange | None = None,
- source_created_time: dict[str, Any] | TimestampRange | None = None,
- source_modified_time: dict[str, Any] | TimestampRange | None = None,
- uploaded_time: dict[str, Any] | TimestampRange | None = None,
- external_id_prefix: str | None = None,
- directory_prefix: str | None = None,
- uploaded: bool | None = None,
- limit: int | None = 25,
- partitions: int | None = None,
-
- Parameters:
name (str | None) – Name of the file.
mime_type (str | None) – File type. E.g. text/plain, application/pdf, ..
metadata (dict[str, str] | None) – Custom, application specific metadata. String key -> String value
asset_ids (Sequence[int] | None) – Only include files that reference these specific asset IDs.
asset_external_ids (SequenceNotStr[str] | None) – No description.
asset_subtree_ids (int | Sequence[int] | None) – Only include files that have a related asset in a subtree rooted at any of these assetIds. If the total size of the given subtrees exceeds 100,000 assets, an error will be returned.
asset_subtree_external_ids (str | SequenceNotStr[str] | None) – Only include files that have a related asset in a subtree rooted at any of these assetExternalIds. If the total size of the given subtrees exceeds 100,000 assets, an error will be returned.
data_set_ids (int | Sequence[int] | None) – Return only files in the specified data set(s) with this id / these ids.
data_set_external_ids (str | SequenceNotStr[str] | None) – Return only files in the specified data set(s) with this external id / these external ids.
labels (LabelFilter | None) – Return only the files matching the specified label filter(s).
geo_location (GeoLocationFilter | None) – Only include files matching the specified geographic relation.
source (str | None) – The source of this event.
created_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps. Possible keys are min and max, with values given as time stamps in ms.
last_updated_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps. Possible keys are min and max, with values given as time stamps in ms.
source_created_time (dict[str, Any] | TimestampRange | None) – Filter for files where the sourceCreatedTime field has been set and is within the specified range.
source_modified_time (dict[str, Any] | TimestampRange | None) – Filter for files where the sourceModifiedTime field has been set and is within the specified range.
uploaded_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps
external_id_prefix (str | None) – External Id provided by client. Should be unique within the project.
directory_prefix (str | None) – Filter by this (case-sensitive) prefix for the directory provided by the client.
uploaded (bool | None) – Whether or not the actual file is uploaded. This field is returned only by the API, it has no effect in a post body.
limit (int | None) – Max number of files to return. Defaults to 25. Set to -1, float(“inf”) or None to return all items.
partitions (int | None) – Retrieve resources in parallel using this number of workers (values up to 10 allowed), limit must be set to None (or -1).
- Returns:
The requested files.
- Return type:
Examples
List files metadata and filter on external id prefix:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> file_list = client.files.list(limit=5, external_id_prefix="prefix")
Iterate over files metadata, one-by-one:
>>> for file_metadata in client.files(): ... file_metadata # do something with the file metadata
Iterate over chunks of files metadata to reduce memory load:
>>> for file_list in client.files(chunk_size=2500): ... file_list # do something with the files
Filter files based on labels:
>>> from cognite.client.data_classes import LabelFilter >>> my_label_filter = LabelFilter(contains_all=["WELL LOG", "VERIFIED"]) >>> file_list = client.files.list(labels=my_label_filter)
Filter files based on geoLocation:
>>> from cognite.client.data_classes import GeoLocationFilter, GeometryFilter >>> my_geo_location_filter = GeoLocationFilter( ... relation="intersects", shape=GeometryFilter(type="Point", coordinates=[35, 10]) ... ) >>> file_list = client.files.list(geo_location=my_geo_location_filter)