forked from galaxydi/go-loghub
-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathclient_project_policy.go
51 lines (47 loc) · 1.06 KB
/
client_project_policy.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
package sls
import (
"fmt"
"io/ioutil"
)
func (c *Client) GetProjectPolicy(project string) (policy string, err error) {
h := map[string]string{
"x-log-bodyrawsize": "0",
"Content-Type": "application/json",
}
uri := "/policy"
r, err := c.request(project, "GET", uri, h, nil)
if err != nil {
return "", err
}
defer r.Body.Close()
buf, _ := ioutil.ReadAll(r.Body)
policy = string(buf)
return policy, nil
}
func (c *Client) UpdateProjectPolicy(project string, policy string) error {
body := []byte(policy)
h := map[string]string{
"x-log-bodyrawsize": fmt.Sprintf("%v", len(body)),
"Content-Type": "application/json",
}
uri := "/policy"
r, err := c.request(project, "POST", uri, h, body)
if err != nil {
return err
}
r.Body.Close()
return nil
}
func (c *Client) DeleteProjectPolicy(project string) error {
h := map[string]string{
"x-log-bodyrawsize": "0",
"Content-Type": "application/json",
}
uri := "/policy"
r, err := c.request(project, "DELETE", uri, h, nil)
if err != nil {
return err
}
r.Body.Close()
return nil
}