Skip to content

Commit

Permalink
feat: new OrganizationProjectsService
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyuan committed May 5, 2024
1 parent bbb059f commit b33f9fa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
37 changes: 37 additions & 0 deletions sentry/organization_projects.go
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 0 additions & 3 deletions sentry/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ type ProjectsService service

type ListProjectsParams struct {
ListCursorParams

Options string `url:"options,omitempty"`
Query string `url:"query,omitempty"`
}

// List projects available.
Expand Down
2 changes: 2 additions & 0 deletions sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Client struct {
OrganizationCodeMappings *OrganizationCodeMappingsService
OrganizationIntegrations *OrganizationIntegrationsService
OrganizationMembers *OrganizationMembersService
OrganizationProjects *OrganizationProjectsService
OrganizationRepositories *OrganizationRepositoriesService
Organizations *OrganizationsService
ProjectFilters *ProjectFiltersService
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b33f9fa

Please sign in to comment.