aws_sdk_ec2/types/_filter.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A filter name and value pair that is used to return a more specific list of results from a describe operation. Filters can be used to match a set of resources by specific criteria, such as tags, attributes, or IDs.</p>
4/// <p>If you specify multiple filters, the filters are joined with an <code>AND</code>, and the request returns only results that match all of the specified filters.</p>
5/// <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html#Filtering_Resources_CLI">List and filter using the CLI and API</a> in the <i>Amazon EC2 User Guide</i>.</p>
6#[non_exhaustive]
7#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
8pub struct Filter {
9 /// <p>The name of the filter. Filter names are case-sensitive.</p>
10 pub name: ::std::option::Option<::std::string::String>,
11 /// <p>The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an <code>OR</code>, and the request returns all results that match any of the specified values.</p>
12 pub values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
13}
14impl Filter {
15 /// <p>The name of the filter. Filter names are case-sensitive.</p>
16 pub fn name(&self) -> ::std::option::Option<&str> {
17 self.name.as_deref()
18 }
19 /// <p>The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an <code>OR</code>, and the request returns all results that match any of the specified values.</p>
20 ///
21 /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.values.is_none()`.
22 pub fn values(&self) -> &[::std::string::String] {
23 self.values.as_deref().unwrap_or_default()
24 }
25}
26impl Filter {
27 /// Creates a new builder-style object to manufacture [`Filter`](crate::types::Filter).
28 pub fn builder() -> crate::types::builders::FilterBuilder {
29 crate::types::builders::FilterBuilder::default()
30 }
31}
32
33/// A builder for [`Filter`](crate::types::Filter).
34#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
35#[non_exhaustive]
36pub struct FilterBuilder {
37 pub(crate) name: ::std::option::Option<::std::string::String>,
38 pub(crate) values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
39}
40impl FilterBuilder {
41 /// <p>The name of the filter. Filter names are case-sensitive.</p>
42 pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
43 self.name = ::std::option::Option::Some(input.into());
44 self
45 }
46 /// <p>The name of the filter. Filter names are case-sensitive.</p>
47 pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
48 self.name = input;
49 self
50 }
51 /// <p>The name of the filter. Filter names are case-sensitive.</p>
52 pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
53 &self.name
54 }
55 /// Appends an item to `values`.
56 ///
57 /// To override the contents of this collection use [`set_values`](Self::set_values).
58 ///
59 /// <p>The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an <code>OR</code>, and the request returns all results that match any of the specified values.</p>
60 pub fn values(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
61 let mut v = self.values.unwrap_or_default();
62 v.push(input.into());
63 self.values = ::std::option::Option::Some(v);
64 self
65 }
66 /// <p>The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an <code>OR</code>, and the request returns all results that match any of the specified values.</p>
67 pub fn set_values(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
68 self.values = input;
69 self
70 }
71 /// <p>The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an <code>OR</code>, and the request returns all results that match any of the specified values.</p>
72 pub fn get_values(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
73 &self.values
74 }
75 /// Consumes the builder and constructs a [`Filter`](crate::types::Filter).
76 pub fn build(self) -> crate::types::Filter {
77 crate::types::Filter {
78 name: self.name,
79 values: self.values,
80 }
81 }
82}