Class: OCI::Core::Models::SecurityRule
- Inherits:
-
Object
- Object
- OCI::Core::Models::SecurityRule
- Defined in:
- lib/oci/core/models/security_rule.rb
Overview
A security rule is one of the items in a NetworkSecurityGroup. It is a virtual firewall rule for the VNICs in the network security group. A rule can be for either inbound (‘direction`= INGRESS) or outbound (`direction`= EGRESS) IP packets.
Constant Summary collapse
- DESTINATION_TYPE_ENUM =
[ DESTINATION_TYPE_CIDR_BLOCK = 'CIDR_BLOCK'.freeze, DESTINATION_TYPE_SERVICE_CIDR_BLOCK = 'SERVICE_CIDR_BLOCK'.freeze, DESTINATION_TYPE_NETWORK_SECURITY_GROUP = 'NETWORK_SECURITY_GROUP'.freeze, DESTINATION_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze ].freeze
- DIRECTION_ENUM =
[ DIRECTION_EGRESS = 'EGRESS'.freeze, DIRECTION_INGRESS = 'INGRESS'.freeze, DIRECTION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze ].freeze
- SOURCE_TYPE_ENUM =
[ SOURCE_TYPE_CIDR_BLOCK = 'CIDR_BLOCK'.freeze, SOURCE_TYPE_SERVICE_CIDR_BLOCK = 'SERVICE_CIDR_BLOCK'.freeze, SOURCE_TYPE_NETWORK_SECURITY_GROUP = 'NETWORK_SECURITY_GROUP'.freeze, SOURCE_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze ].freeze
Instance Attribute Summary collapse
-
#description ⇒ String
An optional description of your choice for the rule.
-
#destination ⇒ String
Conceptually, this is the range of IP addresses that a packet originating from the instance can go to.
-
#destination_type ⇒ String
Type of destination for the rule.
-
#direction ⇒ String
[Required] Direction of the security rule.
-
#icmp_options ⇒ OCI::Core::Models::IcmpOptions
Optional and valid only for ICMP and ICMPv6.
-
#id ⇒ String
An Oracle-assigned identifier for the security rule.
-
#is_stateless ⇒ BOOLEAN
A stateless rule allows traffic in one direction.
-
#is_valid ⇒ BOOLEAN
Whether the rule is valid.
-
#protocol ⇒ String
[Required] The transport protocol.
-
#source ⇒ String
Conceptually, this is the range of IP addresses that a packet coming into the instance can come from.
-
#source_type ⇒ String
Type of source for the rule.
-
#tcp_options ⇒ OCI::Core::Models::TcpOptions
Optional and valid only for TCP.
-
#time_created ⇒ DateTime
The date and time the security rule was created.
-
#udp_options ⇒ OCI::Core::Models::UdpOptions
Optional and valid only for UDP.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks equality by comparing each attribute.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ SecurityRule
constructor
Initializes the object.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
Constructor Details
#initialize(attributes = {}) ⇒ SecurityRule
Initializes the object
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/oci/core/models/security_rule.rb', line 234 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } self.description = attributes[:'description'] if attributes[:'description'] self.destination = attributes[:'destination'] if attributes[:'destination'] self.destination_type = attributes[:'destinationType'] if attributes[:'destinationType'] raise 'You cannot provide both :destinationType and :destination_type' if attributes.key?(:'destinationType') && attributes.key?(:'destination_type') self.destination_type = attributes[:'destination_type'] if attributes[:'destination_type'] self.direction = attributes[:'direction'] if attributes[:'direction'] self. = attributes[:'icmpOptions'] if attributes[:'icmpOptions'] raise 'You cannot provide both :icmpOptions and :icmp_options' if attributes.key?(:'icmpOptions') && attributes.key?(:'icmp_options') self. = attributes[:'icmp_options'] if attributes[:'icmp_options'] self.id = attributes[:'id'] if attributes[:'id'] self.is_stateless = attributes[:'isStateless'] unless attributes[:'isStateless'].nil? raise 'You cannot provide both :isStateless and :is_stateless' if attributes.key?(:'isStateless') && attributes.key?(:'is_stateless') self.is_stateless = attributes[:'is_stateless'] unless attributes[:'is_stateless'].nil? self.is_valid = attributes[:'isValid'] unless attributes[:'isValid'].nil? raise 'You cannot provide both :isValid and :is_valid' if attributes.key?(:'isValid') && attributes.key?(:'is_valid') self.is_valid = attributes[:'is_valid'] unless attributes[:'is_valid'].nil? self.protocol = attributes[:'protocol'] if attributes[:'protocol'] self.source = attributes[:'source'] if attributes[:'source'] self.source_type = attributes[:'sourceType'] if attributes[:'sourceType'] raise 'You cannot provide both :sourceType and :source_type' if attributes.key?(:'sourceType') && attributes.key?(:'source_type') self.source_type = attributes[:'source_type'] if attributes[:'source_type'] self. = attributes[:'tcpOptions'] if attributes[:'tcpOptions'] raise 'You cannot provide both :tcpOptions and :tcp_options' if attributes.key?(:'tcpOptions') && attributes.key?(:'tcp_options') self. = attributes[:'tcp_options'] if attributes[:'tcp_options'] self.time_created = attributes[:'timeCreated'] if attributes[:'timeCreated'] raise 'You cannot provide both :timeCreated and :time_created' if attributes.key?(:'timeCreated') && attributes.key?(:'time_created') self.time_created = attributes[:'time_created'] if attributes[:'time_created'] self. = attributes[:'udpOptions'] if attributes[:'udpOptions'] raise 'You cannot provide both :udpOptions and :udp_options' if attributes.key?(:'udpOptions') && attributes.key?(:'udp_options') self. = attributes[:'udp_options'] if attributes[:'udp_options'] end |
Instance Attribute Details
#description ⇒ String
An optional description of your choice for the rule.
36 37 38 |
# File 'lib/oci/core/models/security_rule.rb', line 36 def description @description end |
#destination ⇒ String
Conceptually, this is the range of IP addresses that a packet originating from the instance can go to.
Allowed values:
* An IP address range in CIDR notation. For example: `192.168.1.0/24` or `2001:0db8:0123:45::/56`
* The `cidrBlock` value for a {Service}, if you're
setting up a security rule for traffic destined for a particular `Service` through
a service gateway. For example: `oci-phx-objectstorage`.
* The OCID of a {NetworkSecurityGroup} in the same
VCN. The value can be the NSG that the rule belongs to if the rule's intent is to control
traffic between VNICs in the same NSG.
54 55 56 |
# File 'lib/oci/core/models/security_rule.rb', line 54 def destination @destination end |
#destination_type ⇒ String
Type of destination for the rule. Required if ‘direction` = `EGRESS`.
Allowed values:
* `CIDR_BLOCK`: If the rule's `destination` is an IP address range in CIDR notation.
* `SERVICE_CIDR_BLOCK`: If the rule's `destination` is the `cidrBlock` value for a
{Service} (the rule is for traffic destined for a
particular `Service` through a service gateway).
* `NETWORK_SECURITY_GROUP`: If the rule's `destination` is the OCID of a
{NetworkSecurityGroup}.
70 71 72 |
# File 'lib/oci/core/models/security_rule.rb', line 70 def destination_type @destination_type end |
#direction ⇒ String
[Required] Direction of the security rule. Set to ‘EGRESS` for rules to allow outbound IP packets, or `INGRESS` for rules to allow inbound IP packets.
74 75 76 |
# File 'lib/oci/core/models/security_rule.rb', line 74 def direction @direction end |
#icmp_options ⇒ OCI::Core::Models::IcmpOptions
Optional and valid only for ICMP and ICMPv6. Use to specify a particular ICMP type and code as defined in:
-
[ICMP Parameters](www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml)
-
[ICMPv6 Parameters](www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml)
If you specify ICMP or ICMPv6 as the protocol but omit this object, then all ICMP types and codes are allowed. If you do provide this object, the type is required and the code is optional. To enable MTU negotiation for ingress internet traffic via IPv4, make sure to allow type 3 ("Destination Unreachable") code 4 ("Fragmentation Needed and Don’t Fragment was Set"). If you need to specify multiple codes for a single type, create a separate security rule for each.
88 89 90 |
# File 'lib/oci/core/models/security_rule.rb', line 88 def @icmp_options end |
#id ⇒ String
An Oracle-assigned identifier for the security rule. You specify this ID when you want to update or delete the rule.
Example: ‘04ABEC`
96 97 98 |
# File 'lib/oci/core/models/security_rule.rb', line 96 def id @id end |
#is_stateless ⇒ BOOLEAN
A stateless rule allows traffic in one direction. Remember to add a corresponding stateless rule in the other direction if you need to support bidirectional traffic. For example, if egress traffic allows TCP destination port 80, there should be an ingress rule to allow TCP source port 80. Defaults to false, which means the rule is stateful and a corresponding rule is not necessary for bidirectional traffic.
105 106 107 |
# File 'lib/oci/core/models/security_rule.rb', line 105 def is_stateless @is_stateless end |
#is_valid ⇒ BOOLEAN
Whether the rule is valid. The value is ‘True` when the rule is first created. If the rule’s ‘source` or `destination` is a network security group, the value changes to `False` if that network security group is deleted.
112 113 114 |
# File 'lib/oci/core/models/security_rule.rb', line 112 def is_valid @is_valid end |
#protocol ⇒ String
[Required] The transport protocol. Specify either ‘all` or an IPv4 protocol number as defined in [Protocol Numbers](www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml). Options are supported only for ICMP ("1"), TCP ("6"), UDP ("17"), and ICMPv6 ("58").
120 121 122 |
# File 'lib/oci/core/models/security_rule.rb', line 120 def protocol @protocol end |
#source ⇒ String
Conceptually, this is the range of IP addresses that a packet coming into the instance can come from.
Allowed values:
* An IP address range in CIDR notation. For example: `192.168.1.0/24` or `2001:0db8:0123:45::/56`
* The `cidrBlock` value for a {Service}, if you're
setting up a security rule for traffic coming from a particular `Service` through
a service gateway. For example: `oci-phx-objectstorage`.
* The OCID of a {NetworkSecurityGroup} in the same
VCN. The value can be the NSG that the rule belongs to if the rule's intent is to control
traffic between VNICs in the same NSG.
138 139 140 |
# File 'lib/oci/core/models/security_rule.rb', line 138 def source @source end |
#source_type ⇒ String
Type of source for the rule. Required if ‘direction` = `INGRESS`.
* `CIDR_BLOCK`: If the rule's `source` is an IP address range in CIDR notation.
* `SERVICE_CIDR_BLOCK`: If the rule's `source` is the `cidrBlock` value for a
{Service} (the rule is for traffic coming from a
particular `Service` through a service gateway).
* `NETWORK_SECURITY_GROUP`: If the rule's `destination` is the OCID of a
{NetworkSecurityGroup}.
152 153 154 |
# File 'lib/oci/core/models/security_rule.rb', line 152 def source_type @source_type end |
#tcp_options ⇒ OCI::Core::Models::TcpOptions
Optional and valid only for TCP. Use to specify particular destination ports for TCP rules. If you specify TCP as the protocol but omit this object, then all destination ports are allowed.
158 159 160 |
# File 'lib/oci/core/models/security_rule.rb', line 158 def @tcp_options end |
#time_created ⇒ DateTime
The date and time the security rule was created. Format defined by RFC3339.
162 163 164 |
# File 'lib/oci/core/models/security_rule.rb', line 162 def time_created @time_created end |
#udp_options ⇒ OCI::Core::Models::UdpOptions
Optional and valid only for UDP. Use to specify particular destination ports for UDP rules. If you specify UDP as the protocol but omit this object, then all destination ports are allowed.
168 169 170 |
# File 'lib/oci/core/models/security_rule.rb', line 168 def @udp_options end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/oci/core/models/security_rule.rb', line 171 def self.attribute_map { # rubocop:disable Style/SymbolLiteral 'description': :'description', 'destination': :'destination', 'destination_type': :'destinationType', 'direction': :'direction', 'icmp_options': :'icmpOptions', 'id': :'id', 'is_stateless': :'isStateless', 'is_valid': :'isValid', 'protocol': :'protocol', 'source': :'source', 'source_type': :'sourceType', 'tcp_options': :'tcpOptions', 'time_created': :'timeCreated', 'udp_options': :'udpOptions' # rubocop:enable Style/SymbolLiteral } end |
.swagger_types ⇒ Object
Attribute type mapping.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/oci/core/models/security_rule.rb', line 193 def self.swagger_types { # rubocop:disable Style/SymbolLiteral 'description': :'String', 'destination': :'String', 'destination_type': :'String', 'direction': :'String', 'icmp_options': :'OCI::Core::Models::IcmpOptions', 'id': :'String', 'is_stateless': :'BOOLEAN', 'is_valid': :'BOOLEAN', 'protocol': :'String', 'source': :'String', 'source_type': :'String', 'tcp_options': :'OCI::Core::Models::TcpOptions', 'time_created': :'DateTime', 'udp_options': :'OCI::Core::Models::UdpOptions' # rubocop:enable Style/SymbolLiteral } end |
Instance Method Details
#==(other) ⇒ Object
Checks equality by comparing each attribute.
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/oci/core/models/security_rule.rb', line 347 def ==(other) return true if equal?(other) self.class == other.class && description == other.description && destination == other.destination && destination_type == other.destination_type && direction == other.direction && == other. && id == other.id && is_stateless == other.is_stateless && is_valid == other.is_valid && protocol == other.protocol && source == other.source && source_type == other.source_type && == other. && time_created == other.time_created && == other. end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/oci/core/models/security_rule.rb', line 390 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) public_method("#{key}=").call( attributes[self.class.attribute_map[key]] .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) } ) end elsif !attributes[self.class.attribute_map[key]].nil? public_method("#{key}=").call( OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]) ) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(other) ⇒ Boolean
370 371 372 |
# File 'lib/oci/core/models/security_rule.rb', line 370 def eql?(other) self == other end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
379 380 381 |
# File 'lib/oci/core/models/security_rule.rb', line 379 def hash [description, destination, destination_type, direction, , id, is_stateless, is_valid, protocol, source, source_type, , time_created, ].hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
423 424 425 426 427 428 429 430 431 432 |
# File 'lib/oci/core/models/security_rule.rb', line 423 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = public_method(attr).call next if value.nil? && !instance_variable_defined?("@#{attr}") hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
417 418 419 |
# File 'lib/oci/core/models/security_rule.rb', line 417 def to_s to_hash.to_s end |