@@ -14,12 +14,19 @@ type DSN struct {
14
14
15
15
// Key is a DSN that sentry has made
16
16
type Key struct {
17
- Label string `json:"label,omitempty"`
18
- DSN DSN `json:"dsn,omitempty"`
19
- Secret string `json:"secret,omitempty"`
20
- ID string `json:"id,omitempty"`
21
- DateCreated time.Time `json:"dateCreated,omitempty"`
22
- Public string `json:"public,omitempty"`
17
+ Label string `json:"label,omitempty"`
18
+ DSN DSN `json:"dsn,omitempty"`
19
+ Secret string `json:"secret,omitempty"`
20
+ ID string `json:"id,omitempty"`
21
+ DateCreated time.Time `json:"dateCreated,omitempty"`
22
+ Public string `json:"public,omitempty"`
23
+ RateLimit * KeyRateLimit `json:"rateLimit,omitempty"`
24
+ }
25
+
26
+ // KeyRateLimit is the rate limit for a DSN
27
+ type KeyRateLimit struct {
28
+ Count int `json:"count"`
29
+ Window int `json:"window"`
23
30
}
24
31
25
32
type nameReq struct {
@@ -57,3 +64,11 @@ func (c *Client) GetClientKeys(o Organization, p Project) ([]Key, error) {
57
64
err := c .do ("GET" , fmt .Sprintf ("projects/%s/%s/keys" , * o .Slug , * p .Slug ), & keys , nil )
58
65
return keys , err
59
66
}
67
+
68
+ // SetClientKeyRateLimit updates the rate limit only of a key. window is in seconds.
69
+ func (c * Client ) SetClientKeyRateLimit (o Organization , p Project , k Key , count , window int ) (Key , error ) {
70
+ var key Key
71
+ req := & Key {RateLimit : & KeyRateLimit {Count : count , Window : window }}
72
+ err := c .do ("PUT" , fmt .Sprintf ("project/%s/%s/keys/%s" , * o .Slug , * p .Slug , k .ID ), & key , & req )
73
+ return key , err
74
+ }
0 commit comments