Class: OCI::Core::Models::UpdateSecurityRuleDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/core/models/update_security_rule_details.rb

Overview

A rule for allowing 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
].freeze
DIRECTION_ENUM =
[
  DIRECTION_EGRESS = 'EGRESS'.freeze,
  DIRECTION_INGRESS = 'INGRESS'.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
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UpdateSecurityRuleDetails

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/oci/core/models/update_security_rule_details.rb', line 200

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.icmp_options = attributes[:'icmpOptions'] if attributes[:'icmpOptions']

  raise 'You cannot provide both :icmpOptions and :icmp_options' if attributes.key?(:'icmpOptions') && attributes.key?(:'icmp_options')

  self.icmp_options = 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.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.tcp_options = attributes[:'tcpOptions'] if attributes[:'tcpOptions']

  raise 'You cannot provide both :tcpOptions and :tcp_options' if attributes.key?(:'tcpOptions') && attributes.key?(:'tcp_options')

  self.tcp_options = attributes[:'tcp_options'] if attributes[:'tcp_options']

  self.udp_options = attributes[:'udpOptions'] if attributes[:'udpOptions']

  raise 'You cannot provide both :udpOptions and :udp_options' if attributes.key?(:'udpOptions') && attributes.key?(:'udp_options')

  self.udp_options = attributes[:'udp_options'] if attributes[:'udp_options']
end

Instance Attribute Details

#descriptionString

An optional description of your choice for the rule. Avoid entering confidential information.

Returns:

  • (String)


31
32
33
# File 'lib/oci/core/models/update_security_rule_details.rb', line 31

def description
  @description
end

#destinationString

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`
  IPv6 addressing is supported for all commercial and government regions. See
  [IPv6 Addresses](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/ipv6.htm).

* 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](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) 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.

Returns:

  • (String)


51
52
53
# File 'lib/oci/core/models/update_security_rule_details.rb', line 51

def destination
  @destination
end

#destination_typeString

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](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of a
  {NetworkSecurityGroup}.

Returns:

  • (String)


67
68
69
# File 'lib/oci/core/models/update_security_rule_details.rb', line 67

def destination_type
  @destination_type
end

#directionString

[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.

Returns:

  • (String)


73
74
75
# File 'lib/oci/core/models/update_security_rule_details.rb', line 73

def direction
  @direction
end

#icmp_optionsOCI::Core::Models::IcmpOptions



76
77
78
# File 'lib/oci/core/models/update_security_rule_details.rb', line 76

def icmp_options
  @icmp_options
end

#idString

[Required] The Oracle-assigned ID of the security rule that you want to update. You can’t change this value.

Example: 04ABEC

Returns:

  • (String)


83
84
85
# File 'lib/oci/core/models/update_security_rule_details.rb', line 83

def id
  @id
end

#is_statelessBOOLEAN

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.

Returns:

  • (BOOLEAN)


92
93
94
# File 'lib/oci/core/models/update_security_rule_details.rb', line 92

def is_stateless
  @is_stateless
end

#protocolString

[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").

Returns:

  • (String)


100
101
102
# File 'lib/oci/core/models/update_security_rule_details.rb', line 100

def protocol
  @protocol
end

#sourceString

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`
  IPv6 addressing is supported for all commercial and government regions. See
  [IPv6 Addresses](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/ipv6.htm).

* 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](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) 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.

Returns:

  • (String)


120
121
122
# File 'lib/oci/core/models/update_security_rule_details.rb', line 120

def source
  @source
end

#source_typeString

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 `source` is the [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of a
  {NetworkSecurityGroup}.

Returns:

  • (String)


134
135
136
# File 'lib/oci/core/models/update_security_rule_details.rb', line 134

def source_type
  @source_type
end

#tcp_optionsOCI::Core::Models::TcpOptions



137
138
139
# File 'lib/oci/core/models/update_security_rule_details.rb', line 137

def tcp_options
  @tcp_options
end

#udp_optionsOCI::Core::Models::UdpOptions



140
141
142
# File 'lib/oci/core/models/update_security_rule_details.rb', line 140

def udp_options
  @udp_options
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/oci/core/models/update_security_rule_details.rb', line 143

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',
    'protocol': :'protocol',
    'source': :'source',
    'source_type': :'sourceType',
    'tcp_options': :'tcpOptions',
    'udp_options': :'udpOptions'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/oci/core/models/update_security_rule_details.rb', line 163

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',
    'protocol': :'String',
    'source': :'String',
    'source_type': :'String',
    'tcp_options': :'OCI::Core::Models::TcpOptions',
    'udp_options': :'OCI::Core::Models::UdpOptions'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/oci/core/models/update_security_rule_details.rb', line 286

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 &&
    icmp_options == other.icmp_options &&
    id == other.id &&
    is_stateless == other.is_stateless &&
    protocol == other.protocol &&
    source == other.source &&
    source_type == other.source_type &&
    tcp_options == other.tcp_options &&
    udp_options == other.udp_options
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/oci/core/models/update_security_rule_details.rb', line 327

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

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


307
308
309
# File 'lib/oci/core/models/update_security_rule_details.rb', line 307

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



316
317
318
# File 'lib/oci/core/models/update_security_rule_details.rb', line 316

def hash
  [description, destination, destination_type, direction, icmp_options, id, is_stateless, protocol, source, source_type, tcp_options, udp_options].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



360
361
362
363
364
365
366
367
368
369
# File 'lib/oci/core/models/update_security_rule_details.rb', line 360

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_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



354
355
356
# File 'lib/oci/core/models/update_security_rule_details.rb', line 354

def to_s
  to_hash.to_s
end