cognite/dto/data_modeling/instances/extensions/
extractors.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use serde_with::skip_serializing_none;
5
6use crate::models::instances::{InstanceId, NodeOrEdgeCreate};
7
8use super::{
9    common::{CogniteDescribable, CogniteSourceable},
10    CogniteExtendable, WithInstance, WithView,
11};
12
13/// A special data models instance type.
14pub type CogniteExtractorFile = CogniteExtendable<ExtractorFileObject>;
15
16#[skip_serializing_none]
17#[derive(Serialize, Deserialize, Clone, Debug, Default)]
18#[serde(rename_all = "camelCase")]
19/// The properties of the file object.
20pub struct ExtractorFileObject {
21    /// Name of the instance.
22    #[serde(flatten)]
23    pub description: CogniteDescribable,
24    #[serde(flatten)]
25    /// Source system.
26    pub source: CogniteSourceable,
27    /// List of assets to which this file relates.
28    pub assets: Option<Vec<InstanceId>>,
29    /// MIME type of the file.
30    pub mime_type: Option<String>,
31    /// Contains the path elements from the source (for when the source system has a file system
32    /// hierarchy or similar).
33    pub directory: Option<String>,
34    /// Whether the file content has been uploaded to Cognite Data Fusion.
35    pub is_uploaded: Option<bool>,
36    /// Point in time when the file upload was completed and the file was made available.
37    pub uploaded_time: Option<i64>,
38    /// Direct relation to an instance of CogniteFileCategory representing the detected
39    /// categorization/class for the file.
40    pub category: Option<InstanceId>,
41    /// Unstructured information extracted from source system.
42    pub extracted_data: Option<HashMap<String, String>>,
43}
44
45impl ExtractorFileObject {
46    /// Create a new file object.
47    pub fn new() -> ExtractorFileObject {
48        Self {
49            ..Default::default()
50        }
51    }
52}
53
54impl WithView for ExtractorFileObject {
55    const SPACE: &'static str = "cdf_extraction_extensions";
56    const EXTERNAL_ID: &'static str = "CogniteExtractorFile";
57    const VERSION: &'static str = "v1";
58}
59
60impl From<CogniteExtractorFile> for NodeOrEdgeCreate<ExtractorFileObject> {
61    fn from(value: CogniteExtractorFile) -> NodeOrEdgeCreate<ExtractorFileObject> {
62        value.instance()
63    }
64}