github.com/CyCoreSystems/ari@v4.8.4+incompatible/modules.go (about) 1 package ari 2 3 // Modules is the communication path for interacting with the 4 // asterisk modules resource 5 type Modules interface { 6 Get(key *Key) *ModuleHandle 7 8 List(filter *Key) ([]*Key, error) 9 10 Load(key *Key) error 11 12 Reload(key *Key) error 13 14 Unload(key *Key) error 15 16 Data(key *Key) (*ModuleData, error) 17 } 18 19 // ModuleData is the data for an asterisk module 20 type ModuleData struct { 21 // Key is the cluster-unique identifier for this module 22 Key *Key `json:"key"` 23 24 Name string `json:"name"` 25 Description string `json:"description"` 26 SupportLevel string `json:"support_level"` 27 UseCount int `json:"use_count"` 28 Status string `json:"status"` 29 } 30 31 // ModuleHandle is the reference to an asterisk module 32 type ModuleHandle struct { 33 key *Key 34 m Modules 35 } 36 37 // NewModuleHandle returns a new module handle 38 func NewModuleHandle(key *Key, m Modules) *ModuleHandle { 39 return &ModuleHandle{key, m} 40 } 41 42 // ID returns the identifier for the module 43 func (mh *ModuleHandle) ID() string { 44 return mh.key.ID 45 } 46 47 // Key returns the key for the module 48 func (mh *ModuleHandle) Key() *Key { 49 return mh.key 50 } 51 52 // Reload reloads the module 53 func (mh *ModuleHandle) Reload() error { 54 return mh.m.Reload(mh.key) 55 } 56 57 // Unload unloads the module 58 func (mh *ModuleHandle) Unload() error { 59 return mh.m.Unload(mh.key) 60 } 61 62 // Load loads the module 63 func (mh *ModuleHandle) Load() error { 64 return mh.m.Load(mh.key) 65 } 66 67 // Data gets the module data 68 func (mh *ModuleHandle) Data() (*ModuleData, error) { 69 return mh.m.Data(mh.key) 70 }