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 GetEntitlementDecision.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct GetEntitlementDecisionOutput {
    /// The decision indicating whether the user may perform the action.
    pub decision: crate::types::EntitlementDecision,
    /// The reason behind the decision.
    pub reason: ::std::option::Option<crate::types::EntitlementReason>,
    /// The ID of the plan the decision was evaluated against, when the user has a subscription.
    pub plan_id: ::std::option::Option<::std::string::String>,
    /// The per-metric quota status relevant to the decision.
    pub metrics: ::std::option::Option<::std::vec::Vec<crate::types::EntitlementMetricStatus>>,
    _request_id: Option<String>,
}
impl GetEntitlementDecisionOutput {
    /// The decision indicating whether the user may perform the action.
    pub fn decision(&self) -> &crate::types::EntitlementDecision {
        &self.decision
    }
    /// The reason behind the decision.
    pub fn reason(&self) -> ::std::option::Option<&crate::types::EntitlementReason> {
        self.reason.as_ref()
    }
    /// The ID of the plan the decision was evaluated against, when the user has a subscription.
    pub fn plan_id(&self) -> ::std::option::Option<&str> {
        self.plan_id.as_deref()
    }
    /// The per-metric quota status relevant to the decision.
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.metrics.is_none()`.
    pub fn metrics(&self) -> &[crate::types::EntitlementMetricStatus] {
        self.metrics.as_deref().unwrap_or_default()
    }
}
impl ::aws_types::request_id::RequestId for GetEntitlementDecisionOutput {
    fn request_id(&self) -> Option<&str> {
        self._request_id.as_deref()
    }
}
impl GetEntitlementDecisionOutput {
    /// Creates a new builder-style object to manufacture [`GetEntitlementDecisionOutput`](crate::operation::get_entitlement_decision::GetEntitlementDecisionOutput).
    pub fn builder() -> crate::operation::get_entitlement_decision::builders::GetEntitlementDecisionOutputBuilder {
        crate::operation::get_entitlement_decision::builders::GetEntitlementDecisionOutputBuilder::default()
    }
}

/// A builder for [`GetEntitlementDecisionOutput`](crate::operation::get_entitlement_decision::GetEntitlementDecisionOutput).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct GetEntitlementDecisionOutputBuilder {
    pub(crate) decision: ::std::option::Option<crate::types::EntitlementDecision>,
    pub(crate) reason: ::std::option::Option<crate::types::EntitlementReason>,
    pub(crate) plan_id: ::std::option::Option<::std::string::String>,
    pub(crate) metrics: ::std::option::Option<::std::vec::Vec<crate::types::EntitlementMetricStatus>>,
    _request_id: Option<String>,
}
impl GetEntitlementDecisionOutputBuilder {
    /// The decision indicating whether the user may perform the action.
    /// This field is required.
    pub fn decision(mut self, input: crate::types::EntitlementDecision) -> Self {
        self.decision = ::std::option::Option::Some(input);
        self
    }
    /// The decision indicating whether the user may perform the action.
    pub fn set_decision(mut self, input: ::std::option::Option<crate::types::EntitlementDecision>) -> Self {
        self.decision = input;
        self
    }
    /// The decision indicating whether the user may perform the action.
    pub fn get_decision(&self) -> &::std::option::Option<crate::types::EntitlementDecision> {
        &self.decision
    }
    /// The reason behind the decision.
    /// This field is required.
    pub fn reason(mut self, input: crate::types::EntitlementReason) -> Self {
        self.reason = ::std::option::Option::Some(input);
        self
    }
    /// The reason behind the decision.
    pub fn set_reason(mut self, input: ::std::option::Option<crate::types::EntitlementReason>) -> Self {
        self.reason = input;
        self
    }
    /// The reason behind the decision.
    pub fn get_reason(&self) -> &::std::option::Option<crate::types::EntitlementReason> {
        &self.reason
    }
    /// The ID of the plan the decision was evaluated against, when the user has a subscription.
    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 ID of the plan the decision was evaluated against, when the user has a subscription.
    pub fn set_plan_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.plan_id = input;
        self
    }
    /// The ID of the plan the decision was evaluated against, when the user has a subscription.
    pub fn get_plan_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.plan_id
    }
    /// Appends an item to `metrics`.
    ///
    /// To override the contents of this collection use [`set_metrics`](Self::set_metrics).
    ///
    /// The per-metric quota status relevant to the decision.
    pub fn metrics(mut self, input: crate::types::EntitlementMetricStatus) -> Self {
        let mut v = self.metrics.unwrap_or_default();
        v.push(input);
        self.metrics = ::std::option::Option::Some(v);
        self
    }
    /// The per-metric quota status relevant to the decision.
    pub fn set_metrics(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::EntitlementMetricStatus>>) -> Self {
        self.metrics = input;
        self
    }
    /// The per-metric quota status relevant to the decision.
    pub fn get_metrics(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::EntitlementMetricStatus>> {
        &self.metrics
    }
    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 [`GetEntitlementDecisionOutput`](crate::operation::get_entitlement_decision::GetEntitlementDecisionOutput).
    /// This method will fail if any of the following fields are not set:
    /// - [`decision`](crate::operation::get_entitlement_decision::builders::GetEntitlementDecisionOutputBuilder::decision)
    pub fn build(
        self,
    ) -> ::std::result::Result<
        crate::operation::get_entitlement_decision::GetEntitlementDecisionOutput,
        ::aws_smithy_types::error::operation::BuildError,
    > {
        ::std::result::Result::Ok(crate::operation::get_entitlement_decision::GetEntitlementDecisionOutput {
            decision: self.decision.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "decision",
                    "decision was not specified but it is required when building GetEntitlementDecisionOutput",
                )
            })?,
            reason: self.reason,
            plan_id: self.plan_id,
            metrics: self.metrics,
            _request_id: self._request_id,
        })
    }
}