class OCI::Waas::Models::HealthCheck

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".

Constants

EXPECTED_RESPONSE_CODE_GROUP_ENUM
METHOD_ENUM

Attributes

expected_response_code_group[R]

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.

@return [Array<String>]

expected_response_text[RW]

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. @return [String]

headers[RW]

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. @return [Hash<String, String>]

healthy_threshold[RW]

Number of successful health checks after which the server is marked up. @return [Integer]

interval_in_seconds[RW]

Time between health checks of an individual origin server, in seconds. @return [Integer]

is_enabled[RW]

Enables or disables the health checks. @return [BOOLEAN]

is_response_text_check_enabled[RW]

Enables or disables additional check for predefined text in addition to response code. @return [BOOLEAN]

method[R]

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

path[RW]

Path to visit on your origins when performing the health check. @return [String]

timeout_in_seconds[RW]

Response timeout represents wait time until request is considered failed, in seconds. @return [Integer]

unhealthy_threshold[RW]

Number of failed health checks after which the server is marked down. @return [Integer]

Public Class Methods

attribute_map() click to toggle source

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

# File lib/oci/waas/models/health_check.rb, line 78
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
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash @option attributes [BOOLEAN] :is_enabled The value to assign to the {#is_enabled} property @option attributes [String] :method The value to assign to the {#method} property @option attributes [String] :path The value to assign to the {#path} property @option attributes [Hash<String, String>] :headers The value to assign to the {#headers} property @option attributes [Array<String>] :expected_response_code_group The value to assign to the {#expected_response_code_group} property @option attributes [BOOLEAN] :is_response_text_check_enabled The value to assign to the {#is_response_text_check_enabled} property @option attributes [String] :expected_response_text The value to assign to the {#expected_response_text} property @option attributes [Integer] :interval_in_seconds The value to assign to the {#interval_in_seconds} property @option attributes [Integer] :timeout_in_seconds The value to assign to the {#timeout_in_seconds} property @option attributes [Integer] :healthy_threshold The value to assign to the {#healthy_threshold} property @option attributes [Integer] :unhealthy_threshold The value to assign to the {#unhealthy_threshold} property

# File lib/oci/waas/models/health_check.rb, line 132
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
swagger_types() click to toggle source

Attribute type mapping.

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

Public Instance Methods

==(other) click to toggle source

Checks equality by comparing each attribute. @param [Object] other the other object to be compared

# File lib/oci/waas/models/health_check.rb, line 241
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) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/oci/waas/models/health_check.rb, line 281
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) click to toggle source

@see the `==` method @param [Object] other the other object to be compared

# File lib/oci/waas/models/health_check.rb, line 261
def eql?(other)
  self == other
end
expected_response_code_group=(expected_response_code_group) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] expected_response_code_group Object to be assigned

# File lib/oci/waas/models/health_check.rb, line 218
def expected_response_code_group=(expected_response_code_group)
  # rubocop:disable Style/ConditionalAssignment
  if expected_response_code_group.nil?
    @expected_response_code_group = nil
  else
    @expected_response_code_group =
      expected_response_code_group.collect do |item|
        if EXPECTED_RESPONSE_CODE_GROUP_ENUM.include?(item)
          item
        else
          OCI.logger.debug("Unknown value for 'expected_response_code_group' [#{item}]. Mapping to 'EXPECTED_RESPONSE_CODE_GROUP_UNKNOWN_ENUM_VALUE'") if OCI.logger
          EXPECTED_RESPONSE_CODE_GROUP_UNKNOWN_ENUM_VALUE
        end
      end
  end
  # rubocop:enable Style/ConditionalAssignment
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/oci/waas/models/health_check.rb, line 270
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
method=(method) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] method Object to be assigned

# File lib/oci/waas/models/health_check.rb, line 205
def method=(method)
  # rubocop:disable Style/ConditionalAssignment
  if method && !METHOD_ENUM.include?(method)
    OCI.logger.debug("Unknown value for 'method' [" + method + "]. Mapping to 'METHOD_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @method = METHOD_UNKNOWN_ENUM_VALUE
  else
    @method = method
  end
  # rubocop:enable Style/ConditionalAssignment
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/oci/waas/models/health_check.rb, line 314
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_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/oci/waas/models/health_check.rb, line 308
def to_s
  to_hash.to_s
end

Private Instance Methods

_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

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