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 pricing plan for an app. Users subscribe to published plans; a plan bundles a subscription price and billing cycle with included usage quotas.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Plan {
    /// The ID of the app the plan belongs to.
    pub app_id: ::std::string::String,
    /// The identifier of the plan. AWS App Monetization generates this value when the plan is created. It is unique within the app and is never reused. Treat it as opaque.
    pub plan_id: ::std::string::String,
    /// The plan's pricing and packaging definition.
    pub definition: ::std::option::Option<crate::types::PlanDefinition>,
    /// The offering stage the plan was read from.
    pub stage: ::std::option::Option<crate::types::PlanStage>,
    /// The time the plan was created.
    pub created_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    /// The time the plan was last updated.
    pub updated_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    /// The Amazon Resource Name (ARN) of the plan.
    pub arn: ::std::option::Option<::std::string::String>,
}
impl Plan {
    /// The ID of the app the plan belongs to.
    pub fn app_id(&self) -> &str {
        use std::ops::Deref;
        self.app_id.deref()
    }
    /// The identifier of the plan. AWS App Monetization generates this value when the plan is created. It is unique within the app and is never reused. Treat it as opaque.
    pub fn plan_id(&self) -> &str {
        use std::ops::Deref;
        self.plan_id.deref()
    }
    /// The plan's pricing and packaging definition.
    pub fn definition(&self) -> ::std::option::Option<&crate::types::PlanDefinition> {
        self.definition.as_ref()
    }
    /// The offering stage the plan was read from.
    pub fn stage(&self) -> ::std::option::Option<&crate::types::PlanStage> {
        self.stage.as_ref()
    }
    /// The time the plan was created.
    pub fn created_at(&self) -> ::std::option::Option<&::aws_smithy_types::DateTime> {
        self.created_at.as_ref()
    }
    /// The time the plan was last updated.
    pub fn updated_at(&self) -> ::std::option::Option<&::aws_smithy_types::DateTime> {
        self.updated_at.as_ref()
    }
    /// The Amazon Resource Name (ARN) of the plan.
    pub fn arn(&self) -> ::std::option::Option<&str> {
        self.arn.as_deref()
    }
}
impl Plan {
    /// Creates a new builder-style object to manufacture [`Plan`](crate::types::Plan).
    pub fn builder() -> crate::types::builders::PlanBuilder {
        crate::types::builders::PlanBuilder::default()
    }
}

/// A builder for [`Plan`](crate::types::Plan).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct PlanBuilder {
    pub(crate) app_id: ::std::option::Option<::std::string::String>,
    pub(crate) plan_id: ::std::option::Option<::std::string::String>,
    pub(crate) definition: ::std::option::Option<crate::types::PlanDefinition>,
    pub(crate) stage: ::std::option::Option<crate::types::PlanStage>,
    pub(crate) created_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) updated_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) arn: ::std::option::Option<::std::string::String>,
}
impl PlanBuilder {
    /// The ID of the app the plan 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 plan 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 plan belongs to.
    pub fn get_app_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.app_id
    }
    /// The identifier of the plan. AWS App Monetization generates this value when the plan is created. It is unique within the app and is never reused. Treat it as opaque.
    /// This field is required.
    pub fn plan_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.plan_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The identifier of the plan. AWS App Monetization generates this value when the plan is created. It is unique within the app and is never reused. Treat it as opaque.
    pub fn set_plan_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.plan_id = input;
        self
    }
    /// The identifier of the plan. AWS App Monetization generates this value when the plan is created. It is unique within the app and is never reused. Treat it as opaque.
    pub fn get_plan_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.plan_id
    }
    /// The plan's pricing and packaging definition.
    /// This field is required.
    pub fn definition(mut self, input: crate::types::PlanDefinition) -> Self {
        self.definition = ::std::option::Option::Some(input);
        self
    }
    /// The plan's pricing and packaging definition.
    pub fn set_definition(mut self, input: ::std::option::Option<crate::types::PlanDefinition>) -> Self {
        self.definition = input;
        self
    }
    /// The plan's pricing and packaging definition.
    pub fn get_definition(&self) -> &::std::option::Option<crate::types::PlanDefinition> {
        &self.definition
    }
    /// The offering stage the plan was read from.
    pub fn stage(mut self, input: crate::types::PlanStage) -> Self {
        self.stage = ::std::option::Option::Some(input);
        self
    }
    /// The offering stage the plan was read from.
    pub fn set_stage(mut self, input: ::std::option::Option<crate::types::PlanStage>) -> Self {
        self.stage = input;
        self
    }
    /// The offering stage the plan was read from.
    pub fn get_stage(&self) -> &::std::option::Option<crate::types::PlanStage> {
        &self.stage
    }
    /// The time the plan was created.
    pub fn created_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.created_at = ::std::option::Option::Some(input);
        self
    }
    /// The time the plan was created.
    pub fn set_created_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.created_at = input;
        self
    }
    /// The time the plan was created.
    pub fn get_created_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.created_at
    }
    /// The time the plan was last updated.
    pub fn updated_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.updated_at = ::std::option::Option::Some(input);
        self
    }
    /// The time the plan 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 time the plan 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 plan.
    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 plan.
    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 plan.
    pub fn get_arn(&self) -> &::std::option::Option<::std::string::String> {
        &self.arn
    }
    /// Consumes the builder and constructs a [`Plan`](crate::types::Plan).
    /// This method will fail if any of the following fields are not set:
    /// - [`app_id`](crate::types::builders::PlanBuilder::app_id)
    /// - [`plan_id`](crate::types::builders::PlanBuilder::plan_id)
    pub fn build(self) -> ::std::result::Result<crate::types::Plan, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Plan {
            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 Plan",
                )
            })?,
            plan_id: self.plan_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "plan_id",
                    "plan_id was not specified but it is required when building Plan",
                )
            })?,
            definition: self.definition,
            stage: self.stage,
            created_at: self.created_at,
            updated_at: self.updated_at,
            arn: self.arn,
        })
    }
}