/
project_ownerships.go
62 lines (54 loc) · 2.08 KB
/
project_ownerships.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package sentry
import (
"context"
"fmt"
"time"
)
// https://github.com/getsentry/sentry/blob/master/src/sentry/api/serializers/models/projectownership.py
type ProjectOwnership struct {
Raw string `json:"raw"`
FallThrough bool `json:"fallthrough"`
DateCreated time.Time `json:"dateCreated"`
LastUpdated time.Time `json:"lastUpdated"`
IsActive bool `json:"isActive"`
AutoAssignment string `json:"autoAssignment"`
CodeownersAutoSync *bool `json:"codeownersAutoSync,omitempty"`
}
// ProjectOwnershipsService provides methods for accessing Sentry project
// ownership API endpoints.
type ProjectOwnershipsService service
// Get details on a project's ownership configuration.
func (s *ProjectOwnershipsService) Get(ctx context.Context, organizationSlug string, projectSlug string) (*ProjectOwnership, *Response, error) {
u := fmt.Sprintf("0/projects/%v/%v/ownership/", organizationSlug, projectSlug)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
owner := new(ProjectOwnership)
resp, err := s.client.Do(ctx, req, owner)
if err != nil {
return nil, resp, err
}
return owner, resp, nil
}
// CreateProjectParams are the parameters for ProjectOwnershipService.Update.
type UpdateProjectOwnershipParams struct {
Raw string `json:"raw,omitempty"`
FallThrough *bool `json:"fallthrough,omitempty"`
AutoAssignment *string `json:"autoAssignment,omitempty"`
CodeownersAutoSync *bool `json:"codeownersAutoSync,omitempty"`
}
// Update a Project's Ownership configuration
func (s *ProjectOwnershipsService) Update(ctx context.Context, organizationSlug string, projectSlug string, params *UpdateProjectOwnershipParams) (*ProjectOwnership, *Response, error) {
u := fmt.Sprintf("0/projects/%v/%v/ownership/", organizationSlug, projectSlug)
req, err := s.client.NewRequest("PUT", u, params)
if err != nil {
return nil, nil, err
}
owner := new(ProjectOwnership)
resp, err := s.client.Do(ctx, req, owner)
if err != nil {
return nil, resp, err
}
return owner, resp, nil
}