-
Notifications
You must be signed in to change notification settings - Fork 9
/
project_repository_default_reviewers.go
65 lines (46 loc) · 2.09 KB
/
project_repository_default_reviewers.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
63
64
65
package bitclient
import (
"fmt"
)
func (bc *BitClient) GetRepositoryDefaultReviewers(projectKey, repositorySlug string) ([]DefaultReviewers, error) {
rError := new(ErrorResponse)
var response []DefaultReviewers
url := fmt.Sprintf("/rest/default-reviewers/1.0/projects/%s/repos/%s/conditions", projectKey, repositorySlug)
resp, _ := bc.sling.New().Get(url).Receive(&response, rError)
resp, err := bc.checkReponse(resp, rError)
return response, err
}
func (bc *BitClient) CreateRepositoryDefaultReviewers(projectKey, repositorySlug string, params DefaultReviewers) (DefaultReviewers, error) {
rError := new(ErrorResponse)
request := RepositoryDefaultReviewersRequest{
SourceMatcher: params.FromRefMatcher,
TargetMatcher: params.ToRefMatcher,
RequiredApprovals: params.RequiredApprovals,
Reviewers: params.Reviewers,
}
response := DefaultReviewers{}
url := fmt.Sprintf("/rest/default-reviewers/latest/projects/%s/repos/%s/condition", projectKey, repositorySlug)
resp, _ := bc.sling.New().Post(url).BodyJSON(request).Receive(&response, rError)
resp, err := bc.checkReponse(resp, rError)
return response, err
}
type RepositoryDefaultReviewersRequest struct {
SourceMatcher Matcher `json:"sourceMatcher,omitempty"`
TargetMatcher Matcher `json:"targetMatcher,omitempty"`
RequiredApprovals int `json:"requiredApprovals"`
Reviewers []User `json:"reviewers,omitempty"`
}
func (bc *BitClient) UpdateRepositoryDefaultReviewers(projectKey, repositorySlug string, params DefaultReviewers) (DefaultReviewers, error) {
rError := new(ErrorResponse)
request := RepositoryDefaultReviewersRequest{
SourceMatcher: params.FromRefMatcher,
TargetMatcher: params.ToRefMatcher,
RequiredApprovals: params.RequiredApprovals,
Reviewers: params.Reviewers,
}
response := DefaultReviewers{}
url := fmt.Sprintf("/rest/default-reviewers/1.0/projects/%s/repos/%s/condition/%d", projectKey, repositorySlug, params.Id)
resp, _ := bc.sling.New().Put(url).BodyJSON(request).Receive(&response, rError)
resp, err := bc.checkReponse(resp, rError)
return response, err
}