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