aws-sdk-appconfigcloudextension 1.0.0

AWS SDK for AWS AppConfig Cloud Extension
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// The output of GetFlag.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct GetFlagOutput {
    /// Whether the flag is enabled.
    pub enabled: bool,
    /// The name of the variant the request context matched, absent when the flag has no variants.
    pub variant: ::std::option::Option<::std::string::String>,
    /// The flag's attribute values, by attribute key, absent when the flag has none.
    pub attributes: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::FlagAttributeValue>>,
    _request_id: Option<String>,
}
impl GetFlagOutput {
    /// Whether the flag is enabled.
    pub fn enabled(&self) -> bool {
        self.enabled
    }
    /// The name of the variant the request context matched, absent when the flag has no variants.
    pub fn variant(&self) -> ::std::option::Option<&str> {
        self.variant.as_deref()
    }
    /// The flag's attribute values, by attribute key, absent when the flag has none.
    pub fn attributes(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, crate::types::FlagAttributeValue>> {
        self.attributes.as_ref()
    }
}
impl ::aws_types::request_id::RequestId for GetFlagOutput {
    fn request_id(&self) -> Option<&str> {
        self._request_id.as_deref()
    }
}
impl GetFlagOutput {
    /// Creates a new builder-style object to manufacture [`GetFlagOutput`](crate::operation::get_flag::GetFlagOutput).
    pub fn builder() -> crate::operation::get_flag::builders::GetFlagOutputBuilder {
        crate::operation::get_flag::builders::GetFlagOutputBuilder::default()
    }
}

/// A builder for [`GetFlagOutput`](crate::operation::get_flag::GetFlagOutput).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct GetFlagOutputBuilder {
    pub(crate) enabled: ::std::option::Option<bool>,
    pub(crate) variant: ::std::option::Option<::std::string::String>,
    pub(crate) attributes: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::FlagAttributeValue>>,
    _request_id: Option<String>,
}
impl GetFlagOutputBuilder {
    /// Whether the flag is enabled.
    /// This field is required.
    pub fn enabled(mut self, input: bool) -> Self {
        self.enabled = ::std::option::Option::Some(input);
        self
    }
    /// Whether the flag is enabled.
    pub fn set_enabled(mut self, input: ::std::option::Option<bool>) -> Self {
        self.enabled = input;
        self
    }
    /// Whether the flag is enabled.
    pub fn get_enabled(&self) -> &::std::option::Option<bool> {
        &self.enabled
    }
    /// The name of the variant the request context matched, absent when the flag has no variants.
    pub fn variant(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.variant = ::std::option::Option::Some(input.into());
        self
    }
    /// The name of the variant the request context matched, absent when the flag has no variants.
    pub fn set_variant(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.variant = input;
        self
    }
    /// The name of the variant the request context matched, absent when the flag has no variants.
    pub fn get_variant(&self) -> &::std::option::Option<::std::string::String> {
        &self.variant
    }
    /// Adds a key-value pair to `attributes`.
    ///
    /// To override the contents of this collection use [`set_attributes`](Self::set_attributes).
    ///
    /// The flag's attribute values, by attribute key, absent when the flag has none.
    pub fn attributes(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::FlagAttributeValue) -> Self {
        let mut hash_map = self.attributes.unwrap_or_default();
        hash_map.insert(k.into(), v);
        self.attributes = ::std::option::Option::Some(hash_map);
        self
    }
    /// The flag's attribute values, by attribute key, absent when the flag has none.
    pub fn set_attributes(
        mut self,
        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::FlagAttributeValue>>,
    ) -> Self {
        self.attributes = input;
        self
    }
    /// The flag's attribute values, by attribute key, absent when the flag has none.
    pub fn get_attributes(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::FlagAttributeValue>> {
        &self.attributes
    }
    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 [`GetFlagOutput`](crate::operation::get_flag::GetFlagOutput).
    /// This method will fail if any of the following fields are not set:
    /// - [`enabled`](crate::operation::get_flag::builders::GetFlagOutputBuilder::enabled)
    pub fn build(self) -> ::std::result::Result<crate::operation::get_flag::GetFlagOutput, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::operation::get_flag::GetFlagOutput {
            enabled: self.enabled.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "enabled",
                    "enabled was not specified but it is required when building GetFlagOutput",
                )
            })?,
            variant: self.variant,
            attributes: self.attributes,
            _request_id: self._request_id,
        })
    }
}