Skip to main content

nominal_api_conjure/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, map(key(type = String, into), value(type = String, into)))]
30    #[serde(
31        rename = "channelNameOverrides",
32        skip_serializing_if = "std::collections::BTreeMap::is_empty",
33        default
34    )]
35    channel_name_overrides: std::collections::BTreeMap<String, String>,
36    #[builder(default, into)]
37    #[serde(
38        rename = "tagKeysFromColumns",
39        skip_serializing_if = "Option::is_none",
40        default
41    )]
42    tag_keys_from_columns: Option<std::collections::BTreeSet<String>>,
43    #[builder(default, into)]
44    #[serde(rename = "tagColumns", skip_serializing_if = "Option::is_none", default)]
45    tag_columns: Option<std::collections::BTreeMap<String, String>>,
46    #[builder(default, into)]
47    #[serde(
48        rename = "additionalFileTags",
49        skip_serializing_if = "Option::is_none",
50        default
51    )]
52    additional_file_tags: Option<std::collections::BTreeMap<String, String>>,
53    #[builder(default, set(item(type = String, into)))]
54    #[serde(
55        rename = "excludeColumns",
56        skip_serializing_if = "std::collections::BTreeSet::is_empty",
57        default
58    )]
59    exclude_columns: std::collections::BTreeSet<String>,
60}
61impl CsvOpts {
62    /// Constructs a new instance of the type.
63    #[inline]
64    pub fn new(
65        source: super::IngestSource,
66        target: super::DatasetIngestTarget,
67        timestamp_metadata: super::TimestampMetadata,
68    ) -> Self {
69        Self::builder()
70            .source(source)
71            .target(target)
72            .timestamp_metadata(timestamp_metadata)
73            .build()
74    }
75    #[inline]
76    pub fn source(&self) -> &super::IngestSource {
77        &*self.source
78    }
79    #[inline]
80    pub fn target(&self) -> &super::DatasetIngestTarget {
81        &*self.target
82    }
83    #[inline]
84    pub fn timestamp_metadata(&self) -> &super::TimestampMetadata {
85        &*self.timestamp_metadata
86    }
87    #[inline]
88    pub fn channel_prefix(&self) -> &super::ChannelPrefix {
89        &self.channel_prefix
90    }
91    #[inline]
92    pub fn channel_name_overrides(&self) -> &std::collections::BTreeMap<String, String> {
93        &self.channel_name_overrides
94    }
95    #[deprecated(note = "Deprecated in favor of tagColumns.")]
96    #[inline]
97    pub fn tag_keys_from_columns(&self) -> Option<&std::collections::BTreeSet<String>> {
98        self.tag_keys_from_columns.as_ref().map(|o| &*o)
99    }
100    /// A map of tag names to column names to derive the tag values from.
101    #[inline]
102    pub fn tag_columns(&self) -> Option<&std::collections::BTreeMap<String, String>> {
103        self.tag_columns.as_ref().map(|o| &*o)
104    }
105    /// Specifies a tag set to apply to all data in the file.
106    #[inline]
107    pub fn additional_file_tags(
108        &self,
109    ) -> Option<&std::collections::BTreeMap<String, String>> {
110        self.additional_file_tags.as_ref().map(|o| &*o)
111    }
112    /// A set of column names to exclude from ingestion. These columns will not be
113    /// ingested as channels. Useful for excluding columns that contain unsupported
114    /// data types like multidimensional arrays.
115    #[inline]
116    pub fn exclude_columns(&self) -> &std::collections::BTreeSet<String> {
117        &self.exclude_columns
118    }
119}