diff --git a/sentry/organization_projects.go b/sentry/organization_projects.go new file mode 100644 index 0000000..abaa48c --- /dev/null +++ b/sentry/organization_projects.go @@ -0,0 +1,37 @@ +package sentry + +import ( + "context" + "fmt" +) + +type OrganizationProjectsService service + +type ListOrganizationProjectsParams struct { + ListCursorParams + + Options string `url:"options,omitempty"` + Query string `url:"query,omitempty"` +} + +// List an Organization's Projects +// https://docs.sentry.io/api/organizations/list-an-organizations-projects/ +func (s *OrganizationProjectsService) List(ctx context.Context, organizationSlug string, params *ListOrganizationProjectsParams) ([]*Project, *Response, error) { + u := fmt.Sprintf("0/organizations/%v/projects/", organizationSlug) + u, err := addQuery(u, params) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + projects := []*Project{} + resp, err := s.client.Do(ctx, req, &projects) + if err != nil { + return nil, resp, err + } + return projects, resp, nil +} diff --git a/sentry/projects.go b/sentry/projects.go index 1fa7c58..4b3c7dd 100644 --- a/sentry/projects.go +++ b/sentry/projects.go @@ -94,9 +94,6 @@ type ProjectsService service type ListProjectsParams struct { ListCursorParams - - Options string `url:"options,omitempty"` - Query string `url:"query,omitempty"` } // List projects available. diff --git a/sentry/sentry.go b/sentry/sentry.go index 6ac56ab..a023bb0 100644 --- a/sentry/sentry.go +++ b/sentry/sentry.go @@ -54,6 +54,7 @@ type Client struct { OrganizationCodeMappings *OrganizationCodeMappingsService OrganizationIntegrations *OrganizationIntegrationsService OrganizationMembers *OrganizationMembersService + OrganizationProjects *OrganizationProjectsService OrganizationRepositories *OrganizationRepositoriesService Organizations *OrganizationsService ProjectFilters *ProjectFiltersService @@ -95,6 +96,7 @@ func NewClient(httpClient *http.Client) *Client { c.OrganizationCodeMappings = (*OrganizationCodeMappingsService)(&c.common) c.OrganizationIntegrations = (*OrganizationIntegrationsService)(&c.common) c.OrganizationMembers = (*OrganizationMembersService)(&c.common) + c.OrganizationProjects = (*OrganizationProjectsService)(&c.common) c.OrganizationRepositories = (*OrganizationRepositoriesService)(&c.common) c.Organizations = (*OrganizationsService)(&c.common) c.ProjectFilters = (*ProjectFiltersService)(&c.common)