Class: OCI::ContainerInstances::Models::ContainerHealthCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/container_instances/models/container_health_check.rb

Overview

Type of container health check which could be either HTTP, TCP, or Command. This class has direct subclasses. If you are using this class as input to a service operations then you should favor using a subclass over the base class

Constant Summary collapse

HEALTH_CHECK_TYPE_ENUM =
[
  HEALTH_CHECK_TYPE_HTTP = 'HTTP'.freeze,
  HEALTH_CHECK_TYPE_TCP = 'TCP'.freeze,
  HEALTH_CHECK_TYPE_COMMAND = 'COMMAND'.freeze,
  HEALTH_CHECK_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
STATUS_ENUM =
[
  STATUS_HEALTHY = 'HEALTHY'.freeze,
  STATUS_UNHEALTHY = 'UNHEALTHY'.freeze,
  STATUS_UNKNOWN = 'UNKNOWN'.freeze,
  STATUS_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
FAILURE_ACTION_ENUM =
[
  FAILURE_ACTION_KILL = 'KILL'.freeze,
  FAILURE_ACTION_NONE = 'NONE'.freeze,
  FAILURE_ACTION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ContainerHealthCheck

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :name (String)

    The value to assign to the #name property

  • :health_check_type (String)

    The value to assign to the #health_check_type property

  • :initial_delay_in_seconds (Integer)

    The value to assign to the #initial_delay_in_seconds property

  • :interval_in_seconds (Integer)

    The value to assign to the #interval_in_seconds property

  • :failure_threshold (Integer)

    The value to assign to the #failure_threshold property

  • :success_threshold (Integer)

    The value to assign to the #success_threshold property

  • :timeout_in_seconds (Integer)

    The value to assign to the #timeout_in_seconds property

  • :status (String)

    The value to assign to the #status property

  • :status_details (String)

    The value to assign to the #status_details property

  • :failure_action (String)

    The value to assign to the #failure_action property



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
201
202
203
204
# File 'lib/oci/container_instances/models/container_health_check.rb', line 144

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

  self.health_check_type = attributes[:'healthCheckType'] if attributes[:'healthCheckType']

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

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

  self.initial_delay_in_seconds = attributes[:'initialDelayInSeconds'] if attributes[:'initialDelayInSeconds']

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

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

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

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

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

  self.success_threshold = attributes[:'successThreshold'] if attributes[:'successThreshold']

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

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

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

  self.status_details = attributes[:'statusDetails'] if attributes[:'statusDetails']

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

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

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

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

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

Instance Attribute Details

#failure_actionString

The action will be triggered when the container health check fails. There are two types of action: KILL or NONE. The default action is KILL. If failure action is KILL, the container will be subject to the container restart policy.

Returns:

  • (String)


73
74
75
# File 'lib/oci/container_instances/models/container_health_check.rb', line 73

def failure_action
  @failure_action
end

#failure_thresholdInteger

Number of consecutive failures at which we consider the check failed.

Returns:

  • (Integer)


51
52
53
# File 'lib/oci/container_instances/models/container_health_check.rb', line 51

def failure_threshold
  @failure_threshold
end

#health_check_typeString

[Required] Container health check type.

Returns:

  • (String)


39
40
41
# File 'lib/oci/container_instances/models/container_health_check.rb', line 39

def health_check_type
  @health_check_type
end

#initial_delay_in_secondsInteger

The initial delay in seconds before start checking container health status.

Returns:

  • (Integer)


43
44
45
# File 'lib/oci/container_instances/models/container_health_check.rb', line 43

def initial_delay_in_seconds
  @initial_delay_in_seconds
end

#interval_in_secondsInteger

Number of seconds between two consecutive runs for checking container health.

Returns:

  • (Integer)


47
48
49
# File 'lib/oci/container_instances/models/container_health_check.rb', line 47

def interval_in_seconds
  @interval_in_seconds
end

#nameString

Health check name.

Returns:

  • (String)


35
36
37
# File 'lib/oci/container_instances/models/container_health_check.rb', line 35

def name
  @name
end

#statusString

Status of container

Returns:

  • (String)


63
64
65
# File 'lib/oci/container_instances/models/container_health_check.rb', line 63

def status
  @status
end

#status_detailsString

A message describing the current status in more details.

Returns:

  • (String)


67
68
69
# File 'lib/oci/container_instances/models/container_health_check.rb', line 67

def status_details
  @status_details
end

#success_thresholdInteger

Number of consecutive successes at which we consider the check succeeded again after it was in failure state.

Returns:

  • (Integer)


55
56
57
# File 'lib/oci/container_instances/models/container_health_check.rb', line 55

def success_threshold
  @success_threshold
end

#timeout_in_secondsInteger

Length of waiting time in seconds before marking health check failed.

Returns:

  • (Integer)


59
60
61
# File 'lib/oci/container_instances/models/container_health_check.rb', line 59

def timeout_in_seconds
  @timeout_in_seconds
end

Class Method Details

.attribute_mapObject

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



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/oci/container_instances/models/container_health_check.rb', line 76

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'name',
    'health_check_type': :'healthCheckType',
    'initial_delay_in_seconds': :'initialDelayInSeconds',
    'interval_in_seconds': :'intervalInSeconds',
    'failure_threshold': :'failureThreshold',
    'success_threshold': :'successThreshold',
    'timeout_in_seconds': :'timeoutInSeconds',
    'status': :'status',
    'status_details': :'statusDetails',
    'failure_action': :'failureAction'
    # rubocop:enable Style/SymbolLiteral
  }
end

.get_subtype(object_hash) ⇒ Object

Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.



116
117
118
119
120
121
122
123
124
125
# File 'lib/oci/container_instances/models/container_health_check.rb', line 116

def self.get_subtype(object_hash)
  type = object_hash[:'healthCheckType'] # rubocop:disable Style/SymbolLiteral

  return 'OCI::ContainerInstances::Models::ContainerTcpHealthCheck' if type == 'TCP'
  return 'OCI::ContainerInstances::Models::ContainerHttpHealthCheck' if type == 'HTTP'
  return 'OCI::ContainerInstances::Models::ContainerCommandHealthCheck' if type == 'COMMAND'

  # TODO: Log a warning when the subtype is not found.
  'OCI::ContainerInstances::Models::ContainerHealthCheck'
end

.swagger_typesObject

Attribute type mapping.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/oci/container_instances/models/container_health_check.rb', line 94

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'String',
    'health_check_type': :'String',
    'initial_delay_in_seconds': :'Integer',
    'interval_in_seconds': :'Integer',
    'failure_threshold': :'Integer',
    'success_threshold': :'Integer',
    'timeout_in_seconds': :'Integer',
    'status': :'String',
    'status_details': :'String',
    'failure_action': :'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



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/oci/container_instances/models/container_health_check.rb', line 252

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

  self.class == other.class &&
    name == other.name &&
    health_check_type == other.health_check_type &&
    initial_delay_in_seconds == other.initial_delay_in_seconds &&
    interval_in_seconds == other.interval_in_seconds &&
    failure_threshold == other.failure_threshold &&
    success_threshold == other.success_threshold &&
    timeout_in_seconds == other.timeout_in_seconds &&
    status == other.status &&
    status_details == other.status_details &&
    failure_action == other.failure_action
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



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/oci/container_instances/models/container_health_check.rb', line 291

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


271
272
273
# File 'lib/oci/container_instances/models/container_health_check.rb', line 271

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



280
281
282
# File 'lib/oci/container_instances/models/container_health_check.rb', line 280

def hash
  [name, health_check_type, initial_delay_in_seconds, interval_in_seconds, failure_threshold, success_threshold, timeout_in_seconds, status, status_details, failure_action].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



324
325
326
327
328
329
330
331
332
333
# File 'lib/oci/container_instances/models/container_health_check.rb', line 324

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



318
319
320
# File 'lib/oci/container_instances/models/container_health_check.rb', line 318

def to_s
  to_hash.to_s
end