Skip to main content

nominal_api_conjure/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 = super::super::super::api::Label)))]
37    #[serde(
38        rename = "labels",
39        skip_serializing_if = "std::collections::BTreeSet::is_empty",
40        default
41    )]
42    labels: std::collections::BTreeSet<super::super::super::api::Label>,
43    #[builder(
44        default,
45        map(
46            key(type = super::super::super::api::PropertyName),
47            value(type = super::super::super::api::PropertyValue)
48        )
49    )]
50    #[serde(
51        rename = "properties",
52        skip_serializing_if = "std::collections::BTreeMap::is_empty",
53        default
54    )]
55    properties: std::collections::BTreeMap<
56        super::super::super::api::PropertyName,
57        super::super::super::api::PropertyValue,
58    >,
59    #[builder(
60        default,
61        map(
62            key(type = super::super::super::api::PropertyName),
63            value(type = super::super::super::api::TypedPropertyValue)
64        )
65    )]
66    #[serde(
67        rename = "typedProperties",
68        skip_serializing_if = "std::collections::BTreeMap::is_empty",
69        default
70    )]
71    typed_properties: std::collections::BTreeMap<
72        super::super::super::api::PropertyName,
73        super::super::super::api::TypedPropertyValue,
74    >,
75    #[builder(default, into)]
76    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
77    description: Option<String>,
78    #[builder(default, into)]
79    #[serde(rename = "granularity", skip_serializing_if = "Option::is_none", default)]
80    granularity: Option<super::super::super::api::Granularity>,
81    #[builder(default, into)]
82    #[serde(rename = "isV2Dataset", skip_serializing_if = "Option::is_none", default)]
83    is_v2_dataset: Option<bool>,
84    #[builder(default, into)]
85    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
86    workspace: Option<super::super::super::api::rids::WorkspaceRid>,
87    #[builder(default, set(item(type = super::super::rids::api::MarkingRid)))]
88    #[serde(
89        rename = "markingRids",
90        skip_serializing_if = "std::collections::BTreeSet::is_empty",
91        default
92    )]
93    marking_rids: std::collections::BTreeSet<super::super::rids::api::MarkingRid>,
94    #[builder(default, into)]
95    #[serde(rename = "datasetType", skip_serializing_if = "Option::is_none", default)]
96    dataset_type: Option<super::DatasetBackingType>,
97    #[builder(
98        default,
99        custom(
100            type = impl
101            Into<Option<super::CreateDerivedDefinition>>,
102            convert = |v|v.into().map(Box::new)
103        )
104    )]
105    #[serde(
106        rename = "derivedDefinition",
107        skip_serializing_if = "Option::is_none",
108        default
109    )]
110    derived_definition: Option<Box<super::CreateDerivedDefinition>>,
111}
112impl CreateDataset {
113    /// Constructs a new instance of the type.
114    #[inline]
115    pub fn new(
116        name: impl Into<String>,
117        origin_metadata: super::DatasetOriginMetadata,
118    ) -> Self {
119        Self::builder().name(name).origin_metadata(origin_metadata).build()
120    }
121    #[inline]
122    pub fn name(&self) -> &str {
123        &*self.name
124    }
125    #[deprecated(
126        note = "Handles should only be specified when adding files to datasets"
127    )]
128    #[inline]
129    pub fn handle(&self) -> Option<&super::Handle> {
130        self.handle.as_ref().map(|o| &**o)
131    }
132    #[deprecated(note = "Deprecated in favor of properties")]
133    #[inline]
134    pub fn metadata(&self) -> &std::collections::BTreeMap<String, String> {
135        &self.metadata
136    }
137    #[inline]
138    pub fn origin_metadata(&self) -> &super::DatasetOriginMetadata {
139        &*self.origin_metadata
140    }
141    #[inline]
142    pub fn labels(
143        &self,
144    ) -> &std::collections::BTreeSet<super::super::super::api::Label> {
145        &self.labels
146    }
147    /// User-defined dataset properties. The UTF-8 JSON serialization must not exceed 2,000 bytes.
148    #[deprecated(note = "use typedProperties")]
149    #[inline]
150    pub fn properties(
151        &self,
152    ) -> &std::collections::BTreeMap<
153        super::super::super::api::PropertyName,
154        super::super::super::api::PropertyValue,
155    > {
156        &self.properties
157    }
158    #[inline]
159    pub fn typed_properties(
160        &self,
161    ) -> &std::collections::BTreeMap<
162        super::super::super::api::PropertyName,
163        super::super::super::api::TypedPropertyValue,
164    > {
165        &self.typed_properties
166    }
167    #[inline]
168    pub fn description(&self) -> Option<&str> {
169        self.description.as_ref().map(|o| &**o)
170    }
171    /// Granularity of dataset timestamps. Defaults to nanoseconds.
172    #[inline]
173    pub fn granularity(&self) -> Option<&super::super::super::api::Granularity> {
174        self.granularity.as_ref().map(|o| &*o)
175    }
176    /// If true, the dataset should be ingested to the v2 tables and is compatible with streaming.
177    #[deprecated(
178        note = "Regardless of what value is specified, this flag is treated as true by the service."
179    )]
180    #[inline]
181    pub fn is_v2_dataset(&self) -> Option<bool> {
182        self.is_v2_dataset.as_ref().map(|o| *o)
183    }
184    /// The workspace in which to create the dataset. If not provided, the dataset will be created in the default workspace for
185    /// the user's organization, if the default workspace for the organization is configured.
186    #[inline]
187    pub fn workspace(&self) -> Option<&super::super::super::api::rids::WorkspaceRid> {
188        self.workspace.as_ref().map(|o| &*o)
189    }
190    /// The markings to apply to the created dataset.
191    /// If not provided, the dataset will be visible to all users in the same workspace.
192    #[inline]
193    pub fn marking_rids(
194        &self,
195    ) -> &std::collections::BTreeSet<super::super::rids::api::MarkingRid> {
196        &self.marking_rids
197    }
198    /// The backing dataset type. Defaults to LEGACY type.
199    #[inline]
200    pub fn dataset_type(&self) -> Option<&super::DatasetBackingType> {
201        self.dataset_type.as_ref().map(|o| &*o)
202    }
203    /// Definition for a derived dataset. When present, the created dataset is virtual and does not ingest or
204    /// persist dataset files.
205    #[inline]
206    pub fn derived_definition(&self) -> Option<&super::CreateDerivedDefinition> {
207        self.derived_definition.as_ref().map(|o| &**o)
208    }
209}