bugsnag-api 1.0.1 → 1.0.2
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 +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +3 -2
- data/README.md +293 -15
- data/Rakefile +1 -5
- data/bugsnag-api.gemspec +1 -1
- data/lib/bugsnag/api/configuration.rb +1 -0
- data/lib/bugsnag/api/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3342f6cc4325b1835c5846f1afa9bd63fef42fb6
|
4
|
+
data.tar.gz: 28ea193213ca5423515f5347041b05cdeae9e439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b023d4477ac3c8353c45e0f305eda52deda433d4b7ab69df4699636c67d7e6c4472ecff76755a3a500c7920afb341eaff0df024c2fb2e157f8b2736105fbe704
|
7
|
+
data.tar.gz: c7d0bba29e231b9bed1826a7ebb6f9f37beca66c282c2e315d78f13a6e52f469be708f369f94b63301456415ee33cce18bea7319f3379586e5a4ac6e36cbb83f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
Copyright (c) 2014
|
1
|
+
Parts of this software are derived from Octokit.rb, Copyright (c) 2009-2014
|
2
|
+
Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober.
|
2
3
|
|
3
|
-
|
4
|
+
The remaining parts are Copyright (c) 2014 Bugsnag Inc.
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
7
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -5,50 +5,323 @@ The library allows for quick read/write access to the [Bugsnag API](https://bugs
|
|
5
5
|
|
6
6
|
If you are looking to automatically detect crashes in your Ruby apps, you should take a look at the [Bugsnag Ruby Detection Library](https://bugsnag.com/docs/notifiers/ruby) instead.
|
7
7
|
|
8
|
-
This library
|
8
|
+
This library borrows heavily from the code and philosophies of the fantastic [Octokit](https://github.com/octokit/octokit.rb) library. A big thanks to [@pengwynn](https://github.com/pengwynn) and the rest of the Octokit team!
|
9
|
+
|
10
|
+
|
11
|
+
## Contents
|
12
|
+
|
13
|
+
- [Installation](#installation)
|
14
|
+
- [Usage](#usage)
|
15
|
+
- [Making Requests](#making-requests)
|
16
|
+
- [Consuming Resources](#consuming-resources)
|
17
|
+
- [Accessing Related Resources](#accessing-related-resources)
|
18
|
+
- [Authentication](#authentication)
|
19
|
+
- [Pagination](#pagination)
|
20
|
+
- [Accessing HTTP responses](#accessing-http-responses)
|
21
|
+
- [API Methods](#api-methods)
|
22
|
+
- [Accounts](#accounts)
|
23
|
+
- [Comments](#comments)
|
24
|
+
- [Errors](#errors)
|
25
|
+
- [Events](#events)
|
26
|
+
- [Projects](#projects)
|
27
|
+
- [Users](#users)
|
28
|
+
- [Advanced Configuration](#advanced-configuration)
|
9
29
|
|
10
30
|
|
11
31
|
## Installation
|
12
32
|
|
13
33
|
Add this line to your application's Gemfile:
|
14
34
|
|
15
|
-
|
35
|
+
```ruby
|
36
|
+
gem "bugsnag-api"
|
37
|
+
```
|
16
38
|
|
17
39
|
And then execute:
|
18
40
|
|
19
|
-
|
41
|
+
```
|
42
|
+
$ bundle
|
43
|
+
```
|
20
44
|
|
21
45
|
Or install it yourself as:
|
22
46
|
|
23
|
-
|
47
|
+
```
|
48
|
+
$ gem install bugsnag-api
|
49
|
+
```
|
24
50
|
|
25
51
|
|
26
52
|
## Usage
|
27
53
|
|
54
|
+
### Making Requests
|
55
|
+
|
56
|
+
API methods are available as module methods or as client instance methods.
|
57
|
+
|
28
58
|
```ruby
|
29
|
-
#
|
59
|
+
# Provide authentication credentials
|
30
60
|
Bugsnag::Api.configure do |config|
|
31
61
|
config.auth_token = "your-account-api-token"
|
32
62
|
end
|
33
63
|
|
34
|
-
# Fetch
|
64
|
+
# Fetch the current account
|
65
|
+
account = Bugsnag::Api.account
|
66
|
+
```
|
67
|
+
|
68
|
+
or...
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# Create an non-static API client
|
72
|
+
client = Bugsnag::Api::Client.new(auth_token: "your-account-api-token")
|
73
|
+
|
74
|
+
# Access API methods on the client
|
75
|
+
accounts = client.accounts
|
76
|
+
```
|
77
|
+
|
78
|
+
### Consuming Resources
|
79
|
+
|
80
|
+
Most methods return a `Resource` object which provides dot notation and [] access for fields returned in the API response.
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
# Fetch the current account
|
35
84
|
account = Bugsnag::Api.account
|
36
85
|
|
37
|
-
|
38
|
-
|
86
|
+
puts account.name
|
87
|
+
# => "Acme Co"
|
88
|
+
|
89
|
+
puts account.fields
|
90
|
+
# => #<Set: {:id, :name, :created_at, :updated_at, :url, :users_url, :projects_url, :account_creator, :billing_contact}>
|
91
|
+
|
92
|
+
puts account[:id]
|
93
|
+
# => "50baed0d9bf39c1431000003"
|
39
94
|
|
40
|
-
|
41
|
-
|
95
|
+
account.rels[:users].href
|
96
|
+
# => "https://api.bugsnag.com/accounts/50baed0d9bf39c1431000003/users"
|
97
|
+
```
|
98
|
+
|
99
|
+
### Accessing Related Resources
|
100
|
+
|
101
|
+
Resources returned by Bugsnag API methods contain not only data but hypermedia link relations:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
account = Bugsnag::Api.account
|
42
105
|
|
43
|
-
# Get
|
44
|
-
|
106
|
+
# Get the users rel, returned from the API as users_url in the resource
|
107
|
+
account.rels[:users].href
|
108
|
+
# => "https://api.bugsnag.com/accounts/50baed0d9bf39c1431000003/users"
|
109
|
+
|
110
|
+
users = account.rels[:users].get.data
|
111
|
+
users.last.name
|
112
|
+
# => "James Smith"
|
45
113
|
```
|
46
114
|
|
115
|
+
When processing API responses, all `*_url` attributes are culled in to the link relations collection. Any `url` attribute becomes `.rels[:self]`.
|
116
|
+
|
47
117
|
|
48
|
-
|
118
|
+
### Authentication
|
49
119
|
|
50
|
-
|
51
|
-
|
120
|
+
API usage requires authentication. You can authenticate using either your
|
121
|
+
Bugsnag account's [auth token](https://bugsnag.com/docs/api#account-authentication)
|
122
|
+
or with your Bugsnag [user credentials](https://bugsnag.com/docs/api#user-authentication).
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
# Authenticate with your Bugsnag account's auth token
|
126
|
+
Bugsnag::Api.configure do |config|
|
127
|
+
config.auth_token = "your-account-api-token"
|
128
|
+
end
|
129
|
+
|
130
|
+
# Authenticate using your Bugsnag email address and password
|
131
|
+
Bugsnag::Api.configure do |config|
|
132
|
+
config.email = "example@example.com"
|
133
|
+
config.password = "password"
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
### Pagination
|
138
|
+
|
139
|
+
Many Bugsnag API resources are paginated. While you may be tempted to start adding :page parameters to your calls, the API returns links to the next and previous pages for you in the `Link` response header, which we expose in `rels`:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
errors = Bugsnag::Api.errors("project-id", per_page: 100)
|
143
|
+
errors.concat Bugsnag::Api.last_response.rels[:next].get.data
|
144
|
+
```
|
145
|
+
|
146
|
+
|
147
|
+
### Accessing HTTP responses
|
148
|
+
|
149
|
+
While most methods return a `Resource` object or a `Boolean`, sometimes you may need access to the raw HTTP response headers. You can access the last HTTP response with `Client#last_response`:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
account = Bugsnag::Api.account
|
153
|
+
response = Bugsnag::Api.last_response
|
154
|
+
status = response.headers[:status]
|
155
|
+
```
|
156
|
+
|
157
|
+
## API Methods
|
158
|
+
|
159
|
+
### Account
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
# List your accounts
|
163
|
+
accounts = Bugsnag::Api.accounts
|
164
|
+
|
165
|
+
# Get a single account
|
166
|
+
account = Bugsnag::Api.account("account-id")
|
167
|
+
|
168
|
+
# Get authenticated account (requires account auth)
|
169
|
+
account = Bugsnag::Api.account
|
170
|
+
```
|
171
|
+
|
172
|
+
### Comments
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
# List error comments
|
176
|
+
comments = Bugsnag::Api.comments("error-id")
|
177
|
+
|
178
|
+
# Get a single comment
|
179
|
+
comment = Bugsnag::Api.comment("comment-id")
|
180
|
+
|
181
|
+
# Create a comment
|
182
|
+
comment = Bugsnag::Api.create_comment("error-id", "comment message")
|
183
|
+
|
184
|
+
# Update a comment
|
185
|
+
comment = Bugsnag::Api.update_comment("comment-id", "new comment message")
|
186
|
+
|
187
|
+
# Delete a comment
|
188
|
+
Bugsnag::Api.delete_comment("comment-id")
|
189
|
+
```
|
190
|
+
|
191
|
+
### Errors
|
192
|
+
|
193
|
+
```ruby
|
194
|
+
# List project errors
|
195
|
+
errors = Bugsnag::Api.errors("project-id")
|
196
|
+
|
197
|
+
# Get a single error
|
198
|
+
error = Bugsnag::Api.error("error-id")
|
199
|
+
|
200
|
+
# Resolve an error
|
201
|
+
error = Bugsnag::Api.resolve_error("error-id")
|
202
|
+
|
203
|
+
# Re-open an error
|
204
|
+
error = Bugsnag::Api.reopen_error("error-id")
|
205
|
+
|
206
|
+
# Update an error
|
207
|
+
error = Bugsnag::Api.update_error("error-id", {
|
208
|
+
resolved: true
|
209
|
+
})
|
210
|
+
|
211
|
+
# Delete an error
|
212
|
+
error = Bugsnag::Api.delete_error("error-id")
|
213
|
+
```
|
214
|
+
|
215
|
+
### Events
|
216
|
+
|
217
|
+
```ruby
|
218
|
+
# List project events
|
219
|
+
events = Bugsnag::Api.events("project-id")
|
220
|
+
|
221
|
+
# List error events
|
222
|
+
events = Bugsnag::Api.error_events("error-id")
|
223
|
+
|
224
|
+
# Get a single event
|
225
|
+
event = Bugsnag::Api.event("event-id")
|
226
|
+
|
227
|
+
# Delete an event
|
228
|
+
Bugsnag::Api.delete_event("event-id")
|
229
|
+
```
|
230
|
+
|
231
|
+
### Projects
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
# List account projects
|
235
|
+
projects = Bugsnag::Api.projects("account-id")
|
236
|
+
|
237
|
+
# List authenticated account's projects (requires account auth)
|
238
|
+
projects = Bugsnag::Api.projects
|
239
|
+
|
240
|
+
# List user projects
|
241
|
+
projects = Bugsnag::Api.user_projects("user-id")
|
242
|
+
|
243
|
+
# Get a single project
|
244
|
+
project = Bugsnag::Api.project("project-id")
|
245
|
+
|
246
|
+
# Create a project
|
247
|
+
project = Bugsnag::Api.create_project("account-id", {
|
248
|
+
name: "Name",
|
249
|
+
type: "rails"
|
250
|
+
})
|
251
|
+
|
252
|
+
# Update a project
|
253
|
+
project = Bugsnag::Api.update_project("project-id", {
|
254
|
+
name: "New Name"
|
255
|
+
})
|
256
|
+
|
257
|
+
# Delete a project
|
258
|
+
Bugsnag::Api.delete_project("project-id")
|
259
|
+
```
|
260
|
+
|
261
|
+
### Users
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
# List account users
|
265
|
+
users = Bugsnag::Api.users("account-id")
|
266
|
+
|
267
|
+
# List authenticated account's users (requires account auth)
|
268
|
+
users = Bugsnag::Api.users
|
269
|
+
|
270
|
+
# List project users
|
271
|
+
users = Bugsnag::Api.project_users("project-id")
|
272
|
+
|
273
|
+
# Get a single user
|
274
|
+
user = Bugsnag::Api.user("user-id")
|
275
|
+
|
276
|
+
# Get authenticated user (requires user auth)
|
277
|
+
user = Bugsnag::Api.user
|
278
|
+
|
279
|
+
# Invite a user to an account
|
280
|
+
user = Bugsnag::Api.invite_user("account-id", "example@example.com", {
|
281
|
+
admin: true
|
282
|
+
})
|
283
|
+
|
284
|
+
# Update a user's account permissions
|
285
|
+
user = Bugsnag::Api.update_user_permissions("account-id", "user-id", {
|
286
|
+
admin: false
|
287
|
+
})
|
288
|
+
|
289
|
+
# Remove a user from an account
|
290
|
+
Bugsnag::Api.remove_user("account-id", "user-id")
|
291
|
+
```
|
292
|
+
|
293
|
+
|
294
|
+
## Advanced Configuration
|
295
|
+
|
296
|
+
### Endpoint
|
297
|
+
|
298
|
+
By default, `https://api.bugsnag.com` is used for API access, if you are using
|
299
|
+
Bugsnag Enterprise, you can configure a custom endpoint.
|
300
|
+
|
301
|
+
```ruby
|
302
|
+
Bugsnag.Api.configure do |config|
|
303
|
+
config.endpoint = "http://api.bugsnag.example.com"
|
304
|
+
end
|
305
|
+
```
|
306
|
+
|
307
|
+
### Proxy
|
308
|
+
|
309
|
+
If you are using a proxy, you can configure the API client to use it.
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
Bugsnag.Api.configure do |config|
|
313
|
+
config.proxy = {
|
314
|
+
uri: "http://proxy.example.com",
|
315
|
+
user: "foo",
|
316
|
+
password: "bar"
|
317
|
+
}
|
318
|
+
end
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
## Build Status
|
323
|
+
|
324
|
+

|
52
325
|
|
53
326
|
|
54
327
|
## Contributing
|
@@ -58,3 +331,8 @@ Full documentation of available methods can be found here:
|
|
58
331
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
332
|
4. Push to the branch (`git push origin my-new-feature`)
|
60
333
|
5. Create new Pull Request
|
334
|
+
|
335
|
+
|
336
|
+
## License
|
337
|
+
|
338
|
+
The Bugsnag API Toolkit for Ruby is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.
|
data/Rakefile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
3
|
# RSpec tasks
|
4
|
-
require 'rspec/core'
|
5
4
|
require "rspec/core/rake_task"
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
-
end
|
9
|
-
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
6
|
task :default => :spec
|
data/bugsnag-api.gemspec
CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
26
|
spec.add_development_dependency "webmock"
|
27
27
|
spec.add_development_dependency "faker"
|
28
|
-
spec.add_development_dependency "vcr"
|
28
|
+
spec.add_development_dependency "vcr", "~> 2.9"
|
29
29
|
spec.add_development_dependency "json"
|
30
30
|
end
|
data/lib/bugsnag/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: vcr
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '2.9'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '2.9'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|