aws-sdk-appmonetization 1.0.0

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

/// Output for GetMetricUsage.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct GetMetricUsageOutput {
    /// One entry per metric in this page, carrying its usage over the window. A metric with no events in the window is returned with usage = 0.
    pub usage: ::std::vec::Vec<crate::types::MetricUsage>,
    /// Opaque continuation token. Present when more metrics remain; pass it back (with the same window) to read the next page. Absent on the last page.
    pub next_token: ::std::option::Option<::std::string::String>,
    _request_id: Option<String>,
}
impl GetMetricUsageOutput {
    /// One entry per metric in this page, carrying its usage over the window. A metric with no events in the window is returned with usage = 0.
    pub fn usage(&self) -> &[crate::types::MetricUsage] {
        use std::ops::Deref;
        self.usage.deref()
    }
    /// Opaque continuation token. Present when more metrics remain; pass it back (with the same window) to read the next page. Absent on the last page.
    pub fn next_token(&self) -> ::std::option::Option<&str> {
        self.next_token.as_deref()
    }
}
impl ::aws_types::request_id::RequestId for GetMetricUsageOutput {
    fn request_id(&self) -> Option<&str> {
        self._request_id.as_deref()
    }
}
impl GetMetricUsageOutput {
    /// Creates a new builder-style object to manufacture [`GetMetricUsageOutput`](crate::operation::get_metric_usage::GetMetricUsageOutput).
    pub fn builder() -> crate::operation::get_metric_usage::builders::GetMetricUsageOutputBuilder {
        crate::operation::get_metric_usage::builders::GetMetricUsageOutputBuilder::default()
    }
}

/// A builder for [`GetMetricUsageOutput`](crate::operation::get_metric_usage::GetMetricUsageOutput).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct GetMetricUsageOutputBuilder {
    pub(crate) usage: ::std::option::Option<::std::vec::Vec<crate::types::MetricUsage>>,
    pub(crate) next_token: ::std::option::Option<::std::string::String>,
    _request_id: Option<String>,
}
impl GetMetricUsageOutputBuilder {
    /// Appends an item to `usage`.
    ///
    /// To override the contents of this collection use [`set_usage`](Self::set_usage).
    ///
    /// One entry per metric in this page, carrying its usage over the window. A metric with no events in the window is returned with usage = 0.
    pub fn usage(mut self, input: crate::types::MetricUsage) -> Self {
        let mut v = self.usage.unwrap_or_default();
        v.push(input);
        self.usage = ::std::option::Option::Some(v);
        self
    }
    /// One entry per metric in this page, carrying its usage over the window. A metric with no events in the window is returned with usage = 0.
    pub fn set_usage(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::MetricUsage>>) -> Self {
        self.usage = input;
        self
    }
    /// One entry per metric in this page, carrying its usage over the window. A metric with no events in the window is returned with usage = 0.
    pub fn get_usage(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::MetricUsage>> {
        &self.usage
    }
    /// Opaque continuation token. Present when more metrics remain; pass it back (with the same window) to read the next page. Absent on the last page.
    pub fn next_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.next_token = ::std::option::Option::Some(input.into());
        self
    }
    /// Opaque continuation token. Present when more metrics remain; pass it back (with the same window) to read the next page. Absent on the last page.
    pub fn set_next_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.next_token = input;
        self
    }
    /// Opaque continuation token. Present when more metrics remain; pass it back (with the same window) to read the next page. Absent on the last page.
    pub fn get_next_token(&self) -> &::std::option::Option<::std::string::String> {
        &self.next_token
    }
    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
        self._request_id = Some(request_id.into());
        self
    }

    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
        self._request_id = request_id;
        self
    }
    /// Consumes the builder and constructs a [`GetMetricUsageOutput`](crate::operation::get_metric_usage::GetMetricUsageOutput).
    /// This method will fail if any of the following fields are not set:
    /// - [`usage`](crate::operation::get_metric_usage::builders::GetMetricUsageOutputBuilder::usage)
    pub fn build(
        self,
    ) -> ::std::result::Result<crate::operation::get_metric_usage::GetMetricUsageOutput, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::operation::get_metric_usage::GetMetricUsageOutput {
            usage: self.usage.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "usage",
                    "usage was not specified but it is required when building GetMetricUsageOutput",
                )
            })?,
            next_token: self.next_token,
            _request_id: self._request_id,
        })
    }
}