forked from neogan74/go-zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.go
61 lines (49 loc) · 1.48 KB
/
user.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
60
61
package zabbix
import (
// "fmt"
)
type UserCreateParams struct {
GetParameters
Alias string `json:"alias,omitempty"`
Passwd string `json:"passwd,omitempty"`
// Type int `json:"type,omitempty"`
RoleID int `json:"roleid,omitempty"`
Usergroup []Usergroups `json:"usrgrps,omitempty"`
}
type UserResponse struct {
UserIDs []string `json:"userids"`
}
// CreateUsers creates a single or multiple new Users.
// Returns a list of ids of created Users.
//
// https://www.zabbix.com/documentation/3.4/manual/api/reference/User/create
func (c *Session) CreateUser(params UserCreateParams) ([]string, error) {
var body UserResponse
if err := c.Get("user.create", params, &body); err != nil {
return []string{""}, err
}
if (body.UserIDs == nil) || (len(body.UserIDs) == 0) {
return []string{""}, ErrNotFound
}
return body.UserIDs, nil
}
// DeleteUsers method allows to delete Users.
// Returns a list of deleted Users ids.
//
// https://www.zabbix.com/documentation/3.4/manual/api/reference/User/delete
func (c *Session) DeleteUsers(UserIDs ...string) ([]string, error) {
var body UserResponse
if err := c.Get("user.delete", UserIDs, &body); err != nil {
return []string{""}, err
}
if (body.UserIDs == nil) || (len(body.UserIDs) == 0) {
return []string{""}, ErrNotFound
}
return body.UserIDs, nil
}
// UserUpdateParams struct represents the Zabbix basic parameters for
// updating the User by Zabbix API
/*
type UserUpdateParams struct {
}
*/