Skip to content

Commit 7b6319d

Browse files
authored
Merge pull request #2 from farazcsk/feature/batch-update-issues
Add issues to client
2 parents 6b75a83 + 73ae343 commit 7b6319d

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

lib/sentry-api/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Client < API
55

66
include Organizations
77
include Projects
8+
include Issues
89
include Events
910
include Teams
1011
include Releases

lib/sentry-api/client/issues.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class SentryApi::Client
2+
module Issues
3+
# List Issues
4+
#
5+
# @example
6+
# SentryApi.project_issues('project-slug', {'query': 'is:unresolved Build-version:6.5.0'})
7+
#
8+
# @param project_slug [String] the slug of the project the client keys belong to.
9+
# @param [Hash] options A customizable set of options. @option options [String] :statsPeriod an optional stat period (can be one of "24h", "14d", and "").
10+
# @option options [String] :query an optional Sentry structured search query. If not provided an implied "is:resolved" is assumed.)
11+
# @return [Array<SentryApi::ObjectifiedHash>]
12+
def issues(project_slug, options={})
13+
get("/projects/#{@default_org_slug}/#{project_slug}/issues/", query: options)
14+
end
15+
16+
# Batch update issues
17+
#
18+
# @example
19+
# SentryApi.update_client_key('project-slug', ['123', '456'], status:'ignored')
20+
#
21+
# @param project_slug [String] the slug of the project the client keys belong to.
22+
# @param issue_ids [Array] An array of issue ids which are to be updated.
23+
# @option options [Object] An object containing the issue fields which are to be updated.
24+
# @return [Array<SentryApi::ObjectifiedHash>]
25+
def batch_update_issues(project_slug, issue_ids=[], options={})
26+
put("/projects/#{@default_org_slug}/#{project_slug}/issues/?id=#{issue_ids.join('&id=')}", body: options)
27+
end
28+
end
29+
30+
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'spec_helper'
2+
3+
describe SentryApi::Client do
4+
5+
describe ".issues" do
6+
before do
7+
stub_get("/projects/sentry-sc/project-slug/issues/", "project_issues")
8+
@issues = SentryApi.issues("project-slug")
9+
end
10+
11+
it "should get the correct resource" do
12+
expect(a_get("/projects/sentry-sc/project-slug/issues/")).to have_been_made
13+
end
14+
15+
it "should return a array of issues" do
16+
expect(@issues.first.culprit).to eq("org.hsqldb.jdbc.Util in throwError")
17+
end
18+
end
19+
20+
end

0 commit comments

Comments
 (0)