Class: OCI::LoadBalancer::Models::HealthChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/load_balancer/models/health_checker.rb

Overview

The health check policy configuration. For more information, see Editing Health Check Policies.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ HealthChecker

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :protocol (String)

    The value to assign to the #protocol property

  • :url_path (String)

    The value to assign to the #url_path property

  • :port (Integer)

    The value to assign to the #port property

  • :return_code (Integer)

    The value to assign to the #return_code property

  • :retries (Integer)

    The value to assign to the #retries property

  • :timeout_in_millis (Integer)

    The value to assign to the #timeout_in_millis property

  • :interval_in_millis (Integer)

    The value to assign to the #interval_in_millis property

  • :response_body_regex (String)

    The value to assign to the #response_body_regex property



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/oci/load_balancer/models/health_checker.rb', line 118

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

  self.url_path = attributes[:'urlPath'] if attributes[:'urlPath']

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

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

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

  self.return_code = attributes[:'returnCode'] if attributes[:'returnCode']

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

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

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

  self.timeout_in_millis = attributes[:'timeoutInMillis'] if attributes[:'timeoutInMillis']

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

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

  self.interval_in_millis = attributes[:'intervalInMillis'] if attributes[:'intervalInMillis']

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

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

  self.response_body_regex = attributes[:'responseBodyRegex'] if attributes[:'responseBodyRegex']

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

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

Instance Attribute Details

#interval_in_millisInteger

The interval between health checks, in milliseconds. The default is 10000 (10 seconds).

Example: 10000

Returns:

  • (Integer)


63
64
65
# File 'lib/oci/load_balancer/models/health_checker.rb', line 63

def interval_in_millis
  @interval_in_millis
end

#portInteger

[Required] The backend server port against which to run the health check. If the port is not specified, the load balancer uses the port information from the Backend object.

Example: 8080

Returns:

  • (Integer)


32
33
34
# File 'lib/oci/load_balancer/models/health_checker.rb', line 32

def port
  @port
end

#protocolString

[Required] The protocol the health check must use; either HTTP or TCP.

Example: HTTP

Returns:

  • (String)


17
18
19
# File 'lib/oci/load_balancer/models/health_checker.rb', line 17

def protocol
  @protocol
end

#response_body_regexString

[Required] A regular expression for parsing the response body from the backend server.

Example: ^((?!false).|\s)*$

Returns:

  • (String)


70
71
72
# File 'lib/oci/load_balancer/models/health_checker.rb', line 70

def response_body_regex
  @response_body_regex
end

#retriesInteger

The number of retries to attempt before a backend server is considered "unhealthy". This number also applies when recovering a server to the "healthy" state. Defaults to 3.

Example: 3

Returns:

  • (Integer)


48
49
50
# File 'lib/oci/load_balancer/models/health_checker.rb', line 48

def retries
  @retries
end

#return_codeInteger

[Required] The status code a healthy backend server should return. If you configure the health check policy to use the HTTP protocol, you can use common HTTP status codes such as "200".

Example: 200

Returns:

  • (Integer)


40
41
42
# File 'lib/oci/load_balancer/models/health_checker.rb', line 40

def return_code
  @return_code
end

#timeout_in_millisInteger

The maximum time, in milliseconds, to wait for a reply to a health check. A health check is successful only if a reply returns within this timeout period. Defaults to 3000 (3 seconds).

Example: 3000

Returns:

  • (Integer)


56
57
58
# File 'lib/oci/load_balancer/models/health_checker.rb', line 56

def timeout_in_millis
  @timeout_in_millis
end

#url_pathString

The path against which to run the health check.

Example: /healthcheck

Returns:

  • (String)


24
25
26
# File 'lib/oci/load_balancer/models/health_checker.rb', line 24

def url_path
  @url_path
end

Class Method Details

.attribute_mapObject

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/oci/load_balancer/models/health_checker.rb', line 73

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'protocol': :'protocol',
    'url_path': :'urlPath',
    'port': :'port',
    'return_code': :'returnCode',
    'retries': :'retries',
    'timeout_in_millis': :'timeoutInMillis',
    'interval_in_millis': :'intervalInMillis',
    'response_body_regex': :'responseBodyRegex'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/oci/load_balancer/models/health_checker.rb', line 89

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'protocol': :'String',
    'url_path': :'String',
    'port': :'Integer',
    'return_code': :'Integer',
    'retries': :'Integer',
    'timeout_in_millis': :'Integer',
    'interval_in_millis': :'Integer',
    'response_body_regex': :'String'
    # 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



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/oci/load_balancer/models/health_checker.rb', line 168

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    protocol == other.protocol &&
    url_path == other.url_path &&
    port == other.port &&
    return_code == other.return_code &&
    retries == other.retries &&
    timeout_in_millis == other.timeout_in_millis &&
    interval_in_millis == other.interval_in_millis &&
    response_body_regex == other.response_body_regex
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



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/oci/load_balancer/models/health_checker.rb', line 205

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


185
186
187
# File 'lib/oci/load_balancer/models/health_checker.rb', line 185

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



194
195
196
# File 'lib/oci/load_balancer/models/health_checker.rb', line 194

def hash
  [protocol, url_path, port, return_code, retries, timeout_in_millis, interval_in_millis, response_body_regex].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



238
239
240
241
242
243
244
245
246
247
# File 'lib/oci/load_balancer/models/health_checker.rb', line 238

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



232
233
234
# File 'lib/oci/load_balancer/models/health_checker.rb', line 232

def to_s
  to_hash.to_s
end