aws_sdk_ec2/types/
_firewall_stateful_rule.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Describes a stateful rule.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct FirewallStatefulRule {
7    /// <p>The ARN of the stateful rule group.</p>
8    pub rule_group_arn: ::std::option::Option<::std::string::String>,
9    /// <p>The source IP addresses, in CIDR notation.</p>
10    pub sources: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
11    /// <p>The destination IP addresses, in CIDR notation.</p>
12    pub destinations: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
13    /// <p>The source ports.</p>
14    pub source_ports: ::std::option::Option<::std::vec::Vec<crate::types::PortRange>>,
15    /// <p>The destination ports.</p>
16    pub destination_ports: ::std::option::Option<::std::vec::Vec<crate::types::PortRange>>,
17    /// <p>The protocol.</p>
18    pub protocol: ::std::option::Option<::std::string::String>,
19    /// <p>The rule action. The possible values are <code>pass</code>, <code>drop</code>, and <code>alert</code>.</p>
20    pub rule_action: ::std::option::Option<::std::string::String>,
21    /// <p>The direction. The possible values are <code>FORWARD</code> and <code>ANY</code>.</p>
22    pub direction: ::std::option::Option<::std::string::String>,
23}
24impl FirewallStatefulRule {
25    /// <p>The ARN of the stateful rule group.</p>
26    pub fn rule_group_arn(&self) -> ::std::option::Option<&str> {
27        self.rule_group_arn.as_deref()
28    }
29    /// <p>The source IP addresses, in CIDR notation.</p>
30    ///
31    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.sources.is_none()`.
32    pub fn sources(&self) -> &[::std::string::String] {
33        self.sources.as_deref().unwrap_or_default()
34    }
35    /// <p>The destination IP addresses, in CIDR notation.</p>
36    ///
37    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.destinations.is_none()`.
38    pub fn destinations(&self) -> &[::std::string::String] {
39        self.destinations.as_deref().unwrap_or_default()
40    }
41    /// <p>The source ports.</p>
42    ///
43    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.source_ports.is_none()`.
44    pub fn source_ports(&self) -> &[crate::types::PortRange] {
45        self.source_ports.as_deref().unwrap_or_default()
46    }
47    /// <p>The destination ports.</p>
48    ///
49    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.destination_ports.is_none()`.
50    pub fn destination_ports(&self) -> &[crate::types::PortRange] {
51        self.destination_ports.as_deref().unwrap_or_default()
52    }
53    /// <p>The protocol.</p>
54    pub fn protocol(&self) -> ::std::option::Option<&str> {
55        self.protocol.as_deref()
56    }
57    /// <p>The rule action. The possible values are <code>pass</code>, <code>drop</code>, and <code>alert</code>.</p>
58    pub fn rule_action(&self) -> ::std::option::Option<&str> {
59        self.rule_action.as_deref()
60    }
61    /// <p>The direction. The possible values are <code>FORWARD</code> and <code>ANY</code>.</p>
62    pub fn direction(&self) -> ::std::option::Option<&str> {
63        self.direction.as_deref()
64    }
65}
66impl FirewallStatefulRule {
67    /// Creates a new builder-style object to manufacture [`FirewallStatefulRule`](crate::types::FirewallStatefulRule).
68    pub fn builder() -> crate::types::builders::FirewallStatefulRuleBuilder {
69        crate::types::builders::FirewallStatefulRuleBuilder::default()
70    }
71}
72
73/// A builder for [`FirewallStatefulRule`](crate::types::FirewallStatefulRule).
74#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
75#[non_exhaustive]
76pub struct FirewallStatefulRuleBuilder {
77    pub(crate) rule_group_arn: ::std::option::Option<::std::string::String>,
78    pub(crate) sources: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
79    pub(crate) destinations: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
80    pub(crate) source_ports: ::std::option::Option<::std::vec::Vec<crate::types::PortRange>>,
81    pub(crate) destination_ports: ::std::option::Option<::std::vec::Vec<crate::types::PortRange>>,
82    pub(crate) protocol: ::std::option::Option<::std::string::String>,
83    pub(crate) rule_action: ::std::option::Option<::std::string::String>,
84    pub(crate) direction: ::std::option::Option<::std::string::String>,
85}
86impl FirewallStatefulRuleBuilder {
87    /// <p>The ARN of the stateful rule group.</p>
88    pub fn rule_group_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
89        self.rule_group_arn = ::std::option::Option::Some(input.into());
90        self
91    }
92    /// <p>The ARN of the stateful rule group.</p>
93    pub fn set_rule_group_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
94        self.rule_group_arn = input;
95        self
96    }
97    /// <p>The ARN of the stateful rule group.</p>
98    pub fn get_rule_group_arn(&self) -> &::std::option::Option<::std::string::String> {
99        &self.rule_group_arn
100    }
101    /// Appends an item to `sources`.
102    ///
103    /// To override the contents of this collection use [`set_sources`](Self::set_sources).
104    ///
105    /// <p>The source IP addresses, in CIDR notation.</p>
106    pub fn sources(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
107        let mut v = self.sources.unwrap_or_default();
108        v.push(input.into());
109        self.sources = ::std::option::Option::Some(v);
110        self
111    }
112    /// <p>The source IP addresses, in CIDR notation.</p>
113    pub fn set_sources(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
114        self.sources = input;
115        self
116    }
117    /// <p>The source IP addresses, in CIDR notation.</p>
118    pub fn get_sources(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
119        &self.sources
120    }
121    /// Appends an item to `destinations`.
122    ///
123    /// To override the contents of this collection use [`set_destinations`](Self::set_destinations).
124    ///
125    /// <p>The destination IP addresses, in CIDR notation.</p>
126    pub fn destinations(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
127        let mut v = self.destinations.unwrap_or_default();
128        v.push(input.into());
129        self.destinations = ::std::option::Option::Some(v);
130        self
131    }
132    /// <p>The destination IP addresses, in CIDR notation.</p>
133    pub fn set_destinations(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
134        self.destinations = input;
135        self
136    }
137    /// <p>The destination IP addresses, in CIDR notation.</p>
138    pub fn get_destinations(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
139        &self.destinations
140    }
141    /// Appends an item to `source_ports`.
142    ///
143    /// To override the contents of this collection use [`set_source_ports`](Self::set_source_ports).
144    ///
145    /// <p>The source ports.</p>
146    pub fn source_ports(mut self, input: crate::types::PortRange) -> Self {
147        let mut v = self.source_ports.unwrap_or_default();
148        v.push(input);
149        self.source_ports = ::std::option::Option::Some(v);
150        self
151    }
152    /// <p>The source ports.</p>
153    pub fn set_source_ports(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::PortRange>>) -> Self {
154        self.source_ports = input;
155        self
156    }
157    /// <p>The source ports.</p>
158    pub fn get_source_ports(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::PortRange>> {
159        &self.source_ports
160    }
161    /// Appends an item to `destination_ports`.
162    ///
163    /// To override the contents of this collection use [`set_destination_ports`](Self::set_destination_ports).
164    ///
165    /// <p>The destination ports.</p>
166    pub fn destination_ports(mut self, input: crate::types::PortRange) -> Self {
167        let mut v = self.destination_ports.unwrap_or_default();
168        v.push(input);
169        self.destination_ports = ::std::option::Option::Some(v);
170        self
171    }
172    /// <p>The destination ports.</p>
173    pub fn set_destination_ports(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::PortRange>>) -> Self {
174        self.destination_ports = input;
175        self
176    }
177    /// <p>The destination ports.</p>
178    pub fn get_destination_ports(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::PortRange>> {
179        &self.destination_ports
180    }
181    /// <p>The protocol.</p>
182    pub fn protocol(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
183        self.protocol = ::std::option::Option::Some(input.into());
184        self
185    }
186    /// <p>The protocol.</p>
187    pub fn set_protocol(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
188        self.protocol = input;
189        self
190    }
191    /// <p>The protocol.</p>
192    pub fn get_protocol(&self) -> &::std::option::Option<::std::string::String> {
193        &self.protocol
194    }
195    /// <p>The rule action. The possible values are <code>pass</code>, <code>drop</code>, and <code>alert</code>.</p>
196    pub fn rule_action(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
197        self.rule_action = ::std::option::Option::Some(input.into());
198        self
199    }
200    /// <p>The rule action. The possible values are <code>pass</code>, <code>drop</code>, and <code>alert</code>.</p>
201    pub fn set_rule_action(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
202        self.rule_action = input;
203        self
204    }
205    /// <p>The rule action. The possible values are <code>pass</code>, <code>drop</code>, and <code>alert</code>.</p>
206    pub fn get_rule_action(&self) -> &::std::option::Option<::std::string::String> {
207        &self.rule_action
208    }
209    /// <p>The direction. The possible values are <code>FORWARD</code> and <code>ANY</code>.</p>
210    pub fn direction(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
211        self.direction = ::std::option::Option::Some(input.into());
212        self
213    }
214    /// <p>The direction. The possible values are <code>FORWARD</code> and <code>ANY</code>.</p>
215    pub fn set_direction(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
216        self.direction = input;
217        self
218    }
219    /// <p>The direction. The possible values are <code>FORWARD</code> and <code>ANY</code>.</p>
220    pub fn get_direction(&self) -> &::std::option::Option<::std::string::String> {
221        &self.direction
222    }
223    /// Consumes the builder and constructs a [`FirewallStatefulRule`](crate::types::FirewallStatefulRule).
224    pub fn build(self) -> crate::types::FirewallStatefulRule {
225        crate::types::FirewallStatefulRule {
226            rule_group_arn: self.rule_group_arn,
227            sources: self.sources,
228            destinations: self.destinations,
229            source_ports: self.source_ports,
230            destination_ports: self.destination_ports,
231            protocol: self.protocol,
232            rule_action: self.rule_action,
233            direction: self.direction,
234        }
235    }
236}