Skip to content

Commit ffee02e

Browse files
committed
finish all team apis
1 parent 9a1797a commit ffee02e

File tree

6 files changed

+143
-4
lines changed

6 files changed

+143
-4
lines changed

lib/sentry-api/client/organizations.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,33 @@ def organization_stats(organization_slug, options={})
7171
get("/organizations/#{organization_slug}/stats/", query: options)
7272
end
7373

74+
# Create a new team bound to an organization
75+
#
76+
# @example
77+
# SentryApi.create_project('team-slug', {name:'team-name', slug:'team-slug'})
78+
#
79+
# @param organization_slug [String] the slug of the organization the team should be created for
80+
# @param [Hash] options A customizable set of options.
81+
# @option options [String] :name the name for the new team.
82+
# @option options [String] :slug optionally a slug for the new team. If it’s not provided a slug is generated from the name.
83+
# @return [SentryApi::ObjectifiedHash]
84+
def create_team(options={}, organization_slug="")
85+
organization_slug = @default_org_slug if organization_slug == ""
86+
post("/organizations/#{organization_slug}/teams/", body: options)
87+
end
88+
89+
# Return a list of teams bound to a organization.
90+
#
91+
# @example
92+
# SentryApi.organization_teams('team-slug')
93+
#
94+
# @param organization_slug [String] the slug of the organization
95+
# @return [Array<SentryApi::ObjectifiedHash>]
96+
def organization_teams(organization_slug="")
97+
organization_slug = @default_org_slug if organization_slug == ""
98+
get("/organizations/#{organization_slug}/teams/")
99+
end
100+
74101
end
75102

76103
end

lib/sentry-api/client/teams.rb

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module Teams
55
# Create a new project bound to a team.
66
#
77
# @example
8-
# SentryApi.create_project('team-slug',{name:'new-name'})
8+
# SentryApi.create_project('team-slug', {name:'team-name'})
99
#
10-
# @param team_slug [String] the slug of the team to create a new project for.
11-
# @param organization_slug [String] the slug of the organization the team belongs to.
10+
# @param team_slug [String] the slug of the team
11+
# @param organization_slug [String] the slug of the organization
1212
# @param [Hash] options A customizable set of options.
1313
# @option options [String] :name the name for the new project.
1414
# @option options [String] :slug optionally a slug for the new project. If it’s not provided a slug is generated from the name.
@@ -18,7 +18,59 @@ def create_project(team_slug, options={}, organization_slug="")
1818
post("/teams/#{organization_slug}/#{team_slug}/projects/", body: options)
1919
end
2020

21+
# Schedules a team for deletion
22+
#
23+
# @example
24+
# SentryApi.delete_team('team-slug')
25+
#
26+
# @param team_slug [String] the slug of the team
27+
# @param organization_slug [String] the slug of the organization
28+
def delete_team(team_slug, organization_slug="")
29+
organization_slug = @default_org_slug if organization_slug == ""
30+
delete("/teams/#{organization_slug}/#{team_slug}/")
31+
end
2132

22-
end
33+
# Return a list of projects bound to a team
34+
#
35+
# @example
36+
# SentryApi.delete_team('team-slug')
37+
#
38+
# @param team_slug [String] the slug of the team
39+
# @param organization_slug [String] the slug of the organization
40+
# @return [Array<SentryApi::ObjectifiedHash>]
41+
def team_projects(team_slug, organization_slug="")
42+
organization_slug = @default_org_slug if organization_slug == ""
43+
get("/teams/#{organization_slug}/#{team_slug}/projects/")
44+
end
2345

46+
# Return details on an individual team.
47+
#
48+
# @example
49+
# SentryApi.team_projects('team-slug')
50+
#
51+
# @param team_slug [String] the slug of the team
52+
# @param organization_slug [String] the slug of the organization
53+
# @return [SentryApi::ObjectifiedHash]
54+
def team(team_slug, organization_slug="")
55+
organization_slug = @default_org_slug if organization_slug == ""
56+
get("/teams/#{organization_slug}/#{team_slug}/")
57+
end
58+
59+
# Update various attributes and configurable settings for the given team.
60+
#
61+
# @example
62+
# SentryApi.update_team('team-slug', {name:'team-name'})
63+
#
64+
# @param team_slug [String] the slug of the team
65+
# @param organization_slug [String] the slug of the organization
66+
# @param [Hash] options A customizable set of options.
67+
# @option options [String] :name the name for the new project.
68+
# @option options [String] :slug optionally a slug for the new project. If it’s not provided a slug is generated from the name.
69+
# @return [SentryApi::ObjectifiedHash]
70+
def update_team(team_slug, options={}, organization_slug="")
71+
organization_slug = @default_org_slug if organization_slug == ""
72+
get("/teams/#{organization_slug}/#{team_slug}/", body: options)
73+
end
74+
75+
end
2476
end

spec/fixtures/create_team.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"slug": "ancient-gabelers",
3+
"name": "Ancient Gabelers",
4+
"hasAccess": true,
5+
"isPending": false,
6+
"dateCreated": "2016-08-30T21:23:02.065Z",
7+
"isMember": false,
8+
"id": "3"
9+
}

spec/fixtures/team.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"slug": "powerful-abolitionist",
3+
"name": "Powerful Abolitionist",
4+
"hasAccess": true,
5+
"isPending": false,
6+
"dateCreated": "2016-08-30T21:22:52.612Z",
7+
"isMember": false,
8+
"organization": {
9+
"name": "The Interstellar Jurisdiction",
10+
"slug": "the-interstellar-jurisdiction",
11+
"id": "2",
12+
"isEarlyAdopter": false,
13+
"dateCreated": "2016-08-30T21:22:52.601Z"
14+
},
15+
"id": "2"
16+
}

spec/sentry-api/client/organizations_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,19 @@
8484
end
8585
end
8686

87+
describe ".create_team" do
88+
before do
89+
stub_post("/organizations/org-slug/teams/", "create_team").with(body: {name: "name"})
90+
@team = SentryApi.create_team({name: "name"}, "org-slug")
91+
end
92+
93+
it "should get the correct resource" do
94+
expect(a_post("/organizations/org-slug/teams/").with(body: {name: "name"})).to have_been_made
95+
end
96+
97+
it "should return array about an organization's event counts" do
98+
expect(@team.slug).to eq("ancient-gabelers")
99+
end
100+
end
101+
87102
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 ".team" do
6+
before do
7+
stub_get("/teams/org-slug/team-slug/", "team")
8+
@team = SentryApi.team("team-slug", "org-slug")
9+
end
10+
11+
it "should get the correct resource" do
12+
expect(a_get("/teams/org-slug/team-slug/")).to have_been_made
13+
end
14+
15+
it "should return an response of team" do
16+
expect(@team.slug).to eq("powerful-abolitionist")
17+
end
18+
end
19+
20+
end

0 commit comments

Comments
 (0)