-
Notifications
You must be signed in to change notification settings - Fork 9
/
hooks.go
63 lines (48 loc) · 1.41 KB
/
hooks.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
package bitclient
import (
"fmt"
)
const yaccHookKey = "com.isroot.stash.plugin.yacc:yaccHook"
type GetHooksRequest struct {
PagedRequest
Type string
}
type GetHooksResponse struct {
PagedResponse
Values []Hook
}
func (bc *BitClient) GetHooks(projectKey, repositorySlug string, params GetHooksRequest) (GetHooksResponse, error) {
response := GetHooksResponse{}
_, err := bc.DoGet(
fmt.Sprintf("/projects/%s/repos/%s/settings/hooks", projectKey, repositorySlug),
params,
&response,
)
return response, err
}
func (bc *BitClient) EnableHook(projectKey, repositorySlug, hookKey string, hookSettings interface{}) error {
_, err := bc.DoPut(
fmt.Sprintf("/projects/%s/repos/%s/settings/hooks/%s/enabled", projectKey, repositorySlug, hookKey),
hookSettings,
nil,
)
return err
}
func (bc *BitClient) DisableHook(projectKey, repositorySlug, hookKey string) error {
_, err := bc.DoDeleteUrl(
fmt.Sprintf("/projects/%s/repos/%s/settings/hooks/%s/enabled", projectKey, repositorySlug, hookKey),
nil,
nil,
)
return err
}
// GetYACCHookSettings return the YACC hook settings from bitbucket
func (bc *BitClient) GetYACCHookSettings(projectKey string , repositorySlug string) (YaccHookSettings, error) {
response := YaccHookSettings{}
_, err := bc.DoGet(
fmt.Sprintf("/projects/%s/repos/%s/settings/hooks/%s/settings", projectKey, repositorySlug, yaccHookKey),
nil,
&response,
)
return response, err
}