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.

/// Full alert entity, returned by both CreateAlert and GetAlert. A create and a read of the same alert describe it identically except for {@code state}, which only the read paths populate. UpdateAlert returns an empty response.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Alert {
    /// The name of the alert.
    pub name: ::std::string::String,
    /// The stable alert identifier (see {@link AlertId}), minted on create and immutable across updates. Use it (not {@code name}) to address the alert on GetAlert/UpdateAlert/DeleteAlert; it is also the ARN's resource id.
    pub alert_id: ::std::option::Option<::std::string::String>,
    /// An optional description of the alert.
    pub description: ::std::option::Option<::std::string::String>,
    /// The AWS account ID that owns the alert.
    pub account_id: ::std::string::String,
    /// The ID of the space the alert belongs to.
    pub space_id: ::std::option::Option<::std::string::String>,
    /// The ID of the access profile associated with the alert.
    pub profile_id: ::std::option::Option<::std::string::String>,
    /// The rule that defines how the alert is evaluated.
    pub rule: ::std::option::Option<crate::types::Rule>,
    /// Whether notifications are enabled.
    pub notification_status: ::std::option::Option<crate::types::NotificationStatus>,
    /// Live evaluation state (read-only, system-managed). Populated by GetAlert. ListAlerts reports state on `AlertSummary` instead, where it stays required. Absent on CreateAlert: a newly created alert has never been evaluated, so any state reported there would be a default rather than an observation. Call GetAlert for live state. Not @required for that reason — GetAlert always populates it. `contributorSummary` is nested inside this member, so it too is absent on CreateAlert.
    pub state: ::std::option::Option<crate::types::AlertStateInfo>,
    /// The notification rules for the alert.
    pub notification_rules: ::std::option::Option<::std::vec::Vec<crate::types::NotificationRule>>,
    /// The timestamp when the alert was created.
    pub created_at: ::aws_smithy_types::DateTime,
    /// The timestamp when the alert was last updated.
    pub updated_at: ::aws_smithy_types::DateTime,
    /// The Amazon Resource Name (ARN) of the alert.
    pub alert_arn: ::std::string::String,
}
impl Alert {
    /// The name of the alert.
    pub fn name(&self) -> &str {
        use std::ops::Deref;
        self.name.deref()
    }
    /// The stable alert identifier (see {@link AlertId}), minted on create and immutable across updates. Use it (not {@code name}) to address the alert on GetAlert/UpdateAlert/DeleteAlert; it is also the ARN's resource id.
    pub fn alert_id(&self) -> ::std::option::Option<&str> {
        self.alert_id.as_deref()
    }
    /// An optional description of the alert.
    pub fn description(&self) -> ::std::option::Option<&str> {
        self.description.as_deref()
    }
    /// The AWS account ID that owns the alert.
    pub fn account_id(&self) -> &str {
        use std::ops::Deref;
        self.account_id.deref()
    }
    /// The ID of the space the alert belongs to.
    pub fn space_id(&self) -> ::std::option::Option<&str> {
        self.space_id.as_deref()
    }
    /// The ID of the access profile associated with the alert.
    pub fn profile_id(&self) -> ::std::option::Option<&str> {
        self.profile_id.as_deref()
    }
    /// The rule that defines how the alert is evaluated.
    pub fn rule(&self) -> ::std::option::Option<&crate::types::Rule> {
        self.rule.as_ref()
    }
    /// Whether notifications are enabled.
    pub fn notification_status(&self) -> ::std::option::Option<&crate::types::NotificationStatus> {
        self.notification_status.as_ref()
    }
    /// Live evaluation state (read-only, system-managed). Populated by GetAlert. ListAlerts reports state on `AlertSummary` instead, where it stays required. Absent on CreateAlert: a newly created alert has never been evaluated, so any state reported there would be a default rather than an observation. Call GetAlert for live state. Not @required for that reason — GetAlert always populates it. `contributorSummary` is nested inside this member, so it too is absent on CreateAlert.
    pub fn state(&self) -> ::std::option::Option<&crate::types::AlertStateInfo> {
        self.state.as_ref()
    }
    /// The notification rules for the alert.
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.notification_rules.is_none()`.
    pub fn notification_rules(&self) -> &[crate::types::NotificationRule] {
        self.notification_rules.as_deref().unwrap_or_default()
    }
    /// The timestamp when the alert was created.
    pub fn created_at(&self) -> &::aws_smithy_types::DateTime {
        &self.created_at
    }
    /// The timestamp when the alert was last updated.
    pub fn updated_at(&self) -> &::aws_smithy_types::DateTime {
        &self.updated_at
    }
    /// The Amazon Resource Name (ARN) of the alert.
    pub fn alert_arn(&self) -> &str {
        use std::ops::Deref;
        self.alert_arn.deref()
    }
}
impl Alert {
    /// Creates a new builder-style object to manufacture [`Alert`](crate::types::Alert).
    pub fn builder() -> crate::types::builders::AlertBuilder {
        crate::types::builders::AlertBuilder::default()
    }
}

/// A builder for [`Alert`](crate::types::Alert).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct AlertBuilder {
    pub(crate) name: ::std::option::Option<::std::string::String>,
    pub(crate) alert_id: ::std::option::Option<::std::string::String>,
    pub(crate) description: ::std::option::Option<::std::string::String>,
    pub(crate) account_id: ::std::option::Option<::std::string::String>,
    pub(crate) space_id: ::std::option::Option<::std::string::String>,
    pub(crate) profile_id: ::std::option::Option<::std::string::String>,
    pub(crate) rule: ::std::option::Option<crate::types::Rule>,
    pub(crate) notification_status: ::std::option::Option<crate::types::NotificationStatus>,
    pub(crate) state: ::std::option::Option<crate::types::AlertStateInfo>,
    pub(crate) notification_rules: ::std::option::Option<::std::vec::Vec<crate::types::NotificationRule>>,
    pub(crate) created_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) updated_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) alert_arn: ::std::option::Option<::std::string::String>,
}
impl AlertBuilder {
    /// The name of the alert.
    /// 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 alert.
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.name = input;
        self
    }
    /// The name of the alert.
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.name
    }
    /// The stable alert identifier (see {@link AlertId}), minted on create and immutable across updates. Use it (not {@code name}) to address the alert on GetAlert/UpdateAlert/DeleteAlert; it is also the ARN's resource id.
    pub fn alert_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.alert_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The stable alert identifier (see {@link AlertId}), minted on create and immutable across updates. Use it (not {@code name}) to address the alert on GetAlert/UpdateAlert/DeleteAlert; it is also the ARN's resource id.
    pub fn set_alert_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.alert_id = input;
        self
    }
    /// The stable alert identifier (see {@link AlertId}), minted on create and immutable across updates. Use it (not {@code name}) to address the alert on GetAlert/UpdateAlert/DeleteAlert; it is also the ARN's resource id.
    pub fn get_alert_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.alert_id
    }
    /// An optional description of the alert.
    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.description = ::std::option::Option::Some(input.into());
        self
    }
    /// An optional description of the alert.
    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.description = input;
        self
    }
    /// An optional description of the alert.
    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
        &self.description
    }
    /// The AWS account ID that owns the alert.
    /// This field is required.
    pub fn account_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.account_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The AWS account ID that owns the alert.
    pub fn set_account_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.account_id = input;
        self
    }
    /// The AWS account ID that owns the alert.
    pub fn get_account_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.account_id
    }
    /// The ID of the space the alert belongs to.
    pub fn space_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.space_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The ID of the space the alert belongs to.
    pub fn set_space_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.space_id = input;
        self
    }
    /// The ID of the space the alert belongs to.
    pub fn get_space_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.space_id
    }
    /// The ID of the access profile associated with the alert.
    pub fn profile_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.profile_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The ID of the access profile associated with the alert.
    pub fn set_profile_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.profile_id = input;
        self
    }
    /// The ID of the access profile associated with the alert.
    pub fn get_profile_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.profile_id
    }
    /// The rule that defines how the alert is evaluated.
    /// This field is required.
    pub fn rule(mut self, input: crate::types::Rule) -> Self {
        self.rule = ::std::option::Option::Some(input);
        self
    }
    /// The rule that defines how the alert is evaluated.
    pub fn set_rule(mut self, input: ::std::option::Option<crate::types::Rule>) -> Self {
        self.rule = input;
        self
    }
    /// The rule that defines how the alert is evaluated.
    pub fn get_rule(&self) -> &::std::option::Option<crate::types::Rule> {
        &self.rule
    }
    /// Whether notifications are enabled.
    pub fn notification_status(mut self, input: crate::types::NotificationStatus) -> Self {
        self.notification_status = ::std::option::Option::Some(input);
        self
    }
    /// Whether notifications are enabled.
    pub fn set_notification_status(mut self, input: ::std::option::Option<crate::types::NotificationStatus>) -> Self {
        self.notification_status = input;
        self
    }
    /// Whether notifications are enabled.
    pub fn get_notification_status(&self) -> &::std::option::Option<crate::types::NotificationStatus> {
        &self.notification_status
    }
    /// Live evaluation state (read-only, system-managed). Populated by GetAlert. ListAlerts reports state on `AlertSummary` instead, where it stays required. Absent on CreateAlert: a newly created alert has never been evaluated, so any state reported there would be a default rather than an observation. Call GetAlert for live state. Not @required for that reason — GetAlert always populates it. `contributorSummary` is nested inside this member, so it too is absent on CreateAlert.
    pub fn state(mut self, input: crate::types::AlertStateInfo) -> Self {
        self.state = ::std::option::Option::Some(input);
        self
    }
    /// Live evaluation state (read-only, system-managed). Populated by GetAlert. ListAlerts reports state on `AlertSummary` instead, where it stays required. Absent on CreateAlert: a newly created alert has never been evaluated, so any state reported there would be a default rather than an observation. Call GetAlert for live state. Not @required for that reason — GetAlert always populates it. `contributorSummary` is nested inside this member, so it too is absent on CreateAlert.
    pub fn set_state(mut self, input: ::std::option::Option<crate::types::AlertStateInfo>) -> Self {
        self.state = input;
        self
    }
    /// Live evaluation state (read-only, system-managed). Populated by GetAlert. ListAlerts reports state on `AlertSummary` instead, where it stays required. Absent on CreateAlert: a newly created alert has never been evaluated, so any state reported there would be a default rather than an observation. Call GetAlert for live state. Not @required for that reason — GetAlert always populates it. `contributorSummary` is nested inside this member, so it too is absent on CreateAlert.
    pub fn get_state(&self) -> &::std::option::Option<crate::types::AlertStateInfo> {
        &self.state
    }
    /// Appends an item to `notification_rules`.
    ///
    /// To override the contents of this collection use [`set_notification_rules`](Self::set_notification_rules).
    ///
    /// The notification rules for the alert.
    pub fn notification_rules(mut self, input: crate::types::NotificationRule) -> Self {
        let mut v = self.notification_rules.unwrap_or_default();
        v.push(input);
        self.notification_rules = ::std::option::Option::Some(v);
        self
    }
    /// The notification rules for the alert.
    pub fn set_notification_rules(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::NotificationRule>>) -> Self {
        self.notification_rules = input;
        self
    }
    /// The notification rules for the alert.
    pub fn get_notification_rules(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::NotificationRule>> {
        &self.notification_rules
    }
    /// The timestamp when the alert was created.
    /// This field is required.
    pub fn created_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.created_at = ::std::option::Option::Some(input);
        self
    }
    /// The timestamp when the alert was created.
    pub fn set_created_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.created_at = input;
        self
    }
    /// The timestamp when the alert was created.
    pub fn get_created_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.created_at
    }
    /// The timestamp when the alert was last updated.
    /// This field is required.
    pub fn updated_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.updated_at = ::std::option::Option::Some(input);
        self
    }
    /// The timestamp when the alert was last updated.
    pub fn set_updated_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.updated_at = input;
        self
    }
    /// The timestamp when the alert was last updated.
    pub fn get_updated_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.updated_at
    }
    /// The Amazon Resource Name (ARN) of the alert.
    /// This field is required.
    pub fn alert_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.alert_arn = ::std::option::Option::Some(input.into());
        self
    }
    /// The Amazon Resource Name (ARN) of the alert.
    pub fn set_alert_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.alert_arn = input;
        self
    }
    /// The Amazon Resource Name (ARN) of the alert.
    pub fn get_alert_arn(&self) -> &::std::option::Option<::std::string::String> {
        &self.alert_arn
    }
    /// Consumes the builder and constructs a [`Alert`](crate::types::Alert).
    /// This method will fail if any of the following fields are not set:
    /// - [`name`](crate::types::builders::AlertBuilder::name)
    /// - [`account_id`](crate::types::builders::AlertBuilder::account_id)
    /// - [`created_at`](crate::types::builders::AlertBuilder::created_at)
    /// - [`updated_at`](crate::types::builders::AlertBuilder::updated_at)
    /// - [`alert_arn`](crate::types::builders::AlertBuilder::alert_arn)
    pub fn build(self) -> ::std::result::Result<crate::types::Alert, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Alert {
            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 Alert",
                )
            })?,
            alert_id: self.alert_id,
            description: self.description,
            account_id: self.account_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "account_id",
                    "account_id was not specified but it is required when building Alert",
                )
            })?,
            space_id: self.space_id,
            profile_id: self.profile_id,
            rule: self.rule,
            notification_status: self.notification_status,
            state: self.state,
            notification_rules: self.notification_rules,
            created_at: self.created_at.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "created_at",
                    "created_at was not specified but it is required when building Alert",
                )
            })?,
            updated_at: self.updated_at.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "updated_at",
                    "updated_at was not specified but it is required when building Alert",
                )
            })?,
            alert_arn: self.alert_arn.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "alert_arn",
                    "alert_arn was not specified but it is required when building Alert",
                )
            })?,
        })
    }
}