-
Notifications
You must be signed in to change notification settings - Fork 73
/
modules.go
70 lines (54 loc) · 1.48 KB
/
modules.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
package ari
// Modules is the communication path for interacting with the
// asterisk modules resource
type Modules interface {
Get(key *Key) *ModuleHandle
List(filter *Key) ([]*Key, error)
Load(key *Key) error
Reload(key *Key) error
Unload(key *Key) error
Data(key *Key) (*ModuleData, error)
}
// ModuleData is the data for an asterisk module
type ModuleData struct {
// Key is the cluster-unique identifier for this module
Key *Key `json:"key"`
Name string `json:"name"`
Description string `json:"description"`
SupportLevel string `json:"support_level"`
UseCount int `json:"use_count"`
Status string `json:"status"`
}
// ModuleHandle is the reference to an asterisk module
type ModuleHandle struct {
key *Key
m Modules
}
// NewModuleHandle returns a new module handle
func NewModuleHandle(key *Key, m Modules) *ModuleHandle {
return &ModuleHandle{key, m}
}
// ID returns the identifier for the module
func (mh *ModuleHandle) ID() string {
return mh.key.ID
}
// Key returns the key for the module
func (mh *ModuleHandle) Key() *Key {
return mh.key
}
// Reload reloads the module
func (mh *ModuleHandle) Reload() error {
return mh.m.Reload(mh.key)
}
// Unload unloads the module
func (mh *ModuleHandle) Unload() error {
return mh.m.Unload(mh.key)
}
// Load loads the module
func (mh *ModuleHandle) Load() error {
return mh.m.Load(mh.key)
}
// Data gets the module data
func (mh *ModuleHandle) Data() (*ModuleData, error) {
return mh.m.Data(mh.key)
}