Class: DatadogAPIClient::V1::Downtime

Inherits:
Object
  • Object
show all
Includes:
BaseGenericModel
Defined in:
lib/datadog_api_client/v1/models/downtime.rb,
lib/datadog_api_client/v1/models/downtime.rb

Overview

Downtiming gives you greater control over monitor notifications by allowing you to globally exclude scopes from alerting. Downtime settings, which can be scheduled with start and end times, prevent all alerting related to specified Datadog tags.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseGenericModel

included

Instance Attribute Details

#_endObject

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.



43
44
45
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 43

def _end
  @_end
end

#_unparsedObject

whether the object has unparsed attributes



23
24
25
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 23

def _unparsed
  @_unparsed
end

#activeObject

If a scheduled downtime currently exists.



26
27
28
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 26

def active
  @active
end

#active_childObject

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.



32
33
34
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 32

def active_child
  @active_child
end

#canceledObject

If a scheduled downtime is canceled.



31
32
33
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 31

def canceled
  @canceled
end

#creator_idObject

User ID of the downtime creator.



34
35
36
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 34

def creator_id
  @creator_id
end

#disabledObject

If a downtime has been disabled.



37
38
39
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 37

def disabled
  @disabled
end

#downtime_typeObject

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.



40
41
42
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 40

def downtime_type
  @downtime_type
end

#idObject

The downtime ID.



46
47
48
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 46

def id
  @id
end

#messageObject

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.



49
50
51
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 49

def message
  @message
end

#monitor_idObject

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.



52
53
54
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 52

def monitor_id
  @monitor_id
end

#monitor_tagsObject

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.



55
56
57
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 55

def monitor_tags
  @monitor_tags
end

#mute_first_recovery_notificationObject

If the first recovery notification during a downtime should be muted.



70
71
72
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 70

def mute_first_recovery_notification
  @mute_first_recovery_notification
end

#notify_end_statesObject

States for which notify_end_types sends out notifications for.



73
74
75
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 73

def notify_end_states
  @notify_end_states
end

#notify_end_typesObject

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.



79
80
81
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 79

def notify_end_types
  @notify_end_types
end

#parent_idObject

ID of the parent Downtime.



58
59
60
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 58

def parent_id
  @parent_id
end

#recurrenceObject

An object defining the recurrence of the downtime.



85
86
87
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 85

def recurrence
  @recurrence
end

#scopeObject

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).



63
64
65
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 63

def scope
  @scope
end

#startObject

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.



66
67
68
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 66

def start
  @start
end

#timezoneObject

The timezone in which to display the downtime's start and end times in Datadog applications.



69
70
71
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 69

def timezone
  @timezone
end

#updater_idObject

ID of the last user that updated the downtime.



72
73
74
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 72

def updater_id
  @updater_id
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



98
99
100
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 98

def self.acceptable_attributes
  attribute_map.values
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



323
324
325
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 323

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

Instance Method Details

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 353

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when :Array
    # generic array, return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = DatadogAPIClient::V1.const_get(type)
    res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
    if res.instance_of? DatadogAPIClient::V1::UnparsedObject
      self._unparsed = true
    end
    res
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 431

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

#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



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 330

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


310
311
312
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 310

def eql?(o)
  self == o
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 228

def list_invalid_properties
  invalid_properties = Array.new
  if !@creator_id.nil? && @creator_id > 2147483647
    invalid_properties.push('invalid value for "creator_id", must be smaller than or equal to 2147483647.')
  end

  if !@downtime_type.nil? && @downtime_type > 2147483647
    invalid_properties.push('invalid value for "downtime_type", must be smaller than or equal to 2147483647.')
  end

  if !@updater_id.nil? && @updater_id > 2147483647
    invalid_properties.push('invalid value for "updater_id", must be smaller than or equal to 2147483647.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



407
408
409
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 407

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 413

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



401
402
403
# File 'lib/datadog_api_client/v1/models/downtime.rb', line 401

def to_s
  to_hash.to_s
end