Class: LinodeOpenapiClient::PostNodeBalancerRequestConfigsInner

Inherits:
Object
  • Object
show all
Defined in:
lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb

Overview

A request object representing a NodeBalancer Config, including Nodes.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PostNodeBalancerRequestConfigsInner

Initializes the object

Parameters:

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

    Model attributes in the form of hash



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 148

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `LinodeOpenapiClient::PostNodeBalancerRequestConfigsInner` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `LinodeOpenapiClient::PostNodeBalancerRequestConfigsInner`. 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?(:'check_path')
    self.check_path = attributes[:'check_path']
  end

  if attributes.key?(:'ssl_key')
    self.ssl_key = attributes[:'ssl_key']
  end

  if attributes.key?(:'check_passive')
    self.check_passive = attributes[:'check_passive']
  else
    self.check_passive = true
  end

  if attributes.key?(:'nodes')
    if (value = attributes[:'nodes']).is_a?(Array)
      self.nodes = value
    end
  else
    self.nodes = nil
  end

  if attributes.key?(:'algorithm')
    self.algorithm = attributes[:'algorithm']
  else
    self.algorithm = 'roundrobin'
  end

  if attributes.key?(:'check_timeout')
    self.check_timeout = attributes[:'check_timeout']
  else
    self.check_timeout = 30
  end

  if attributes.key?(:'protocol')
    self.protocol = attributes[:'protocol']
  else
    self.protocol = 'http'
  end

  if attributes.key?(:'stickiness')
    self.stickiness = attributes[:'stickiness']
  else
    self.stickiness = 'none'
  end

  if attributes.key?(:'cipher_suite')
    self.cipher_suite = attributes[:'cipher_suite']
  else
    self.cipher_suite = 'recommended'
  end

  if attributes.key?(:'check_body')
    self.check_body = attributes[:'check_body']
  end

  if attributes.key?(:'ssl_cert')
    self.ssl_cert = attributes[:'ssl_cert']
  end

  if attributes.key?(:'check_attempts')
    self.check_attempts = attributes[:'check_attempts']
  else
    self.check_attempts = 3
  end

  if attributes.key?(:'port')
    self.port = attributes[:'port']
  else
    self.port = 80
  end

  if attributes.key?(:'proxy_protocol')
    self.proxy_protocol = attributes[:'proxy_protocol']
  else
    self.proxy_protocol = 'none'
  end

  if attributes.key?(:'check_interval')
    self.check_interval = attributes[:'check_interval']
  else
    self.check_interval = 31
  end

  if attributes.key?(:'check')
    self.check = attributes[:'check']
  else
    self.check = 'none'
  end
end

Instance Attribute Details

#algorithmObject

What algorithm this NodeBalancer should use for routing traffic to backends.



32
33
34
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 32

def algorithm
  @algorithm
end

#checkObject

The type of check to perform against backends to ensure they are serving requests. This is used to determine if backends are up or down. - If ‘none` no check is performed. - `connection` requires only a connection to the backend to succeed. - `http` and `http_body` rely on the backend serving HTTP, and that the response returned matches what is expected.



65
66
67
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 65

def check
  @check
end

#check_attemptsObject

How many times to attempt a check before considering a backend to be down.



53
54
55
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 53

def check_attempts
  @check_attempts
end

#check_bodyObject

This value must be present in the response body of the check in order for it to pass. If this value is not present in the response body of a check request, the backend is considered to be down.



47
48
49
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 47

def check_body
  @check_body
end

#check_intervalObject

How often, in seconds, to check that backends are up and serving requests. Must be greater than ‘check_timeout`.



62
63
64
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 62

def check_interval
  @check_interval
end

#check_passiveObject

If true, any response from this backend with a ‘5xx` status code will be enough for it to be considered unhealthy and taken out of rotation.



26
27
28
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 26

def check_passive
  @check_passive
end

#check_pathObject

The URL path to check on each backend. If the backend does not respond to this request it is considered to be down.



20
21
22
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 20

def check_path
  @check_path
end

#check_timeoutObject

How long, in seconds, to wait for a check attempt before considering it failed. Must be less than ‘check_interval`.



35
36
37
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 35

def check_timeout
  @check_timeout
end

#cipher_suiteObject

What ciphers to use for SSL connections served by this NodeBalancer. - ‘legacy` is considered insecure and should only be used if necessary.



44
45
46
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 44

def cipher_suite
  @cipher_suite
end

#nodesObject

The NodeBalancer Nodes that serve this Config.



29
30
31
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 29

def nodes
  @nodes
end

#portObject

The port this Config is for. These values must be unique across configs on a single NodeBalancer (you can’t have two configs for port 80, for example). While some ports imply some protocols, no enforcement is done and you may configure your NodeBalancer however is useful to you. For example, while port 443 is generally used for HTTPS, you do not need SSL configured to have a NodeBalancer listening on port 443.



56
57
58
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 56

def port
  @port
end

#protocolObject

The protocol this port is configured to serve. - The ‘http` and `tcp` protocols do not support `ssl_cert` and `ssl_key`. - The `https` protocol is mutually required with `ssl_cert` and `ssl_key`. Review our guide on [Available Protocols](www.linode.com/docs/products/networking/nodebalancers/guides/protocols/) for information on protocol features.



38
39
40
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 38

def protocol
  @protocol
end

#proxy_protocolObject

ProxyProtocol is a TCP extension that sends initial TCP connection information such as source/destination IPs and ports to backend devices. This information would be lost otherwise. Backend devices must be configured to work with ProxyProtocol if enabled. - If omitted, or set to ‘none`, the NodeBalancer doesn’t send any auxiliary data over TCP connections. This is the default. - If set to ‘v1`, the human-readable header format (Version 1) is used. Requires `tcp` protocol. - If set to `v2`, the binary header format (Version 2) is used. Requires `tcp` protocol.



59
60
61
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 59

def proxy_protocol
  @proxy_protocol
end

#ssl_certObject

The PEM-formatted public SSL certificate (or the combined PEM-formatted SSL certificate and Certificate Authority chain) that should be served on this NodeBalancerConfig’s port. Line breaks must be represented as ‘\n` in the string for requests (but not when using the Linode CLI). [Diffie-Hellman Parameters](www.linode.com/docs/products/networking/nodebalancers/guides/ssl-termination/#diffie-hellman-parameters) can be included in this value to enable forward secrecy. The contents of this field will not be shown in any responses that display the NodeBalancerConfig. Instead, `<REDACTED>` will be printed where the field appears. The read-only `ssl_commonname` and `ssl_fingerprint` fields in a NodeBalancerConfig response are automatically derived from your certificate. Please refer to these fields to verify that the appropriate certificate was assigned to your NodeBalancerConfig.



50
51
52
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 50

def ssl_cert
  @ssl_cert
end

#ssl_keyObject

The PEM-formatted private key for the SSL certificate set in the ‘ssl_cert` field. Line breaks must be represented as `\n` in the string for requests (but not when using the Linode CLI). The contents of this field will not be shown in any responses that display the NodeBalancerConfig. Instead, `<REDACTED>` will be printed where the field appears. The read-only `ssl_commonname` and `ssl_fingerprint` fields in a NodeBalancerConfig response are automatically derived from your certificate. Please refer to these fields to verify that the appropriate certificate was assigned to your NodeBalancerConfig.



23
24
25
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 23

def ssl_key
  @ssl_key
end

#stickinessObject

Controls how session stickiness is handled on this port. - If set to ‘none` connections will always be assigned a backend based on the algorithm configured. - If set to `table` sessions from the same remote address will be routed to the same backend. - For HTTP or HTTPS clients, `http_cookie` allows sessions to be routed to the same backend based on a cookie set by the NodeBalancer.



41
42
43
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 41

def stickiness
  @stickiness
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 511

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = LinodeOpenapiClient.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



112
113
114
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 112

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 90

def self.attribute_map
  {
    :'check_path' => :'check_path',
    :'ssl_key' => :'ssl_key',
    :'check_passive' => :'check_passive',
    :'nodes' => :'nodes',
    :'algorithm' => :'algorithm',
    :'check_timeout' => :'check_timeout',
    :'protocol' => :'protocol',
    :'stickiness' => :'stickiness',
    :'cipher_suite' => :'cipher_suite',
    :'check_body' => :'check_body',
    :'ssl_cert' => :'ssl_cert',
    :'check_attempts' => :'check_attempts',
    :'port' => :'port',
    :'proxy_protocol' => :'proxy_protocol',
    :'check_interval' => :'check_interval',
    :'check' => :'check'
  }
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



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 487

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



139
140
141
142
143
144
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 139

def self.openapi_nullable
  Set.new([
    :'ssl_key',
    :'ssl_cert',
  ])
end

.openapi_typesObject

Attribute type mapping.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 117

def self.openapi_types
  {
    :'check_path' => :'String',
    :'ssl_key' => :'String',
    :'check_passive' => :'Boolean',
    :'nodes' => :'Array<PostNodeBalancerRequestConfigsInnerNodesInner>',
    :'algorithm' => :'String',
    :'check_timeout' => :'Integer',
    :'protocol' => :'String',
    :'stickiness' => :'String',
    :'cipher_suite' => :'String',
    :'check_body' => :'String',
    :'ssl_cert' => :'String',
    :'check_attempts' => :'Integer',
    :'port' => :'Integer',
    :'proxy_protocol' => :'String',
    :'check_interval' => :'Integer',
    :'check' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 451

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      check_path == o.check_path &&
      ssl_key == o.ssl_key &&
      check_passive == o.check_passive &&
      nodes == o.nodes &&
      algorithm == o.algorithm &&
      check_timeout == o.check_timeout &&
      protocol == o.protocol &&
      stickiness == o.stickiness &&
      cipher_suite == o.cipher_suite &&
      check_body == o.check_body &&
      ssl_cert == o.ssl_cert &&
      check_attempts == o.check_attempts &&
      port == o.port &&
      proxy_protocol == o.proxy_protocol &&
      check_interval == o.check_interval &&
      check == o.check
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 582

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


474
475
476
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 474

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



480
481
482
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 480

def hash
  [check_path, ssl_key, check_passive, nodes, algorithm, check_timeout, protocol, stickiness, cipher_suite, check_body, ssl_cert, check_attempts, port, proxy_protocol, check_interval, check].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 254

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  pattern = Regexp.new(/^[a-zA-Z0-9\/\-%?&=.]*$/)
  if !@check_path.nil? && @check_path !~ pattern
    invalid_properties.push("invalid value for \"check_path\", must conform to the pattern #{pattern}.")
  end

  if @nodes.nil?
    invalid_properties.push('invalid value for "nodes", nodes cannot be nil.')
  end

  if !@check_timeout.nil? && @check_timeout > 30
    invalid_properties.push('invalid value for "check_timeout", must be smaller than or equal to 30.')
  end

  if !@check_timeout.nil? && @check_timeout < 1
    invalid_properties.push('invalid value for "check_timeout", must be greater than or equal to 1.')
  end

  if !@check_attempts.nil? && @check_attempts > 30
    invalid_properties.push('invalid value for "check_attempts", must be smaller than or equal to 30.')
  end

  if !@check_attempts.nil? && @check_attempts < 1
    invalid_properties.push('invalid value for "check_attempts", must be greater than or equal to 1.')
  end

  if !@port.nil? && @port > 65535
    invalid_properties.push('invalid value for "port", must be smaller than or equal to 65535.')
  end

  if !@port.nil? && @port < 1
    invalid_properties.push('invalid value for "port", must be greater than or equal to 1.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



558
559
560
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 558

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 564

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



552
553
554
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 552

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/linode_openapi_client/models/post_node_balancer_request_configs_inner.rb', line 295

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@check_path.nil? && @check_path !~ Regexp.new(/^[a-zA-Z0-9\/\-%?&=.]*$/)
  return false if @nodes.nil?
  algorithm_validator = EnumAttributeValidator.new('String', ["roundrobin", "leastconn", "source"])
  return false unless algorithm_validator.valid?(@algorithm)
  return false if !@check_timeout.nil? && @check_timeout > 30
  return false if !@check_timeout.nil? && @check_timeout < 1
  protocol_validator = EnumAttributeValidator.new('String', ["http", "https", "tcp"])
  return false unless protocol_validator.valid?(@protocol)
  stickiness_validator = EnumAttributeValidator.new('String', ["none", "table", "http_cookie"])
  return false unless stickiness_validator.valid?(@stickiness)
  cipher_suite_validator = EnumAttributeValidator.new('String', ["recommended", "legacy"])
  return false unless cipher_suite_validator.valid?(@cipher_suite)
  return false if !@check_attempts.nil? && @check_attempts > 30
  return false if !@check_attempts.nil? && @check_attempts < 1
  return false if !@port.nil? && @port > 65535
  return false if !@port.nil? && @port < 1
  proxy_protocol_validator = EnumAttributeValidator.new('String', ["none", "v1", "v2"])
  return false unless proxy_protocol_validator.valid?(@proxy_protocol)
  check_validator = EnumAttributeValidator.new('String', ["none", "connection", "http", "http_body"])
  return false unless check_validator.valid?(@check)
  true
end