Class: Doggy::Models::Monitor
Defined Under Namespace
Classes: Options
Instance Attribute Summary
Attributes inherited from Doggy::Model
#is_deleted, #loading_source, #path
Class Method Summary
collapse
Instance Method Summary
collapse
#==, accepted_response, all_local_resources, changed_resources, current_sha, #destroy, #destroy_local, emit_shipit_deployment, find, find_local, infer_type, #initialize, request, #save, #save_local, sort_by_key
Constructor Details
This class inherits a constructor from Doggy::Model
Class Method Details
.resource_url(id = nil) ⇒ Object
51
52
53
54
55
|
# File 'lib/doggy/models/monitor.rb', line 51
def self.resource_url(id = nil)
"https://app.datadoghq.com/api/v1/monitor".tap do |base_url|
base_url << "/#{ id }" if id
end
end
|
Instance Method Details
#ensure_managed_emoji! ⇒ Object
61
62
63
64
65
|
# File 'lib/doggy/models/monitor.rb', line 61
def ensure_managed_emoji!
return unless managed?
return if self.name =~ /\xF0\x9F\x90\xB6/
self.name += " \xF0\x9F\x90\xB6"
end
|
#ensure_read_only! ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/doggy/models/monitor.rb', line 35
def ensure_read_only!
if options
self.options.locked = true
else
self.options = Options.new(locked: true)
end
end
|
#human_edit_url ⇒ Object
89
90
91
|
# File 'lib/doggy/models/monitor.rb', line 89
def human_edit_url
"https://app.datadoghq.com/monitors##{ id }/edit"
end
|
#human_url ⇒ Object
85
86
87
|
# File 'lib/doggy/models/monitor.rb', line 85
def human_url
"https://app.datadoghq.com/monitors##{ id }"
end
|
#managed? ⇒ Boolean
57
58
59
|
# File 'lib/doggy/models/monitor.rb', line 57
def managed?
!(name =~ Doggy::DOG_SKIP_REGEX)
end
|
#prefix ⇒ Object
31
32
33
|
# File 'lib/doggy/models/monitor.rb', line 31
def prefix
'monitor'
end
|
#refute_read_only! ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/doggy/models/monitor.rb', line 43
def refute_read_only!
if options
self.options.locked = false
else
self.options = Options.new(locked: false)
end
end
|
#to_h ⇒ Object
93
94
95
|
# File 'lib/doggy/models/monitor.rb', line 93
def to_h
Doggy::Model.sort_by_key(super.merge(options: options.to_h))
end
|
#toggle_mute!(action, body = nil) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/doggy/models/monitor.rb', line 71
def toggle_mute!(action, body=nil)
return unless ['mute', 'unmute'].include?(action) && id
attributes = request(:post, "#{ resource_url(id) }/#{action}", body)
if message = attributes['errors']
Doggy.ui.error(message)
else
self.attributes = attributes
if local_version = Doggy::Model.find_local(id)
self.path = local_version.path
end
save_local
end
end
|
#validate ⇒ Object
67
68
69
|
# File 'lib/doggy/models/monitor.rb', line 67
def validate
ensure_renotify_interval_valid
end
|