forked from atlassian/go-sentry-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrule.go
52 lines (43 loc) · 1.46 KB
/
rule.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
package sentry
import (
"encoding/json"
"fmt"
"time"
)
type Rule struct {
ActionMatch string `json:"actionMatch"`
Actions []Action `json:"actions"`
Conditions []Condition `json:"conditions"`
Name string `json:"name"`
Frequency int `json:"frequency"`
Id string `json:"id,omitempty"`
DateCreated time.Time `json:"dateCreated,omitempty"`
}
type Action struct {
Id string `json:"id"`
Service string `json:"service,omitempty"`
Workspace string `json:"workspace,omitempty"`
Channel string `json:"channel,omitempty"`
}
type Condition struct {
Id string `json:"id"`
Interval string `json:"interval,omitempty"`
Value json.Number `json:"value,omitempty"`
Key string `json:"key,omitempty"`
Match string `json:"match,omitempty"`
}
// GetRules fetchs all rules for a given project
func (c *Client) GetRules(o Organization, p Project) ([]Rule, error) {
var rules []Rule
err := c.do("GET", fmt.Sprintf("projects/%s/%s/rules", *o.Slug, *p.Slug), &rules, nil)
return rules, err
}
func (c *Client) CreateRule(o Organization, p Project, rule Rule) (Rule, error) {
var resRule Rule
err := c.do("POST", fmt.Sprintf("projects/%s/%s/rules", *o.Slug, *p.Slug), &resRule, &rule)
return resRule, err
}
func (c *Client) DeleteRule(o Organization, p Project, ruleId string) error {
err := c.do("DELETE", fmt.Sprintf("projects/%s/%s/rules/%s", *o.Slug, *p.Slug, ruleId), nil, nil)
return err
}