aws-sdk-budgets 1.76.0

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

/// <p>The amount of cost or usage that's measured for a budget.</p>
/// <p><i>Cost example:</i> A <code>Spend</code> for <code>3 USD</code> of costs has the following parameters:</p>
/// <ul>
/// <li>
/// <p>An <code>Amount</code> of <code>3</code></p></li>
/// <li>
/// <p>A <code>Unit</code> of <code>USD</code></p></li>
/// </ul>
/// <p><i>Usage example:</i> A <code>Spend</code> for <code>3 GB</code> of S3 usage has the following parameters:</p>
/// <ul>
/// <li>
/// <p>An <code>Amount</code> of <code>3</code></p></li>
/// <li>
/// <p>A <code>Unit</code> of <code>GB</code></p></li>
/// </ul>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Spend {
    /// <p>The cost or usage amount that's associated with a budget forecast, actual spend, or budget threshold.</p>
    pub amount: ::std::string::String,
    /// <p>The unit of measurement that's used for the budget forecast, actual spend, or budget threshold.</p>
    pub unit: ::std::string::String,
}
impl Spend {
    /// <p>The cost or usage amount that's associated with a budget forecast, actual spend, or budget threshold.</p>
    pub fn amount(&self) -> &str {
        use std::ops::Deref;
        self.amount.deref()
    }
    /// <p>The unit of measurement that's used for the budget forecast, actual spend, or budget threshold.</p>
    pub fn unit(&self) -> &str {
        use std::ops::Deref;
        self.unit.deref()
    }
}
impl Spend {
    /// Creates a new builder-style object to manufacture [`Spend`](crate::types::Spend).
    pub fn builder() -> crate::types::builders::SpendBuilder {
        crate::types::builders::SpendBuilder::default()
    }
}

/// A builder for [`Spend`](crate::types::Spend).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct SpendBuilder {
    pub(crate) amount: ::std::option::Option<::std::string::String>,
    pub(crate) unit: ::std::option::Option<::std::string::String>,
}
impl SpendBuilder {
    /// <p>The cost or usage amount that's associated with a budget forecast, actual spend, or budget threshold.</p>
    /// This field is required.
    pub fn amount(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.amount = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The cost or usage amount that's associated with a budget forecast, actual spend, or budget threshold.</p>
    pub fn set_amount(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.amount = input;
        self
    }
    /// <p>The cost or usage amount that's associated with a budget forecast, actual spend, or budget threshold.</p>
    pub fn get_amount(&self) -> &::std::option::Option<::std::string::String> {
        &self.amount
    }
    /// <p>The unit of measurement that's used for the budget forecast, actual spend, or budget threshold.</p>
    /// This field is required.
    pub fn unit(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.unit = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The unit of measurement that's used for the budget forecast, actual spend, or budget threshold.</p>
    pub fn set_unit(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.unit = input;
        self
    }
    /// <p>The unit of measurement that's used for the budget forecast, actual spend, or budget threshold.</p>
    pub fn get_unit(&self) -> &::std::option::Option<::std::string::String> {
        &self.unit
    }
    /// Consumes the builder and constructs a [`Spend`](crate::types::Spend).
    /// This method will fail if any of the following fields are not set:
    /// - [`amount`](crate::types::builders::SpendBuilder::amount)
    /// - [`unit`](crate::types::builders::SpendBuilder::unit)
    pub fn build(self) -> ::std::result::Result<crate::types::Spend, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Spend {
            amount: self.amount.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "amount",
                    "amount was not specified but it is required when building Spend",
                )
            })?,
            unit: self.unit.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "unit",
                    "unit was not specified but it is required when building Spend",
                )
            })?,
        })
    }
}