Skip to content

Instantly share code, notes, and snippets.

@kerinin
Created April 28, 2014 18:20
Show Gist options
  • Save kerinin/11379898 to your computer and use it in GitHub Desktop.
Save kerinin/11379898 to your computer and use it in GitHub Desktop.
The API I want Assembler to provide
# This is for building a JSON request to the monitoring service
MonitorClient.group(name: 'my group') do |g|
g.add_watch(name: 'Something fragile') do |w|
w.description = 'information about watch'
w.docs = 'http://triage.com'
w.owners = ['ryan@example.com']
w.metric = MonitorClient::Metric::Graphite.new(target: 'foo.bar.baz')
w.policy = never_be_zero
w.add_action MonitorClient::Action::Email.new
w.add_action MonitorClient::Action::Pagerduty.new
end
end.upload
# So an alternate form that doesn't require anything special could look like this
MonitorClient.group(name: 'my group', watches: []) do |g|
g.watches << MonitorClient::Watch.new(name: 'Something fragile', actions: []) do |w|
w.description = 'information about watch'
w.docs = 'http://triage.com'
w.owners = ['ryan@example.com']
w.metric = MonitorClient::Metric::Graphite.new(target: 'foo.bar.baz')
w.policy = never_be_zero
w.actions << MonitorClient::Action::Email.new
w.actions << MonitorClient::Action::Pagerduty.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment