-
Notifications
You must be signed in to change notification settings - Fork 39
/
plugin.go
35 lines (26 loc) · 1.04 KB
/
plugin.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
package sentry
import (
"fmt"
"net/http"
)
func (c *Client) touchPlugin(o Organization, p Project, pluginID string, enabled bool) error {
method := http.MethodDelete
if enabled {
method = http.MethodPost
}
return c.do(method, fmt.Sprintf("projects/%s/%s/plugins/%s/", *o.Slug, *p.Slug, pluginID), nil, nil)
}
func (c *Client) EnablePlugin(o Organization, p Project, pluginID string) error {
return c.touchPlugin(o, p, pluginID, true)
}
func (c *Client) DisablePlugin(o Organization, p Project, pluginID string) error {
return c.touchPlugin(o, p, pluginID, false)
}
func (c *Client) GetPlugin(o Organization, p Project, pluginID string) (plugin Plugin, err error) {
err = c.do(http.MethodGet, fmt.Sprintf("projects/%s/%s/plugins/%s/", *o.Slug, *p.Slug, pluginID), &plugin, nil)
return
}
func (c *Client) SetPluginConfig(o Organization, p Project, pluginID string, config map[string]interface{}) (plugin Plugin, err error) {
err = c.do(http.MethodPut, fmt.Sprintf("projects/%s/%s/plugins/%s/", *o.Slug, *p.Slug, pluginID), &plugin, config)
return
}