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
@@ -0,0 +1,49 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for the Project Event Fields API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields
8
+ module EventFields
9
+ # List the Event Fields for a Project
10
+ #
11
+ # @option per_page []Number] Number of results required per page
12
+ # @return [Array<Sawyer::Resource>] List of event fields
13
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/list-the-event-fields-for-a-project
14
+ def event_fields(project_id, options = {})
15
+ paginate "projects/#{project_id}/event_fields", options
16
+ end
17
+
18
+ # Create a custom Event Field
19
+ #
20
+ # @option reindex [Boolean] Whether to reindex historical events
21
+ # @option pivot_options [Object] Configuration for how this field will appear in pivots
22
+ # @return [Sawyer::Resource] New Event Field
23
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/create-a-custom-event-field
24
+ def create_event_field(project_id, display_id, path, filter_options, options = {})
25
+ post "projects/#{project_id}/event_fields", options.merge({:display_id => display_id, :path => path, :filter_options => filter_options})
26
+ end
27
+
28
+ # Update a custom Event Field
29
+ #
30
+ # @option reindex [Boolean] Whether to reindex historical events
31
+ # @option filter_options [Object] Configuration for how the field will appear in the Filter Bar
32
+ # @option pivot_options [Object] Configuration for how this field will appear in pivots
33
+ # @return [Sawyer::Resource] Updated Event Field
34
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/update-a-custom-event-field
35
+ def update_event_field(project_id, display_id, path, options = {})
36
+ patch "projects/#{id}/event_fields/#{display_id}", options.merge({:display_id => display_id, :path => path})
37
+ end
38
+
39
+ # Delete a custom Event Field
40
+ #
41
+ # @return
42
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/delete-a-custom-event-field
43
+ def delete_event_field(project_id, display_id, options = {})
44
+ boolean_from_resposne :delete, "project/#{project_id}/event_fields/#{display_id}", options
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -4,49 +4,54 @@ 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
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,42 @@
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
@@ -4,83 +4,56 @@ 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
@@ -0,0 +1,41 @@
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
+ defaults = {:query => {:buckets_count => buckets_count}}
16
+ merged_opts = deep_merge(defaults, options)
17
+ if !error_id.nil?
18
+ get "projects/#{project_id}/errors/#{error_id}/trend", merged_opts
19
+ else
20
+ get "projects/#{project_id}/trend", merged_opts
21
+ end
22
+ end
23
+
24
+ # List Trends for an Error in resolution form
25
+ #
26
+ # @option filters [Object] An optional filter object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
27
+ # @return [Array<Sawyer::Resource>] List of Trends as requested
28
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/trends/list-the-trends-for-an-error-(buckets)
29
+ def trends_resolution(project_id, resolution, error_id=nil, options = {})
30
+ defaults = {:query => {:resolution => resolution}}
31
+ merged_opts = deep_merge(defaults, options)
32
+ if !error_id.nil?
33
+ get "projects/#{project_id}/errors/#{error_id}/trend", merged_opts
34
+ else
35
+ get "projects/#{project_id}/trend", merged_opts
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -45,7 +45,7 @@ module Bugsnag
45
45
 
46
46
  # Load configuration from hash
47
47
  def load(options = {})
48
- options.each {|k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=") && !v.nil?}
48
+ options.each { |k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=") && !v.nil?}
49
49
  end
50
50
  end
51
51
  end
@@ -3,7 +3,7 @@ module Bugsnag
3
3
  # Custom error class for rescuing from all Bugsnag API errors
4
4
  class Error < StandardError
5
5
 
6
- # Returns the appropriate Bugnsag::Api::Error subclass based
6
+ # Returns the appropriate Bugsnag::Api::Error subclass based
7
7
  # on status and response message
8
8
  #
9
9
  # @param [Hash] response HTTP response
@@ -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
 
@@ -9,8 +9,6 @@ module Bugsnag
9
9
  # This class raises an Bugsnag-flavored exception based
10
10
  # HTTP status codes returned by the API
11
11
  class RaiseError < Faraday::Response::Middleware
12
-
13
- private
14
12
  def on_complete(response)
15
13
  if error = Bugsnag::Api::Error.from_response(response)
16
14
  raise error
@@ -1,5 +1,5 @@
1
1
  module Bugsnag
2
2
  module Api
3
- VERSION = "1.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ curl https://raw.githubusercontent.com/bugsnag/license-audit/master/config/decision_files/global.yml -o config/global.yml
3
+ bundle install
4
+ license_finder --decisions-file=config/global.yml