aws-sdk-cloudsearch 1.98.0

AWS SDK for Amazon CloudSearch
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>A named expression that can be evaluated at search time. Can be used to sort the search results, define other expressions, or return computed information in the search results.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Expression {
    /// <p>Names must begin with a letter and can contain the following characters: a-z (lowercase), 0-9, and _ (underscore).</p>
    pub expression_name: ::std::string::String,
    /// <p>The expression to evaluate for sorting while processing a search request. The <code>Expression</code> syntax is based on JavaScript expressions. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html" target="_blank">Configuring Expressions</a> in the <i>Amazon CloudSearch Developer Guide</i>.</p>
    pub expression_value: ::std::string::String,
}
impl Expression {
    /// <p>Names must begin with a letter and can contain the following characters: a-z (lowercase), 0-9, and _ (underscore).</p>
    pub fn expression_name(&self) -> &str {
        use std::ops::Deref;
        self.expression_name.deref()
    }
    /// <p>The expression to evaluate for sorting while processing a search request. The <code>Expression</code> syntax is based on JavaScript expressions. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html" target="_blank">Configuring Expressions</a> in the <i>Amazon CloudSearch Developer Guide</i>.</p>
    pub fn expression_value(&self) -> &str {
        use std::ops::Deref;
        self.expression_value.deref()
    }
}
impl Expression {
    /// Creates a new builder-style object to manufacture [`Expression`](crate::types::Expression).
    pub fn builder() -> crate::types::builders::ExpressionBuilder {
        crate::types::builders::ExpressionBuilder::default()
    }
}

/// A builder for [`Expression`](crate::types::Expression).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct ExpressionBuilder {
    pub(crate) expression_name: ::std::option::Option<::std::string::String>,
    pub(crate) expression_value: ::std::option::Option<::std::string::String>,
}
impl ExpressionBuilder {
    /// <p>Names must begin with a letter and can contain the following characters: a-z (lowercase), 0-9, and _ (underscore).</p>
    /// This field is required.
    pub fn expression_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.expression_name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>Names must begin with a letter and can contain the following characters: a-z (lowercase), 0-9, and _ (underscore).</p>
    pub fn set_expression_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.expression_name = input;
        self
    }
    /// <p>Names must begin with a letter and can contain the following characters: a-z (lowercase), 0-9, and _ (underscore).</p>
    pub fn get_expression_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.expression_name
    }
    /// <p>The expression to evaluate for sorting while processing a search request. The <code>Expression</code> syntax is based on JavaScript expressions. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html" target="_blank">Configuring Expressions</a> in the <i>Amazon CloudSearch Developer Guide</i>.</p>
    /// This field is required.
    pub fn expression_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.expression_value = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The expression to evaluate for sorting while processing a search request. The <code>Expression</code> syntax is based on JavaScript expressions. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html" target="_blank">Configuring Expressions</a> in the <i>Amazon CloudSearch Developer Guide</i>.</p>
    pub fn set_expression_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.expression_value = input;
        self
    }
    /// <p>The expression to evaluate for sorting while processing a search request. The <code>Expression</code> syntax is based on JavaScript expressions. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html" target="_blank">Configuring Expressions</a> in the <i>Amazon CloudSearch Developer Guide</i>.</p>
    pub fn get_expression_value(&self) -> &::std::option::Option<::std::string::String> {
        &self.expression_value
    }
    /// Consumes the builder and constructs a [`Expression`](crate::types::Expression).
    /// This method will fail if any of the following fields are not set:
    /// - [`expression_name`](crate::types::builders::ExpressionBuilder::expression_name)
    /// - [`expression_value`](crate::types::builders::ExpressionBuilder::expression_value)
    pub fn build(self) -> ::std::result::Result<crate::types::Expression, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Expression {
            expression_name: self.expression_name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "expression_name",
                    "expression_name was not specified but it is required when building Expression",
                )
            })?,
            expression_value: self.expression_value.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "expression_value",
                    "expression_value was not specified but it is required when building Expression",
                )
            })?,
        })
    }
}