-
Notifications
You must be signed in to change notification settings - Fork 1
/
apikey.go
76 lines (63 loc) · 2.05 KB
/
apikey.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package go_ts3
// apikeyadd `manage_scope`
type ApiKeyScope string
//noinspection GoUnusedConst
const (
ApiKeyScopeManage ApiKeyScope = "manage"
ApiKeyScopeWrite ApiKeyScope = "write"
ApiKeyScopeRead ApiKeyScope = "read"
)
type ApiKeyAddRequest struct {
Scope ApiKeyScope `schema:"scope,required"`
Lifetime int `schema:"lifetime,omitempty"`
ClientDbId int `schema:"cldbid,omitempty"`
}
type ApiKeyAddResponse struct {
Apikey string `json:"apikey"`
ClientDbId int `json:"cldbid,string"`
CreatedAt int `json:"created_at,string"`
ExpiresAt int `json:"expires_at,string"`
Id int `json:"id,string"`
Scope string `json:"scope"`
ServerId int `json:"sid,string"`
TimeLeft int `json:"time_left,string"`
}
func (c *TeamspeakHttpClient) ApiKeyAdd(request ApiKeyAddRequest) (*ApiKeyAddResponse, error) {
var apiKeys []ApiKeyAddResponse
err := c.requestWithParams("apikeyadd", request, &apiKeys)
if err != nil {
return nil, err
}
return &apiKeys[0], nil
}
// apikeydel `manage_scope`
type apiKeyDeleteRequest struct {
Id int `schema:"id,required"`
}
func (c *TeamspeakHttpClient) ApiKeyDelete(id int) error {
return c.requestWithParams("apikeydel", apiKeyDeleteRequest{Id: id}, nil)
}
// apikeylist `manage_scope`
type ApiKeyListResponse struct {
ClientDbId int `json:"cldbid,string"`
CreatedAt int `json:"created_at,string"`
ExpiresAt int `json:"expires_at,string"`
ID int `json:"id,string"`
Scope string `json:"scope"`
ServerId int `json:"sid,string"`
TimeLeft string `json:"time_left"`
}
type ApiKeyListRequest struct {
ClientDbId string `schema:"cldbid,omitempty"`
Start int `schema:"start,omitempty"`
Duration int `schema:"duration,omitempty"`
Count bool `schema:"count,omitempty"`
}
func (c *TeamspeakHttpClient) ApiKeyList(request ApiKeyListRequest) (*[]ApiKeyListResponse, error) {
var apiKeys []ApiKeyListResponse
err := c.requestWithParams("apikeylist", request, &apiKeys)
if err != nil {
return nil, err
}
return &apiKeys, nil
}