Class: OCI::ContainerInstances::Models::CreateContainerHealthCheckDetails

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

Overview

Container Health Check is used to check and report the status of a container.

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
].freeze
FAILURE_ACTION_ENUM =
[
  FAILURE_ACTION_KILL = 'KILL'.freeze,
  FAILURE_ACTION_NONE = 'NONE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CreateContainerHealthCheckDetails

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

  • :failure_action (String)

    The value to assign to the #failure_action property



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
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 121

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


56
57
58
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 56

def failure_action
  @failure_action
end

#failure_thresholdInteger

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

Returns:

  • (Integer)


42
43
44
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 42

def failure_threshold
  @failure_threshold
end

#health_check_typeString

[Required] Container health check type.

Returns:

  • (String)


30
31
32
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 30

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)


34
35
36
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 34

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)


38
39
40
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 38

def interval_in_seconds
  @interval_in_seconds
end

#nameString

Health check name.

Returns:

  • (String)


26
27
28
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 26

def name
  @name
end

#success_thresholdInteger

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

Returns:

  • (Integer)


46
47
48
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 46

def success_threshold
  @success_threshold
end

#timeout_in_secondsInteger

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

Returns:

  • (Integer)


50
51
52
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 50

def timeout_in_seconds
  @timeout_in_seconds
end

Class Method Details

.attribute_mapObject

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



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 59

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',
    '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.



95
96
97
98
99
100
101
102
103
104
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 95

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

  return 'OCI::ContainerInstances::Models::CreateContainerTcpHealthCheckDetails' if type == 'TCP'
  return 'OCI::ContainerInstances::Models::CreateContainerHttpHealthCheckDetails' if type == 'HTTP'
  return 'OCI::ContainerInstances::Models::CreateContainerCommandHealthCheckDetails' if type == 'COMMAND'

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

.swagger_typesObject

Attribute type mapping.



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

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',
    '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



197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 197

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 &&
    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



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 234

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


214
215
216
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 214

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



223
224
225
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 223

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

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



267
268
269
270
271
272
273
274
275
276
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 267

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



261
262
263
# File 'lib/oci/container_instances/models/create_container_health_check_details.rb', line 261

def to_s
  to_hash.to_s
end