Class: OCI::Waas::Models::HealthCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/waas/models/health_check.rb

Overview

Health checks monitor the status of your origin servers and only route traffic to the origins that pass the health check. If the health check fails, origin is automatically removed from the load balancing. There is roughly one health check per EDGE POP per period. Any checks that pass will be reported as "healthy".

Constant Summary collapse

METHOD_ENUM =
[
  METHOD_GET = 'GET'.freeze,
  METHOD_HEAD = 'HEAD'.freeze,
  METHOD_POST = 'POST'.freeze,
  METHOD_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
EXPECTED_RESPONSE_CODE_GROUP_ENUM =
[
  EXPECTED_RESPONSE_CODE_GROUP_2_XX = '2XX'.freeze,
  EXPECTED_RESPONSE_CODE_GROUP_3_XX = '3XX'.freeze,
  EXPECTED_RESPONSE_CODE_GROUP_4_XX = '4XX'.freeze,
  EXPECTED_RESPONSE_CODE_GROUP_5_XX = '5XX'.freeze,
  EXPECTED_RESPONSE_CODE_GROUP_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ HealthCheck

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :is_enabled (BOOLEAN)

    The value to assign to the #is_enabled property

  • :method (String)

    The value to assign to the #method property

  • :path (String)

    The value to assign to the #path property

  • :headers (Hash<String, String>)

    The value to assign to the #headers property

  • :expected_response_code_group (Array<String>)

    The value to assign to the #expected_response_code_group property

  • :is_response_text_check_enabled (BOOLEAN)

    The value to assign to the #is_response_text_check_enabled property

  • :expected_response_text (String)

    The value to assign to the #expected_response_text property

  • :interval_in_seconds (Integer)

    The value to assign to the #interval_in_seconds property

  • :timeout_in_seconds (Integer)

    The value to assign to the #timeout_in_seconds property

  • :healthy_threshold (Integer)

    The value to assign to the #healthy_threshold property

  • :unhealthy_threshold (Integer)

    The value to assign to the #unhealthy_threshold property



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
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
# File 'lib/oci/waas/models/health_check.rb', line 133

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.is_enabled = attributes[:'isEnabled'] unless attributes[:'isEnabled'].nil?
  self.is_enabled = false if is_enabled.nil? && !attributes.key?(:'isEnabled') # rubocop:disable Style/StringLiterals

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

  self.is_enabled = attributes[:'is_enabled'] unless attributes[:'is_enabled'].nil?
  self.is_enabled = false if is_enabled.nil? && !attributes.key?(:'isEnabled') && !attributes.key?(:'is_enabled') # rubocop:disable Style/StringLiterals

  self.method = attributes[:'method'] if attributes[:'method']
  self.method = "HEAD" if method.nil? && !attributes.key?(:'method') # rubocop:disable Style/StringLiterals

  self.path = attributes[:'path'] if attributes[:'path']
  self.path = "/" if path.nil? && !attributes.key?(:'path') # rubocop:disable Style/StringLiterals

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

  self.expected_response_code_group = attributes[:'expectedResponseCodeGroup'] if attributes[:'expectedResponseCodeGroup']

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

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

  self.is_response_text_check_enabled = attributes[:'isResponseTextCheckEnabled'] unless attributes[:'isResponseTextCheckEnabled'].nil?
  self.is_response_text_check_enabled = false if is_response_text_check_enabled.nil? && !attributes.key?(:'isResponseTextCheckEnabled') # rubocop:disable Style/StringLiterals

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

  self.is_response_text_check_enabled = attributes[:'is_response_text_check_enabled'] unless attributes[:'is_response_text_check_enabled'].nil?
  self.is_response_text_check_enabled = false if is_response_text_check_enabled.nil? && !attributes.key?(:'isResponseTextCheckEnabled') && !attributes.key?(:'is_response_text_check_enabled') # rubocop:disable Style/StringLiterals

  self.expected_response_text = attributes[:'expectedResponseText'] if attributes[:'expectedResponseText']
  self.expected_response_text = "success" if expected_response_text.nil? && !attributes.key?(:'expectedResponseText') # rubocop:disable Style/StringLiterals

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

  self.expected_response_text = attributes[:'expected_response_text'] if attributes[:'expected_response_text']
  self.expected_response_text = "success" if expected_response_text.nil? && !attributes.key?(:'expectedResponseText') && !attributes.key?(:'expected_response_text') # rubocop:disable Style/StringLiterals

  self.interval_in_seconds = attributes[:'intervalInSeconds'] if attributes[:'intervalInSeconds']

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

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

  self.timeout_in_seconds = attributes[:'timeoutInSeconds'] if attributes[:'timeoutInSeconds']

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

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

  self.healthy_threshold = attributes[:'healthyThreshold'] if attributes[:'healthyThreshold']

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

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

  self.unhealthy_threshold = attributes[:'unhealthyThreshold'] if attributes[:'unhealthyThreshold']

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

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

Instance Attribute Details

#expected_response_code_groupArray<String>

The HTTP response codes that signify a healthy state. - 2XX: Success response code group. - 3XX: Redirection response code group. - 4XX: Client errors response code group. - 5XX: Server errors response code group.

Returns:

  • (Array<String>)


52
53
54
# File 'lib/oci/waas/models/health_check.rb', line 52

def expected_response_code_group
  @expected_response_code_group
end

#expected_response_textString

Health check will search for the given text in a case-sensitive manner within the response body and will fail if the text is not found.

Returns:

  • (String)


60
61
62
# File 'lib/oci/waas/models/health_check.rb', line 60

def expected_response_text
  @expected_response_text
end

#headersHash<String, String>

HTTP header fields to include in health check requests, expressed as \"name\": \"value\" properties. Because HTTP header field names are case-insensitive, any use of names that are case-insensitive equal to other names will be rejected. If Host is not specified, requests will include a Host header field with value matching the policy's protected domain. If User-Agent is not specified, requests will include a User-Agent header field with value "waf health checks".

Note: The only currently-supported header fields are Host and User-Agent.

Returns:

  • (Hash<String, String>)


44
45
46
# File 'lib/oci/waas/models/health_check.rb', line 44

def headers
  @headers
end

#healthy_thresholdInteger

Number of successful health checks after which the server is marked up.

Returns:

  • (Integer)


72
73
74
# File 'lib/oci/waas/models/health_check.rb', line 72

def healthy_threshold
  @healthy_threshold
end

#interval_in_secondsInteger

Time between health checks of an individual origin server, in seconds.

Returns:

  • (Integer)


64
65
66
# File 'lib/oci/waas/models/health_check.rb', line 64

def interval_in_seconds
  @interval_in_seconds
end

#is_enabledBOOLEAN

Enables or disables the health checks.

Returns:

  • (BOOLEAN)


30
31
32
# File 'lib/oci/waas/models/health_check.rb', line 30

def is_enabled
  @is_enabled
end

#is_response_text_check_enabledBOOLEAN

Enables or disables additional check for predefined text in addition to response code.

Returns:

  • (BOOLEAN)


56
57
58
# File 'lib/oci/waas/models/health_check.rb', line 56

def is_response_text_check_enabled
  @is_response_text_check_enabled
end

#methodString

An HTTP verb (i.e. HEAD, GET, or POST) to use when performing the health check.

Returns:

  • (String)


34
35
36
# File 'lib/oci/waas/models/health_check.rb', line 34

def method
  @method
end

#pathString

Path to visit on your origins when performing the health check.

Returns:

  • (String)


38
39
40
# File 'lib/oci/waas/models/health_check.rb', line 38

def path
  @path
end

#timeout_in_secondsInteger

Response timeout represents wait time until request is considered failed, in seconds.

Returns:

  • (Integer)


68
69
70
# File 'lib/oci/waas/models/health_check.rb', line 68

def timeout_in_seconds
  @timeout_in_seconds
end

#unhealthy_thresholdInteger

Number of failed health checks after which the server is marked down.

Returns:

  • (Integer)


76
77
78
# File 'lib/oci/waas/models/health_check.rb', line 76

def unhealthy_threshold
  @unhealthy_threshold
end

Class Method Details

.attribute_mapObject

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/oci/waas/models/health_check.rb', line 79

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'is_enabled': :'isEnabled',
    'method': :'method',
    'path': :'path',
    'headers': :'headers',
    'expected_response_code_group': :'expectedResponseCodeGroup',
    'is_response_text_check_enabled': :'isResponseTextCheckEnabled',
    'expected_response_text': :'expectedResponseText',
    'interval_in_seconds': :'intervalInSeconds',
    'timeout_in_seconds': :'timeoutInSeconds',
    'healthy_threshold': :'healthyThreshold',
    'unhealthy_threshold': :'unhealthyThreshold'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/oci/waas/models/health_check.rb', line 98

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'is_enabled': :'BOOLEAN',
    'method': :'String',
    'path': :'String',
    'headers': :'Hash<String, String>',
    'expected_response_code_group': :'Array<String>',
    'is_response_text_check_enabled': :'BOOLEAN',
    'expected_response_text': :'String',
    'interval_in_seconds': :'Integer',
    'timeout_in_seconds': :'Integer',
    'healthy_threshold': :'Integer',
    'unhealthy_threshold': :'Integer'
    # 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



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/oci/waas/models/health_check.rb', line 242

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

  self.class == other.class &&
    is_enabled == other.is_enabled &&
    method == other.method &&
    path == other.path &&
    headers == other.headers &&
    expected_response_code_group == other.expected_response_code_group &&
    is_response_text_check_enabled == other.is_response_text_check_enabled &&
    expected_response_text == other.expected_response_text &&
    interval_in_seconds == other.interval_in_seconds &&
    timeout_in_seconds == other.timeout_in_seconds &&
    healthy_threshold == other.healthy_threshold &&
    unhealthy_threshold == other.unhealthy_threshold
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



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/oci/waas/models/health_check.rb', line 282

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


262
263
264
# File 'lib/oci/waas/models/health_check.rb', line 262

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



271
272
273
# File 'lib/oci/waas/models/health_check.rb', line 271

def hash
  [is_enabled, method, path, headers, expected_response_code_group, is_response_text_check_enabled, expected_response_text, interval_in_seconds, timeout_in_seconds, healthy_threshold, unhealthy_threshold].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



315
316
317
318
319
320
321
322
323
324
# File 'lib/oci/waas/models/health_check.rb', line 315

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



309
310
311
# File 'lib/oci/waas/models/health_check.rb', line 309

def to_s
  to_hash.to_s
end