Skip to content

Commit f7f3b31

Browse files
committed
Move to go mod and add some support for list endpoints
1 parent 26d8b8c commit f7f3b31

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/atlassian/go-sentry-api
2+
3+
go 1.13
4+
5+
require (
6+
github.com/certifi/gocertifi v0.0.0-20200104152315-a6d78f326758 // indirect
7+
github.com/getsentry/raven-go v0.2.0
8+
github.com/pkg/errors v0.9.1 // indirect
9+
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github.com/certifi/gocertifi v0.0.0-20200104152315-a6d78f326758 h1:epkmRmrjzR0Km6DrVMk/ZQwDdMY2w31I3kQT91DbxS0=
2+
github.com/certifi/gocertifi v0.0.0-20200104152315-a6d78f326758/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
3+
github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs=
4+
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
5+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
6+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

project.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,17 @@ func (c *Client) UpdateProject(o Organization, p Project) error {
7272
}
7373

7474
// GetProjects fetchs all projects in a sentry instance
75-
func (c *Client) GetProjects() ([]Project, error) {
75+
func (c *Client) GetProjects() ([]Project, *Link, error) {
7676
var proj []Project
77-
err := c.do("GET", "projects", &proj, nil)
78-
return proj, err
77+
link, err := c.doWithPagination("GET", "projects", &proj, nil)
78+
return proj, link, err
79+
}
80+
81+
// GetOrgProjects fetchs all projects belonging to a organization
82+
func (c *Client) GetOrgProjects(o Organization) ([]Project, *Link, error) {
83+
var proj []Project
84+
link, err := c.doWithPagination("GET", fmt.Sprintf("organizations/%s/projects/", *o.Slug), &proj, nil)
85+
return proj, link, err
7986
}
8087

8188
// DeleteProject will take your org, team, and proj and delete it from sentry.

project_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestProjectResource(t *testing.T) {
4646
})
4747

4848
t.Run("Fetch all projects", func(t *testing.T) {
49-
projects, err := client.GetProjects()
49+
projects, _, err := client.GetProjects()
5050
if err != nil {
5151
t.Error(err)
5252
}

team.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ func (c *Client) CreateTeam(o Organization, name string, slug *string) (Team, er
3030
return team, err
3131
}
3232

33+
// GetTeams will take a organization and retrieve a list of teams
34+
func (c *Client) GetTeams(o Organization) ([]Team, *Link, error) {
35+
teams := make([]Team, 0)
36+
link, err := c.doWithPagination(http.MethodGet, fmt.Sprintf("organizations/%s/teams", *o.Slug), &teams, nil)
37+
return teams, link, err
38+
}
39+
3340
// GetTeam takes a team slug and returns back the team
3441
func (c *Client) GetTeam(o Organization, teamSlug string) (Team, error) {
3542
var team Team

0 commit comments

Comments
 (0)