#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash
)]
#[serde(crate = "conjure_object::serde")]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct DataSourceChannel {
    #[builder(custom(type = super::StringConstant, convert = Box::new))]
    #[serde(rename = "dataSourceRid")]
    data_source_rid: Box<super::StringConstant>,
    #[builder(custom(type = super::StringConstant, convert = Box::new))]
    #[serde(rename = "channel")]
    channel: Box<super::StringConstant>,
    #[builder(
        default,
        map(key(type = String, into), value(type = super::StringConstant))
    )]
    #[serde(
        rename = "tags",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    tags: std::collections::BTreeMap<String, super::StringConstant>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::TagFilters>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "tagFilters", skip_serializing_if = "Option::is_none", default)]
    tag_filters: Option<Box<super::TagFilters>>,
    #[builder(default, set(item(type = String, into)))]
    #[serde(
        rename = "tagsToGroupBy",
        skip_serializing_if = "std::collections::BTreeSet::is_empty",
        default
    )]
    tags_to_group_by: std::collections::BTreeSet<String>,
    #[builder(default, set(item(type = super::StringConstant)))]
    #[serde(
        rename = "groupByTags",
        skip_serializing_if = "std::collections::BTreeSet::is_empty",
        default
    )]
    group_by_tags: std::collections::BTreeSet<super::StringConstant>,
}
impl DataSourceChannel {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        data_source_rid: super::StringConstant,
        channel: super::StringConstant,
    ) -> Self {
        Self::builder().data_source_rid(data_source_rid).channel(channel).build()
    }
    #[inline]
    pub fn data_source_rid(&self) -> &super::StringConstant {
        &*self.data_source_rid
    }
    #[inline]
    pub fn channel(&self) -> &super::StringConstant {
        &*self.channel
    }
    #[deprecated(note = "Use tagFilters")]
    #[inline]
    pub fn tags(&self) -> &std::collections::BTreeMap<String, super::StringConstant> {
        &self.tags
    }
    /// Tags to filter the channel by. Only returns points from the channel where tag values match the provided
    /// expression. For log series, include arg filters here in addition to tag filters.
    #[inline]
    pub fn tag_filters(&self) -> Option<&super::TagFilters> {
        self.tag_filters.as_ref().map(|o| &**o)
    }
    #[deprecated(
        note = "Use groupByTags instead. Throws if both tagsToGroupBy and groupByTags are specified.\n"
    )]
    #[inline]
    pub fn tags_to_group_by(&self) -> &std::collections::BTreeSet<String> {
        &self.tags_to_group_by
    }
    /// Tags that the channel should be grouped by. If this is non-empty a grouped result will be returned
    /// with an entry for each grouping. Only one of tagsToGroupBy and groupByTags should be specified.
    #[inline]
    pub fn group_by_tags(&self) -> &std::collections::BTreeSet<super::StringConstant> {
        &self.group_by_tags
    }
}
