-
Notifications
You must be signed in to change notification settings - Fork 1
/
user.go
49 lines (40 loc) · 1.38 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
package wserest
import (
"github.com/openfresh/wse-rest-library-go/entity/application/helper"
"github.com/openfresh/wse-rest-library-go/entity/base"
)
// User is Server Users utiliyt
type User struct {
wowza
}
// NewUser create User object
func NewUser(settings *helper.Settings, userName string) *User {
u := new(User)
u.init(settings)
u.props["userName"] = userName
u.props["password"] = ""
u.props["groups"] = []string{}
u.baseURI = u.host() + "/servers/" + u.serverInstance() + "/users"
return u
}
// Create adds a new server User to the list
func (u *User) Create(password string, group []string) (map[string]interface{}, error) {
u.props["password"] = password
u.props["group"] = group
u.setRestURI(u.baseURI)
response, err := u.sendRequest(u.preparePropertiesForRequest(), []base.Entity{}, POST, "")
return response, err
}
// GetAll retrieves the list of server Users
func (u *User) GetAll() (map[string]interface{}, error) {
u.AddSkipParameter("userName")
u.AddSkipParameter("password")
u.AddSkipParameter("group")
u.setRestURI(u.baseURI)
return u.sendRequest(u.preparePropertiesForRequest(), []base.Entity{}, GET, "")
}
// Remove deletes the specified User configuration
func (u *User) Remove() (map[string]interface{}, error) {
u.setRestURI(u.baseURI + "/" + u.props["userName"].(string))
return u.sendRequest(u.preparePropertiesForRequest(), []base.Entity{}, DELETE, "")
}