lib/ionoscloud/models/loadbalancer_properties.rb in ionoscloud-5.1.2 vs lib/ionoscloud/models/loadbalancer_properties.rb in ionoscloud-6.0.0.beta.1
- old
+ new
@@ -1,42 +1,58 @@
=begin
#CLOUD API
#An enterprise-grade Infrastructure is provided as a Service (IaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to perform a variety of management tasks such as spinning up additional servers, adding volumes, adjusting networking, and so forth. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive.
-The version of the OpenAPI document: 5.0
+The version of the OpenAPI document: 6.0
Generated by: https://openapi-generator.tech
-OpenAPI Generator version: 5.2.1-SNAPSHOT
+OpenAPI Generator version: 5.0.1-SNAPSHOT
=end
require 'date'
require 'time'
module Ionoscloud
class LoadbalancerProperties
-
# A name of that resource
attr_accessor :name
-
# IPv4 address of the loadbalancer. All attached NICs will inherit this IP. Leaving value null will assign IP automatically
attr_accessor :ip
-
# Indicates if the loadbalancer will reserve an IP using DHCP
attr_accessor :dhcp
+ class EnumAttributeValidator
+ attr_reader :datatype
+ attr_reader :allowable_values
+
+ def initialize(datatype, allowable_values)
+ @allowable_values = allowable_values.map do |value|
+ case datatype.to_s
+ when /Integer/i
+ value.to_i
+ when /Float/i
+ value.to_f
+ else
+ value
+ end
+ end
+ end
+
+ def valid?(value)
+ !value || allowable_values.include?(value)
+ end
+ end
+
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
-
:'name' => :'name',
-
:'ip' => :'ip',
-
:'dhcp' => :'dhcp'
}
end
# Returns all the JSON keys this model knows about
@@ -45,25 +61,19 @@
end
# Attribute type mapping.
def self.openapi_types
{
-
:'name' => :'String',
-
:'ip' => :'String',
-
:'dhcp' => :'Boolean'
}
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
@@ -77,74 +87,57 @@
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Ionoscloud::LoadbalancerProperties`. 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?(:'ip')
self.ip = attributes[:'ip']
end
-
if attributes.key?(:'dhcp')
self.dhcp = attributes[:'dhcp']
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
-
-
- 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 !@ip.nil? && @ip !~ pattern
- invalid_properties.push("invalid value for \"ip\", must conform to the pattern #{pattern}.")
- 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 !@ip.nil? && @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]?)$/)
-
+ ip_validator = EnumAttributeValidator.new('String', ["@Valid IP address@", "null"])
+ return false unless ip_validator.valid?(@ip)
true
end
-
-
- # Custom attribute writer method with validation
- # @param [Object] ip Value to be assigned
+ # Custom attribute writer method checking allowed values (enum).
+ # @param [Object] ip Object to be assigned
def ip=(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 !ip.nil? && ip !~ pattern
- fail ArgumentError, "invalid value for \"ip\", must conform to the pattern #{pattern}."
+ validator = EnumAttributeValidator.new('String', ["@Valid IP address@", "null"])
+ unless validator.valid?(ip)
+ fail ArgumentError, "invalid value for \"ip\", must be one of #{validator.allowable_values}."
end
-
@ip = ip
end
-
# 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 &&
- ip == o.ip &&
- dhcp == o.dhcp
+ name == o.name &&
+ ip == o.ip &&
+ dhcp == o.dhcp
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
@@ -272,9 +265,7 @@
value.to_hash
else
value
end
end
-
end
-
end