aws-sdk-pricing 1.99.0

AWS SDK for AWS Price List Service
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>The metadata for a service, such as the service code and available attribute names.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Service {
    /// <p>The code for the Amazon Web Services service.</p>
    pub service_code: ::std::string::String,
    /// <p>The attributes that are available for this service.</p>
    pub attribute_names: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
}
impl Service {
    /// <p>The code for the Amazon Web Services service.</p>
    pub fn service_code(&self) -> &str {
        use std::ops::Deref;
        self.service_code.deref()
    }
    /// <p>The attributes that are available for this service.</p>
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.attribute_names.is_none()`.
    pub fn attribute_names(&self) -> &[::std::string::String] {
        self.attribute_names.as_deref().unwrap_or_default()
    }
}
impl Service {
    /// Creates a new builder-style object to manufacture [`Service`](crate::types::Service).
    pub fn builder() -> crate::types::builders::ServiceBuilder {
        crate::types::builders::ServiceBuilder::default()
    }
}

/// A builder for [`Service`](crate::types::Service).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct ServiceBuilder {
    pub(crate) service_code: ::std::option::Option<::std::string::String>,
    pub(crate) attribute_names: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
}
impl ServiceBuilder {
    /// <p>The code for the Amazon Web Services service.</p>
    /// This field is required.
    pub fn service_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.service_code = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The code for the Amazon Web Services service.</p>
    pub fn set_service_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.service_code = input;
        self
    }
    /// <p>The code for the Amazon Web Services service.</p>
    pub fn get_service_code(&self) -> &::std::option::Option<::std::string::String> {
        &self.service_code
    }
    /// Appends an item to `attribute_names`.
    ///
    /// To override the contents of this collection use [`set_attribute_names`](Self::set_attribute_names).
    ///
    /// <p>The attributes that are available for this service.</p>
    pub fn attribute_names(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.attribute_names.unwrap_or_default();
        v.push(input.into());
        self.attribute_names = ::std::option::Option::Some(v);
        self
    }
    /// <p>The attributes that are available for this service.</p>
    pub fn set_attribute_names(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.attribute_names = input;
        self
    }
    /// <p>The attributes that are available for this service.</p>
    pub fn get_attribute_names(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.attribute_names
    }
    /// Consumes the builder and constructs a [`Service`](crate::types::Service).
    /// This method will fail if any of the following fields are not set:
    /// - [`service_code`](crate::types::builders::ServiceBuilder::service_code)
    pub fn build(self) -> ::std::result::Result<crate::types::Service, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Service {
            service_code: self.service_code.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "service_code",
                    "service_code was not specified but it is required when building Service",
                )
            })?,
            attribute_names: self.attribute_names,
        })
    }
}