Class: OCI::StackMonitoring::Models::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/stack_monitoring/models/condition.rb

Overview

The Monitoring Template Alarm Condition.

Constant Summary collapse

SEVERITY_ENUM =
[
  SEVERITY_CRITICAL = 'CRITICAL'.freeze,
  SEVERITY_WARNING = 'WARNING'.freeze,
  SEVERITY_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Condition

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :severity (String)

    The value to assign to the #severity property

  • :query (String)

    The value to assign to the #query property

  • :body (String)

    The value to assign to the #body property

  • :should_append_note (BOOLEAN)

    The value to assign to the #should_append_note property

  • :should_append_url (BOOLEAN)

    The value to assign to the #should_append_url property

  • :trigger_delay (String)

    The value to assign to the #trigger_delay property



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/oci/stack_monitoring/models/condition.rb', line 82

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

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

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

  self.should_append_note = attributes[:'shouldAppendNote'] unless attributes[:'shouldAppendNote'].nil?
  self.should_append_note = true if should_append_note.nil? && !attributes.key?(:'shouldAppendNote') # rubocop:disable Style/StringLiterals

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

  self.should_append_note = attributes[:'should_append_note'] unless attributes[:'should_append_note'].nil?
  self.should_append_note = true if should_append_note.nil? && !attributes.key?(:'shouldAppendNote') && !attributes.key?(:'should_append_note') # rubocop:disable Style/StringLiterals

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

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

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

  self.trigger_delay = attributes[:'triggerDelay'] if attributes[:'triggerDelay']

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

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

Instance Attribute Details

#bodyString

The human-readable content of the delivered alarm notification. Oracle recommends providing guidance to operators for resolving the alarm condition. Consider adding links to standard runbook practices. Avoid entering confidential information.

Returns:

  • (String)


28
29
30
# File 'lib/oci/stack_monitoring/models/condition.rb', line 28

def body
  @body
end

#queryString

[Required] The Monitoring Query Language (MQL) expression to evaluate for the alarm.

Returns:

  • (String)


24
25
26
# File 'lib/oci/stack_monitoring/models/condition.rb', line 24

def query
  @query
end

#severityString

[Required] Severity - Critical/Warning

Returns:

  • (String)


20
21
22
# File 'lib/oci/stack_monitoring/models/condition.rb', line 20

def severity
  @severity
end

#should_append_noteBOOLEAN

Whether the note need to add into bottom of the body for mapping the alarms information with template or not.

Returns:

  • (BOOLEAN)


32
33
34
# File 'lib/oci/stack_monitoring/models/condition.rb', line 32

def should_append_note
  @should_append_note
end

#should_append_urlBOOLEAN

Whether the URL need to add into bottom of the body for mapping the alarms information with template or not.

Returns:

  • (BOOLEAN)


36
37
38
# File 'lib/oci/stack_monitoring/models/condition.rb', line 36

def should_append_url
  @should_append_url
end

#trigger_delayString

The period of time that the condition defined in the alarm must persist before the alarm state changes from "OK" to "FIRING".

Returns:

  • (String)


40
41
42
# File 'lib/oci/stack_monitoring/models/condition.rb', line 40

def trigger_delay
  @trigger_delay
end

Class Method Details

.attribute_mapObject

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



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/oci/stack_monitoring/models/condition.rb', line 43

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'severity': :'severity',
    'query': :'query',
    'body': :'body',
    'should_append_note': :'shouldAppendNote',
    'should_append_url': :'shouldAppendUrl',
    'trigger_delay': :'triggerDelay'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/oci/stack_monitoring/models/condition.rb', line 57

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'severity': :'String',
    'query': :'String',
    'body': :'String',
    'should_append_note': :'BOOLEAN',
    'should_append_url': :'BOOLEAN',
    'trigger_delay': :'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



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/oci/stack_monitoring/models/condition.rb', line 137

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

  self.class == other.class &&
    severity == other.severity &&
    query == other.query &&
    body == other.body &&
    should_append_note == other.should_append_note &&
    should_append_url == other.should_append_url &&
    trigger_delay == other.trigger_delay
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



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/oci/stack_monitoring/models/condition.rb', line 172

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


152
153
154
# File 'lib/oci/stack_monitoring/models/condition.rb', line 152

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



161
162
163
# File 'lib/oci/stack_monitoring/models/condition.rb', line 161

def hash
  [severity, query, body, should_append_note, should_append_url, trigger_delay].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



205
206
207
208
209
210
211
212
213
214
# File 'lib/oci/stack_monitoring/models/condition.rb', line 205

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



199
200
201
# File 'lib/oci/stack_monitoring/models/condition.rb', line 199

def to_s
  to_hash.to_s
end