lib/ionoscloud/models/firewallrule_properties.rb in ionoscloud-6.0.0.beta.4 vs lib/ionoscloud/models/firewallrule_properties.rb in ionoscloud-6.0.0

- old
+ new

@@ -1,11 +1,11 @@ =begin #CLOUD API #IONOS Enterprise-grade Infrastructure as a Service (IaaS) solutions can be managed through the Cloud API, in addition or as an alternative to the \"Data Center Designer\" (DCD) browser-based tool. Both methods employ consistent concepts and features, deliver similar power and flexibility, and can be used to perform a multitude of management tasks, including adding servers, volumes, configuring networks, and so on. -The version of the OpenAPI document: 6.0-SDK.3 +The version of the OpenAPI document: 6.0 Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.2.1-SNAPSHOT =end @@ -13,38 +13,48 @@ require 'date' require 'time' module Ionoscloud class FirewallruleProperties - # A name of that resource + + # The name of the resource. attr_accessor :name - # The protocol for the rule. Property cannot be modified after creation (disallowed in update requests) + + # The protocol for the rule. Property cannot be modified after it is created (disallowed in update requests). attr_accessor :protocol - # Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address + + # Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows traffic from any MAC address. attr_accessor :source_mac - # Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs + + # Only traffic originating from the respective IPv4 address is allowed. Value null allows traffic from any IP address. attr_accessor :source_ip - # In case the target NIC has multiple IP addresses, only traffic directed to the respective IP address of the NIC is allowed. Value null allows all target IPs + + # If the target NIC has multiple IP addresses, only the traffic directed to the respective IP address of the NIC is allowed. Value null Value null allows traffic to any target IP address. attr_accessor :target_ip - # Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes + + # Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes. attr_accessor :icmp_code - # Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types + + # Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types. attr_accessor :icmp_type - # Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports + + # Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports. attr_accessor :port_range_start - # Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd null to allow all ports + + # Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd null to allow all ports. attr_accessor :port_range_end - # The type of firewall rule. If is not specified, it will take the default value INGRESS + + # The type of firewall rule. If not specified, the default INGRESS value is taken. attr_accessor :type class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values @@ -68,19 +78,29 @@ end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'name' => :'name', + :'protocol' => :'protocol', + :'source_mac' => :'sourceMac', + :'source_ip' => :'sourceIp', + :'target_ip' => :'targetIp', + :'icmp_code' => :'icmpCode', + :'icmp_type' => :'icmpType', + :'port_range_start' => :'portRangeStart', + :'port_range_end' => :'portRangeEnd', + :'type' => :'type' } end # Returns all the JSON keys this model knows about @@ -89,26 +109,46 @@ end # Attribute type mapping. def self.openapi_types { + :'name' => :'String', + :'protocol' => :'String', + :'source_mac' => :'String', + :'source_ip' => :'String', + :'target_ip' => :'String', + :'icmp_code' => :'Integer', + :'icmp_type' => :'Integer', + :'port_range_start' => :'Integer', + :'port_range_end' => :'Integer', + :'type' => :'String' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ + + + + + + + + + + ]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash @@ -122,142 +162,175 @@ if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Ionoscloud::FirewallruleProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } + if attributes.key?(:'name') self.name = attributes[:'name'] end + if attributes.key?(:'protocol') self.protocol = attributes[:'protocol'] end + if attributes.key?(:'source_mac') self.source_mac = attributes[:'source_mac'] end + if attributes.key?(:'source_ip') self.source_ip = attributes[:'source_ip'] end + if attributes.key?(:'target_ip') self.target_ip = attributes[:'target_ip'] end + if attributes.key?(:'icmp_code') self.icmp_code = attributes[:'icmp_code'] end + if attributes.key?(:'icmp_type') self.icmp_type = attributes[:'icmp_type'] end + if attributes.key?(:'port_range_start') self.port_range_start = attributes[:'port_range_start'] end + if attributes.key?(:'port_range_end') self.port_range_end = attributes[:'port_range_end'] end + if attributes.key?(:'type') self.type = attributes[:'type'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + + if @protocol.nil? invalid_properties.push('invalid value for "protocol", protocol cannot be nil.') end + pattern = Regexp.new(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/) if !@source_mac.nil? && @source_mac !~ pattern invalid_properties.push("invalid value for \"source_mac\", must conform to the pattern #{pattern}.") end + pattern = Regexp.new(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) if !@source_ip.nil? && @source_ip !~ pattern invalid_properties.push("invalid value for \"source_ip\", must conform to the pattern #{pattern}.") end + pattern = Regexp.new(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) if !@target_ip.nil? && @target_ip !~ pattern invalid_properties.push("invalid value for \"target_ip\", must conform to the pattern #{pattern}.") end + if !@icmp_code.nil? && @icmp_code > 254 invalid_properties.push('invalid value for "icmp_code", must be smaller than or equal to 254.') end if !@icmp_code.nil? && @icmp_code < 0 invalid_properties.push('invalid value for "icmp_code", must be greater than or equal to 0.') end + if !@icmp_type.nil? && @icmp_type > 254 invalid_properties.push('invalid value for "icmp_type", must be smaller than or equal to 254.') end if !@icmp_type.nil? && @icmp_type < 0 invalid_properties.push('invalid value for "icmp_type", must be greater than or equal to 0.') end + if !@port_range_start.nil? && @port_range_start > 65534 invalid_properties.push('invalid value for "port_range_start", must be smaller than or equal to 65534.') end if !@port_range_start.nil? && @port_range_start < 1 invalid_properties.push('invalid value for "port_range_start", must be greater than or equal to 1.') end + if !@port_range_end.nil? && @port_range_end > 65534 invalid_properties.push('invalid value for "port_range_end", must be smaller than or equal to 65534.') end if !@port_range_end.nil? && @port_range_end < 1 invalid_properties.push('invalid value for "port_range_end", must be greater than or equal to 1.') end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + + return false if @protocol.nil? protocol_validator = EnumAttributeValidator.new('String', ["TCP", "UDP", "ICMP", "ANY"]) return false unless protocol_validator.valid?(@protocol) + return false if !@source_mac.nil? && @source_mac !~ Regexp.new(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/) + return false if !@source_ip.nil? && @source_ip !~ Regexp.new(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) + return false if !@target_ip.nil? && @target_ip !~ Regexp.new(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) + return false if !@icmp_code.nil? && @icmp_code > 254 return false if !@icmp_code.nil? && @icmp_code < 0 + return false if !@icmp_type.nil? && @icmp_type > 254 return false if !@icmp_type.nil? && @icmp_type < 0 + return false if !@port_range_start.nil? && @port_range_start > 65534 return false if !@port_range_start.nil? && @port_range_start < 1 + return false if !@port_range_end.nil? && @port_range_end > 65534 return false if !@port_range_end.nil? && @port_range_end < 1 + type_validator = EnumAttributeValidator.new('String', ["INGRESS", "EGRESS"]) return false unless type_validator.valid?(@type) true end + + # Custom attribute writer method checking allowed values (enum). # @param [Object] protocol Object to be assigned def protocol=(protocol) validator = EnumAttributeValidator.new('String', ["TCP", "UDP", "ICMP", "ANY"]) unless validator.valid?(protocol) fail ArgumentError, "invalid value for \"protocol\", must be one of #{validator.allowable_values}." end @protocol = protocol end + # Custom attribute writer method with validation # @param [Object] source_mac Value to be assigned def source_mac=(source_mac) pattern = Regexp.new(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/) if !source_mac.nil? && source_mac !~ pattern @@ -265,10 +338,11 @@ end @source_mac = source_mac end + # Custom attribute writer method with validation # @param [Object] source_ip Value to be assigned def source_ip=(source_ip) pattern = Regexp.new(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) if !source_ip.nil? && source_ip !~ pattern @@ -276,10 +350,11 @@ end @source_ip = source_ip end + # Custom attribute writer method with validation # @param [Object] target_ip Value to be assigned def target_ip=(target_ip) pattern = Regexp.new(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) if !target_ip.nil? && target_ip !~ pattern @@ -287,10 +362,11 @@ end @target_ip = target_ip end + # Custom attribute writer method with validation # @param [Object] icmp_code Value to be assigned def icmp_code=(icmp_code) if !icmp_code.nil? && icmp_code > 254 fail ArgumentError, 'invalid value for "icmp_code", must be smaller than or equal to 254.' @@ -301,10 +377,11 @@ end @icmp_code = icmp_code end + # Custom attribute writer method with validation # @param [Object] icmp_type Value to be assigned def icmp_type=(icmp_type) if !icmp_type.nil? && icmp_type > 254 fail ArgumentError, 'invalid value for "icmp_type", must be smaller than or equal to 254.' @@ -315,10 +392,11 @@ end @icmp_type = icmp_type end + # Custom attribute writer method with validation # @param [Object] port_range_start Value to be assigned def port_range_start=(port_range_start) if !port_range_start.nil? && port_range_start > 65534 fail ArgumentError, 'invalid value for "port_range_start", must be smaller than or equal to 65534.' @@ -329,10 +407,11 @@ end @port_range_start = port_range_start end + # Custom attribute writer method with validation # @param [Object] port_range_end Value to be assigned def port_range_end=(port_range_end) if !port_range_end.nil? && port_range_end > 65534 fail ArgumentError, 'invalid value for "port_range_end", must be smaller than or equal to 65534.' @@ -343,10 +422,11 @@ end @port_range_end = port_range_end end + # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) validator = EnumAttributeValidator.new('String', ["INGRESS", "EGRESS"]) unless validator.valid?(type) @@ -358,19 +438,19 @@ # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && - name == o.name && - protocol == o.protocol && - source_mac == o.source_mac && - source_ip == o.source_ip && - target_ip == o.target_ip && - icmp_code == o.icmp_code && - icmp_type == o.icmp_type && - port_range_start == o.port_range_start && - port_range_end == o.port_range_end && - type == o.type + name == o.name && + protocol == o.protocol && + source_mac == o.source_mac && + source_ip == o.source_ip && + target_ip == o.target_ip && + icmp_code == o.icmp_code && + icmp_type == o.icmp_type && + port_range_start == o.port_range_start && + port_range_end == o.port_range_end && + type == o.type end # @see the `==` method # @param [Object] Object to be compared def eql?(o)