1# coding: utf-8 2# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. 3# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. 4 5 6from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 7from oci.decorators import init_model_state_from_kwargs 8 9 10@init_model_state_from_kwargs 11class IngressSecurityRule(object): 12 """ 13 A rule for allowing inbound IP packets. 14 """ 15 16 #: A constant which can be used with the source_type property of a IngressSecurityRule. 17 #: This constant has a value of "CIDR_BLOCK" 18 SOURCE_TYPE_CIDR_BLOCK = "CIDR_BLOCK" 19 20 #: A constant which can be used with the source_type property of a IngressSecurityRule. 21 #: This constant has a value of "SERVICE_CIDR_BLOCK" 22 SOURCE_TYPE_SERVICE_CIDR_BLOCK = "SERVICE_CIDR_BLOCK" 23 24 def __init__(self, **kwargs): 25 """ 26 Initializes a new IngressSecurityRule object with values from keyword arguments. 27 The following keyword arguments are supported (corresponding to the getters/setters of this class): 28 29 :param icmp_options: 30 The value to assign to the icmp_options property of this IngressSecurityRule. 31 :type icmp_options: oci.core.models.IcmpOptions 32 33 :param is_stateless: 34 The value to assign to the is_stateless property of this IngressSecurityRule. 35 :type is_stateless: bool 36 37 :param protocol: 38 The value to assign to the protocol property of this IngressSecurityRule. 39 :type protocol: str 40 41 :param source: 42 The value to assign to the source property of this IngressSecurityRule. 43 :type source: str 44 45 :param source_type: 46 The value to assign to the source_type property of this IngressSecurityRule. 47 Allowed values for this property are: "CIDR_BLOCK", "SERVICE_CIDR_BLOCK", 'UNKNOWN_ENUM_VALUE'. 48 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 49 :type source_type: str 50 51 :param tcp_options: 52 The value to assign to the tcp_options property of this IngressSecurityRule. 53 :type tcp_options: oci.core.models.TcpOptions 54 55 :param udp_options: 56 The value to assign to the udp_options property of this IngressSecurityRule. 57 :type udp_options: oci.core.models.UdpOptions 58 59 :param description: 60 The value to assign to the description property of this IngressSecurityRule. 61 :type description: str 62 63 """ 64 self.swagger_types = { 65 'icmp_options': 'IcmpOptions', 66 'is_stateless': 'bool', 67 'protocol': 'str', 68 'source': 'str', 69 'source_type': 'str', 70 'tcp_options': 'TcpOptions', 71 'udp_options': 'UdpOptions', 72 'description': 'str' 73 } 74 75 self.attribute_map = { 76 'icmp_options': 'icmpOptions', 77 'is_stateless': 'isStateless', 78 'protocol': 'protocol', 79 'source': 'source', 80 'source_type': 'sourceType', 81 'tcp_options': 'tcpOptions', 82 'udp_options': 'udpOptions', 83 'description': 'description' 84 } 85 86 self._icmp_options = None 87 self._is_stateless = None 88 self._protocol = None 89 self._source = None 90 self._source_type = None 91 self._tcp_options = None 92 self._udp_options = None 93 self._description = None 94 95 @property 96 def icmp_options(self): 97 """ 98 Gets the icmp_options of this IngressSecurityRule. 99 100 :return: The icmp_options of this IngressSecurityRule. 101 :rtype: oci.core.models.IcmpOptions 102 """ 103 return self._icmp_options 104 105 @icmp_options.setter 106 def icmp_options(self, icmp_options): 107 """ 108 Sets the icmp_options of this IngressSecurityRule. 109 110 :param icmp_options: The icmp_options of this IngressSecurityRule. 111 :type: oci.core.models.IcmpOptions 112 """ 113 self._icmp_options = icmp_options 114 115 @property 116 def is_stateless(self): 117 """ 118 Gets the is_stateless of this IngressSecurityRule. 119 A stateless rule allows traffic in one direction. Remember to add a corresponding 120 stateless rule in the other direction if you need to support bidirectional traffic. For 121 example, if ingress traffic allows TCP destination port 80, there should be an egress 122 rule to allow TCP source port 80. Defaults to false, which means the rule is stateful 123 and a corresponding rule is not necessary for bidirectional traffic. 124 125 126 :return: The is_stateless of this IngressSecurityRule. 127 :rtype: bool 128 """ 129 return self._is_stateless 130 131 @is_stateless.setter 132 def is_stateless(self, is_stateless): 133 """ 134 Sets the is_stateless of this IngressSecurityRule. 135 A stateless rule allows traffic in one direction. Remember to add a corresponding 136 stateless rule in the other direction if you need to support bidirectional traffic. For 137 example, if ingress traffic allows TCP destination port 80, there should be an egress 138 rule to allow TCP source port 80. Defaults to false, which means the rule is stateful 139 and a corresponding rule is not necessary for bidirectional traffic. 140 141 142 :param is_stateless: The is_stateless of this IngressSecurityRule. 143 :type: bool 144 """ 145 self._is_stateless = is_stateless 146 147 @property 148 def protocol(self): 149 """ 150 **[Required]** Gets the protocol of this IngressSecurityRule. 151 The transport protocol. Specify either `all` or an IPv4 protocol number as 152 defined in 153 `Protocol Numbers`__. 154 Options are supported only for ICMP (\"1\"), TCP (\"6\"), UDP (\"17\"), and ICMPv6 (\"58\"). 155 156 __ http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml 157 158 159 :return: The protocol of this IngressSecurityRule. 160 :rtype: str 161 """ 162 return self._protocol 163 164 @protocol.setter 165 def protocol(self, protocol): 166 """ 167 Sets the protocol of this IngressSecurityRule. 168 The transport protocol. Specify either `all` or an IPv4 protocol number as 169 defined in 170 `Protocol Numbers`__. 171 Options are supported only for ICMP (\"1\"), TCP (\"6\"), UDP (\"17\"), and ICMPv6 (\"58\"). 172 173 __ http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml 174 175 176 :param protocol: The protocol of this IngressSecurityRule. 177 :type: str 178 """ 179 self._protocol = protocol 180 181 @property 182 def source(self): 183 """ 184 **[Required]** Gets the source of this IngressSecurityRule. 185 Conceptually, this is the range of IP addresses that a packet coming into the instance 186 can come from. 187 188 Allowed values: 189 190 * IP address range in CIDR notation. For example: `192.168.1.0/24` or `2001:0db8:0123:45::/56`. 191 IPv6 addressing is supported for all commercial and government regions. See 192 `IPv6 Addresses`__. 193 194 * The `cidrBlock` value for a :class:`Service`, if you're 195 setting up a security list rule for traffic coming from a particular `Service` through 196 a service gateway. For example: `oci-phx-objectstorage`. 197 198 __ https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/ipv6.htm 199 200 201 :return: The source of this IngressSecurityRule. 202 :rtype: str 203 """ 204 return self._source 205 206 @source.setter 207 def source(self, source): 208 """ 209 Sets the source of this IngressSecurityRule. 210 Conceptually, this is the range of IP addresses that a packet coming into the instance 211 can come from. 212 213 Allowed values: 214 215 * IP address range in CIDR notation. For example: `192.168.1.0/24` or `2001:0db8:0123:45::/56`. 216 IPv6 addressing is supported for all commercial and government regions. See 217 `IPv6 Addresses`__. 218 219 * The `cidrBlock` value for a :class:`Service`, if you're 220 setting up a security list rule for traffic coming from a particular `Service` through 221 a service gateway. For example: `oci-phx-objectstorage`. 222 223 __ https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/ipv6.htm 224 225 226 :param source: The source of this IngressSecurityRule. 227 :type: str 228 """ 229 self._source = source 230 231 @property 232 def source_type(self): 233 """ 234 Gets the source_type of this IngressSecurityRule. 235 Type of source for the rule. The default is `CIDR_BLOCK`. 236 237 * `CIDR_BLOCK`: If the rule's `source` is an IP address range in CIDR notation. 238 239 * `SERVICE_CIDR_BLOCK`: If the rule's `source` is the `cidrBlock` value for a 240 :class:`Service` (the rule is for traffic coming from a 241 particular `Service` through a service gateway). 242 243 Allowed values for this property are: "CIDR_BLOCK", "SERVICE_CIDR_BLOCK", 'UNKNOWN_ENUM_VALUE'. 244 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 245 246 247 :return: The source_type of this IngressSecurityRule. 248 :rtype: str 249 """ 250 return self._source_type 251 252 @source_type.setter 253 def source_type(self, source_type): 254 """ 255 Sets the source_type of this IngressSecurityRule. 256 Type of source for the rule. The default is `CIDR_BLOCK`. 257 258 * `CIDR_BLOCK`: If the rule's `source` is an IP address range in CIDR notation. 259 260 * `SERVICE_CIDR_BLOCK`: If the rule's `source` is the `cidrBlock` value for a 261 :class:`Service` (the rule is for traffic coming from a 262 particular `Service` through a service gateway). 263 264 265 :param source_type: The source_type of this IngressSecurityRule. 266 :type: str 267 """ 268 allowed_values = ["CIDR_BLOCK", "SERVICE_CIDR_BLOCK"] 269 if not value_allowed_none_or_none_sentinel(source_type, allowed_values): 270 source_type = 'UNKNOWN_ENUM_VALUE' 271 self._source_type = source_type 272 273 @property 274 def tcp_options(self): 275 """ 276 Gets the tcp_options of this IngressSecurityRule. 277 278 :return: The tcp_options of this IngressSecurityRule. 279 :rtype: oci.core.models.TcpOptions 280 """ 281 return self._tcp_options 282 283 @tcp_options.setter 284 def tcp_options(self, tcp_options): 285 """ 286 Sets the tcp_options of this IngressSecurityRule. 287 288 :param tcp_options: The tcp_options of this IngressSecurityRule. 289 :type: oci.core.models.TcpOptions 290 """ 291 self._tcp_options = tcp_options 292 293 @property 294 def udp_options(self): 295 """ 296 Gets the udp_options of this IngressSecurityRule. 297 298 :return: The udp_options of this IngressSecurityRule. 299 :rtype: oci.core.models.UdpOptions 300 """ 301 return self._udp_options 302 303 @udp_options.setter 304 def udp_options(self, udp_options): 305 """ 306 Sets the udp_options of this IngressSecurityRule. 307 308 :param udp_options: The udp_options of this IngressSecurityRule. 309 :type: oci.core.models.UdpOptions 310 """ 311 self._udp_options = udp_options 312 313 @property 314 def description(self): 315 """ 316 Gets the description of this IngressSecurityRule. 317 An optional description of your choice for the rule. 318 319 320 :return: The description of this IngressSecurityRule. 321 :rtype: str 322 """ 323 return self._description 324 325 @description.setter 326 def description(self, description): 327 """ 328 Sets the description of this IngressSecurityRule. 329 An optional description of your choice for the rule. 330 331 332 :param description: The description of this IngressSecurityRule. 333 :type: str 334 """ 335 self._description = description 336 337 def __repr__(self): 338 return formatted_flat_dict(self) 339 340 def __eq__(self, other): 341 if other is None: 342 return False 343 344 return self.__dict__ == other.__dict__ 345 346 def __ne__(self, other): 347 return not self == other 348