cognite/dto/data_organization/
labels.rs

1use serde::{Deserialize, Serialize};
2use serde_with::skip_serializing_none;
3
4use crate::Identity;
5
6#[skip_serializing_none]
7#[derive(Serialize, Deserialize, Debug, Default, Clone)]
8#[serde(rename_all = "camelCase")]
9/// Label, used for labeling CDF resources.
10pub struct Label {
11    /// Label external ID. Must be unique within the project.
12    pub external_id: String,
13    /// Human readable label name.
14    pub name: String,
15    /// Label description.
16    pub description: Option<String>,
17    /// Data set this label belongs to.
18    pub data_set_id: Option<i64>,
19    /// Time this file was created, in milliseconds since epoch.
20    pub created_time: i64,
21}
22
23#[skip_serializing_none]
24#[derive(Serialize, Deserialize, Debug, Default, Clone)]
25#[serde(rename_all = "camelCase")]
26/// Create a label.
27pub struct AddLabel {
28    /// Label external ID. Must be unique within the project.
29    pub external_id: String,
30    /// Human readable label name.
31    pub name: String,
32    /// Label description.
33    pub description: Option<String>,
34    /// Data set this label belongs to.
35    pub data_set_id: Option<i64>,
36}
37
38impl From<Label> for AddLabel {
39    fn from(label: Label) -> Self {
40        AddLabel {
41            external_id: label.external_id,
42            name: label.name,
43            description: label.description,
44            data_set_id: label.data_set_id,
45        }
46    }
47}
48
49#[skip_serializing_none]
50#[derive(Serialize, Deserialize, Debug, Default, Clone)]
51#[serde(rename_all = "camelCase")]
52/// Filter used for listing labels.
53pub struct LabelFilter {
54    /// Include labels with this name.
55    pub name: Option<String>,
56    /// Include labels with this (case sensitive) prefix on external ID.
57    pub external_id_prefix: Option<String>,
58    /// Include labels with one of these data sets.
59    pub data_set_ids: Option<Vec<Identity>>,
60}