cachet_api 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +94 -0
- data/Rakefile +28 -0
- data/bin/console +7 -0
- data/bin/console_load.rb +40 -0
- data/bin/setup +8 -0
- data/cachet_api.gemspec +31 -0
- data/lib/cachet/rb/version.rb +7 -0
- data/lib/cachet.rb +432 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a74ffacc97cfc8f3d53ef2560b16c6b62e924a3c
|
4
|
+
data.tar.gz: ab77ea80501284d0a11187a6d1f156f936e39d80
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf05a911ec86ebf13a5d6555d61d99054e2fe494ff2e49dff70f4d089840271c7cee2fbc2b6497504447e3aacfb36003876cd2c64e77c75ef17114ab210f8503
|
7
|
+
data.tar.gz: aeaddf3b0fb96c5c0c656a97f4f9acd6866391aecb6be15cc55be06022c2e306fae04ee931bfef1a16bd800fee816b7f6677e78c96d58fa64979262368368580
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Levi Smith
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Cachet API Library Wrapper
|
2
|
+
[![Travis CI](https://travis-ci.org/TheFynx/cachet_api.svg)](https://travis-ci.org/TheFynx/cachet_api) [![Code Climate](https://codeclimate.com/github/TheFynx/cachet_api/badges/gpa.svg)](https://codeclimate.com/github/TheFynx/cachet_api) [![Test Coverage](https://codeclimate.com/github/TheFynx/cachet_api/badges/coverage.svg)](https://codeclimate.com/github/TheFynx/cachet_api/coverage) [![Issue Count](https://codeclimate.com/github/TheFynx/cachet_api/badges/issue_count.svg)](https://codeclimate.com/github/TheFynx/cachet_api) [![Inline docs](http://inch-ci.org/github/thefynx/cachet_api.svg?branch=master)](http://inch-ci.org/github/thefynx/cachet_api)
|
3
|
+
|
4
|
+
Ruby library wrapper for [CachetHQ.io](https://cachethq.io)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cachet_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install cachet_api
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Under your profile in Cachet, get your api_key from the API Token section. Base url is https://demo.cachethq.io/api/v1/ or https://cachet.yourdomain.com/api/v1/
|
29
|
+
|
30
|
+
CachetClient = CachetClient.new(api_key, base_url)
|
31
|
+
CachetComponents = CachetComponents.new(api_key, base_url)
|
32
|
+
CachetIncidents = CachetIncidents.new(api_key, base_url)
|
33
|
+
CachetMetrics = CachetMetrics.new(api_key, base_url)
|
34
|
+
CachetSubscribers = CachetSubscribers.new(api_key, base_url)
|
35
|
+
```
|
36
|
+
|
37
|
+
View the last release API documentation at: [https://docs.cachethq.io/](https://docs.cachethq.io/)
|
38
|
+
|
39
|
+
## Library to API Quick Reference
|
40
|
+
### Ping
|
41
|
+
|
42
|
+
Cachet API | Ruby Library
|
43
|
+
:--------- | :----------------
|
44
|
+
get/ping | CachetClient.ping
|
45
|
+
|
46
|
+
### Components
|
47
|
+
|
48
|
+
Cachet API | Ruby Library
|
49
|
+
:--------------------------- | :------------------------------
|
50
|
+
get/components | CachetComponents.list
|
51
|
+
get/components/:id | CachetComponents.list_id
|
52
|
+
post/components | CachetComponents.create
|
53
|
+
put/components/:id | CachetComponents.update
|
54
|
+
delete/components/:id | CachetComponents.delete
|
55
|
+
get/components/groups | CachetComponents.groups_list
|
56
|
+
get/components/groups/:id | CachetComponents.groups_list_id
|
57
|
+
post/components/groups | CachetComponents.groups_create
|
58
|
+
put/components/groups/:id | CachetComponents.groups_update
|
59
|
+
delete/components/groups/:id | CachetComponents.groups_delete
|
60
|
+
|
61
|
+
### Incidents
|
62
|
+
|
63
|
+
Cachet API | Ruby Library
|
64
|
+
:------------------- | :----------------------
|
65
|
+
get/incidents | CachetIncidents.list
|
66
|
+
get/incidents/:id | CachetIncidents.list_id
|
67
|
+
post/incidents | CachetIncidents.create
|
68
|
+
put/incidents/:id | CachetIncidents.update
|
69
|
+
delete/incidents/:id | CachetIncidents.delete
|
70
|
+
|
71
|
+
### Metrics
|
72
|
+
|
73
|
+
Cachet API | Ruby Library
|
74
|
+
:---------------------------------- | :-------------------------
|
75
|
+
get/metrics | CachetMetrics.list
|
76
|
+
post/metrics | CachetMetrics.create
|
77
|
+
get/metrics/:id | CachetMetrics.list_id
|
78
|
+
delete/metrics/:id | CachetMetrics.delete
|
79
|
+
get/metrics/:id/points | CachetMetrics.point_list
|
80
|
+
post/metrics/:id/points | CachetMetrics.point_add
|
81
|
+
delete/metrics/:id/points/:point_id | CachetMetrics.point_delete
|
82
|
+
|
83
|
+
### Subscribers
|
84
|
+
|
85
|
+
Cachet API | Ruby Library
|
86
|
+
:--------------------- | :-----------------------
|
87
|
+
get/subscribers | CachetSubscribers.list
|
88
|
+
post/subscribers | CachetSubscribers.create
|
89
|
+
delete/subscribers/:id | CachetSubscribers.delete
|
90
|
+
|
91
|
+
## Development
|
92
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
93
|
+
|
94
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'yard'
|
4
|
+
require 'rspec'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
Rake::TestTask.new do |t|
|
8
|
+
t.test_files = FileList['spec/*_spec.rb', 'lib/cachet.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
13
|
+
t.pattern = Dir.glob('spec/*_spec.rb')
|
14
|
+
end
|
15
|
+
|
16
|
+
YARD::Rake::YardocTask.new do |t|
|
17
|
+
t.options = ['--markup-provider=redcarpet', '--markup=markdown']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Open an irb session preloaded with this library'
|
21
|
+
task :console do
|
22
|
+
sh 'irb -rubygems -I lib -r cachet.rb'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Common task'
|
26
|
+
task all: [:test, :spec]
|
27
|
+
|
28
|
+
task :default => :test
|
data/bin/console
ADDED
data/bin/console_load.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'irb'
|
4
|
+
require 'cachet.rb'
|
5
|
+
|
6
|
+
module IRB
|
7
|
+
def self.start_session(binding)
|
8
|
+
IRB.setup(nil)
|
9
|
+
|
10
|
+
workspace = WorkSpace.new(binding)
|
11
|
+
|
12
|
+
if @CONF[:SCRIPT]
|
13
|
+
irb = Irb.new(workspace, @CONF[:SCRIPT])
|
14
|
+
else
|
15
|
+
irb = Irb.new(workspace)
|
16
|
+
end
|
17
|
+
|
18
|
+
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
19
|
+
@CONF[:MAIN_CONTEXT] = irb.context
|
20
|
+
|
21
|
+
trap("SIGINT") do
|
22
|
+
irb.signal_handle
|
23
|
+
end
|
24
|
+
|
25
|
+
catch(:IRB_EXIT) do
|
26
|
+
irb.eval_input
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# we want to manipulate this in IRB
|
32
|
+
CachetComponents = CachetComponents.new('9yMHsdioQosnyVK4iCVR', 'https://demo.cachethq.io/api/v1/')
|
33
|
+
CachetIncidents = CachetIncidents.new('9yMHsdioQosnyVK4iCVR', 'https://demo.cachethq.io/api/v1/')
|
34
|
+
CachetMetrics = CachetMetrics.new('9yMHsdioQosnyVK4iCVR', 'https://demo.cachethq.io/api/v1/')
|
35
|
+
options = {}
|
36
|
+
options['id'] = '1'
|
37
|
+
options['name'] = 'API'
|
38
|
+
options['status'] = '1'
|
39
|
+
|
40
|
+
IRB.start_session(Kernel.binding)
|
data/bin/setup
ADDED
data/cachet_api.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cachet/rb/version'
|
5
|
+
require 'rbconfig'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'cachet_api'
|
9
|
+
spec.version = CachetClient::VERSION
|
10
|
+
spec.authors = ['TheFynx']
|
11
|
+
spec.email = ['levi@fynx.me']
|
12
|
+
|
13
|
+
spec.summary = 'Ruby library wrapper for Cachet API'
|
14
|
+
spec.description = 'Ruby library wrapper for CachetHQ.io - Beautiful & simple service statuses - The open source status page system, for everyone'
|
15
|
+
spec.homepage = 'https://github.com/TheFynx/cachet_api'
|
16
|
+
|
17
|
+
spec.license = "MIT"
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "httparty"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_dependency "rest-client"
|
29
|
+
spec.add_dependency "yard"
|
30
|
+
spec.add_dependency "redcarpet"
|
31
|
+
end
|
data/lib/cachet.rb
ADDED
@@ -0,0 +1,432 @@
|
|
1
|
+
require 'rubygems' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION < '2.0'
|
2
|
+
require 'cachet/rb/version'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'uri'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
###
|
8
|
+
# Basic client to call to make calls into rest-client
|
9
|
+
#
|
10
|
+
class CachetClient
|
11
|
+
##
|
12
|
+
# class to catch errors
|
13
|
+
class Error < StandardError; end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Constant to utilize for Component Status Operational
|
17
|
+
STATUS_OPERATIONAL = 1
|
18
|
+
##
|
19
|
+
# Constant to utilize for Component Status Peformance Issues
|
20
|
+
STATUS_PERFORMANCE_ISSUES = 2
|
21
|
+
##
|
22
|
+
# Constant to utilize for Component Status Partial Outage
|
23
|
+
STATUS_PARTIAL_OUTAGE = 3
|
24
|
+
##
|
25
|
+
# Constant to utilize for Component Status Major Outage
|
26
|
+
STATUS_MAJOR_OUTAGE = 4
|
27
|
+
|
28
|
+
##
|
29
|
+
# Constant to utilize for Incident Status Scheduled Incident/Maintainence
|
30
|
+
INCIDENT_SCHEDULED = 0
|
31
|
+
##
|
32
|
+
# Constant to utilize for Incident Status Investigating
|
33
|
+
INCIDENT_INVESTIGATING = 1
|
34
|
+
##
|
35
|
+
# Constant to utilize for Incident Status Identified
|
36
|
+
INCIDENT_IDENTIFIED = 3
|
37
|
+
##
|
38
|
+
# Constant to utilize for Incident Status Watching
|
39
|
+
INCIDENT_WATCHING = 3
|
40
|
+
##
|
41
|
+
# Constant to utilize for Incident Status Fixed
|
42
|
+
INCIDENT_FIXED = 4
|
43
|
+
|
44
|
+
##
|
45
|
+
# Providing Demo api/url information if none provided
|
46
|
+
# @param api_key [string] :api_key Your cachet API Token/Key
|
47
|
+
# @param base_url [string] :base_url Your cachet base api url
|
48
|
+
# @return object
|
49
|
+
|
50
|
+
def initialize(api_key, base_url)
|
51
|
+
@api_key = api_key
|
52
|
+
@base_url = base_url
|
53
|
+
@headers = {
|
54
|
+
'X-Cachet-Token' => @api_key,
|
55
|
+
'Content-Type' => 'application/json'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Posts token, url, headers, and any payloads to rest-client all params are passed by methods
|
61
|
+
# @param api_key [string] :api_key Your cachet API Token/Key
|
62
|
+
# @param url [string] :url Your complete cachet api url, built by methods
|
63
|
+
# @param method [string] :method Get, Post, Put, and Delete
|
64
|
+
# @param payload [hash] :options Set of options provided by the Cachet methods
|
65
|
+
# @param headers [hash] :headers provides by initialize methods
|
66
|
+
# @return object
|
67
|
+
|
68
|
+
def request(params)
|
69
|
+
response = RestClient::Request.execute(params.merge(headers: @headers))
|
70
|
+
code = response.code
|
71
|
+
|
72
|
+
if response.code == 200
|
73
|
+
body = JSON.parse(response.body)
|
74
|
+
return body
|
75
|
+
elsif response.code == 204
|
76
|
+
return code
|
77
|
+
else
|
78
|
+
fail Net::HTTPError, response.inspect
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Ping.
|
84
|
+
#
|
85
|
+
# @return object
|
86
|
+
|
87
|
+
def ping
|
88
|
+
request method: :get,
|
89
|
+
url: @base_url + 'ping'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
###
|
94
|
+
# Inherits CachetClient and handles all Components API Calls
|
95
|
+
#
|
96
|
+
class CachetComponents < CachetClient
|
97
|
+
##
|
98
|
+
# List all Components.
|
99
|
+
#
|
100
|
+
# @return object
|
101
|
+
|
102
|
+
def list
|
103
|
+
request method: :get,
|
104
|
+
url: @base_url + 'components'
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# List Component by ID.
|
109
|
+
# @option options [string] :id Numeric component id
|
110
|
+
# @return object
|
111
|
+
# id
|
112
|
+
|
113
|
+
def list_id(options)
|
114
|
+
request method: :get,
|
115
|
+
url: @base_url + 'components/' + options['id']
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Create Component.
|
120
|
+
#
|
121
|
+
# @option options [string] :name **Required** Component name
|
122
|
+
# @option options [int] :status **Required** Numeric status of the component; 1-4
|
123
|
+
# @option options [string] :description Description of the component
|
124
|
+
# @option options [string] :link A hyperlink to the component
|
125
|
+
# @option options [int] :order Numeric order of the component
|
126
|
+
# @option options [int] :group_id Numeric group id component is within
|
127
|
+
# @option options [boolean] :enabled True/False to enable/disable component
|
128
|
+
# @return object
|
129
|
+
|
130
|
+
def create(options)
|
131
|
+
request method: :post,
|
132
|
+
url: @base_url + 'components',
|
133
|
+
payload: options
|
134
|
+
end
|
135
|
+
|
136
|
+
##
|
137
|
+
# Update Component.
|
138
|
+
#
|
139
|
+
# @option options [string] :id **Required** Numeric component id
|
140
|
+
# @option options [int] :status **Required** Numeric status of the component; 1-4
|
141
|
+
# @option options [string] :name **Required** Component name
|
142
|
+
# @option options [string] :link A hyperlink to the component
|
143
|
+
# @option options [int] :order Numeric order of the component
|
144
|
+
# @option options [int] :group_id Numeric group id component is within
|
145
|
+
# @option options [boolean] :enabled True/False to enable/disable component
|
146
|
+
# @return object
|
147
|
+
|
148
|
+
def update(options)
|
149
|
+
request method: :put,
|
150
|
+
url: @base_url + 'components/' + options['id'],
|
151
|
+
payload: options
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# Delete Component.
|
156
|
+
#
|
157
|
+
# @option options [string] :id **Required** Numeric component id
|
158
|
+
# @return object
|
159
|
+
|
160
|
+
def delete(options)
|
161
|
+
request method: :delete,
|
162
|
+
url: @base_url + 'components/' + options['id']
|
163
|
+
end
|
164
|
+
|
165
|
+
##
|
166
|
+
# List all Component Groups.
|
167
|
+
#
|
168
|
+
# @return object
|
169
|
+
|
170
|
+
def groups_list
|
171
|
+
request method: :get,
|
172
|
+
url: @base_url + 'components/groups'
|
173
|
+
end
|
174
|
+
|
175
|
+
##
|
176
|
+
# List Component Group by ID.
|
177
|
+
#
|
178
|
+
# @option options [string] :id **Required** Numeric component group id
|
179
|
+
# @return object
|
180
|
+
|
181
|
+
def groups_list_id(options)
|
182
|
+
request method: :get,
|
183
|
+
url: @base_url + 'components/groups/' + options['id']
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# Create Component Group.
|
188
|
+
#
|
189
|
+
# @option options [string] :name **Required** Component group name
|
190
|
+
# @option options [int] :order Numeric order of the component group
|
191
|
+
# @option options [boolean] :collapsed Whether to collapse the group by default
|
192
|
+
# @return object
|
193
|
+
|
194
|
+
def groups_create(options)
|
195
|
+
request method: :post,
|
196
|
+
url: @base_url + 'components/groups',
|
197
|
+
payload: options
|
198
|
+
end
|
199
|
+
|
200
|
+
##
|
201
|
+
# Update Component Group.
|
202
|
+
#
|
203
|
+
# @option options [string] :id **Required** Numeric component group id
|
204
|
+
# @option options [string] :name Component group name
|
205
|
+
# @option options [int] :order Numeric order of the component group
|
206
|
+
# @option options [boolean] :collapsed Whether to collapse the group by default
|
207
|
+
# @return object
|
208
|
+
|
209
|
+
def groups_update(options)
|
210
|
+
request method: :put,
|
211
|
+
url: @base_url + 'components/groups',
|
212
|
+
payload: options
|
213
|
+
end
|
214
|
+
|
215
|
+
##
|
216
|
+
# Delete Component Group.
|
217
|
+
#
|
218
|
+
# @option options [string] :id **Required** Numeric component group id
|
219
|
+
# @return object
|
220
|
+
|
221
|
+
def groups_delete(options)
|
222
|
+
options['id'].each_pair do |_k, v|
|
223
|
+
options['id'] = v.to_s
|
224
|
+
end
|
225
|
+
request method: :delete,
|
226
|
+
url: @base_url + 'components/groups/' + options['id']
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
###
|
231
|
+
# Inherits CachetClient and handles all Incidents API Calls
|
232
|
+
#
|
233
|
+
class CachetIncidents < CachetClient
|
234
|
+
##
|
235
|
+
# List all Incidents.
|
236
|
+
#
|
237
|
+
# @return object
|
238
|
+
|
239
|
+
def list
|
240
|
+
request method: :get,
|
241
|
+
url: @base_url + 'incidents'
|
242
|
+
end
|
243
|
+
|
244
|
+
##
|
245
|
+
# List Incident by ID.
|
246
|
+
#
|
247
|
+
# @option options [string] :id Numeric incident id
|
248
|
+
# @return object
|
249
|
+
|
250
|
+
def list_id(options)
|
251
|
+
request method: :get,
|
252
|
+
url: @base_url + 'incidents/' + options['id']
|
253
|
+
end
|
254
|
+
|
255
|
+
##
|
256
|
+
# Create Incident.
|
257
|
+
#
|
258
|
+
# @option options [string] :name **Required** Incident name
|
259
|
+
# @option options [string] :message **Required** Description of the incident
|
260
|
+
# @option options [int] :status **Required** Status of the incident; 1-4
|
261
|
+
# @option options [int] :visible **Required** value whether the incident public 0/1
|
262
|
+
# @option options [int] :component_id Component to update.(Required with component_status)
|
263
|
+
# @option options [int] :component_status The status to update the given component with.
|
264
|
+
# @option options [boolean] :notify True/False Whether to notify subscribers.
|
265
|
+
# @return object
|
266
|
+
|
267
|
+
def create(options)
|
268
|
+
request method: :post,
|
269
|
+
url: @base_url + 'incidents',
|
270
|
+
payload: options
|
271
|
+
end
|
272
|
+
|
273
|
+
##
|
274
|
+
# Update Incident.
|
275
|
+
#
|
276
|
+
# @option options [string] :id Numeric incident id
|
277
|
+
# @option options [string] :name Incident name
|
278
|
+
# @option options [string] :message Description of the incident
|
279
|
+
# @option options [int] :status Status of the incident; 1-4
|
280
|
+
# @option options [int] :visible value whether the incident public 0/1
|
281
|
+
# @option options [int] :component_id Component to update.(Required with component_status)
|
282
|
+
# @option options [int] :component_status The status to update the given component with.
|
283
|
+
# @option options [boolean] :notify True/False Whether to notify subscribers.
|
284
|
+
# @return object
|
285
|
+
|
286
|
+
def update(options)
|
287
|
+
request method: :put,
|
288
|
+
url: @base_url + 'incidents/' + options['id'],
|
289
|
+
payload: options
|
290
|
+
end
|
291
|
+
|
292
|
+
##
|
293
|
+
# Delete Incident.
|
294
|
+
#
|
295
|
+
# @option options [string] :id Numeric incident id
|
296
|
+
# @return object
|
297
|
+
|
298
|
+
def delete(options)
|
299
|
+
request method: :delete,
|
300
|
+
url: @base_url + 'incidents/' + options['id']
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
###
|
305
|
+
# Inherits CachetClient and handles all Metrics API Calls
|
306
|
+
#
|
307
|
+
class CachetMetrics < CachetClient
|
308
|
+
##
|
309
|
+
# List all Metrics.
|
310
|
+
#
|
311
|
+
# @return object
|
312
|
+
|
313
|
+
def list
|
314
|
+
request method: :get,
|
315
|
+
url: @base_url + 'metrics'
|
316
|
+
end
|
317
|
+
|
318
|
+
##
|
319
|
+
# Create Metric.
|
320
|
+
#
|
321
|
+
# @option options [string] :name **Required** Metric name
|
322
|
+
# @option options [string] :suffix **Required** Measurments in
|
323
|
+
# @option options [string] :description **Required** Description of what is measured
|
324
|
+
# @option options [int] :default_value **Required** The default value for points
|
325
|
+
# @option options [int] :display_chart Whether to display the chart on the status page
|
326
|
+
# @return object
|
327
|
+
|
328
|
+
def create(options)
|
329
|
+
request method: :post,
|
330
|
+
url: @base_url + 'metrics',
|
331
|
+
payload: options
|
332
|
+
end
|
333
|
+
|
334
|
+
##
|
335
|
+
# List Metric by ID Without Points.
|
336
|
+
#
|
337
|
+
# @option options [string] :id Numeric Metric id
|
338
|
+
# @return object
|
339
|
+
|
340
|
+
def list_id(options)
|
341
|
+
request method: :get,
|
342
|
+
url: @base_url + 'metrics/' + options['id']
|
343
|
+
end
|
344
|
+
|
345
|
+
##
|
346
|
+
# Delete a Metric.
|
347
|
+
#
|
348
|
+
# @option options [string] :id Numeric Metric id
|
349
|
+
# @return object
|
350
|
+
|
351
|
+
def delete(options)
|
352
|
+
request method: :delete,
|
353
|
+
url: @base_url + 'metrics/' + options['id']
|
354
|
+
end
|
355
|
+
|
356
|
+
##
|
357
|
+
# List Metric Points.
|
358
|
+
#
|
359
|
+
# @option options [string] :id Numeric Metric id
|
360
|
+
# @return object
|
361
|
+
|
362
|
+
def point_list(options)
|
363
|
+
request method: :get,
|
364
|
+
url: @base_url + 'metrics/' + options['id'] + '/points'
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Add Metric Point.
|
369
|
+
#
|
370
|
+
# @option options [string] :id Numeric Metric id
|
371
|
+
# @option options [int] :value **Required** Value to plot on the metric graph
|
372
|
+
# @option options [string] :timestamp Unix timestamp of the point was measured
|
373
|
+
# @return object
|
374
|
+
|
375
|
+
def point_add(options)
|
376
|
+
request method: :post,
|
377
|
+
url: @base_url + 'metrics/' + options['id'] + '/points',
|
378
|
+
payload: options
|
379
|
+
end
|
380
|
+
|
381
|
+
##
|
382
|
+
# Delete Metric Point.
|
383
|
+
#
|
384
|
+
# @option options [string] :id Numeric Metric id
|
385
|
+
# @option options [int] :point_id **Required** Metric Point id
|
386
|
+
# @return object
|
387
|
+
|
388
|
+
def point_delete(options)
|
389
|
+
request method: :delete,
|
390
|
+
url: @base_url + 'metrics/' + options['id'] + '/points/' + options['point_id'],
|
391
|
+
payload: options
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
###
|
396
|
+
# Inherits CachetClient and handles all Subscribers API Calls
|
397
|
+
#
|
398
|
+
class CachetSubscribers < CachetClient
|
399
|
+
##
|
400
|
+
# List all Subscribers.
|
401
|
+
#
|
402
|
+
# @return object
|
403
|
+
|
404
|
+
def list
|
405
|
+
request method: :get,
|
406
|
+
url: @base_url + 'subscribers'
|
407
|
+
end
|
408
|
+
|
409
|
+
##
|
410
|
+
# Create Subscriber.
|
411
|
+
#
|
412
|
+
# @option options [string] :email **Required** Email address to subscribe
|
413
|
+
# @option options [int] :verify Whether to send verification email 0/1
|
414
|
+
# @return object
|
415
|
+
|
416
|
+
def create(options)
|
417
|
+
request method: :post,
|
418
|
+
url: @base_url + 'subscribers',
|
419
|
+
payload: options
|
420
|
+
end
|
421
|
+
|
422
|
+
##
|
423
|
+
# Delete a Subscriber.
|
424
|
+
#
|
425
|
+
# @option options [string] :id ID of the subscriber to delete
|
426
|
+
# @return object
|
427
|
+
|
428
|
+
def delete(options)
|
429
|
+
request method: :delete,
|
430
|
+
url: @base_url + 'subscribers/' + options['id']
|
431
|
+
end
|
432
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cachet_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TheFynx
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: codeclimate-test-reporter
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rest-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: redcarpet
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Ruby library wrapper for CachetHQ.io - Beautiful & simple service statuses
|
126
|
+
- The open source status page system, for everyone
|
127
|
+
email:
|
128
|
+
- levi@fynx.me
|
129
|
+
executables:
|
130
|
+
- console
|
131
|
+
- console_load.rb
|
132
|
+
- setup
|
133
|
+
extensions: []
|
134
|
+
extra_rdoc_files: []
|
135
|
+
files:
|
136
|
+
- .gitignore
|
137
|
+
- .rspec
|
138
|
+
- .travis.yml
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/console_load.rb
|
145
|
+
- bin/setup
|
146
|
+
- cachet_api.gemspec
|
147
|
+
- lib/cachet.rb
|
148
|
+
- lib/cachet/rb/version.rb
|
149
|
+
homepage: https://github.com/TheFynx/cachet_api
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>'
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.3.1
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.0.14
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Ruby library wrapper for Cachet API
|
173
|
+
test_files: []
|
174
|
+
has_rdoc:
|