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.

/// A usage metric definition for an app. Metrics aggregate raw usage events (by event type) into a metered quantity used for quota enforcement and usage-based billing.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Metric {
    /// The ID of the app the metric belongs to.
    pub app_id: ::std::string::String,
    /// The ID of the metric. We assign this value when you create the metric; it is unique within the app. Treat it as opaque.
    pub metric_id: ::std::string::String,
    /// A human-readable display name for the metric.
    pub name: ::std::string::String,
    /// A description of what the metric measures.
    pub description: ::std::string::String,
    /// The event type this metric aggregates.
    pub event_type: ::std::string::String,
    /// The unit of measure for the metric.
    pub unit_name: ::std::string::String,
    /// The aggregation definition: filters, aggregation function, grouping, and period.
    pub definition: ::std::option::Option<crate::types::MetricDefinition>,
    /// The Amazon Resource Name (ARN) of the metric. Output only.
    pub arn: ::std::option::Option<::std::string::String>,
    /// The offering stage this metric was read from: DRAFT or PUBLISHED. Present on metric reads; absent on write responses.
    pub stage: ::std::option::Option<crate::types::PlanStage>,
}
impl Metric {
    /// The ID of the app the metric belongs to.
    pub fn app_id(&self) -> &str {
        use std::ops::Deref;
        self.app_id.deref()
    }
    /// The ID of the metric. We assign this value when you create the metric; it is unique within the app. Treat it as opaque.
    pub fn metric_id(&self) -> &str {
        use std::ops::Deref;
        self.metric_id.deref()
    }
    /// A human-readable display name for the metric.
    pub fn name(&self) -> &str {
        use std::ops::Deref;
        self.name.deref()
    }
    /// A description of what the metric measures.
    pub fn description(&self) -> &str {
        use std::ops::Deref;
        self.description.deref()
    }
    /// The event type this metric aggregates.
    pub fn event_type(&self) -> &str {
        use std::ops::Deref;
        self.event_type.deref()
    }
    /// The unit of measure for the metric.
    pub fn unit_name(&self) -> &str {
        use std::ops::Deref;
        self.unit_name.deref()
    }
    /// The aggregation definition: filters, aggregation function, grouping, and period.
    pub fn definition(&self) -> ::std::option::Option<&crate::types::MetricDefinition> {
        self.definition.as_ref()
    }
    /// The Amazon Resource Name (ARN) of the metric. Output only.
    pub fn arn(&self) -> ::std::option::Option<&str> {
        self.arn.as_deref()
    }
    /// The offering stage this metric was read from: DRAFT or PUBLISHED. Present on metric reads; absent on write responses.
    pub fn stage(&self) -> ::std::option::Option<&crate::types::PlanStage> {
        self.stage.as_ref()
    }
}
impl Metric {
    /// Creates a new builder-style object to manufacture [`Metric`](crate::types::Metric).
    pub fn builder() -> crate::types::builders::MetricBuilder {
        crate::types::builders::MetricBuilder::default()
    }
}

/// A builder for [`Metric`](crate::types::Metric).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct MetricBuilder {
    pub(crate) app_id: ::std::option::Option<::std::string::String>,
    pub(crate) metric_id: ::std::option::Option<::std::string::String>,
    pub(crate) name: ::std::option::Option<::std::string::String>,
    pub(crate) description: ::std::option::Option<::std::string::String>,
    pub(crate) event_type: ::std::option::Option<::std::string::String>,
    pub(crate) unit_name: ::std::option::Option<::std::string::String>,
    pub(crate) definition: ::std::option::Option<crate::types::MetricDefinition>,
    pub(crate) arn: ::std::option::Option<::std::string::String>,
    pub(crate) stage: ::std::option::Option<crate::types::PlanStage>,
}
impl MetricBuilder {
    /// The ID of the app the metric belongs to.
    /// This field is required.
    pub fn app_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.app_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The ID of the app the metric belongs to.
    pub fn set_app_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.app_id = input;
        self
    }
    /// The ID of the app the metric belongs to.
    pub fn get_app_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.app_id
    }
    /// The ID of the metric. We assign this value when you create the metric; it is unique within the app. Treat it as opaque.
    /// This field is required.
    pub fn metric_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.metric_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The ID of the metric. We assign this value when you create the metric; it is unique within the app. Treat it as opaque.
    pub fn set_metric_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.metric_id = input;
        self
    }
    /// The ID of the metric. We assign this value when you create the metric; it is unique within the app. Treat it as opaque.
    pub fn get_metric_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.metric_id
    }
    /// A human-readable display name for the metric.
    /// 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
    }
    /// A human-readable display name for the metric.
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.name = input;
        self
    }
    /// A human-readable display name for the metric.
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.name
    }
    /// A description of what the metric measures.
    /// This field is required.
    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.description = ::std::option::Option::Some(input.into());
        self
    }
    /// A description of what the metric measures.
    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.description = input;
        self
    }
    /// A description of what the metric measures.
    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
        &self.description
    }
    /// The event type this metric aggregates.
    /// This field is required.
    pub fn event_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.event_type = ::std::option::Option::Some(input.into());
        self
    }
    /// The event type this metric aggregates.
    pub fn set_event_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.event_type = input;
        self
    }
    /// The event type this metric aggregates.
    pub fn get_event_type(&self) -> &::std::option::Option<::std::string::String> {
        &self.event_type
    }
    /// The unit of measure for the metric.
    /// This field is required.
    pub fn unit_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.unit_name = ::std::option::Option::Some(input.into());
        self
    }
    /// The unit of measure for the metric.
    pub fn set_unit_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.unit_name = input;
        self
    }
    /// The unit of measure for the metric.
    pub fn get_unit_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.unit_name
    }
    /// The aggregation definition: filters, aggregation function, grouping, and period.
    /// This field is required.
    pub fn definition(mut self, input: crate::types::MetricDefinition) -> Self {
        self.definition = ::std::option::Option::Some(input);
        self
    }
    /// The aggregation definition: filters, aggregation function, grouping, and period.
    pub fn set_definition(mut self, input: ::std::option::Option<crate::types::MetricDefinition>) -> Self {
        self.definition = input;
        self
    }
    /// The aggregation definition: filters, aggregation function, grouping, and period.
    pub fn get_definition(&self) -> &::std::option::Option<crate::types::MetricDefinition> {
        &self.definition
    }
    /// The Amazon Resource Name (ARN) of the metric. Output only.
    pub fn arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.arn = ::std::option::Option::Some(input.into());
        self
    }
    /// The Amazon Resource Name (ARN) of the metric. Output only.
    pub fn set_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.arn = input;
        self
    }
    /// The Amazon Resource Name (ARN) of the metric. Output only.
    pub fn get_arn(&self) -> &::std::option::Option<::std::string::String> {
        &self.arn
    }
    /// The offering stage this metric was read from: DRAFT or PUBLISHED. Present on metric reads; absent on write responses.
    pub fn stage(mut self, input: crate::types::PlanStage) -> Self {
        self.stage = ::std::option::Option::Some(input);
        self
    }
    /// The offering stage this metric was read from: DRAFT or PUBLISHED. Present on metric reads; absent on write responses.
    pub fn set_stage(mut self, input: ::std::option::Option<crate::types::PlanStage>) -> Self {
        self.stage = input;
        self
    }
    /// The offering stage this metric was read from: DRAFT or PUBLISHED. Present on metric reads; absent on write responses.
    pub fn get_stage(&self) -> &::std::option::Option<crate::types::PlanStage> {
        &self.stage
    }
    /// Consumes the builder and constructs a [`Metric`](crate::types::Metric).
    /// This method will fail if any of the following fields are not set:
    /// - [`app_id`](crate::types::builders::MetricBuilder::app_id)
    /// - [`metric_id`](crate::types::builders::MetricBuilder::metric_id)
    /// - [`name`](crate::types::builders::MetricBuilder::name)
    /// - [`description`](crate::types::builders::MetricBuilder::description)
    /// - [`event_type`](crate::types::builders::MetricBuilder::event_type)
    /// - [`unit_name`](crate::types::builders::MetricBuilder::unit_name)
    pub fn build(self) -> ::std::result::Result<crate::types::Metric, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Metric {
            app_id: self.app_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "app_id",
                    "app_id was not specified but it is required when building Metric",
                )
            })?,
            metric_id: self.metric_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "metric_id",
                    "metric_id was not specified but it is required when building Metric",
                )
            })?,
            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 Metric",
                )
            })?,
            description: self.description.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "description",
                    "description was not specified but it is required when building Metric",
                )
            })?,
            event_type: self.event_type.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "event_type",
                    "event_type was not specified but it is required when building Metric",
                )
            })?,
            unit_name: self.unit_name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "unit_name",
                    "unit_name was not specified but it is required when building Metric",
                )
            })?,
            definition: self.definition,
            arn: self.arn,
            stage: self.stage,
        })
    }
}