forked from neogan74/go-zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusergroup.go
59 lines (46 loc) · 1.29 KB
/
usergroup.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
package zabbix
import (
// "fmt"
)
type Usergroups struct {
UsergroupID string `json:"usrgrpid,omitempty"`
}
type UsergroupResponse struct {
UsergroupIDs []string `json:"usrgrpids"`
}
type UsergroupCreateParams struct {
GetParameters
Name string `json:"name,omitempty"`
Rights []UsergroupRight `json:"rights,omitempty"`
UserID string `json:"userids,omitempty"`
}
type UsergroupRight struct {
Permission int `json:"permission"`
ID string `json:"id,omitempty"`
}
func (c *Session) CreateUsergroup(params UsergroupCreateParams) ([]string, error) {
var body UsergroupResponse
if err := c.Get("usergroup.create", params, &body); err != nil {
return []string{""}, err
}
if len(body.UsergroupIDs) == 0 {
return []string{""}, ErrNotFound
}
return body.UsergroupIDs, nil
}
func (c *Session) DeleteUsergroups(UsergroupIDs ...string) ([]string, error) {
var body UsergroupResponse
if err := c.Get("usergroup.delete", UsergroupIDs, &body); err != nil {
return []string{""}, err
}
if (body.UsergroupIDs == nil) || (len(body.UsergroupIDs) == 0) {
return []string{""}, ErrNotFound
}
return body.UsergroupIDs, nil
}
// HostUpdateParams struct represents the Zabbix basic parameters for
// updating the host by Zabbix API
/*
type UsergroupUpdateParams struct {
}
*/