bugsnag-api 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -3
  3. data/CHANGELOG.md +32 -0
  4. data/CONTRIBUTING.md +40 -0
  5. data/README.md +126 -111
  6. data/bugsnag-api.gemspec +4 -3
  7. data/lib/bugsnag/api/client.rb +18 -9
  8. data/lib/bugsnag/api/client/collaborators.rb +87 -0
  9. data/lib/bugsnag/api/client/comments.rb +31 -40
  10. data/lib/bugsnag/api/client/currentuser.rb +33 -0
  11. data/lib/bugsnag/api/client/errors.rb +45 -51
  12. data/lib/bugsnag/api/client/eventfields.rb +50 -0
  13. data/lib/bugsnag/api/client/events.rb +38 -32
  14. data/lib/bugsnag/api/client/organizations.rb +46 -0
  15. data/lib/bugsnag/api/client/pivots.rb +43 -0
  16. data/lib/bugsnag/api/client/projects.rb +37 -63
  17. data/lib/bugsnag/api/client/trends.rb +38 -0
  18. data/lib/bugsnag/api/error.rb +4 -0
  19. data/lib/bugsnag/api/version.rb +1 -1
  20. data/spec/bugsnag/api/client/collaborators_spec.rb +101 -0
  21. data/spec/bugsnag/api/client/comments_spec.rb +42 -30
  22. data/spec/bugsnag/api/client/currentuser_spec.rb +57 -0
  23. data/spec/bugsnag/api/client/errors_spec.rb +44 -41
  24. data/spec/bugsnag/api/client/eventfields_spec.rb +56 -0
  25. data/spec/bugsnag/api/client/events_spec.rb +41 -29
  26. data/spec/bugsnag/api/client/organizations_spec.rb +53 -0
  27. data/spec/bugsnag/api/client/pivots_spec.rb +49 -0
  28. data/spec/bugsnag/api/client/projects_spec.rb +35 -59
  29. data/spec/bugsnag/api/client/trends_spec.rb +44 -0
  30. data/spec/bugsnag/api/client_spec.rb +8 -3
  31. data/spec/cassettes/Bugsnag_Api_Client/_get/handles_query_params.yml +45 -27
  32. data/spec/cassettes/Bugsnag_Api_Client/_last_response/caches_the_last_agent_response.yml +45 -27
  33. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/_invitecollaborator/creates_and_returns_a_collaborator.yml +80 -0
  34. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/_invitecollaborator/invites_multiple_collaborators.yml +80 -0
  35. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborator/returns_a_collaborator.yml +157 -0
  36. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/returns_a_list_of_all_organization_collaborators.yml +160 -0
  37. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/returns_a_list_of_all_project_collaborators.yml +160 -0
  38. 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 +80 -0
  39. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_delete_collaborator/deletes_a_collaborator.yml +80 -0
  40. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_update_collaborator_permissions/updates_and_returns_the_collaborator.yml +157 -0
  41. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_view_collaborator_projects/returns_a_list_of_projects_belonging_to_the_collaborator.yml +159 -0
  42. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/creates_a_comment_on_the_error.yml +82 -0
  43. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_comment/retrieves_the_comment_specified.yml +159 -0
  44. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_comments/retrieves_all_comments_on_an_error.yml +161 -0
  45. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_delete_comment/deletes_the_comment_and_returns_true.yml +82 -0
  46. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_update_comment/updates_the_message_on_a_comment.yml +159 -0
  47. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_organizations/when_using_auth_token/returns_the_organization_the_auth_token_belongs_to.yml +81 -0
  48. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_organizations/when_using_user_credentials/returns_users_organizations.yml +85 -0
  49. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_projects/when_using_auth_token/lists_current_user_s_projects_in_the_organization.yml +82 -0
  50. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_projects/when_using_user_credentials/lists_current_user_s_projects_in_the_organization.yml +86 -0
  51. data/spec/cassettes/Bugsnag_Api_Client_Errors/_error/returns_a_single_error.yml +82 -0
  52. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_errors_on_the_project.yml +84 -0
  53. data/spec/cassettes/Bugsnag_Api_Client_Errors/_update_errors/updates_and_returns_the_updated_errors.yml +80 -0
  54. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/lists_all_error_events.yml +84 -0
  55. data/spec/cassettes/Bugsnag_Api_Client_Events/_event/returns_the_specified_event.yml +253 -0
  56. data/spec/cassettes/Bugsnag_Api_Client_Events/_events/returns_the_a_list_of_project_errors.yml +84 -0
  57. data/spec/cassettes/Bugsnag_Api_Client_Events/_latest_event/returns_the_last_event_on_an_error.yml +253 -0
  58. data/spec/cassettes/Bugsnag_Api_Client_Organizations/_create_organization/creates_a_new_organization.yml +84 -0
  59. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_delete_organization/deletes_the_organization.yml +159 -0
  60. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_organization/returns_the_requested_organization.yml +165 -0
  61. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_update_organization/updates_and_returns_the_organization.yml +165 -0
  62. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_new_project.yml +80 -0
  63. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_delete_project/deletes_the_project.yml +151 -0
  64. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_project/returns_the_requested_project.yml +157 -0
  65. 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 +157 -0
  66. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_update_project/updates_and_returns_the_project.yml +157 -0
  67. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_buckets/returns_a_list_of_error_trends_in_bucket_form.yml +80 -0
  68. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_buckets/returns_a_list_of_project_trends_in_bucket_form.yml +80 -0
  69. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_resolution/returns_a_list_of_project_trends_in_resolution_form.yml +80 -0
  70. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_resolution/returns_a_list_of_trends_in_resolution_form.yml +80 -0
  71. data/spec/spec_helper.rb +29 -27
  72. metadata +124 -83
  73. data/lib/bugsnag/api/client/accounts.rb +0 -44
  74. data/lib/bugsnag/api/client/users.rb +0 -99
  75. data/spec/bugsnag/api/client/accounts_spec.rb +0 -45
  76. data/spec/bugsnag/api/client/users_spec.rb +0 -105
  77. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/returns_the_requested_account.yml +0 -49
  78. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/when_using_account_credentials/returns_the_account.yml +0 -51
  79. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_accounts/returns_all_accounts.yml +0 -49
  80. data/spec/cassettes/Bugsnag_Api_Client_Comments/_comments/returns_all_comments_on_an_error.yml +0 -107
  81. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/created_a_comment.yml +0 -51
  82. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_comment/returns_a_comment.yml +0 -97
  83. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_delete_comment/deletes_an_existing_comment.yml +0 -92
  84. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_update_comment/updates_an_existing_comment.yml +0 -97
  85. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_all_errors_on_an_project.yml +0 -48
  86. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_error/returns_an_error.yml +0 -48
  87. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_reopen_error/reopens_the_error.yml +0 -48
  88. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_resolve_error/resolves_the_error.yml +0 -48
  89. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_update_error/updates_the_error.yml +0 -48
  90. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/returns_all_events_on_an_error.yml +0 -64
  91. data/spec/cassettes/Bugsnag_Api_Client_Events/_project_events/returns_all_events_on_a_project.yml +0 -64
  92. data/spec/cassettes/Bugsnag_Api_Client_Events/with_event/_event/returns_an_event.yml +0 -56
  93. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/returns_all_projects_on_an_account.yml +0 -61
  94. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/when_using_account_credentials/returns_all_projects.yml +0 -63
  95. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_project_on_an_account.yml +0 -50
  96. data/spec/cassettes/Bugsnag_Api_Client_Projects/_user_projects/returns_all_projects_for_a_user.yml +0 -61
  97. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_delete_project/deletes_an_existing_project.yml +0 -91
  98. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_project/returns_a_project.yml +0 -95
  99. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_update_project/updates_an_existing_project.yml +0 -95
  100. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/returns_all_users_on_an_account.yml +0 -49
  101. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/when_using_account_credentials/returns_all_users.yml +0 -51
  102. data/spec/cassettes/Bugsnag_Api_Client_Users/_invite_user/invites_a_user_to_an_account.yml +0 -48
  103. data/spec/cassettes/Bugsnag_Api_Client_Users/_project_users/returns_all_users_for_a_project.yml +0 -49
  104. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/returns_a_user.yml +0 -48
  105. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/when_using_user_credentials/returns_the_authed_user.yml +0 -48
  106. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_remove_user/removes_a_user_from_an_account.yml +0 -89
  107. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_update_user_permissions/updates_a_users_permissions.yml +0 -93
@@ -4,51 +4,57 @@ module Bugsnag
4
4
 
5
5
  # Methods for the Events API
6
6
  #
7
- # @see https://bugsnag.com/docs/api/events
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/events
8
8
  module Events
9
- # List a project's events
9
+ # View an Event
10
10
  #
11
- # @param project [String] Bugsnag project for which to list events
12
- # @return [Array<Sawyer::Resource>] List of events
13
- # @see https://bugsnag.com/docs/api/events#list-a-project-s-events
14
- # @example
15
- # Bugsnag::Api.events("50baed119bf39c1431000004")
16
- def events(project, options = {})
17
- paginate "projects/#{project}/events", options
11
+ # @return [Sawyer::Resource] Requested Event
12
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/events/view-an-event
13
+ def event(project_id, id, options = {})
14
+ get "projects/#{project_id}/events/#{id}", options
18
15
  end
19
- alias :project_events :events
20
16
 
21
- # List an error's events
17
+ # Delete an Event
22
18
  #
23
- # @param error [String] Bugsnag error for which to list events
24
- # @return [Array<Sawyer::Resource>] List of events
25
- # @see https://bugsnag.com/docs/api/events#list-an-error-s-events
26
- # @example
27
- # Bugsnag::Api.error_events("518031bcd775355c48a1cd4e")
28
- def error_events(error, options = {})
29
- paginate "errors/#{error}/events", options
19
+ # @return
20
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/events/delete-an-event
21
+ def delete_event(project_id, id, options = {})
22
+ boolean_from_response :delete, "projects/#{project_id}/events/#{id}", options
30
23
  end
31
24
 
32
- # Get a single event
25
+ # List the Events on an Error
33
26
  #
34
- # @param event [String] A Bugsnag event id
35
- # @return [Sawyer::Resource] The event you requested, if it exists
36
- # @see https://bugsnag.com/docs/api/events#get-event-details
37
- # @example
38
- # Bugsnag::Api.event("51f5d152f002c6686d013a22")
39
- def event(event, options = {})
40
- get "events/#{event}", options
27
+ # @option base [String] Only Error Events occuring before this time will be returned
28
+ # @option sort [String] Which field to sort the results by, one of: last_seen, first_seen, users, events
29
+ # @option direction [String] Which direction to sort the results by, one of: asc, desc
30
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
31
+ # @return [Array<Sawyer::Resource>] List of Events for the specified Error
32
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/events/list-the-events-on-an-error
33
+ def error_events(project_id, error_id, options = {})
34
+ paginate "projects/#{project_id}/errors/#{error_id}/events", options
41
35
  end
42
36
 
43
- # Delete an event
37
+ # View the latest Event on an Error
44
38
  #
45
- # @param event [String] A Bugsnag event
46
- # @return [Boolean] `true` if event was deleted
47
- # @see https://bugsnag.com/docs/api/events#delete-an-event
48
- def delete_event(event, options = {})
49
- boolean_from_response :delete, "events/#{event}", options
39
+ # @return [Sawyer::Resource] Last event reported Event
40
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/events/view-the-latest-event-on-an-error
41
+ def latest_event(error_id, options = {})
42
+ get "errors/#{error_id}/latest_event", options
43
+ end
44
+
45
+ # List the Events on a Project
46
+ #
47
+ # @option base [String] Only Project Events occuring before this time will be returned
48
+ # @option sort [String] Which field to sort the results by, one of: last_seen, first_seen, users, events
49
+ # @option direction [String] Which direction to sort the results by, one of: asc, desc
50
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
51
+ # @return [Array<Sawyer::Resource>] List of Events for the specified Project
52
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/events/list-the-events-on-a-project
53
+ def events(project_id, options = {})
54
+ get "projects/#{project_id}/events", options
50
55
  end
51
56
  end
52
57
  end
53
58
  end
54
59
  end
60
+
@@ -0,0 +1,46 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for the Organizations API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations
8
+ module Organizations
9
+ # Create an Organization
10
+ #
11
+ # @return [Sawyer::Resource] New Organization
12
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/organizations/create-an-organization
13
+ def create_organization(name, options = {})
14
+ post "organizations", options.merge({:name => name})
15
+ end
16
+
17
+ # View an Organization
18
+ #
19
+ # @return [Sawyer::Resource] Requested Organization
20
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/organizations/view-an-organization
21
+ def organization(id, options = {})
22
+ get "organizations/#{id}", options
23
+ end
24
+
25
+ # Update an Organization
26
+ #
27
+ # @option invoice_address [String] Additional information to print on your invoice
28
+ # @option billing_emails [Array<String>] List of billing emails
29
+ # @return [Sawyer::Resource] Updated Organization
30
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/organizations/update-an-organization
31
+ def update_organization(id, name, auto_upgrade, options = {})
32
+ patch "organizations/#{id}", options.merge({:name => name, :auto_upgrade => auto_upgrade})
33
+ end
34
+
35
+ # Delete an Organization
36
+ #
37
+ # @return
38
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/organizations/delete-an-organization
39
+ def delete_organization(id, options = {})
40
+ boolean_from_response :delete, "organizations/#{id}", options
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,43 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for the Pivots API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/pivots
8
+ module Pivots
9
+ # List Pivots on an Error
10
+ #
11
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
12
+ # @option summary_size [Number] The number of elements to include in the list
13
+ # @option pivots [Array] EventField display_ids to identify pivots to return
14
+ # @option per_page [Number] Number of results to be returned per page
15
+ # @return [Array<Sawyer::Resource>] List of Pivots for the Error specified
16
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/pivots/list-pivots-on-an-error
17
+ def pivots(project_id, error_id=nil, options = {})
18
+ if error_id.nil?
19
+ get "projects/#{project_id}/pivots", options
20
+ else
21
+ paginate "projects/#{project_id}/errors/#{error_id}/pivots", options
22
+ end
23
+ end
24
+
25
+ # List values of a Pivot on an Error
26
+ #
27
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
28
+ # @option sort [String] Sorting method
29
+ # @option base [String] Only Events occuring before this time will be used
30
+ # @return [Array<Sawyer::Resource>] List of values for the Pivots requested
31
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/pivots/list-values-of-a-pivot-on-an-error
32
+ def pivot_values(project_id, ef_display_id, error_id=nil, options = {})
33
+ if error_id.nil?
34
+ paginate "projects/#{project_id}/pivots/#{ef_display_id}/values", options
35
+ else
36
+ paginate "projects/#{project_id}/errors/#{error_id}/pivots/#{ef_display_id}/values", options
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -4,85 +4,59 @@ module Bugsnag
4
4
 
5
5
  # Methods for the Projects API
6
6
  #
7
- # @see https://bugsnag.com/docs/api/projects
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects
8
8
  module Projects
9
- # List account projects
9
+ # Create a Project in an Organization
10
10
  #
11
- # @param account [String] Bugsnag account for which to list projects
12
- # @return [Array<Sawyer::Resource>] List of projects
13
- # @see https://bugsnag.com/docs/api/projects#list-an-account-s-projects
14
- # @example
15
- # Bugsnag::Api.projects("515fb9337c1074f6fd000009")
16
- def projects(account=nil, options = {})
17
- if account.nil? || account.is_a?(Hash)
18
- options = account || {}
19
-
20
- raise Bugsnag::Api::AccountCredentialsRequired.new(
21
- "Fetching projects without an account id is only possible when "\
22
- "using an account auth token."
23
- ) unless token_authenticated?
24
-
25
- paginate "account/projects", options
26
- else
27
- paginate "accounts/#{account}/projects", options
28
- end
29
- end
30
- alias :account_projects :projects
31
-
32
- # List user projects
33
- #
34
- # @param account [String] Bugsnag user for which to list projects
35
- # @return [Array<Sawyer::Resource>] List of projects
36
- # @see https://bugsnag.com/docs/api/projects#list-a-user-s-projects
37
- # @example
38
- # Bugsnag::Api.user_projects("515fb9337c1074f6fd000007")
39
- def user_projects(user, options = {})
40
- paginate "users/#{user}/projects", options
11
+ # @return [Sawyer::Resource] New Project
12
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/projects/create-a-project-in-an-organization
13
+ def create_project(org_id, name, type, options = {})
14
+ post "organizations/#{org_id}/projects", options.merge({:name => name, :type => type})
41
15
  end
42
16
 
43
- # Get a single project
17
+ # View a Project
44
18
  #
45
- # @param project [String] A Bugsnag project
46
- # @return [Sawyer::Resource] The project you requested, if it exists
47
- # @see https://bugsnag.com/docs/api/projects#get-project-details
48
- # @example
49
- # Bugsnag::Api.project("50baed119bf39c1431000004")
50
- def project(project, options = {})
51
- get "projects/#{project}", options
19
+ # @return [Sawyer::Resource] Requested Project
20
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/projects/view-a-project
21
+ def project(id, options = {})
22
+ get "projects/#{id}", options
52
23
  end
53
24
 
54
- # Create a project
25
+ # Update a Project
55
26
  #
56
- # @param account [String] The Bugsnag account to create project on
57
- # @option name [String] The project's name
58
- # @option type [String] The type of the project
59
- # @see https://bugsnag.com/docs/api/projects#create-a-project
60
- # @example
61
- # Bugsnag::Api.create_project("515fb9337c1074f6fd000009", name: "Website")
62
- def create_project(account, options = {})
63
- post "accounts/#{account}/projects", options
27
+ # @option name [String] A name for the project
28
+ # @option global_grouping [Array<String>] A list of error classes, which will be grouped by class
29
+ # @option location_grouping [Array<String>] A list of error classes, which will be grouped by context
30
+ # @option discarded_app_versions [Array<String>] A list of app versions whose events will be ignored
31
+ # @option discarded_errors [Array<String>] A list of error classes that will be ignored
32
+ # @option url_whitelist [Array<String>] If configured only errors from whitelisted URLs will be processed
33
+ # @option ignore_old_browsers [Boolean] Set to ignore events from old web browsers
34
+ # @option ignored_browser_versions [Object] A mapping of browser name to ignored versions
35
+ # @option resolve_on_deploy [Boolean] Set all errors to resolved once a new deployment has been notified
36
+ # @option collaborator_ids [Array<String>] Update the collaborators in the project to only these ids
37
+ # @return [Sawyer::Resource] Updated Project
38
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/projects/update-a-project
39
+ def update_project(id, options = {})
40
+ patch "projects/#{id}", options
64
41
  end
65
42
 
66
- # Update a project
43
+ # Regenerate a Project's notifier API key
67
44
  #
68
- # @param project [String] A Bugsnag project
69
- # @return [Sawyer::Resource] The updated project
70
- # @see https://bugsnag.com/docs/api/projects#update-a-project
71
- # @example
72
- # Bugsnag::Api.update_project("50baed119bf39c1431000004", name: "Dashboard")
73
- def update_project(project, options = {})
74
- patch "projects/#{project}", options
45
+ # @return
46
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/projects/regenerate-a-project's-notifier-api-key
47
+ def regenerate_api_key(id, options = {})
48
+ delete "projects/#{id}/api_key", options
75
49
  end
76
50
 
77
- # Delete a project
51
+ # Delete a Project
78
52
  #
79
- # @param project [String] A Bugsnag project
80
- # @return [Boolean] `true` if project was deleted
81
- # @see https://bugsnag.com/docs/api/projects#delete-a-project
82
- def delete_project(project, options = {})
83
- boolean_from_response :delete, "projects/#{project}", options
53
+ # @return
54
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/organizations/delete-an-organization
55
+ def delete_project(id, options = {})
56
+ boolean_from_response :delete, "projects/#{id}", options
84
57
  end
85
58
  end
86
59
  end
87
60
  end
88
61
  end
62
+
@@ -0,0 +1,38 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for the Pivots API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/trends
8
+ module Trends
9
+ # List Trends for an Error in bucket form
10
+ #
11
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
12
+ # @return [Array<Sawyer::Resource>] List of Trends as requested
13
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/trends/list-the-trends-for-an-error-(buckets)
14
+ def trends_buckets(project_id, buckets_count, error_id=nil, options = {})
15
+ if !error_id.nil?
16
+ get "projects/#{project_id}/errors/#{error_id}/trend", options.merge({:query => {:buckets_count => buckets_count}})
17
+ else
18
+ get "projects/#{project_id}/trend", options.merge({:query => {:buckets_count => buckets_count}})
19
+ end
20
+ end
21
+
22
+ # List Trends for an Error in resolution form
23
+ #
24
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
25
+ # @return [Array<Sawyer::Resource>] List of Trends as requested
26
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/trends/list-the-trends-for-an-error-(buckets)
27
+ def trends_resolution(project_id, resolution, error_id=nil, options = {})
28
+ if !error_id.nil?
29
+ get "projects/#{project_id}/errors/#{error_id}/trend", options.merge({:query => {:resolution => resolution}})
30
+ else
31
+ get "projects/#{project_id}/trend", options.merge({:query => {:resolution => resolution}})
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -23,6 +23,7 @@ module Bugsnag
23
23
  when 409 then Bugsnag::Api::Conflict
24
24
  when 415 then Bugsnag::Api::UnsupportedMediaType
25
25
  when 422 then Bugsnag::Api::UnprocessableEntity
26
+ when 429 then Bugsnag::Api::RateLimitExceeded
26
27
  when 400..499 then Bugsnag::Api::ClientError
27
28
  when 500 then Bugsnag::Api::InternalServerError
28
29
  when 501 then Bugsnag::Api::NotImplemented
@@ -102,6 +103,9 @@ module Bugsnag
102
103
  # Raised when Bugsnag returns a 422 HTTP status code
103
104
  class UnprocessableEntity < ClientError; end
104
105
 
106
+ # Raised when the api limit has been exceeded
107
+ class RateLimitExceeded < ClientError; end
108
+
105
109
  # Raised on errors in the 500-599 range
106
110
  class ServerError < Error; end
107
111
 
@@ -1,5 +1,5 @@
1
1
  module Bugsnag
2
2
  module Api
3
- VERSION = "1.0.3"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,101 @@
1
+ require "spec_helper"
2
+
3
+ describe Bugsnag::Api::Client::Collaborators do
4
+ before do
5
+ @client = auth_token_client
6
+ @organization_id = test_bugsnag_org_id
7
+ @project_id = test_bugsnag_project_id
8
+ @collaborator_email = test_bugsnag_collaborator
9
+ @admin_email = test_bugsnag_email
10
+ Bugsnag::Api.reset!
11
+ end
12
+
13
+ describe ".invitecollaborator", :vcr do
14
+ it "creates and returns a collaborator" do
15
+ collaborator = @client.invite_collaborators @organization_id, @collaborator_email
16
+ expect(collaborator.email).to eq(@collaborator_email)
17
+
18
+ assert_requested :post, bugsnag_url("/organizations/#{@organization_id}/collaborators")
19
+ end
20
+
21
+ it "invites multiple collaborators" do
22
+ collaborators = @client.invite_collaborators @organization_id, [@collaborator_email, @admin_email]
23
+ expect(collaborators).to be_a_kind_of(Array)
24
+ expect(collaborators.length).to eq(2)
25
+
26
+ assert_requested :post, bugsnag_url("/organizations/#{@organization_id}/collaborators/bulk_invite")
27
+ end
28
+ end
29
+
30
+ context "given a collaborator exists", :vcr do
31
+ before do
32
+ @collaborator = @client.invite_collaborators @organization_id, @collaborator_email, {:project_ids => [@project_id]}
33
+ end
34
+
35
+ describe ".collaborator", :vcr do
36
+ it "returns a collaborator" do
37
+ collaborator = @client.collaborator @organization_id, @collaborator.id
38
+ expect(collaborator.id).to eq(@collaborator.id)
39
+ expect(collaborator.name).to eq(@collaborator.name)
40
+
41
+ assert_requested :get, bugsnag_url("/organizations/#{@organization_id}/collaborators/#{@collaborator.id}")
42
+ end
43
+ end
44
+
45
+ describe ".collaborators", :vcr do
46
+ it "returns a list of all organization collaborators" do
47
+ collaborators = @client.collaborators @organization_id
48
+ expect(collaborators).to be_a_kind_of(Array)
49
+ expect(collaborators.length).to be > 1
50
+
51
+ assert_requested :get, bugsnag_url("/organizations/#{@organization_id}/collaborators")
52
+ end
53
+
54
+ it "returns a list of all project collaborators" do
55
+ collaborators = @client.collaborators(nil, @project_id)
56
+ expect(collaborators).to be_a_kind_of(Array)
57
+ expect(collaborators.length).to be > 1
58
+
59
+ assert_requested :get, bugsnag_url("/projects/#{@project_id}/collaborators")
60
+ end
61
+
62
+ it "throws an argument error if neither org_id or project_id are provided" do
63
+ begin
64
+ @client.collaborators
65
+ rescue Exception => ex
66
+ expect(ex).to be_a_kind_of(ArgumentError)
67
+ end
68
+ end
69
+ end
70
+
71
+ describe ".view_collaborator_projects", :vcr do
72
+ it "returns a list of projects belonging to the collaborator" do
73
+ projects = @client.view_collaborator_projects @organization_id, @collaborator.id
74
+ expect(projects).to be_a_kind_of(Array)
75
+ expect(projects.length).to be > 0
76
+
77
+ assert_requested :get, bugsnag_url("/organizations/#{@organization_id}/collaborators/#{@collaborator.id}/projects")
78
+ end
79
+ end
80
+
81
+ describe ".update_collaborator_permissions", :vcr do
82
+ it "updates and returns the collaborator" do
83
+ collaborator = @client.update_collaborator_permissions @organization_id, @collaborator.id, {:admin => true}
84
+ expect(collaborator.id).to eq(@collaborator.id)
85
+ expect(collaborator.is_admin).to be true
86
+
87
+ assert_requested :patch, bugsnag_url("/organizations/#{@organization_id}/collaborators/#{@collaborator.id}")
88
+ end
89
+ end
90
+
91
+ describe ".delete_collaborator", :vcr do
92
+ it "deletes a collaborator" do
93
+ stub_request(:delete, bugsnag_url("/organizations/#{@organization_id}/collaborators/#{@collaborator.id}")).to_return(:status => [204, "No Content"])
94
+ collaborator = @client.delete_collaborator @organization_id, @collaborator.id
95
+ expect(collaborator).to be true
96
+
97
+ assert_requested :delete, bugsnag_url("/organizations/#{@organization_id}/collaborators/#{@collaborator.id}")
98
+ end
99
+ end
100
+ end
101
+ end