aws_sdk_forecast/types/
_filter.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Describes a filter for choosing a subset of objects. Each filter consists of a condition and a match statement. The condition is either <code>IS</code> or <code>IS_NOT</code>, which specifies whether to include or exclude the objects that match the statement, respectively. The match statement consists of a key and a value.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Filter {
7    /// <p>The name of the parameter to filter on.</p>
8    pub key: ::std::string::String,
9    /// <p>The value to match.</p>
10    pub value: ::std::string::String,
11    /// <p>The condition to apply. To include the objects that match the statement, specify <code>IS</code>. To exclude matching objects, specify <code>IS_NOT</code>.</p>
12    pub condition: crate::types::FilterConditionString,
13}
14impl Filter {
15    /// <p>The name of the parameter to filter on.</p>
16    pub fn key(&self) -> &str {
17        use std::ops::Deref;
18        self.key.deref()
19    }
20    /// <p>The value to match.</p>
21    pub fn value(&self) -> &str {
22        use std::ops::Deref;
23        self.value.deref()
24    }
25    /// <p>The condition to apply. To include the objects that match the statement, specify <code>IS</code>. To exclude matching objects, specify <code>IS_NOT</code>.</p>
26    pub fn condition(&self) -> &crate::types::FilterConditionString {
27        &self.condition
28    }
29}
30impl Filter {
31    /// Creates a new builder-style object to manufacture [`Filter`](crate::types::Filter).
32    pub fn builder() -> crate::types::builders::FilterBuilder {
33        crate::types::builders::FilterBuilder::default()
34    }
35}
36
37/// A builder for [`Filter`](crate::types::Filter).
38#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
39#[non_exhaustive]
40pub struct FilterBuilder {
41    pub(crate) key: ::std::option::Option<::std::string::String>,
42    pub(crate) value: ::std::option::Option<::std::string::String>,
43    pub(crate) condition: ::std::option::Option<crate::types::FilterConditionString>,
44}
45impl FilterBuilder {
46    /// <p>The name of the parameter to filter on.</p>
47    /// This field is required.
48    pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
49        self.key = ::std::option::Option::Some(input.into());
50        self
51    }
52    /// <p>The name of the parameter to filter on.</p>
53    pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
54        self.key = input;
55        self
56    }
57    /// <p>The name of the parameter to filter on.</p>
58    pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
59        &self.key
60    }
61    /// <p>The value to match.</p>
62    /// This field is required.
63    pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
64        self.value = ::std::option::Option::Some(input.into());
65        self
66    }
67    /// <p>The value to match.</p>
68    pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
69        self.value = input;
70        self
71    }
72    /// <p>The value to match.</p>
73    pub fn get_value(&self) -> &::std::option::Option<::std::string::String> {
74        &self.value
75    }
76    /// <p>The condition to apply. To include the objects that match the statement, specify <code>IS</code>. To exclude matching objects, specify <code>IS_NOT</code>.</p>
77    /// This field is required.
78    pub fn condition(mut self, input: crate::types::FilterConditionString) -> Self {
79        self.condition = ::std::option::Option::Some(input);
80        self
81    }
82    /// <p>The condition to apply. To include the objects that match the statement, specify <code>IS</code>. To exclude matching objects, specify <code>IS_NOT</code>.</p>
83    pub fn set_condition(mut self, input: ::std::option::Option<crate::types::FilterConditionString>) -> Self {
84        self.condition = input;
85        self
86    }
87    /// <p>The condition to apply. To include the objects that match the statement, specify <code>IS</code>. To exclude matching objects, specify <code>IS_NOT</code>.</p>
88    pub fn get_condition(&self) -> &::std::option::Option<crate::types::FilterConditionString> {
89        &self.condition
90    }
91    /// Consumes the builder and constructs a [`Filter`](crate::types::Filter).
92    /// This method will fail if any of the following fields are not set:
93    /// - [`key`](crate::types::builders::FilterBuilder::key)
94    /// - [`value`](crate::types::builders::FilterBuilder::value)
95    /// - [`condition`](crate::types::builders::FilterBuilder::condition)
96    pub fn build(self) -> ::std::result::Result<crate::types::Filter, ::aws_smithy_types::error::operation::BuildError> {
97        ::std::result::Result::Ok(crate::types::Filter {
98            key: self.key.ok_or_else(|| {
99                ::aws_smithy_types::error::operation::BuildError::missing_field(
100                    "key",
101                    "key was not specified but it is required when building Filter",
102                )
103            })?,
104            value: self.value.ok_or_else(|| {
105                ::aws_smithy_types::error::operation::BuildError::missing_field(
106                    "value",
107                    "value was not specified but it is required when building Filter",
108                )
109            })?,
110            condition: self.condition.ok_or_else(|| {
111                ::aws_smithy_types::error::operation::BuildError::missing_field(
112                    "condition",
113                    "condition was not specified but it is required when building Filter",
114                )
115            })?,
116        })
117    }
118}