Skip to main content

nominal_api/conjure/objects/scout/catalog/
create_dataset.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct CreateDataset {
13    #[builder(into)]
14    #[serde(rename = "name")]
15    name: String,
16    #[builder(
17        default,
18        custom(
19            type = impl
20            Into<Option<super::Handle>>,
21            convert = |v|v.into().map(Box::new)
22        )
23    )]
24    #[serde(rename = "handle", skip_serializing_if = "Option::is_none", default)]
25    handle: Option<Box<super::Handle>>,
26    #[builder(default, map(key(type = String, into), value(type = String, into)))]
27    #[serde(
28        rename = "metadata",
29        skip_serializing_if = "std::collections::BTreeMap::is_empty",
30        default
31    )]
32    metadata: std::collections::BTreeMap<String, String>,
33    #[builder(custom(type = super::DatasetOriginMetadata, convert = Box::new))]
34    #[serde(rename = "originMetadata")]
35    origin_metadata: Box<super::DatasetOriginMetadata>,
36    #[builder(default, set(item(type = String, into)))]
37    #[serde(
38        rename = "labels",
39        skip_serializing_if = "std::collections::BTreeSet::is_empty",
40        default
41    )]
42    labels: std::collections::BTreeSet<String>,
43    #[builder(default, map(key(type = String, into), value(type = String, into)))]
44    #[serde(
45        rename = "properties",
46        skip_serializing_if = "std::collections::BTreeMap::is_empty",
47        default
48    )]
49    properties: std::collections::BTreeMap<String, String>,
50    #[builder(default, into)]
51    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
52    description: Option<String>,
53    #[builder(default, into)]
54    #[serde(rename = "granularity", skip_serializing_if = "Option::is_none", default)]
55    granularity: Option<super::super::super::api::Granularity>,
56    #[builder(default, into)]
57    #[serde(rename = "isV2Dataset", skip_serializing_if = "Option::is_none", default)]
58    is_v2_dataset: Option<bool>,
59    #[builder(default, into)]
60    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
61    workspace: Option<conjure_object::ResourceIdentifier>,
62    #[builder(default, set(item(type = super::super::rids::api::MarkingRid)))]
63    #[serde(
64        rename = "markingRids",
65        skip_serializing_if = "std::collections::BTreeSet::is_empty",
66        default
67    )]
68    marking_rids: std::collections::BTreeSet<super::super::rids::api::MarkingRid>,
69    #[builder(default, into)]
70    #[serde(rename = "datasetType", skip_serializing_if = "Option::is_none", default)]
71    dataset_type: Option<super::DatasetBackingType>,
72    #[builder(
73        default,
74        custom(
75            type = impl
76            Into<Option<super::CreateDerivedDefinition>>,
77            convert = |v|v.into().map(Box::new)
78        )
79    )]
80    #[serde(
81        rename = "derivedDefinition",
82        skip_serializing_if = "Option::is_none",
83        default
84    )]
85    derived_definition: Option<Box<super::CreateDerivedDefinition>>,
86}
87impl CreateDataset {
88    /// Constructs a new instance of the type.
89    #[inline]
90    pub fn new(
91        name: impl Into<String>,
92        origin_metadata: super::DatasetOriginMetadata,
93    ) -> Self {
94        Self::builder().name(name).origin_metadata(origin_metadata).build()
95    }
96    #[inline]
97    pub fn name(&self) -> &str {
98        &*self.name
99    }
100    #[deprecated(
101        note = "Handles should only be specified when adding files to datasets"
102    )]
103    #[inline]
104    pub fn handle(&self) -> Option<&super::Handle> {
105        self.handle.as_ref().map(|o| &**o)
106    }
107    #[deprecated(note = "Deprecated in favor of properties")]
108    #[inline]
109    pub fn metadata(&self) -> &std::collections::BTreeMap<String, String> {
110        &self.metadata
111    }
112    #[inline]
113    pub fn origin_metadata(&self) -> &super::DatasetOriginMetadata {
114        &*self.origin_metadata
115    }
116    #[inline]
117    pub fn labels(&self) -> &std::collections::BTreeSet<String> {
118        &self.labels
119    }
120    #[inline]
121    pub fn properties(&self) -> &std::collections::BTreeMap<String, String> {
122        &self.properties
123    }
124    #[inline]
125    pub fn description(&self) -> Option<&str> {
126        self.description.as_ref().map(|o| &**o)
127    }
128    /// Granularity of dataset timestamps. Defaults to nanoseconds.
129    #[inline]
130    pub fn granularity(&self) -> Option<&super::super::super::api::Granularity> {
131        self.granularity.as_ref().map(|o| &*o)
132    }
133    /// If true, the dataset should be ingested to the v2 tables and is compatible with streaming.
134    #[deprecated(
135        note = "Regardless of what value is specified, this flag is treated as true by the service."
136    )]
137    #[inline]
138    pub fn is_v2_dataset(&self) -> Option<bool> {
139        self.is_v2_dataset.as_ref().map(|o| *o)
140    }
141    /// The workspace in which to create the dataset. If not provided, the dataset will be created in the default workspace for
142    /// the user's organization, if the default workspace for the organization is configured.
143    #[inline]
144    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
145        self.workspace.as_ref().map(|o| &*o)
146    }
147    /// The markings to apply to the created dataset.
148    /// If not provided, the dataset will be visible to all users in the same workspace.
149    #[inline]
150    pub fn marking_rids(
151        &self,
152    ) -> &std::collections::BTreeSet<super::super::rids::api::MarkingRid> {
153        &self.marking_rids
154    }
155    /// The backing dataset type. Defaults to LEGACY type.
156    #[inline]
157    pub fn dataset_type(&self) -> Option<&super::DatasetBackingType> {
158        self.dataset_type.as_ref().map(|o| &*o)
159    }
160    /// Definition for a derived dataset. When present, the created dataset is virtual and does not ingest or
161    /// persist dataset files.
162    #[inline]
163    pub fn derived_definition(&self) -> Option<&super::CreateDerivedDefinition> {
164        self.derived_definition.as_ref().map(|o| &**o)
165    }
166}