Resource

Struct Resource 

Source
pub struct Resource<T> {
    pub api_client: Arc<ApiClient>,
    /* private fields */
}
Expand description

A resource instance contains methods for accessing a single CDF resource type.

Fields§

§api_client: Arc<ApiClient>

A reference to the shared API Client.

Implementations§

Source§

impl Resource<Asset>

Source

pub async fn retrieve<R>( &self, asset_ids: impl Into<IdentityList<R>>, ignore_unknown_ids: bool, aggregated_properties: Option<Vec<AssetAggregatedProperty>>, ) -> Result<Vec<Asset>>
where IdentityList<R>: Serialize, R: Send + Sync,

Retrieve a list of assets by their IDs.

Will fail if ignore_unknown_ids is false and the assets are not present in CDF.

§Arguments
  • asset_ids - List of IDs or external IDs to retrieve.
  • ignore_unknown_ids - If true, missing assets will be ignored, instead of causing the request to fail.
  • aggregated_properties - List of aggregated properties to include in response.
Source

pub async fn delete<R>( &self, asset_ids: impl Into<IdentityList<R>>, ignore_unknown_ids: bool, recursive: bool, ) -> Result<()>
where IdentityList<R>: Serialize, R: Send + Sync,

Delete a list of assets by their IDs.

Will fail if ignore_unknown_ids is false and the assets are not present in CDF.

§Arguments
  • asset_ids - List of IDs or external IDs to delete.
  • ignore_unknown_ids - If true, missing assets will be ignored, instead of causing the request to fail.
  • recursive - If true, recursively delete any children of the deleted assets.
Source

pub async fn aggregate( &self, aggregate: AssetAggregateRequest, ) -> Result<Vec<AssetAggregateResponse>>

Compute aggregates over assets, such as getting the count of all assets in a project, checking different names and descriptions of assets in your project, etc.

§Arguments
  • aggregate - Aggregate to compute

The returned aggregates depend on which aggregates were requested.

Source§

impl Resource<Event>

Source

pub async fn aggregate( &self, aggregate: EventAggregateRequest, ) -> Result<Vec<EventAggregateResponse>>

Compute aggregates over events, such as getting the count of all events in a project, checking different names and descriptions of events in your project, etc.

§Arguments
  • aggregate - Aggregate to compute

The returned aggregates depend on which aggregates were requested.

Source§

impl Resource<FileMetadata>

Source

pub async fn upload_stream<S>( &self, mime_type: &str, url: &str, stream: S, stream_chunked: bool, ) -> Result<()>
where S: TryStream + Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, Bytes: From<S::Ok>,

Upload a stream to a url, the url is received from Files::upload

§Arguments
  • mime_type - Mime type of file to upload. For example application/pdf.
  • url - URL to upload stream to.
  • stream - Stream to upload.
  • stream_chunked - Set this to true to use chunked streaming. Note that this is not supported for the azure file backend. If this is set to false, the entire file is read into memory before uploading, which may be very expensive. Use upload_stream_known_size if the size of the file is known.
§Example
use tokio_util::codec::{BytesCodec, FramedRead};

let file = tokio::fs::File::open("my-file");
let stream = FramedRead::new(file, BytesCodec::new());
cognite_client.files.upload_stream(&file.mime_type.unwrap(), &file.upload_url, stream, true).await?;

Note that stream_chunked being true is in general more efficient, but it is not supported for the azure file backend.

Source

pub async fn upload_stream_known_size<S>( &self, mime_type: &str, url: &str, stream: S, size: u64, ) -> Result<()>
where S: TryStream + Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, Bytes: From<S::Ok>,

Upload a stream to an url, the url is received from Files::upload This method requires that the length of the stream in bytes is known before hand. If the specified size is wrong, the request may fail or even hang.

§Arguments
  • mime_type - Mime type of file to upload. For example application/pdf.
  • url - URL to upload stream to.
  • stream - Stream to upload.
  • size - Known size of stream in bytes. Note: Do not use this method if the size is not actually known!
§Example
use tokio_util::codec::{BytesCodec, FramedRead};

let file = tokio::fs::File::open("my-file").await?;
let size = file.metadata().await?.len();
let stream = FramedRead::new(file, BytesCodec::new());

cognite_client.files.upload_stream_known_size(&file_res.mime_type.unwrap(), &file_res.extra.upload_url, stream, size).await?;

Note that this will still stream the data from disk, so it should be as efficient as upload_stream with upload_chunked, but not require the target to accept content-encoding: chunked.

Source

pub async fn upload_file( &self, mime_type: &str, url: &str, file: File, ) -> Result<()>

Upload a file as a stream to CDF. url should be the upload URL returned from upload.

§Arguments
  • mime_type - Mime type of file to upload. For example application/pdf.
  • url - URL to upload the file to.
  • file - File to upload.
Source

pub async fn upload_blob( &self, mime_type: &str, url: &str, blob: impl Into<Bytes>, ) -> Result<()>

Upload a binary vector to url.

§Arguments
  • mime_type - Mime type of file to upload. For example application/pdf.
  • url - URL to upload blob to.
  • blob - File to upload, as bytes.
Source

pub async fn upload( &self, overwrite: bool, item: &AddFile, ) -> Result<FileUploadResult<UploadUrl>>

Create a file, optionally overwriting an existing file.

The result will contain an upload URL that can be used to upload a file.

§Arguments
  • overwrite - Set this to true to overwrite existing files with the same external_id. If this is false, and a file with the given external_id already exists, the request will fail.
  • item - The file to upload.

Get an upload link for a file with given identity.

§Arguments

id - Identity of file metadata or data models file.

Get multipart upload link for an existing file metadata or data models file.

§Arguments
  • id - Identity of file metadata or data models file.
  • parts - Number of parts to be uploaded.
Source

pub async fn multipart_upload<'a>( &'a self, overwrite: bool, parts: u32, item: &AddFile, ) -> Result<(MultipartUploader<'a>, FileMetadata)>

Create a file, specifying that it should be uploaded in multiple parts.

This returns a MultipartUploader, which wraps the upload process.

§Arguments
  • overwrite - Set this to true to overwrite existing files with the same external_id. If this is false, and a file with the given external_id already exists, the request will fail.
  • parts - The number of parts to upload, should be a number between 1 and 250.
  • item - The file to upload.
Source

pub async fn multipart_upload_existing<'a>( &'a self, id: &IdentityOrInstance, parts: u32, ) -> Result<(MultipartUploader<'a>, FileMetadata)>

Upload files for an existing file metadata or data models file.

This returns a MultipartUploader, which wraps the upload process.

§Arguments
  • parts - The number of parts to upload, should be a number between 1 and 250.
  • id - Identity of file metadata or data models file.
Source

pub async fn init_multipart_upload( &self, overwrite: bool, parts: u32, item: &AddFile, ) -> Result<FileUploadResult<MultiUploadUrls>>

Create a file, specifying that it should be uploaded in multiple parts.

§Arguments
  • overwrite - Set this to true to overwrite existing files with the same external_id. If this is false, and a file with the given external_id already exists, the request will fail.
  • parts - The number of parts to upload, should be a number between 1 and 250.
  • item - The file to upload.
Source

pub async fn complete_multipart_upload( &self, id: IdentityOrInstance, upload_id: String, ) -> Result<()>

Complete a multipart upload. This endpoint must be called after all parts of a multipart file upload have been uploaded.

§Arguments
  • id - ID of the file that was uploaded.
  • upload_id - upload_id returned by init_multipart_upload.

Get download links for a list of files.

§Arguments
  • ids - List of file IDs or external IDs.
Source

pub async fn download( &self, url: &str, ) -> Result<impl TryStream<Ok = Bytes, Error = Error>>

Stream a file from url.

§Arguments
  • url - URL to download from.
Source

pub async fn download_file( &self, id: IdentityOrInstance, ) -> Result<impl TryStream<Ok = Bytes, Error = Error>>

Stream a file given by id.

§Arguments
  • id - ID or external ID of file to download.
Source§

impl Resource<Sequence>

Source

pub async fn insert_rows(&self, rows: &[InsertSequenceRows]) -> Result<()>

Insert a list of rows into a set of sequences.

§Arguments
  • rows - Sequence row batches to insert.
Source

pub async fn retrieve_rows( &self, query: RetrieveSequenceRows, ) -> Result<RetrieveSequenceRowsResponse>

Retrieve a rows from a set of sequences.

§Arguments
  • query - Sequence rows retrieval query.
Source

pub async fn retrieve_last_row( &self, query: RetrieveLastSequenceRow, ) -> Result<RetrieveSequenceRowsResponse>

Retrieve the last row from a sequence. The last row is the one with the highest row number, not necessarily the one that was ingested the most recently.

§Arguments
  • query - Sequence row retrieval query.
Source

pub async fn delete_rows(&self, query: &[DeleteSequenceRows]) -> Result<()>

Delete rows from a set of sequences.

§Arguments
  • query - Row ranges to delete.
Source§

impl Resource<TimeSeries>

Source

pub async fn insert_datapoints( &self, add_datapoints: Vec<AddDatapoints>, ) -> Result<()>

Insert datapoints for a set of timeseries. Any existing datapoints with the same timestamp will be overwritten.

Note: datapoints are inserted using protobuf, this converts from a slightly more ergonomic type to the protobuf types used directly in insert_datapoints_proto.

For very performance intensive workloads, consider using insert_datapoints_proto directly.

§Arguments
  • add_datapoints - List of datapoint batches to insert.
Source

pub async fn insert_datapoints_proto( &self, add_datapoints: &DataPointInsertionRequest, ) -> Result<()>

Insert datapoints for a set of timeseries. Any existing datapoints with the same timestamp will be overwritten.

§Arguments
  • add_datapoints - Datapoint batches to insert.
Source

pub async fn insert_datapoints_proto_create_missing<T: Iterator<Item = AddDmOrTimeSeries>>( &self, add_datapoints: &DataPointInsertionRequest, generator: &impl Fn(&[IdentityOrInstance]) -> T, ) -> Result<()>

Insert datapoints for a set of time series, then create any missing time series.

In order for this to work correctly, generator must return an iterator over time series with the same length as the passed slice.

§Arguments
  • add_datapoints - Datapoint batches to insert.
  • generator - Method called to produce timeseries that does not exist.
§Example
client.time_series.insert_datapoints_proto_create_missing(
    &dps,
    |idts| idts.iter().map(|idt| AddTimeSeries {
        external_id: idt.as_external_id().unwrap(),
        ..Default::default()
    })
)
Source

pub async fn insert_datapoints_create_missing<T: Iterator<Item = AddDmOrTimeSeries>>( &self, add_datapoints: Vec<AddDatapoints>, generator: &impl Fn(&[IdentityOrInstance]) -> T, ) -> Result<()>

Insert datapoints for a set of time series, then create any missing time series.

In order for this to work correctly, generator must return an iterator over time series with the same length as the passed slice.

§Arguments
  • add_datapoints - Datapoint batches to insert.
  • generator - Method called to produce timeseries that does not exist.
§Example
client.time_series.insert_datapoints_create_missing(
    &dps,
    |idts| idts.iter().map(|idt| AddTimeSeries {
        external_id: idt.as_external_id().unwrap(),
        ..Default::default()
    })
)
Source

pub async fn insert_datapoints_proto_ignore_missing( &self, add_datapoints: &DataPointInsertionRequest, ) -> Result<()>

Insert datapoints for a set of timeseries. If the request fails due to any missing time series, remove them from the request and retry.

§Arguments
  • add_datapoints - Datapoint batches to insert.
Source

pub async fn insert_datapoints_ignore_missing( &self, add_datapoints: Vec<AddDatapoints>, ) -> Result<()>

Insert datapoints for a set of timeseries. If the request fails due to any missing time series, remove them from the request and retry.

§Arguments
  • add_datapoints - Datapoint batches to insert.
Source

pub async fn retrieve_datapoints( &self, datapoints_filter: &DatapointsFilter, ) -> Result<Vec<DatapointsResponse>>

Retrieve datapoints for a collection of time series.

Note: datapoints are inserted using protobuf, this converts to a slightly more ergonomic type from the type returned by retrieve_datapoints_proto.

For very performance intensive workloads, consider using retrieve_datapoints_proto directly.

§Arguments
  • datapoints_filter - Filter describing which datapoints to retrieve.
Source

pub async fn retrieve_datapoints_proto( &self, datapoints_filter: &DatapointsFilter, ) -> Result<DataPointListResponse>

Retrieve datapoints for a collection of time series.

§Arguments
  • datapoints_filter - Filter describing which datapoints to retrieve.
Source

pub async fn retrieve_latest_datapoints( &self, items: &[LatestDatapointsQuery], ignore_unknown_ids: bool, ) -> Result<Vec<LatestDatapointsResponse>>

Retrieve the latest datapoint before a given time for a list of time series.

§Arguments
  • items - Queries for latest datapoint.
  • ignore_unknown_ids - Set this to true to ignore timeseries that do not exist.
Source

pub async fn delete_datapoints( &self, query: &[DeleteDatapointsQuery], ) -> Result<()>

Delete ranges of datapoints for a list of time series.

§Arguments
  • query - Ranges of datapoints to delete.
Source

pub async fn query_synthetic_timeseries( &self, query: &[SyntheticTimeSeriesQuery], ) -> Result<Vec<SyntheticQueryResponse>>

Query synthetic time series. Synthetic time series lets you combine various input time series, constants, and operators, to create completely new time series.

See synthetic timeseries for more details.

§Arguments
  • query - Synthetic datapoints queries.
Source

pub fn stream_datapoints( &self, filter: DatapointsFilter, options: DatapointsStreamOptions, ) -> impl Stream<Item = Result<DataPointRef>> + '_

Stream datapoints for a list of timeseries. The datapoints are returned in ascending order, but we do not guarantee anything on the order between timeseries.

We batch for you, so the items array in DatapointsFilter can contain more than 100 entries, but batch_size should not be set larger than 100.

parallelism controls how many requests we have in-flight at any given time. Avoid setting this too high, as it may lead to rate limiting, which will reduce the actual throughput.

§Arguments
  • filter - Filter describing common filter properties and a list of timeseries to retrieve data from.
  • options - Options for controlling the stream.
Source

pub fn stream_datapoint_batches( &self, filter: DatapointsFilter, options: DatapointsStreamOptions, ) -> impl Stream<Item = Result<DataPointListResponse>> + '_

Stream datapoints for a list of timeseries. This returns raw batches of datapoints as they arrive from CDF. Use stream_datapoints if you want to work with individual datapoints.

We batch for you, so the items array in DatapointsFilter can contain more than 100 entries, but batch_size should not be set larger than 100.

parallelism controls how many requests we have in-flight at any given time. Avoid setting this too high, as it may lead to rate limiting, which will reduce the actual throughput.

§Arguments
  • filter - Filter describing common filter properties and a list of timeseries to retrieve data from.
  • options - Options for controlling the stream.
Source§

impl Resource<RawRow>

Source

pub async fn list_databases( &self, limit: Option<i32>, cursor: Option<String>, ) -> Result<ItemsVec<Database, Cursor>>

List Raw databases in the project.

§Arguments
  • limit - Maximum number of databases to retrieve.
  • cursor - Optional cursor for pagination.
Source

pub async fn create_databases(&self, dbs: &[Database]) -> Result<Vec<Database>>

Create a list of Raw databases.

§Arguments
  • dbs - Databases to create.
Source

pub async fn delete_databases( &self, to_delete: &DeleteDatabasesRequest, ) -> Result<()>

Delete a list of raw databases.

§Arguments
  • to_delete - Request describing which databases to delete and how.
Source

pub async fn list_tables( &self, db_name: &str, limit: Option<i32>, cursor: Option<String>, ) -> Result<ItemsVec<Table, Cursor>>

List tables in a a raw database.

§Arguments
  • db_name - Database to list tables in.
  • limit - Maximum number of tables to retrieve.
  • cursor - Optional cursor for pagination.
Source

pub async fn create_tables( &self, db_name: &str, ensure_parent: bool, tables: &[Table], ) -> Result<Vec<Table>>

Create tables in a raw database.

§Arguments
  • db_name - Database to create tables in.
  • ensure_parent - If this is set to true, create database if it doesn’t already exist.
  • tables - Tables to create.
Source

pub async fn delete_tables( &self, db_name: &str, to_delete: &[Table], ) -> Result<()>

Delete tables in a raw database.

§Arguments
  • db_name - Database to delete tables from.
  • to_delete - Tables to delete.
Source

pub async fn retrieve_cursors_for_parallel_reads( &self, db_name: &str, table_name: &str, params: Option<RetrieveCursorsQuery>, ) -> Result<Vec<String>>

Retrieve cursors for parallel reads. This can be used to efficiently download large volumes of data from a raw table in parallel.

§Arguments
  • db_name - Database to retrieve from.
  • table_name - Table to retrieve from.
  • params - Optional filter parameters.
Source

pub async fn retrieve_rows( &self, db_name: &str, table_name: &str, params: Option<RetrieveRowsQuery>, ) -> Result<ItemsVec<RawRow, Cursor>>

Retrieve rows from a table, with some basic filtering options.

§Arguments
  • db_name - Database to retrieve rows from.
  • table_name - Table to retrieve rows from.
  • params - Optional filter parameters.
Source

pub fn retrieve_all_rows_stream<'a>( &'a self, db_name: &'a str, table_name: &'a str, params: Option<RetrieveRowsQuery>, ) -> impl TryStream<Ok = RawRow, Error = Error, Item = Result<RawRow>> + Send + 'a

Retrieve all rows from a table, following cursors. This returns a stream, you can abort the stream whenever you want and only resources retrieved up to that point will be returned.

Each item in the stream will be a result, after the first error is returned the stream will end.

limit in the filter only affects how many rows are returned per request.

§Arguments
  • db_name - Database to retrieve rows from.
  • table_name - Table to retrieve rows from.
  • params - Optional filter parameters. This can set a cursor to start streaming from there.
Source

pub async fn retrieve_all_rows( &self, db_name: &str, table_name: &str, params: Option<RetrieveRowsQuery>, ) -> Result<Vec<RawRow>>

Retrieve all rows from a table, following cursors.

limit in the filter only affects how many rows are returned per request.

§Arguments
  • db_name - Database to retrieve rows from.
  • table_name - Table to retrieve rows from.
  • params - Optional filter parameters. This can set a cursor to start reading from there.
Source

pub async fn retrieve_all_rows_partitioned( &self, db_name: &str, table_name: &str, params: RetrieveAllPartitionedQuery, ) -> Result<Vec<RawRow>>

Retrieve all rows from a table, following cursors and reading from multiple streams in parallel.

The order of the returned values is not guaranteed to be in any way consistent.

  • db_name - Database to retrieve rows from.
  • table_name - Table to retrieve rows from.
  • params - Optional filter parameters.
Source

pub fn retrieve_all_rows_partitioned_stream<'a>( &'a self, db_name: &'a str, table_name: &'a str, params: RetrieveAllPartitionedQuery, ) -> impl TryStream<Ok = RawRow, Error = Error, Item = Result<RawRow>> + Send + 'a

Retrieve all rows from a table, following cursors and reading from multiple streams in parallel.

The order of the returned values is not guaranteed to be in any way consistent.

  • db_name - Database to retrieve rows from.
  • table_name - Table to retrieve rows from.
  • params - Optional filter parameters.
Source

pub async fn insert_rows( &self, db_name: &str, table_name: &str, ensure_parent: bool, rows: &[RawRowCreate], ) -> Result<()>

Insert rows into a table.

If ensure_parent is true, create the database and/or table if they do not exist.

§Arguments
  • db_name - Database to insert rows into.
  • table_name - Table to insert rows into.
  • ensure_parent - Create database and/or table if they do not exist.
  • rows - Raw rows to create.
Source

pub async fn retrieve_row( &self, db_name: &str, table_name: &str, key: &str, ) -> Result<RawRow>

Retrieve a single row from a raw table.

§Arguments
  • db_name - Database to retrieve from.
  • table_name - Table to retrieve from.
  • key - Key of row to retrieve.
Source

pub async fn delete_rows( &self, db_name: &str, table_name: &str, to_delete: &[DeleteRow], ) -> Result<()>

Delete rows from a raw table.

§Arguments
  • db_name - Database to delete from.
  • table_name - Table to delete from.
  • to_delete - Rows to delete.
Source§

impl Resource<ContainerDefinition>

Source

pub async fn delete_constraints( &self, items: &[ContainerComponentId], ) -> Result<Vec<ContainerComponentId>>

Delete constraints from a container.

§Arguments
  • items - IDs of container constraints to delete.
Source

pub async fn delete_indexes( &self, items: &[ContainerComponentId], ) -> Result<Vec<ContainerComponentId>>

Delete indexes from a container.

§Arguments
  • items - IDs of container indexes to delete.
Source§

impl Resource<SlimNodeOrEdge>

Source

pub async fn filter_with_type_info<TProperties: DeserializeOwned + Send + Sync + 'static>( &self, req: FilterInstancesRequest, ) -> Result<InstancesFilterResponse<TProperties>>

Filter instances optionally returning type information.

§Arguments
  • req - Request with optional filter.
Source

pub async fn query<TProperties: DeserializeOwned + Send + Sync + 'static>( &self, query: QueryInstancesRequest, ) -> Result<QueryInstancesResponse<TProperties>>

Perform a complex query against data models.

§Arguments
  • query - Query to execute.
Source

pub async fn sync<TProperties: DeserializeOwned + Send + Sync + 'static>( &self, query: QueryInstancesRequest, ) -> Result<QueryInstancesResponse<TProperties>>

Perform a complex query against data models. This always returns cursors, so you can keep querying to get any changes since the last query.

§Arguments
  • query - Query to execute.
Source

pub async fn aggregate( &self, req: AggregateInstancesRequest, ) -> Result<AggregateInstancesResponse>

Aggregate nodes and edges.

§Arguments
  • req - Aggregates to compute.
Source

pub async fn search<TProperties: DeserializeOwned + Send + Sync + 'static>( &self, req: SearchInstancesRequest, ) -> Result<NodeAndEdgeRetrieveResponse<TProperties>>

Search nodes and edges.

§Arguments
  • req - Search request.
Source

pub async fn fetch<TEntity, TProperties>( &self, items: &[NodeOrEdgeSpecification], view: Option<&ViewReference>, ) -> Result<Vec<TEntity>>
where TProperties: Serialize + DeserializeOwned + Send + Sync, TEntity: FromReadable<TProperties> + WithView + Send,

Fetch special data models instance collection.

§Arguments
  • items - A list of specifications of node/edges to retrieve.
Source

pub async fn apply<TEntity, TProperties>( &self, col: &[TEntity], auto_create_direct_relations: Option<bool>, auto_create_start_nodes: Option<bool>, auto_create_end_nodes: Option<bool>, skip_on_version_conflict: Option<bool>, replace: bool, ) -> Result<Vec<SlimNodeOrEdge>>
where TProperties: Serialize + DeserializeOwned + Send + Sync, TEntity: Clone + Into<NodeOrEdgeCreate<TProperties>> + Send,

Upsert data models instances of this type.

§Arguments
  • col - A list of this type to be created.
  • auto_create_direct_relation - Whether to auto create direct relation that do no exist.
  • auto_create_start_nodes - Whether to auto create end nodes that do not exist.
  • auto_create_end_nodes - Whether to auto create end nodes that do not exist.
  • skip_on_version_conflict - Whether to skip when a version conflict is encountered.
  • replace - Whether to replace all matching and existing values with the supplied values.
Source§

impl Resource<Record<HashMap<String, RawValue>>>

Source

pub async fn ingest<T: Serialize>( &self, stream_id: &str, records: &[RecordWrite<T>], ) -> Result<()>

Ingest records into a stream.

Note: The maximum total request size is 10 MB.

§Arguments
  • stream_id - ID of the stream to ingest records into.
  • records - Records to ingest.
Source

pub async fn upsert<T: Serialize>( &self, stream_id: &str, records: &[RecordWrite<T>], ) -> Result<()>

Upsert records into a stream.

Note: The maximum total request size is 10 MB.

§Arguments
  • stream_id - ID of the stream to ingest records into.
  • records - Records to ingest.
Source

pub async fn retrieve<T: DeserializeOwned>( &self, stream_id: &str, request: &RecordsRetrieveRequest, ) -> Result<ItemsVec<Record<T>>>

Retrieve records from a stream.

§Arguments
  • stream_id - ID of the stream to retrieve records from.
  • request - Request with optional filter and sort.
Source

pub async fn sync<T: DeserializeOwned>( &self, stream_id: &str, request: &RecordsSyncRequest, ) -> Result<ItemsVec<Record<T>, CursorAndHasNext>>

Subscribe to changes for records from the stream, matching a supplied filter.

§Arguments
  • stream_id - ID of the stream to subscribe to.
  • request - Request with optional filter.
Source

pub async fn delete(&self, stream_id: &str, items: &[ItemId]) -> Result<()>

Delete records from a stream.

§Arguments
  • stream_id - ID of the stream to delete records from.
  • items - IDs of the records to delete.
Source§

impl Resource<Stream>

Source

pub async fn retrieve( &self, stream_id: &str, include_statistics: bool, ) -> Result<Stream>

Retrieve a stream by its ID.

§Arguments
  • stream_id - ID of the stream to retrieve.
Source

pub async fn delete(&self, stream_ids: &[&str]) -> Result<()>

Delete a stream by its ID.

§Arguments
  • stream_ids - IDs of the streams to delete.
Source§

impl Resource<DataSet>

Source

pub async fn count(&self, filter: DataSetFilter) -> Result<DataSetsCount>

Calculate the total number of data sets in the project matching the given filter

§Arguments
  • filter - Optional filter.
Source§

impl Resource<Relationship>

Source

pub async fn retrieve( &self, relationship_ids: &[CogniteExternalId], ignore_unknown_ids: bool, fetch_resources: bool, ) -> Result<Vec<Relationship>>

Retrieve a list of relationships by their ID.

§Arguments
  • relationship_ids - IDs of relationships to retrieve.
  • ignore_unknown_ids - Set this to true to ignore any IDs not found in CDF. If this is false, any missing IDs will cause the request to fail.
  • fetch_resources - Whether to fetch the associated resources along with the relationship itself.
Source§

impl Resource<Session>

Source

pub async fn revoke(&self, session_ids: &[CogniteId]) -> Result<Vec<Session>>

Revoke a list of sessions.

§Arguments
  • session_ids - Sessions to revoke.
Source§

impl<T> Resource<T>

Source

pub fn new(api_client: Arc<ApiClient>) -> Self

Create a new resource with given API client.

§Arguments
  • api_client - API client reference.

Trait Implementations§

Source§

impl<T> Clone for Resource<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Create<ContainerCreate, ContainerDefinition> for Resource<ContainerDefinition>

Source§

fn create( &self, creates: &[TCreate], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources. Read more
Source§

fn create_from( &self, creates: &[impl Into<TCreate> + Sync + Clone], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources, converting from a different type. Read more
Source§

impl Create<DataModelCreate, DataModel> for Resource<DataModel>

Source§

fn create( &self, creates: &[TCreate], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources. Read more
Source§

fn create_from( &self, creates: &[impl Into<TCreate> + Sync + Clone], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources, converting from a different type. Read more
Source§

impl Create<SpaceCreate, Space> for Resource<Space>

Source§

fn create( &self, creates: &[TCreate], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources. Read more
Source§

fn create_from( &self, creates: &[impl Into<TCreate> + Sync + Clone], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources, converting from a different type. Read more
Source§

impl Create<StreamWrite, Stream> for Resource<Stream>

Source§

fn create( &self, creates: &[TCreate], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources. Read more
Source§

fn create_from( &self, creates: &[impl Into<TCreate> + Sync + Clone], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources, converting from a different type. Read more
Source§

impl Create<ViewCreateDefinition, ViewDefinition> for Resource<ViewDefinition>

Source§

fn create( &self, creates: &[TCreate], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources. Read more
Source§

fn create_from( &self, creates: &[impl Into<TCreate> + Sync + Clone], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Create a list of resources, converting from a different type. Read more
Source§

impl DeleteWithResponse<DataModelId, DataModelId> for Resource<DataModel>

Source§

fn delete( &self, deletes: &[TIdt], ) -> impl Future<Output = Result<ItemsVec<TResponse>>> + Send

Delete a list of resources. Read more
Source§

impl DeleteWithResponse<ItemId, ItemId> for Resource<ContainerDefinition>

Source§

fn delete( &self, deletes: &[TIdt], ) -> impl Future<Output = Result<ItemsVec<TResponse>>> + Send

Delete a list of resources. Read more
Source§

impl DeleteWithResponse<NodeOrEdgeSpecification, NodeOrEdgeSpecification> for Resource<SlimNodeOrEdge>

Source§

fn delete( &self, deletes: &[TIdt], ) -> impl Future<Output = Result<ItemsVec<TResponse>>> + Send

Delete a list of resources. Read more
Source§

impl DeleteWithResponse<SpaceId, SpaceId> for Resource<Space>

Source§

fn delete( &self, deletes: &[TIdt], ) -> impl Future<Output = Result<ItemsVec<TResponse>>> + Send

Delete a list of resources. Read more
Source§

impl DeleteWithResponse<ViewReference, ViewReference> for Resource<ViewDefinition>

Source§

fn delete( &self, deletes: &[TIdt], ) -> impl Future<Output = Result<ItemsVec<TResponse>>> + Send

Delete a list of resources. Read more
Source§

impl<TProperties> FilterWithRequest<FilterInstancesRequest, NodeOrEdge<TProperties>> for Resource<SlimNodeOrEdge>
where TProperties: Serialize + DeserializeOwned + Send + Sync,

Source§

fn filter( &self, filter: TFilter, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Filter resources. Read more
Source§

fn filter_all( &self, filter: TFilter, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TFilter: SetCursor, TResponse: Send,

Filter resources, following cursors until they are exhausted. Read more
Source§

fn filter_all_stream( &self, filter: TFilter, ) -> impl TryStream<Ok = TResponse, Error = Error, Item = Result<TResponse>> + Send
where TFilter: SetCursor, TResponse: Send + 'static,

Filter resources, following cursors. This returns a stream, you can abort the stream whenever you want and only resources retrieved up to that point will be returned. Read more
Source§

impl List<ContainerQuery, ContainerDefinition> for Resource<ContainerDefinition>

Source§

fn list( &self, params: Option<TParams>, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Query a resource with optional query parameters. Read more
Source§

fn list_all( &self, params: TParams, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TParams: SetCursor + Clone, TResponse: Send,

Query a resource with query parameters, continuing until the cursor is exhausted. Read more
Source§

fn list_all_stream( &self, params: TParams, ) -> impl TryStream<Ok = TResponse, Error = Error, Item = Result<TResponse>> + Send
where TParams: SetCursor + Clone, TResponse: Send + 'static,

List resources, following cursors. This returns a stream, you can abort the stream whenever you want and only resources retrieved up to that point will be returned. Read more
Source§

impl List<DataModelQuery, DataModel> for Resource<DataModel>

Source§

fn list( &self, params: Option<TParams>, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Query a resource with optional query parameters. Read more
Source§

fn list_all( &self, params: TParams, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TParams: SetCursor + Clone, TResponse: Send,

Query a resource with query parameters, continuing until the cursor is exhausted. Read more
Source§

fn list_all_stream( &self, params: TParams, ) -> impl TryStream<Ok = TResponse, Error = Error, Item = Result<TResponse>> + Send
where TParams: SetCursor + Clone, TResponse: Send + 'static,

List resources, following cursors. This returns a stream, you can abort the stream whenever you want and only resources retrieved up to that point will be returned. Read more
Source§

impl List<LimitCursorQuery, Space> for Resource<Space>

Source§

fn list( &self, params: Option<TParams>, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Query a resource with optional query parameters. Read more
Source§

impl List<ListStreamParams, Stream> for Resource<Stream>

Source§

fn list( &self, params: Option<TParams>, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Query a resource with optional query parameters. Read more
Source§

impl List<ViewQuery, ViewDefinition> for Resource<ViewDefinition>

Source§

fn list( &self, params: Option<TParams>, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Query a resource with optional query parameters. Read more
Source§

fn list_all( &self, params: TParams, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TParams: SetCursor + Clone, TResponse: Send,

Query a resource with query parameters, continuing until the cursor is exhausted. Read more
Source§

fn list_all_stream( &self, params: TParams, ) -> impl TryStream<Ok = TResponse, Error = Error, Item = Result<TResponse>> + Send
where TParams: SetCursor + Clone, TResponse: Send + 'static,

List resources, following cursors. This returns a stream, you can abort the stream whenever you want and only resources retrieved up to that point will be returned. Read more
Source§

impl Retrieve<DataModelId, DataModel> for Resource<DataModel>

Source§

fn retrieve( &self, ids: &[TIdt], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Retrieve a list of items from CDF by id. Read more
Source§

impl Retrieve<ItemId, ContainerDefinition> for Resource<ContainerDefinition>

Source§

fn retrieve( &self, ids: &[TIdt], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Retrieve a list of items from CDF by id. Read more
Source§

impl Retrieve<ItemIdOptionalVersion, ViewDefinition> for Resource<ViewDefinition>

Source§

fn retrieve( &self, ids: &[TIdt], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Retrieve a list of items from CDF by id. Read more
Source§

impl Retrieve<SpaceId, Space> for Resource<Space>

Source§

fn retrieve( &self, ids: &[TIdt], ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Retrieve a list of items from CDF by id. Read more
Source§

impl<TProperties> RetrieveWithRequest<NodeAndEdgeRetrieveRequest, NodeAndEdgeRetrieveResponse<TProperties>> for Resource<SlimNodeOrEdge>
where TProperties: Serialize + DeserializeOwned + Send + Sync,

Source§

fn retrieve( &self, req: &TRequest, ) -> impl Future<Output = Result<TResponse>> + Send

Retrieve items from CDF with a more complex request. Read more
Source§

impl<TProperties> UpsertCollection<NodeAndEdgeCreateCollection<TProperties>, SlimNodeOrEdge> for Resource<SlimNodeOrEdge>

Source§

fn upsert( &self, collection: &TUpsert, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TUpsert: Serialize + Sync + Send, TResponse: Serialize + DeserializeOwned + Sync + Send, Self: WithApiClient + WithBasePath + Sync,

Upsert a list of resources. Read more
Source§

impl<T> WithApiClient for Resource<T>

Source§

fn get_client(&self) -> &ApiClient

Get the API client for this type.
Source§

impl WithBasePath for Resource<ContainerDefinition>

Source§

const BASE_PATH: &'static str = "models/containers"

Base path for this resource type.
Source§

impl WithBasePath for Resource<DataModel>

Source§

const BASE_PATH: &'static str = "models/datamodels"

Base path for this resource type.
Source§

impl WithBasePath for Resource<SlimNodeOrEdge>

Source§

const BASE_PATH: &'static str = "models/instances"

Base path for this resource type.
Source§

impl WithBasePath for Resource<Space>

Source§

const BASE_PATH: &'static str = "models/spaces"

Base path for this resource type.
Source§

impl WithBasePath for Resource<Stream>

Source§

const BASE_PATH: &'static str = "streams"

Base path for this resource type.
Source§

impl WithBasePath for Resource<ViewDefinition>

Source§

const BASE_PATH: &'static str = "models/views"

Base path for this resource type.

Auto Trait Implementations§

§

impl<T> Freeze for Resource<T>

§

impl<T> !RefUnwindSafe for Resource<T>

§

impl<T> Send for Resource<T>
where T: Send,

§

impl<T> Sync for Resource<T>
where T: Sync,

§

impl<T> Unpin for Resource<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Resource<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<TFilter, TResponse, T> FilterWithRequest<Filter<TFilter>, TResponse> for T
where TFilter: Serialize + Sync + Send + 'static, TResponse: Serialize + DeserializeOwned, T: FilterItems<TFilter, TResponse> + WithApiClient + WithBasePath,

Source§

fn filter( &self, filter: TFilter, ) -> impl Future<Output = Result<ItemsVec<TResponse, Cursor>>> + Send

Filter resources. Read more
Source§

fn filter_all( &self, filter: TFilter, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TFilter: SetCursor, TResponse: Send,

Filter resources, following cursors until they are exhausted. Read more
Source§

fn filter_all_stream( &self, filter: TFilter, ) -> impl TryStream<Ok = TResponse, Error = Error, Item = Result<TResponse>> + Send
where TFilter: SetCursor, TResponse: Send + 'static,

Filter resources, following cursors. This returns a stream, you can abort the stream whenever you want and only resources retrieved up to that point will be returned. Read more
Source§

fn filter_all_partitioned( &self, filter: TFilter, num_partitions: u32, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send
where TFilter: SetCursor + WithPartition, TResponse: Send,

Filter resources using partitioned reads, following cursors until all partitions are exhausted. Read more
Source§

fn filter_all_partitioned_stream( &self, filter: TFilter, num_partitions: u32, ) -> impl TryStream<Ok = TResponse, Error = Error, Item = Result<TResponse>> + Send
where TFilter: SetCursor + WithPartition, TResponse: Send + 'static,

Filter resources using partitioned reads, following cursors until all partitions are exhausted. This returns a stream. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoPatchItem<UpdateSet<T>> for T

Source§

fn patch(self, _options: &UpsertOptions) -> Option<UpdateSet<T>>

Convert self into a patch, optionally ignoring null values.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, T, TCreate, TUpdate, TResponse> Upsert<'a, TCreate, TUpdate, TResponse> for T
where T: Create<TCreate, TResponse> + Update<Patch<TUpdate>, TResponse> + Sync, TCreate: Serialize + Sync + Send + EqIdentity + 'a + Clone + IntoPatch<TUpdate>, TUpdate: Serialize + Sync + Send + Default, TResponse: Serialize + DeserializeOwned + Sync + Send,

Source§

fn upsert( &'a self, upserts: &'a [TCreate], options: &UpsertOptions, ) -> impl Future<Output = Result<Vec<TResponse>>> + Send

Upsert a list resources, meaning that they will first be attempted created, and if that fails with a conflict, update any that already existed, and create the remainder. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more