aws-sdk-cloudwatchomni 1.2.0

AWS SDK for CloudWatch Omni
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// A telemetry field available for use in query expressions.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Field {
    /// The name of the field. Field names are case-sensitive and must be used exactly as returned when referencing them in query expressions.
    pub name: ::std::string::String,
    /// Child fields nested under this field.
    pub children: ::std::option::Option<::std::vec::Vec<crate::types::Field>>,
}
impl Field {
    /// The name of the field. Field names are case-sensitive and must be used exactly as returned when referencing them in query expressions.
    pub fn name(&self) -> &str {
        use std::ops::Deref;
        self.name.deref()
    }
    /// Child fields nested under this field.
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.children.is_none()`.
    pub fn children(&self) -> &[crate::types::Field] {
        self.children.as_deref().unwrap_or_default()
    }
}
impl Field {
    /// Creates a new builder-style object to manufacture [`Field`](crate::types::Field).
    pub fn builder() -> crate::types::builders::FieldBuilder {
        crate::types::builders::FieldBuilder::default()
    }
}

/// A builder for [`Field`](crate::types::Field).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct FieldBuilder {
    pub(crate) name: ::std::option::Option<::std::string::String>,
    pub(crate) children: ::std::option::Option<::std::vec::Vec<crate::types::Field>>,
}
impl FieldBuilder {
    /// The name of the field. Field names are case-sensitive and must be used exactly as returned when referencing them in query expressions.
    /// This field is required.
    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.name = ::std::option::Option::Some(input.into());
        self
    }
    /// The name of the field. Field names are case-sensitive and must be used exactly as returned when referencing them in query expressions.
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.name = input;
        self
    }
    /// The name of the field. Field names are case-sensitive and must be used exactly as returned when referencing them in query expressions.
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.name
    }
    /// Appends an item to `children`.
    ///
    /// To override the contents of this collection use [`set_children`](Self::set_children).
    ///
    /// Child fields nested under this field.
    pub fn children(mut self, input: crate::types::Field) -> Self {
        let mut v = self.children.unwrap_or_default();
        v.push(input);
        self.children = ::std::option::Option::Some(v);
        self
    }
    /// Child fields nested under this field.
    pub fn set_children(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Field>>) -> Self {
        self.children = input;
        self
    }
    /// Child fields nested under this field.
    pub fn get_children(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Field>> {
        &self.children
    }
    /// Consumes the builder and constructs a [`Field`](crate::types::Field).
    /// This method will fail if any of the following fields are not set:
    /// - [`name`](crate::types::builders::FieldBuilder::name)
    pub fn build(self) -> ::std::result::Result<crate::types::Field, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Field {
            name: self.name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "name",
                    "name was not specified but it is required when building Field",
                )
            })?,
            children: self.children,
        })
    }
}