bugsnag-api 1.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +5 -5
  2. data/.buildkite/pipeline.yml +6 -0
  3. data/.github/ISSUE_TEMPLATE/A.md +14 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
  7. data/.github/support.md +19 -0
  8. data/.github/workflows/tests.yml +53 -0
  9. data/.rubocop.yml +2 -0
  10. data/.rubocop_todo.yml +271 -0
  11. data/CHANGELOG.md +59 -0
  12. data/CONTRIBUTING.md +40 -0
  13. data/Gemfile +9 -0
  14. data/README.md +178 -109
  15. data/bugsnag-api.gemspec +42 -6
  16. data/config/.gitignore +1 -0
  17. data/docker-compose.yml +9 -0
  18. data/dockerfiles/Dockerfile.audit +5 -0
  19. data/lib/bugsnag/api/client.rb +32 -10
  20. data/lib/bugsnag/api/client/collaborators.rb +86 -0
  21. data/lib/bugsnag/api/client/comments.rb +31 -40
  22. data/lib/bugsnag/api/client/currentuser.rb +32 -0
  23. data/lib/bugsnag/api/client/errors.rb +48 -53
  24. data/lib/bugsnag/api/client/eventfields.rb +49 -0
  25. data/lib/bugsnag/api/client/events.rb +37 -32
  26. data/lib/bugsnag/api/client/organizations.rb +45 -0
  27. data/lib/bugsnag/api/client/pivots.rb +42 -0
  28. data/lib/bugsnag/api/client/projects.rb +36 -63
  29. data/lib/bugsnag/api/client/trends.rb +41 -0
  30. data/lib/bugsnag/api/configuration.rb +1 -1
  31. data/lib/bugsnag/api/error.rb +5 -1
  32. data/lib/bugsnag/api/response/raise_error.rb +0 -2
  33. data/lib/bugsnag/api/version.rb +1 -1
  34. data/scripts/license_finder.sh +4 -0
  35. data/spec/bugsnag/api/client/collaborators_spec.rb +101 -0
  36. data/spec/bugsnag/api/client/comments_spec.rb +42 -30
  37. data/spec/bugsnag/api/client/currentuser_spec.rb +57 -0
  38. data/spec/bugsnag/api/client/errors_spec.rb +44 -41
  39. data/spec/bugsnag/api/client/eventfields_spec.rb +56 -0
  40. data/spec/bugsnag/api/client/events_spec.rb +41 -29
  41. data/spec/bugsnag/api/client/organizations_spec.rb +53 -0
  42. data/spec/bugsnag/api/client/pivots_spec.rb +49 -0
  43. data/spec/bugsnag/api/client/projects_spec.rb +35 -59
  44. data/spec/bugsnag/api/client/trends_spec.rb +44 -0
  45. data/spec/bugsnag/api/client_spec.rb +76 -9
  46. data/spec/bugsnag/api_spec.rb +2 -0
  47. data/spec/cassettes/Bugsnag_Api_Client/_get/handles_query_params.yml +36 -26
  48. data/spec/cassettes/Bugsnag_Api_Client/_last_response/caches_the_last_agent_response.yml +36 -26
  49. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/_invitecollaborator/creates_and_returns_a_collaborator.yml +68 -0
  50. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/_invitecollaborator/invites_multiple_collaborators.yml +68 -0
  51. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborator/returns_a_collaborator.yml +133 -0
  52. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/returns_a_list_of_all_organization_collaborators.yml +135 -0
  53. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/returns_a_list_of_all_project_collaborators.yml +135 -0
  54. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/throws_an_argument_error_if_neither_org_id_or_project_id_are_provided.yml +68 -0
  55. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_delete_collaborator/deletes_a_collaborator.yml +68 -0
  56. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_update_collaborator_permissions/updates_and_returns_the_collaborator.yml +133 -0
  57. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_view_collaborator_projects/returns_a_list_of_projects_belonging_to_the_collaborator.yml +153 -0
  58. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/creates_a_comment_on_the_error.yml +70 -0
  59. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_comment/retrieves_the_comment_specified.yml +135 -0
  60. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_comments/retrieves_all_comments_on_an_error.yml +137 -0
  61. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_delete_comment/deletes_the_comment_and_returns_true.yml +70 -0
  62. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_update_comment/updates_the_message_on_a_comment.yml +135 -0
  63. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_organizations/when_using_auth_token/returns_the_organization_the_auth_token_belongs_to.yml +68 -0
  64. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_organizations/when_using_user_credentials/returns_users_organizations.yml +71 -0
  65. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_projects/when_using_auth_token/lists_current_user_s_projects_in_the_organization.yml +88 -0
  66. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_projects/when_using_user_credentials/lists_current_user_s_projects_in_the_organization.yml +91 -0
  67. data/spec/cassettes/Bugsnag_Api_Client_Errors/_error/returns_a_single_error.yml +68 -0
  68. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_errors_on_the_project.yml +70 -0
  69. data/spec/cassettes/Bugsnag_Api_Client_Errors/_update_errors/updates_and_returns_the_updated_errors.yml +68 -0
  70. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/lists_all_error_events.yml +73 -0
  71. data/spec/cassettes/Bugsnag_Api_Client_Events/_event/returns_the_specified_event.yml +70 -0
  72. data/spec/cassettes/Bugsnag_Api_Client_Events/_events/returns_the_a_list_of_project_errors.yml +73 -0
  73. data/spec/cassettes/Bugsnag_Api_Client_Events/_latest_event/returns_the_last_event_on_an_error.yml +70 -0
  74. data/spec/cassettes/Bugsnag_Api_Client_Organizations/_create_organization/creates_a_new_organization.yml +71 -0
  75. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_delete_organization/deletes_the_organization.yml +133 -0
  76. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_organization/returns_the_requested_organization.yml +139 -0
  77. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_update_organization/updates_and_returns_the_organization.yml +139 -0
  78. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_new_project.yml +68 -0
  79. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_delete_project/deletes_the_project.yml +127 -0
  80. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_project/returns_the_requested_project.yml +133 -0
  81. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_regenerate_api_key/removes_the_current_api_key_and_replaces_it_with_a_new_api_key.yml +133 -0
  82. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_update_project/updates_and_returns_the_project.yml +133 -0
  83. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_buckets/returns_a_list_of_error_trends_in_bucket_form.yml +68 -0
  84. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_buckets/returns_a_list_of_project_trends_in_bucket_form.yml +68 -0
  85. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_resolution/returns_a_list_of_project_trends_in_resolution_form.yml +68 -0
  86. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_resolution/returns_a_list_of_trends_in_resolution_form.yml +68 -0
  87. data/spec/spec_helper.rb +32 -30
  88. metadata +167 -115
  89. data/.travis.yml +0 -9
  90. data/lib/bugsnag/api/client/accounts.rb +0 -44
  91. data/lib/bugsnag/api/client/users.rb +0 -99
  92. data/spec/bugsnag/api/client/accounts_spec.rb +0 -45
  93. data/spec/bugsnag/api/client/users_spec.rb +0 -105
  94. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/returns_the_requested_account.yml +0 -49
  95. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/when_using_account_credentials/returns_the_account.yml +0 -51
  96. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_accounts/returns_all_accounts.yml +0 -49
  97. data/spec/cassettes/Bugsnag_Api_Client_Comments/_comments/returns_all_comments_on_an_error.yml +0 -107
  98. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/created_a_comment.yml +0 -51
  99. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_comment/returns_a_comment.yml +0 -97
  100. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_delete_comment/deletes_an_existing_comment.yml +0 -92
  101. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_update_comment/updates_an_existing_comment.yml +0 -97
  102. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_all_errors_on_an_project.yml +0 -48
  103. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_error/returns_an_error.yml +0 -48
  104. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_reopen_error/reopens_the_error.yml +0 -48
  105. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_resolve_error/resolves_the_error.yml +0 -48
  106. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_update_error/updates_the_error.yml +0 -48
  107. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/returns_all_events_on_an_error.yml +0 -64
  108. data/spec/cassettes/Bugsnag_Api_Client_Events/_project_events/returns_all_events_on_a_project.yml +0 -64
  109. data/spec/cassettes/Bugsnag_Api_Client_Events/with_event/_event/returns_an_event.yml +0 -56
  110. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/returns_all_projects_on_an_account.yml +0 -61
  111. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/when_using_account_credentials/returns_all_projects.yml +0 -63
  112. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_project_on_an_account.yml +0 -50
  113. data/spec/cassettes/Bugsnag_Api_Client_Projects/_user_projects/returns_all_projects_for_a_user.yml +0 -61
  114. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_delete_project/deletes_an_existing_project.yml +0 -91
  115. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_project/returns_a_project.yml +0 -95
  116. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_update_project/updates_an_existing_project.yml +0 -95
  117. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/returns_all_users_on_an_account.yml +0 -49
  118. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/when_using_account_credentials/returns_all_users.yml +0 -51
  119. data/spec/cassettes/Bugsnag_Api_Client_Users/_invite_user/invites_a_user_to_an_account.yml +0 -48
  120. data/spec/cassettes/Bugsnag_Api_Client_Users/_project_users/returns_all_users_for_a_project.yml +0 -49
  121. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/returns_a_user.yml +0 -48
  122. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/when_using_user_credentials/returns_the_authed_user.yml +0 -48
  123. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_remove_user/removes_a_user_from_an_account.yml +0 -89
  124. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_update_user_permissions/updates_a_users_permissions.yml +0 -93
data/CHANGELOG.md CHANGED
@@ -1,6 +1,65 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 2.0.3 (11 May 2021)
5
+
6
+ ### Fixes
7
+
8
+ * Fix error handling middleware compatibility with Faraday v1.2.0 and above
9
+ | [askreet](https://github.com/askreet)
10
+ | [#30](https://github.com/bugsnag/bugsnag-api-ruby/pull/30)
11
+
12
+ * Remove call to deprecated `URI.escape`
13
+ | [askreet](https://github.com/askreet)
14
+ | [#28](https://github.com/bugsnag/bugsnag-api-ruby/pull/28)
15
+
16
+ ## 2.0.2 (21 Feb 2018)
17
+
18
+ ### Fixes
19
+
20
+ * Fixes issue with custom query parameters being overridden
21
+ | [#13](https://github.com/bugsnag/bugsnag-api-ruby/pull/13)
22
+
23
+ ## 2.0.1 (15 Nov 2017)
24
+
25
+ ### Fixes
26
+
27
+ * Adds `X-Bugsnag-Api` header so that on-prem clients may use this tool
28
+ | [tremlab](https://github.com/tremlab)
29
+ | [#14](https://github.com/bugsnag/bugsnag-api-ruby/pull/14)
30
+
31
+ ## 2.0.0 (10 Oct 2017)
32
+
33
+ This release changes the gem to access v2 of the [Bugsnag data-access API](https://docs.bugsnag.com/api/data-access/), with full API documentation found [here](http://docs.bugsnagapiv2.apiary.io/).
34
+
35
+ ### Enhancements
36
+
37
+ * Uses Bugsnag data-access API v2 endpoints with associated changes to endpoints and methods, namely:
38
+ - Removes:
39
+ * accounts
40
+ * users
41
+ - Adds:
42
+ * organizations
43
+ * collaborators
44
+ * event fields
45
+ * pivots
46
+ * trends
47
+ - Updates:
48
+ * comments
49
+ * errors
50
+ * events
51
+ * projects
52
+
53
+ | [#11](https://github.com/bugsnag/bugsnag-api-ruby/pull/11)
54
+
55
+ * Adds error response to hitting rate limit
56
+ | [#10](https://github.com/bugsnag/bugsnag-api-ruby/pull/10)
57
+
58
+ ### Known Issues
59
+
60
+ * per_page option not respected in paginated API calls
61
+ * issues with event_fields not being created correctly
62
+
4
63
  1.0.2
5
64
  -----
6
65
  - Fix load-order bug when requiring from certain environments
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,40 @@
1
+ # How to contribute
2
+
3
+ 1. [Fork](https://help.github.com/articles/fork-a-repo) the [library on GitHub](https://github.com/bugsnag/bugsnag-api-ruby)
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit and push until you are happy with your contribution
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Run the tests and make sure they all pass:
8
+
9
+ ```
10
+ rake spec
11
+ ```
12
+
13
+ 6. Create a [Pull Request](https://help.github.com/articles/using-pull-requests)
14
+
15
+ Thank you!
16
+
17
+ ## How to release
18
+
19
+ If you're a member of the core team, follow these instructions for releasing bugsnag-api-ruby.
20
+
21
+ ### First time setup
22
+
23
+ * Create a Rubygems account
24
+ * Get a member of the platforms team to add you as contributor on bugsnag-ruby in Rubygems
25
+
26
+ ### Every time
27
+
28
+ * Update `CHANGELOG.md`
29
+ * Update the version number in [`lib/bugsnag/api/version.rb`](./lib/bugsnag/api/version.rb)
30
+ * Update `README.md` if necessary with changes to the interface or configuration
31
+ * Commit/push your changes
32
+ * Release to rubygems
33
+
34
+ ```
35
+ gem build bugsnag-api.gemspec
36
+ gem push bugsnag-api-[version].gem
37
+ ```
38
+ * Create a new GitHub release, copying the changes from the change log
39
+
40
+
data/Gemfile CHANGED
@@ -1,4 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ # Any :development dependencies are ignored for license auditing purposes
4
+ group :development do
5
+ end
6
+
7
+ # Any :test dependencies are ignored for license auditing purposes
8
+ group :test do
9
+ end
10
+
3
11
  # Specify your gem's dependencies in bugsnag-api.gemspec
4
12
  gemspec
13
+
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  Bugsnag API Toolkit for Ruby
2
2
  ============================
3
+ ![Build status](https://travis-ci.org/bugsnag/bugsnag-api-ruby.svg?branch=master)
4
+
5
+ The library allows for quick read/write access to the [Bugsnag Data Access API](https://docs.bugsnag.com/api/data-access/) from your Ruby applications. You can use this library to build your own applications which leverage data found in your Bugsnag dashboard.
3
6
 
4
- The library allows for quick read/write access to the [Bugsnag API](https://bugsnag.com/docs/api) from your Ruby applications. You can use this library to build your own applications which leverage data found in your Bugsnag dashboard.
7
+ Version 2.x (current) of this gem corresponds to v2 of the Data Access API, while [1.x](https://github.com/bugsnag/bugsnag-api-ruby/tree/v1.0.3) uses the (deprecated) v1 of the Data Access API.
5
8
 
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.
9
+ If you are looking to automatically detect crashes in your Ruby apps, you should take a look at the [Bugsnag Ruby Detection Library](https://docs.bugsnag.com/platforms/ruby) instead.
7
10
 
8
11
  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
12
 
@@ -17,14 +20,18 @@ This library borrows heavily from the code and philosophies of the fantastic [Oc
17
20
  - [Accessing Related Resources](#accessing-related-resources)
18
21
  - [Authentication](#authentication)
19
22
  - [Pagination](#pagination)
23
+ - [Filtering](#filtering)
20
24
  - [Accessing HTTP responses](#accessing-http-responses)
21
25
  - [API Methods](#api-methods)
22
- - [Accounts](#accounts)
26
+ - [Organizations](#organizations)
27
+ - [Collaborators](#collaborators)
23
28
  - [Comments](#comments)
24
29
  - [Errors](#errors)
25
30
  - [Events](#events)
31
+ - [Event Fields](#event-fields)
32
+ - [Pivots](#pivots)
26
33
  - [Projects](#projects)
27
- - [Users](#users)
34
+ - [Trends](#trends)
28
35
  - [Advanced Configuration](#advanced-configuration)
29
36
 
30
37
 
@@ -51,6 +58,12 @@ $ gem install bugsnag-api
51
58
 
52
59
  ## Usage
53
60
 
61
+ ### Require gem
62
+
63
+ ```ruby
64
+ require 'bugsnag/api'
65
+ ```
66
+
54
67
  ### Making Requests
55
68
 
56
69
  API methods are available as module methods or as client instance methods.
@@ -58,42 +71,44 @@ API methods are available as module methods or as client instance methods.
58
71
  ```ruby
59
72
  # Provide authentication credentials
60
73
  Bugsnag::Api.configure do |config|
61
- config.auth_token = "your-account-api-token"
74
+ config.auth_token = "your-personal-auth-token"
62
75
  end
63
76
 
64
- # Fetch the current account
65
- account = Bugsnag::Api.account
77
+ # Access API methods
78
+ organizations = Bugsnag::Api.organizations
66
79
  ```
67
80
 
68
81
  or...
69
82
 
70
83
  ```ruby
71
84
  # Create an non-static API client
72
- client = Bugsnag::Api::Client.new(auth_token: "your-account-api-token")
85
+ client = Bugsnag::Api::Client.new(auth_token: "your-personal-auth-token")
73
86
 
74
87
  # Access API methods on the client
75
- accounts = client.accounts
88
+ organizations = client.organizations
76
89
  ```
77
90
 
78
91
  ### Consuming Resources
79
92
 
80
- Most methods return a `Resource` object which provides dot notation and [] access for fields returned in the API response.
93
+ Most methods return a [`Resource`](http://www.rubydoc.info/gems/sawyer/Sawyer/Resource)
94
+ object which provides dot notation and [] access for fields returned in the API
95
+ response.
81
96
 
82
97
  ```ruby
83
- # Fetch the current account
84
- account = Bugsnag::Api.account
98
+ # Fetch an organization
99
+ org = Bugsnag::Api.organization("organization-id")
85
100
 
86
- puts account.name
101
+ puts org.name
87
102
  # => "Acme Co"
88
103
 
89
- puts account.fields
90
- # => #<Set: {:id, :name, :created_at, :updated_at, :url, :users_url, :projects_url, :account_creator, :billing_contact}>
104
+ puts org.fields
105
+ # => #<Set: {:id, :name, :slug, :creator, :created_at, :updated_at, :auto_upgrade, :upgrade_url, :billing_emails}>
91
106
 
92
- puts account[:id]
107
+ puts org.id
93
108
  # => "50baed0d9bf39c1431000003"
94
109
 
95
- account.rels[:users].href
96
- # => "https://api.bugsnag.com/accounts/50baed0d9bf39c1431000003/users"
110
+ account.rels[:upgrade].href
111
+ # => "https://api.bugsnag.com/organizations/50baed0d9bf39c1431000003/..."
97
112
  ```
98
113
 
99
114
  ### Accessing Related Resources
@@ -101,15 +116,15 @@ account.rels[:users].href
101
116
  Resources returned by Bugsnag API methods contain not only data but hypermedia link relations:
102
117
 
103
118
  ```ruby
104
- account = Bugsnag::Api.account
119
+ project = Bugsnag::Api.projects("organization-id")
105
120
 
106
121
  # 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"
122
+ project.rels[:errors].href
123
+ # => "https://api.bugsnag.com/projects/50baed0d9bf39c1431000003/errors"
109
124
 
110
- users = account.rels[:users].get.data
111
- users.last.name
112
- # => "James Smith"
125
+ errors = project.rels[:errors].get.data
126
+ errors.first.message
127
+ # => "Can't find method: getStrng()"
113
128
  ```
114
129
 
115
130
  When processing API responses, all `*_url` attributes are culled in to the link relations collection. Any `url` attribute becomes `.rels[:self]`.
@@ -118,16 +133,17 @@ When processing API responses, all `*_url` attributes are culled in to the link
118
133
  ### Authentication
119
134
 
120
135
  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).
136
+ Bugsnag account's [auth token](https://app.bugsnag.com/settings/my-account/)
137
+ or with your Bugsnag user credentials.
123
138
 
124
139
  ```ruby
125
140
  # Authenticate with your Bugsnag account's auth token
126
141
  Bugsnag::Api.configure do |config|
127
- config.auth_token = "your-account-api-token"
142
+ config.auth_token = "your-personal-auth-token"
128
143
  end
129
144
 
130
- # Authenticate using your Bugsnag email address and password
145
+ # Authenticate using your Bugsnag email address and password. Unavailable when
146
+ # using multi-factor authentication.
131
147
  Bugsnag::Api.configure do |config|
132
148
  config.email = "example@example.com"
133
149
  config.password = "password"
@@ -140,46 +156,102 @@ Many Bugsnag API resources are paginated. While you may be tempted to start addi
140
156
 
141
157
  ```ruby
142
158
  errors = Bugsnag::Api.errors("project-id", per_page: 100)
143
- errors.concat Bugsnag::Api.last_response.rels[:next].get.data
159
+ last_response = Bugsnag::Api.last_response
160
+ until last_response.rels[:next].nil?
161
+ last_response = last_response.rels[:next].get
162
+ errors.concat last_response.data
163
+ end
144
164
  ```
145
165
 
166
+ ### Filtering
167
+
168
+ Events and Errors can be filtered to return a subset of data. Any of the filters usable in the Bugsnag dashoard can be used in this API. The filter object is a hash of Event Field keys containing an array of filter values. Each filter value has a `type` and a `value` to filter on. The type determines the type of comparison that will be performed.
169
+
170
+ | `type` | Description | Multiple value combination logic |
171
+ |-|-|-|
172
+ | `eq` | Filter for items that 'match' the value. Some fields require an exact match and some support substring matching. | OR |
173
+ | `ne` | Filter for items that don't match the value. | AND |
174
+
175
+ :warning: Note that the Event Field `search` can not be used more than once in a call.
176
+
177
+ You can see the filterable fields for a project using the following snippet, after setting the `project-id` value.
178
+
179
+ ```ruby
180
+ fields = Bugsnag::Api.event_fields("project-id")
181
+
182
+ puts "List of the searchable fields for this project:"
183
+ fields.each_with_index do |field,idx|
184
+ puts " [#{idx}] #{field.display_id}"
185
+ end
186
+ # => List of the searchable fields for this project:
187
+ # => [0] event
188
+ # => [1] error
189
+ # => [2] search
190
+ # => [3] user.id
191
+ # => ...
192
+ ```
146
193
 
147
194
  ### Accessing HTTP responses
148
195
 
149
196
  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
197
 
151
198
  ```ruby
152
- account = Bugsnag::Api.account
153
- response = Bugsnag::Api.last_response
154
- status = response.headers[:status]
199
+ organization = Bugsnag::Api.organizations.first
200
+ response = Bugsnag::Api.last_response
201
+ status = response.headers[:status]
155
202
  ```
156
203
 
157
204
  ## API Methods
158
205
 
159
- ### Account
206
+ The following methods are available via `Bugsnag::Api` and the Client interface.
207
+ For more information, consult the [API
208
+ documentation](http://www.rubydoc.info/gems/bugsnag-api/Bugsnag/Api/Client)
209
+
210
+ ### Organizations
160
211
 
161
212
  ```ruby
162
- # List your accounts
163
- accounts = Bugsnag::Api.accounts
213
+ # List your organizations
214
+ orgs = Bugsnag::Api.organizations
164
215
 
165
- # Get a single account
166
- account = Bugsnag::Api.account("account-id")
216
+ # Get a single organization
217
+ org = Bugsnag::Api.organization("organization-id")
218
+ ```
167
219
 
168
- # Get authenticated account (requires account auth)
169
- account = Bugsnag::Api.account
220
+ ### Collaborators
221
+
222
+ ```ruby
223
+ # List organization collaborators
224
+ users = Bugsnag::Api.collaborators("organization-id")
225
+
226
+ # List project collaborators
227
+ users = Bugsnag::Api.collaborators(nil, "project-id")
228
+
229
+ # Invite a user to an account
230
+ user = Bugsnag::Api.invite_collaborators("org-id", "example@example.com", {
231
+ admin: true
232
+ })
233
+
234
+ # Update a user's account permissions
235
+ user = Bugsnag::Api.update_collaborator_permissions("org-id", "user-id", {
236
+ admin: false
237
+ })
238
+
239
+ # Remove a user from an account
240
+ Bugsnag::Api.delete_collaborator("org-id", "user-id")
170
241
  ```
171
242
 
243
+
172
244
  ### Comments
173
245
 
174
246
  ```ruby
175
247
  # List error comments
176
- comments = Bugsnag::Api.comments("error-id")
248
+ comments = Bugsnag::Api.comments("project-id", "error-id")
177
249
 
178
250
  # Get a single comment
179
- comment = Bugsnag::Api.comment("comment-id")
251
+ comment = Bugsnag::Api.comment("project-id", "comment-id")
180
252
 
181
253
  # Create a comment
182
- comment = Bugsnag::Api.create_comment("error-id", "comment message")
254
+ comment = Bugsnag::Api.create_comment("project-id", "error-id", "comment message")
183
255
 
184
256
  # Update a comment
185
257
  comment = Bugsnag::Api.update_comment("comment-id", "new comment message")
@@ -192,24 +264,26 @@ Bugsnag::Api.delete_comment("comment-id")
192
264
 
193
265
  ```ruby
194
266
  # List project errors
195
- errors = Bugsnag::Api.errors("project-id")
267
+ errors = Bugsnag::Api.errors("project-id", nil)
268
+
269
+ # List errors with a filter (see Filtering section for more information)
270
+ # Returns errors that match `EXC_BAD_INSTRUCTION`, this could be from the error class, message, context, or stack trace.
271
+ errors = Bugsnag::Api.errors("project-id", nil, direction:"desc", filters: {
272
+ "search": [{ "type":"eq", "value":"EXC_BAD_INSTRUCTION" }]
273
+ })
196
274
 
197
275
  # Get a single error
198
- error = Bugsnag::Api.error("error-id")
276
+ error = Bugsnag::Api.error("project-id", "error-id")
199
277
 
200
- # Resolve an error
201
- error = Bugsnag::Api.resolve_error("error-id")
278
+ # Update a single error
279
+ error = Bugsnag::Api.update_errors("project-id", "error-id")
202
280
 
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
- })
281
+ # Update bulk errors
282
+ error = Bugsnag::Api.update_errors("project-id",
283
+ ["error-id1", "error-id2"])
210
284
 
211
285
  # Delete an error
212
- error = Bugsnag::Api.delete_error("error-id")
286
+ error = Bugsnag::Api.delete_error("project-id", "error-id")
213
287
  ```
214
288
 
215
289
  ### Events
@@ -219,78 +293,87 @@ error = Bugsnag::Api.delete_error("error-id")
219
293
  events = Bugsnag::Api.events("project-id")
220
294
 
221
295
  # List error events
222
- events = Bugsnag::Api.error_events("error-id")
296
+ events = Bugsnag::Api.error_events("project-id", "error-id")
297
+
298
+ # List events with a filter (see Filtering section for more information)
299
+ # Returns events with
300
+ # class `EXC_BAD_INSTRUCTION` OR `EXC_BAD_ACCESS`
301
+ # AND where the device is jailbroken
302
+ events = Bugsnag::Api.events(PROJECT_ID, direction:"desc", filters: {
303
+ "event.class": [{ "type":"eq", "value":"EXC_BAD_INSTRUCTION" }, { "type":"eq", "value":"EXC_BAD_ACCESS" }],
304
+ "device.jailbroken": [{ "type":"eq", "value":"false"}]
305
+ })
306
+
307
+ # Get the latest event
308
+ event = Bugsnag::Api.latest_event("project-id", "error-id")
223
309
 
224
310
  # Get a single event
225
- event = Bugsnag::Api.event("event-id")
311
+ event = Bugsnag::Api.event("project-id", "event-id")
226
312
 
227
313
  # Delete an event
228
- Bugsnag::Api.delete_event("event-id")
314
+ Bugsnag::Api.delete_event("project-id", "event-id")
229
315
  ```
230
316
 
231
- ### Projects
317
+ ### Event Fields
232
318
 
233
319
  ```ruby
234
- # List account projects
235
- projects = Bugsnag::Api.projects("account-id")
320
+ # list a project's event fields
321
+ Bugsnag::Api.event_fields("project-id")
236
322
 
237
- # List authenticated account's projects (requires account auth)
238
- projects = Bugsnag::Api.projects
323
+ # create an event field
324
+ Bugsnag::Api.create_event_field("project-id", "display id", "path.to.field", {})
239
325
 
240
- # List user projects
241
- projects = Bugsnag::Api.user_projects("user-id")
326
+ # update an event field
327
+ Bugsnag::Api.update_event_field("project-id", "display id", "new.path.to.field")
328
+
329
+ # delete an event field
330
+ Bugsnag::Api.delete_event_field("project-id", "display id")
331
+ ```
332
+
333
+ ### Projects
334
+
335
+ ```ruby
336
+ # List organization projects
337
+ projects = Bugsnag::Api.projects("organization-id")
242
338
 
243
339
  # Get a single project
244
340
  project = Bugsnag::Api.project("project-id")
245
341
 
246
342
  # Create a project
247
- project = Bugsnag::Api.create_project("account-id", {
248
- name: "Name",
249
- type: "rails"
250
- })
343
+ project = Bugsnag::Api.create_project("organization-id", "project name", "rails")
251
344
 
252
345
  # Update a project
253
346
  project = Bugsnag::Api.update_project("project-id", {
254
347
  name: "New Name"
255
348
  })
256
349
 
350
+ # Regenerate a project API key
351
+ Bugsnag::Api.regenerate_api_key("project-id")
352
+
257
353
  # Delete a project
258
354
  Bugsnag::Api.delete_project("project-id")
259
355
  ```
260
356
 
261
- ### Users
357
+ ### Pivots
262
358
 
263
359
  ```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
360
+ # list a project's pivots
361
+ Bugsnag::Api.pivots("project-id")
269
362
 
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
363
+ # list pivot values
364
+ Bugsnag::Api.pivot_values("project-id", "display id")
365
+ ```
278
366
 
279
- # Invite a user to an account
280
- user = Bugsnag::Api.invite_user("account-id", "example@example.com", {
281
- admin: true
282
- })
367
+ ### Trends
283
368
 
284
- # Update a user's account permissions
285
- user = Bugsnag::Api.update_user_permissions("account-id", "user-id", {
286
- admin: false
287
- })
369
+ ```ruby
370
+ # list an error's trends in 5 buckets
371
+ Bugsnag::Api.trends_buckets("project-id", 5, "error-id")
288
372
 
289
- # Remove a user from an account
290
- Bugsnag::Api.remove_user("account-id", "user-id")
373
+ # list a project's trends by resolution
374
+ Bugsnag::Api.trends_resolution("project-id", "2h")
291
375
  ```
292
376
 
293
-
294
377
  ## Advanced Configuration
295
378
 
296
379
  ### Endpoint
@@ -299,7 +382,7 @@ By default, `https://api.bugsnag.com` is used for API access, if you are using
299
382
  Bugsnag Enterprise, you can configure a custom endpoint.
300
383
 
301
384
  ```ruby
302
- Bugsnag.Api.configure do |config|
385
+ Bugsnag::Api.configure do |config|
303
386
  config.endpoint = "http://api.bugsnag.example.com"
304
387
  end
305
388
  ```
@@ -309,7 +392,7 @@ end
309
392
  If you are using a proxy, you can configure the API client to use it.
310
393
 
311
394
  ```ruby
312
- Bugsnag.Api.configure do |config|
395
+ Bugsnag::Api.configure do |config|
313
396
  config.proxy = {
314
397
  uri: "http://proxy.example.com",
315
398
  user: "foo",
@@ -319,20 +402,6 @@ end
319
402
  ```
320
403
 
321
404
 
322
- ## Build Status
323
-
324
- ![Build status](https://travis-ci.org/bugsnag/bugsnag-api-ruby.svg?branch=master)
325
-
326
-
327
- ## Contributing
328
-
329
- 1. Fork it
330
- 2. Create your feature branch (`git checkout -b my-new-feature`)
331
- 3. Commit your changes (`git commit -am 'Add some feature'`)
332
- 4. Push to the branch (`git push origin my-new-feature`)
333
- 5. Create new Pull Request
334
-
335
-
336
405
  ## License
337
406
 
338
407
  The Bugsnag API Toolkit for Ruby is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.