bugsnag_data 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +14 -0
- data/README.md +33 -0
- data/example.rb +14 -0
- data/lib/bugsnag_data.rb +240 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac8615b617f8c31635dbc4eb943116a7d80636e3
|
4
|
+
data.tar.gz: fb24581a43c2ce1f5f8f38a7f3023a803d74abf5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a45fc32a28f163b5db09b4b6fbc6cf9a7e65bbb5943a9dea09dd379ce4766c2a5848f4fae45bde8dcfb2115e6b14e70447b1de24277f1d4f993c45848a202cb
|
7
|
+
data.tar.gz: dad0aac41af7918d38895427d06784deafa3b6762173a11f6b636e00e1f3dd37dbec7910e2c2a6106cbd155521fc0fb7dac8412fd14a13e1cb41f70a3c8f3dda
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright 2014 Tim Hilliard
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# bugsnag-data-client
|
2
|
+
|
3
|
+
Interact with the Bugsnag Data REST API.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/timhilliard/bugsnag-data-client)
|
6
|
+
|
7
|
+
## API calls
|
8
|
+
|
9
|
+
require 'bugsnag_data'
|
10
|
+
bugsnag = BugsnagData.new("BUGSNAG_API_KEY")
|
11
|
+
bugsnag.account
|
12
|
+
bugsnag.users
|
13
|
+
bugsnag.project_users(PROJECT_ID)
|
14
|
+
bugsnag.user(USER_ID)
|
15
|
+
bugsnag.projects
|
16
|
+
bugsnag.user_projects(USER_ID)
|
17
|
+
bugsnag.project(PROJECT_ID)
|
18
|
+
bugsnag.project_errors(PROJECT_ID)
|
19
|
+
bugsnag.project_events(PROJECT_ID)
|
20
|
+
bugsnag.error_events(ERROR_ID)
|
21
|
+
|
22
|
+
## Use the API docs
|
23
|
+
|
24
|
+
For more - you should be able to find the latest at
|
25
|
+
[https://bugsnag.com/docs/api](https://bugsnag.com/docs/api) if you are a
|
26
|
+
Bugsnag customer.
|
27
|
+
|
28
|
+
## Note on Patches/Pull Requests
|
29
|
+
|
30
|
+
* Fork the project.
|
31
|
+
* Make your feature addition or bug fix.
|
32
|
+
* Commit.
|
33
|
+
* Send me a pull request. Bonus points for topic branches.
|
data/example.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bugsnag_data'
|
2
|
+
|
3
|
+
bugsnag = BugsnagData.new("BUGSNAG_API_KEY")
|
4
|
+
|
5
|
+
bugsnag.account
|
6
|
+
bugsnag.users
|
7
|
+
bugsnag.project_users(PROJECT_ID)
|
8
|
+
bugsnag.user(USER_ID)
|
9
|
+
bugsnag.projects
|
10
|
+
bugsnag.user_projects(USER_ID)
|
11
|
+
bugsnag.project(PROJECT_ID)
|
12
|
+
bugsnag.project_errors(PROJECT_ID)
|
13
|
+
bugsnag.project_events(PROJECT_ID)
|
14
|
+
bugsnag.error_events(ERROR_ID)
|
data/lib/bugsnag_data.rb
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tim Hilliard (<timhilliard@gmail.com>)
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'httparty'
|
19
|
+
|
20
|
+
# Top level class for dealing with Bugsnag specific exceptions
|
21
|
+
class BugsnagDataExceptions
|
22
|
+
# Exception class for dealing with failed requests
|
23
|
+
class RequestFailed < RuntimeError; end
|
24
|
+
# Exception class for dealing with requests that return not found by the API
|
25
|
+
class NotFound < RequestFailed; end
|
26
|
+
# Exception class for dealing with authorization failed requests
|
27
|
+
class AuthorizationFailed < RequestFailed; end
|
28
|
+
# Exception class for dealing with poorly formatted requests
|
29
|
+
class BadRequest < RequestFailed; end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Class for retrieving data from the Bugsnag API.
|
33
|
+
class BugsnagData
|
34
|
+
include HTTParty
|
35
|
+
|
36
|
+
attr_accessor :options
|
37
|
+
|
38
|
+
base_uri 'https://api.bugsnag.com'
|
39
|
+
|
40
|
+
# Creates a new base object for interacting with Bugnsags's REST API
|
41
|
+
#
|
42
|
+
# @param [String] api_key
|
43
|
+
# Your Bugsnag API key
|
44
|
+
#
|
45
|
+
def initialize(api_key)
|
46
|
+
@options = { headers: { 'Authorization' => "token #{api_key}" } }
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Get Account details
|
51
|
+
##
|
52
|
+
# Get details for the currently authenticated Account.
|
53
|
+
#
|
54
|
+
# See: https://bugsnag.com/docs/api/accounts#get-account-details
|
55
|
+
#
|
56
|
+
# @param [Hash] params
|
57
|
+
# A hash of parameters to pass to the request.
|
58
|
+
#
|
59
|
+
def account(params = {})
|
60
|
+
make_get_request('/account', params)
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# List your Account's Users
|
65
|
+
##
|
66
|
+
# Get a list of all Users with access to the currently authenticated Bugsnag
|
67
|
+
# Account.
|
68
|
+
#
|
69
|
+
# See: https://bugsnag.com/docs/api/users#list-your-account-s-users
|
70
|
+
#
|
71
|
+
# @param [Hash] params
|
72
|
+
# A hash of parameters to pass to the request.
|
73
|
+
#
|
74
|
+
def users(params = {})
|
75
|
+
make_get_request('/account/users', params)
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# List a Project's Users
|
80
|
+
##
|
81
|
+
# Get a list of Users with access to the specified Project.
|
82
|
+
#
|
83
|
+
# See: https://bugsnag.com/docs/api/users#list-a-project-s-users
|
84
|
+
#
|
85
|
+
# @param [String] project_id
|
86
|
+
# A project ID
|
87
|
+
# @param [Hash] params
|
88
|
+
# A hash of parameters to pass to the request.
|
89
|
+
#
|
90
|
+
def project_users(project_id, params = {})
|
91
|
+
make_get_request("/projects/#{project_id}/users", params)
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Get User details
|
96
|
+
##
|
97
|
+
# Get the details about a Bugsnag user, including name and email address.
|
98
|
+
#
|
99
|
+
# See: https://bugsnag.com/docs/api/users#get-user-details
|
100
|
+
#
|
101
|
+
# @param [String] user_id
|
102
|
+
# A user ID
|
103
|
+
# @param [Hash] params
|
104
|
+
# A hash of parameters to pass to the request.
|
105
|
+
#
|
106
|
+
def user(user_id, params = {})
|
107
|
+
make_get_request("/users/#{user_id}", params)
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# List your Account's Projects
|
112
|
+
##
|
113
|
+
# Get the details about a Bugsnag user, including name and email address.
|
114
|
+
#
|
115
|
+
# See: https://bugsnag.com/docs/api/projects#list-your-account-s-projects
|
116
|
+
#
|
117
|
+
# @param [Hash] params
|
118
|
+
# A hash of parameters to pass to the request.
|
119
|
+
#
|
120
|
+
def projects(params = {})
|
121
|
+
make_get_request('/account/projects', params)
|
122
|
+
end
|
123
|
+
|
124
|
+
##
|
125
|
+
# List a User's Projects
|
126
|
+
##
|
127
|
+
# Get a list of Projects that the specified Bugsnag User has access to.
|
128
|
+
#
|
129
|
+
# See: https://bugsnag.com/docs/api/projects#list-a-user-s-projects
|
130
|
+
#
|
131
|
+
# @param [String] user_id
|
132
|
+
# A user ID
|
133
|
+
# @param [Hash] params
|
134
|
+
# A hash of parameters to pass to the request.
|
135
|
+
#
|
136
|
+
def users_projects(user_id, params = {})
|
137
|
+
make_get_request("/user/#{user_id}/projects", params)
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# Get Project Details
|
142
|
+
##
|
143
|
+
# Get the details of the given Bugsnag Project.
|
144
|
+
#
|
145
|
+
# See: https://bugsnag.com/docs/api/projects#get-project-details
|
146
|
+
#
|
147
|
+
# @param [String] project_id
|
148
|
+
# A project ID
|
149
|
+
# @param [Hash] params
|
150
|
+
# A hash of parameters to pass to the request.
|
151
|
+
#
|
152
|
+
def project(project_id, params = {})
|
153
|
+
make_get_request("/projects/#{project_id}", params)
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# List a Project's Errors
|
158
|
+
##
|
159
|
+
# Get a list of all errors (grouped exceptions) for the given Bugsnag Project.
|
160
|
+
#
|
161
|
+
# See: https://bugsnag.com/docs/api/errors#list-a-project-s-errors
|
162
|
+
#
|
163
|
+
# @param [String] project_id
|
164
|
+
# A project ID
|
165
|
+
# @param [Hash] params
|
166
|
+
# A hash of parameters to pass to the request.
|
167
|
+
#
|
168
|
+
def project_errors(project_id, params = {})
|
169
|
+
make_get_request("/projects/#{project_id}/errors", params)
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# List a Project's Events
|
174
|
+
##
|
175
|
+
# Get a list of all events (individual crashes) for the given Bugsnag Project.
|
176
|
+
#
|
177
|
+
# See: https://bugsnag.com/docs/api/events#list-a-project-s-events
|
178
|
+
#
|
179
|
+
# @param [String] project_id
|
180
|
+
# A project ID
|
181
|
+
# @param [Hash] params
|
182
|
+
# A hash of parameters to pass to the request.
|
183
|
+
#
|
184
|
+
def project_events(project_id, params = {})
|
185
|
+
make_get_request("/projects/#{project_id}/events", params)
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# List an Error's Events
|
190
|
+
##
|
191
|
+
# Get a list of all events (individual crashes) grouped under the given
|
192
|
+
# Bugsnag Error.
|
193
|
+
#
|
194
|
+
# See: https://bugsnag.com/docs/api/events#list-an-error-s-events
|
195
|
+
#
|
196
|
+
# @param [String] error_id
|
197
|
+
# An error ID
|
198
|
+
# @param [Hash] params
|
199
|
+
# A hash of parameters to pass to the request.
|
200
|
+
#
|
201
|
+
def error_events(error_id, params = {})
|
202
|
+
make_get_request("/errors/#{error_id}/events", params)
|
203
|
+
end
|
204
|
+
|
205
|
+
private
|
206
|
+
|
207
|
+
def make_get_request(path, params = {})
|
208
|
+
parse_response(self.class.get(path, prepare_params(params)))
|
209
|
+
end
|
210
|
+
|
211
|
+
def make_post_request(path, params = {})
|
212
|
+
parse_response(self.class.post(path, prepare_params(params)))
|
213
|
+
end
|
214
|
+
|
215
|
+
def make_put_request(path, params = {})
|
216
|
+
parse_response(self.class.put(path, prepare_params(params)))
|
217
|
+
end
|
218
|
+
|
219
|
+
def make_delete_request(path, params = {})
|
220
|
+
parse_response(self.class.delete(path, prepare_params(params)))
|
221
|
+
end
|
222
|
+
|
223
|
+
def prepare_params(params = {})
|
224
|
+
params[:headers] ||= {}
|
225
|
+
params[:headers].merge!(options[:headers])
|
226
|
+
params
|
227
|
+
end
|
228
|
+
|
229
|
+
def parse_response(response)
|
230
|
+
case response.headers['status']
|
231
|
+
when '404 Not Found'
|
232
|
+
fail BugsnagDataExceptions::NotFound, 'Not Found'
|
233
|
+
when '401 Unauthorized'
|
234
|
+
fail BugsnagDataExceptions::AuthorizationFailed, 'Authorization Failed'
|
235
|
+
when '400 Bad Request'
|
236
|
+
fail BugsnagDataExceptions::BadRequest, 'Bad Request'
|
237
|
+
end
|
238
|
+
response.parsed_response
|
239
|
+
end
|
240
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bugsnag_data
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Hilliard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.4.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.4.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.20.4
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.20.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.7.6
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.7.6
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: redcarpet
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.2.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.2.2
|
97
|
+
description: Use the Bugsnag Data REST API
|
98
|
+
email: timhilliard@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files:
|
102
|
+
- LICENSE
|
103
|
+
- README.md
|
104
|
+
- example.rb
|
105
|
+
files:
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- example.rb
|
110
|
+
- lib/bugsnag_data.rb
|
111
|
+
homepage: http://github.com/timhilliard/bugsnag-data-client
|
112
|
+
licenses:
|
113
|
+
- Apache-2.0
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 1.9.3
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.2.2
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Bugsnag Data API Client library
|
135
|
+
test_files: []
|
136
|
+
has_rdoc:
|