aws_sdk_ssm/types/
_ops_item_filter.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Describes an OpsItem filter.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct OpsItemFilter {
7    /// <p>The name of the filter.</p>
8    pub key: crate::types::OpsItemFilterKey,
9    /// <p>The filter value.</p>
10    pub values: ::std::vec::Vec<::std::string::String>,
11    /// <p>The operator used by the filter call.</p>
12    pub operator: crate::types::OpsItemFilterOperator,
13}
14impl OpsItemFilter {
15    /// <p>The name of the filter.</p>
16    pub fn key(&self) -> &crate::types::OpsItemFilterKey {
17        &self.key
18    }
19    /// <p>The filter value.</p>
20    pub fn values(&self) -> &[::std::string::String] {
21        use std::ops::Deref;
22        self.values.deref()
23    }
24    /// <p>The operator used by the filter call.</p>
25    pub fn operator(&self) -> &crate::types::OpsItemFilterOperator {
26        &self.operator
27    }
28}
29impl OpsItemFilter {
30    /// Creates a new builder-style object to manufacture [`OpsItemFilter`](crate::types::OpsItemFilter).
31    pub fn builder() -> crate::types::builders::OpsItemFilterBuilder {
32        crate::types::builders::OpsItemFilterBuilder::default()
33    }
34}
35
36/// A builder for [`OpsItemFilter`](crate::types::OpsItemFilter).
37#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
38#[non_exhaustive]
39pub struct OpsItemFilterBuilder {
40    pub(crate) key: ::std::option::Option<crate::types::OpsItemFilterKey>,
41    pub(crate) values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
42    pub(crate) operator: ::std::option::Option<crate::types::OpsItemFilterOperator>,
43}
44impl OpsItemFilterBuilder {
45    /// <p>The name of the filter.</p>
46    /// This field is required.
47    pub fn key(mut self, input: crate::types::OpsItemFilterKey) -> Self {
48        self.key = ::std::option::Option::Some(input);
49        self
50    }
51    /// <p>The name of the filter.</p>
52    pub fn set_key(mut self, input: ::std::option::Option<crate::types::OpsItemFilterKey>) -> Self {
53        self.key = input;
54        self
55    }
56    /// <p>The name of the filter.</p>
57    pub fn get_key(&self) -> &::std::option::Option<crate::types::OpsItemFilterKey> {
58        &self.key
59    }
60    /// Appends an item to `values`.
61    ///
62    /// To override the contents of this collection use [`set_values`](Self::set_values).
63    ///
64    /// <p>The filter value.</p>
65    pub fn values(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
66        let mut v = self.values.unwrap_or_default();
67        v.push(input.into());
68        self.values = ::std::option::Option::Some(v);
69        self
70    }
71    /// <p>The filter value.</p>
72    pub fn set_values(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
73        self.values = input;
74        self
75    }
76    /// <p>The filter value.</p>
77    pub fn get_values(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
78        &self.values
79    }
80    /// <p>The operator used by the filter call.</p>
81    /// This field is required.
82    pub fn operator(mut self, input: crate::types::OpsItemFilterOperator) -> Self {
83        self.operator = ::std::option::Option::Some(input);
84        self
85    }
86    /// <p>The operator used by the filter call.</p>
87    pub fn set_operator(mut self, input: ::std::option::Option<crate::types::OpsItemFilterOperator>) -> Self {
88        self.operator = input;
89        self
90    }
91    /// <p>The operator used by the filter call.</p>
92    pub fn get_operator(&self) -> &::std::option::Option<crate::types::OpsItemFilterOperator> {
93        &self.operator
94    }
95    /// Consumes the builder and constructs a [`OpsItemFilter`](crate::types::OpsItemFilter).
96    /// This method will fail if any of the following fields are not set:
97    /// - [`key`](crate::types::builders::OpsItemFilterBuilder::key)
98    /// - [`values`](crate::types::builders::OpsItemFilterBuilder::values)
99    /// - [`operator`](crate::types::builders::OpsItemFilterBuilder::operator)
100    pub fn build(self) -> ::std::result::Result<crate::types::OpsItemFilter, ::aws_smithy_types::error::operation::BuildError> {
101        ::std::result::Result::Ok(crate::types::OpsItemFilter {
102            key: self.key.ok_or_else(|| {
103                ::aws_smithy_types::error::operation::BuildError::missing_field(
104                    "key",
105                    "key was not specified but it is required when building OpsItemFilter",
106                )
107            })?,
108            values: self.values.ok_or_else(|| {
109                ::aws_smithy_types::error::operation::BuildError::missing_field(
110                    "values",
111                    "values was not specified but it is required when building OpsItemFilter",
112                )
113            })?,
114            operator: self.operator.ok_or_else(|| {
115                ::aws_smithy_types::error::operation::BuildError::missing_field(
116                    "operator",
117                    "operator was not specified but it is required when building OpsItemFilter",
118                )
119            })?,
120        })
121    }
122}