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.
pub use crate::operation::get_metric_usage::_get_metric_usage_input::GetMetricUsageInputBuilder;

pub use crate::operation::get_metric_usage::_get_metric_usage_output::GetMetricUsageOutputBuilder;

impl crate::operation::get_metric_usage::builders::GetMetricUsageInputBuilder {
    /// Sends a request with this input using the given client.
    pub async fn send_with(
        self,
        client: &crate::Client,
    ) -> ::std::result::Result<
        crate::operation::get_metric_usage::GetMetricUsageOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::get_metric_usage::GetMetricUsageError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let mut fluent_builder = client.get_metric_usage();
        fluent_builder.inner = self;
        fluent_builder.send().await
    }
}
/// Fluent builder constructing a request to `GetMetricUsage`.
///
/// Returns a user's raw per-metric usage over a caller-supplied window. Usage is aggregated by event time with each metric's aggregation function: summed or counted, or the largest value for a MAX metric, in the environment the scope selects (the live app or its sandbox). It returns usage only: it does not resolve the user's plan, apply quota, or attribute usage to a plan. Combine it with GetSubscriptionHistory to compute charges for each plan the user was on, or compare it against a plan's allowance to make an entitlement decision. Usage is read at hour resolution: startedAt is floored to its hour and endedAt is rounded up to the next hour boundary, so the window read can be wider than the requested one. Paginated over the app's metric set: one page of per-metric usage per call, continued with nextToken. The window is fixed across a pagination sequence.
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct GetMetricUsageFluentBuilder {
    handle: ::std::sync::Arc<crate::client::Handle>,
    inner: crate::operation::get_metric_usage::builders::GetMetricUsageInputBuilder,
    config_override: ::std::option::Option<crate::config::Builder>,
}
impl
    crate::client::customize::internal::CustomizableSend<
        crate::operation::get_metric_usage::GetMetricUsageOutput,
        crate::operation::get_metric_usage::GetMetricUsageError,
    > for GetMetricUsageFluentBuilder
{
    fn send(
        self,
        config_override: crate::config::Builder,
    ) -> crate::client::customize::internal::BoxFuture<
        crate::client::customize::internal::SendResult<
            crate::operation::get_metric_usage::GetMetricUsageOutput,
            crate::operation::get_metric_usage::GetMetricUsageError,
        >,
    > {
        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
    }
}
impl GetMetricUsageFluentBuilder {
    /// Creates a new `GetMetricUsageFluentBuilder`.
    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
        Self {
            handle,
            inner: ::std::default::Default::default(),
            config_override: ::std::option::Option::None,
        }
    }
    /// Access the GetMetricUsage as a reference.
    pub fn as_input(&self) -> &crate::operation::get_metric_usage::builders::GetMetricUsageInputBuilder {
        &self.inner
    }
    /// Sends the request and returns the response.
    ///
    /// If an error occurs, an `SdkError` will be returned with additional details that
    /// can be matched against.
    ///
    /// By default, any retryable failures will be retried twice. Retry behavior
    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
    /// set when configuring the client.
    pub async fn send(
        self,
    ) -> ::std::result::Result<
        crate::operation::get_metric_usage::GetMetricUsageOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::get_metric_usage::GetMetricUsageError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let input = self
            .inner
            .build()
            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
        let runtime_plugins = crate::operation::get_metric_usage::GetMetricUsage::operation_runtime_plugins(
            self.handle.runtime_plugins.clone(),
            &self.handle.conf,
            self.config_override,
        );
        crate::operation::get_metric_usage::GetMetricUsage::orchestrate(&runtime_plugins, input).await
    }

    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
    pub fn customize(
        self,
    ) -> crate::client::customize::CustomizableOperation<
        crate::operation::get_metric_usage::GetMetricUsageOutput,
        crate::operation::get_metric_usage::GetMetricUsageError,
        Self,
    > {
        crate::client::customize::CustomizableOperation::new(self)
    }
    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
        self.set_config_override(::std::option::Option::Some(config_override.into()));
        self
    }

    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
        self.config_override = config_override;
        self
    }
    /// Create a paginator for this request
    ///
    /// Paginators are used by calling [`send().await`](crate::operation::get_metric_usage::paginator::GetMetricUsagePaginator::send) which returns a [`PaginationStream`](aws_smithy_async::future::pagination_stream::PaginationStream).
    pub fn into_paginator(self) -> crate::operation::get_metric_usage::paginator::GetMetricUsagePaginator {
        crate::operation::get_metric_usage::paginator::GetMetricUsagePaginator::new(self.handle, self.inner)
    }
    /// The ID of the app.
    pub fn app_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.app_id(input.into());
        self
    }
    /// The ID of the app.
    pub fn set_app_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_app_id(input);
        self
    }
    /// The ID of the app.
    pub fn get_app_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_app_id()
    }
    /// The end user whose usage is read. Do not include personally identifiable or otherwise sensitive data in this value.
    pub fn user_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.user_id(input.into());
        self
    }
    /// The end user whose usage is read. Do not include personally identifiable or otherwise sensitive data in this value.
    pub fn set_user_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_user_id(input);
        self
    }
    /// The end user whose usage is read. Do not include personally identifiable or otherwise sensitive data in this value.
    pub fn get_user_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_user_id()
    }
    /// Inclusive start of the reporting window (half-open \[startedAt, endedAt)).
    pub fn started_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.inner = self.inner.started_at(input);
        self
    }
    /// Inclusive start of the reporting window (half-open \[startedAt, endedAt)).
    pub fn set_started_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.inner = self.inner.set_started_at(input);
        self
    }
    /// Inclusive start of the reporting window (half-open \[startedAt, endedAt)).
    pub fn get_started_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        self.inner.get_started_at()
    }
    /// Exclusive end of the reporting window. Must be after startedAt; the window may span at most 744 hours (31 days, the longest monthly billing period). Must not be in the future beyond a small clock-skew allowance.
    pub fn ended_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.inner = self.inner.ended_at(input);
        self
    }
    /// Exclusive end of the reporting window. Must be after startedAt; the window may span at most 744 hours (31 days, the longest monthly billing period). Must not be in the future beyond a small clock-skew allowance.
    pub fn set_ended_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.inner = self.inner.set_ended_at(input);
        self
    }
    /// Exclusive end of the reporting window. Must be after startedAt; the window may span at most 744 hours (31 days, the longest monthly billing period). Must not be in the future beyond a small clock-skew allowance.
    pub fn get_ended_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        self.inner.get_ended_at()
    }
    /// Required. The environment: live or sandbox. sandbox reads the app's isolated test environment. Usage is kept separately per environment.
    pub fn scope(mut self, input: crate::types::RequestScope) -> Self {
        self.inner = self.inner.scope(input);
        self
    }
    /// Required. The environment: live or sandbox. sandbox reads the app's isolated test environment. Usage is kept separately per environment.
    pub fn set_scope(mut self, input: ::std::option::Option<crate::types::RequestScope>) -> Self {
        self.inner = self.inner.set_scope(input);
        self
    }
    /// Required. The environment: live or sandbox. sandbox reads the app's isolated test environment. Usage is kept separately per environment.
    pub fn get_scope(&self) -> &::std::option::Option<crate::types::RequestScope> {
        self.inner.get_scope()
    }
    /// Maximum number of per-metric usage entries to return in this page (1-25, default 25).
    pub fn max_results(mut self, input: i32) -> Self {
        self.inner = self.inner.max_results(input);
        self
    }
    /// Maximum number of per-metric usage entries to return in this page (1-25, default 25).
    pub fn set_max_results(mut self, input: ::std::option::Option<i32>) -> Self {
        self.inner = self.inner.set_max_results(input);
        self
    }
    /// Maximum number of per-metric usage entries to return in this page (1-25, default 25).
    pub fn get_max_results(&self) -> &::std::option::Option<i32> {
        self.inner.get_max_results()
    }
    /// Opaque continuation token from a prior response. The window (startedAt/endedAt) must be unchanged across a pagination sequence.
    pub fn next_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.next_token(input.into());
        self
    }
    /// Opaque continuation token from a prior response. The window (startedAt/endedAt) must be unchanged across a pagination sequence.
    pub fn set_next_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_next_token(input);
        self
    }
    /// Opaque continuation token from a prior response. The window (startedAt/endedAt) must be unchanged across a pagination sequence.
    pub fn get_next_token(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_next_token()
    }
}