Skip to content

Commit b33f9fa

Browse files
committed
feat: new OrganizationProjectsService
1 parent bbb059f commit b33f9fa

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

sentry/organization_projects.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package sentry
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
type OrganizationProjectsService service
9+
10+
type ListOrganizationProjectsParams struct {
11+
ListCursorParams
12+
13+
Options string `url:"options,omitempty"`
14+
Query string `url:"query,omitempty"`
15+
}
16+
17+
// List an Organization's Projects
18+
// https://docs.sentry.io/api/organizations/list-an-organizations-projects/
19+
func (s *OrganizationProjectsService) List(ctx context.Context, organizationSlug string, params *ListOrganizationProjectsParams) ([]*Project, *Response, error) {
20+
u := fmt.Sprintf("0/organizations/%v/projects/", organizationSlug)
21+
u, err := addQuery(u, params)
22+
if err != nil {
23+
return nil, nil, err
24+
}
25+
26+
req, err := s.client.NewRequest("GET", u, nil)
27+
if err != nil {
28+
return nil, nil, err
29+
}
30+
31+
projects := []*Project{}
32+
resp, err := s.client.Do(ctx, req, &projects)
33+
if err != nil {
34+
return nil, resp, err
35+
}
36+
return projects, resp, nil
37+
}

sentry/projects.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ type ProjectsService service
9494

9595
type ListProjectsParams struct {
9696
ListCursorParams
97-
98-
Options string `url:"options,omitempty"`
99-
Query string `url:"query,omitempty"`
10097
}
10198

10299
// List projects available.

sentry/sentry.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type Client struct {
5454
OrganizationCodeMappings *OrganizationCodeMappingsService
5555
OrganizationIntegrations *OrganizationIntegrationsService
5656
OrganizationMembers *OrganizationMembersService
57+
OrganizationProjects *OrganizationProjectsService
5758
OrganizationRepositories *OrganizationRepositoriesService
5859
Organizations *OrganizationsService
5960
ProjectFilters *ProjectFiltersService
@@ -95,6 +96,7 @@ func NewClient(httpClient *http.Client) *Client {
9596
c.OrganizationCodeMappings = (*OrganizationCodeMappingsService)(&c.common)
9697
c.OrganizationIntegrations = (*OrganizationIntegrationsService)(&c.common)
9798
c.OrganizationMembers = (*OrganizationMembersService)(&c.common)
99+
c.OrganizationProjects = (*OrganizationProjectsService)(&c.common)
98100
c.OrganizationRepositories = (*OrganizationRepositoriesService)(&c.common)
99101
c.Organizations = (*OrganizationsService)(&c.common)
100102
c.ProjectFilters = (*ProjectFiltersService)(&c.common)

0 commit comments

Comments
 (0)