Skip to main content

nominal_api/conjure/objects/ingest/api/
csv_opts.rs

1/// Options for ingesting csv files.  Supported file formats include .csv, .csv.gz
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash
12)]
13#[serde(crate = "conjure_object::serde")]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct CsvOpts {
17    #[builder(custom(type = super::IngestSource, convert = Box::new))]
18    #[serde(rename = "source")]
19    source: Box<super::IngestSource>,
20    #[builder(custom(type = super::DatasetIngestTarget, convert = Box::new))]
21    #[serde(rename = "target")]
22    target: Box<super::DatasetIngestTarget>,
23    #[builder(custom(type = super::TimestampMetadata, convert = Box::new))]
24    #[serde(rename = "timestampMetadata")]
25    timestamp_metadata: Box<super::TimestampMetadata>,
26    #[builder(default)]
27    #[serde(rename = "channelPrefix", skip_serializing_if = "Option::is_none", default)]
28    channel_prefix: super::ChannelPrefix,
29    #[builder(default, into)]
30    #[serde(
31        rename = "tagKeysFromColumns",
32        skip_serializing_if = "Option::is_none",
33        default
34    )]
35    tag_keys_from_columns: Option<std::collections::BTreeSet<String>>,
36    #[builder(default, into)]
37    #[serde(rename = "tagColumns", skip_serializing_if = "Option::is_none", default)]
38    tag_columns: Option<std::collections::BTreeMap<String, String>>,
39    #[builder(default, into)]
40    #[serde(
41        rename = "additionalFileTags",
42        skip_serializing_if = "Option::is_none",
43        default
44    )]
45    additional_file_tags: Option<std::collections::BTreeMap<String, String>>,
46    #[builder(default, set(item(type = String, into)))]
47    #[serde(
48        rename = "excludeColumns",
49        skip_serializing_if = "std::collections::BTreeSet::is_empty",
50        default
51    )]
52    exclude_columns: std::collections::BTreeSet<String>,
53}
54impl CsvOpts {
55    /// Constructs a new instance of the type.
56    #[inline]
57    pub fn new(
58        source: super::IngestSource,
59        target: super::DatasetIngestTarget,
60        timestamp_metadata: super::TimestampMetadata,
61    ) -> Self {
62        Self::builder()
63            .source(source)
64            .target(target)
65            .timestamp_metadata(timestamp_metadata)
66            .build()
67    }
68    #[inline]
69    pub fn source(&self) -> &super::IngestSource {
70        &*self.source
71    }
72    #[inline]
73    pub fn target(&self) -> &super::DatasetIngestTarget {
74        &*self.target
75    }
76    #[inline]
77    pub fn timestamp_metadata(&self) -> &super::TimestampMetadata {
78        &*self.timestamp_metadata
79    }
80    #[inline]
81    pub fn channel_prefix(&self) -> &super::ChannelPrefix {
82        &self.channel_prefix
83    }
84    #[deprecated(note = "Deprecated in favor of tagColumns.")]
85    #[inline]
86    pub fn tag_keys_from_columns(&self) -> Option<&std::collections::BTreeSet<String>> {
87        self.tag_keys_from_columns.as_ref().map(|o| &*o)
88    }
89    /// A map of tag names to column names to derive the tag values from.
90    #[inline]
91    pub fn tag_columns(&self) -> Option<&std::collections::BTreeMap<String, String>> {
92        self.tag_columns.as_ref().map(|o| &*o)
93    }
94    /// Specifies a tag set to apply to all data in the file.
95    #[inline]
96    pub fn additional_file_tags(
97        &self,
98    ) -> Option<&std::collections::BTreeMap<String, String>> {
99        self.additional_file_tags.as_ref().map(|o| &*o)
100    }
101    /// A set of column names to exclude from ingestion. These columns will not be
102    /// ingested as channels. Useful for excluding columns that contain unsupported
103    /// data types like multidimensional arrays.
104    #[inline]
105    pub fn exclude_columns(&self) -> &std::collections::BTreeSet<String> {
106        &self.exclude_columns
107    }
108}