forked from mborodin/go-xen-api-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent_gen.go
303 lines (282 loc) · 10.4 KB
/
event_gen.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
//
// This file is generated. To change the content of this file, please do not
// apply the change to this file because it will get overwritten. Instead,
// change xenapi.go and execute 'go generate'.
//
package xenAPI
import (
"fmt"
"github.com/janeprather/go-xmlrpc-client"
"reflect"
"strconv"
"time"
)
var _ = fmt.Errorf
var _ = xmlrpc.NewClient
var _ = reflect.TypeOf
var _ = strconv.Atoi
var _ = time.UTC
type EventOperation string
const (
// An object has been created
EventOperationAdd EventOperation = "add"
// An object has been deleted
EventOperationDel EventOperation = "del"
// An object has been modified
EventOperationMod EventOperation = "mod"
)
type EventRecord struct {
// An ID, monotonically increasing, and local to the current session
ID int
// The time at which the event occurred
Timestamp string
// The name of the class of the object that changed
Class string
// The operation that was performed
Operation EventOperation
// A reference to the object that changed
Ref string
// The uuid of the object that changed
ObjUUID string
}
type EventRef string
// Asynchronous event registration and handling
type EventClass struct {
client *Client
}
// Asynchronous event registration and handling
type AsyncEventClass struct {
client *Client
}
// Injects an artificial event on the given object and return the corresponding ID
func (_class EventClass) Inject(sessionID SessionRef, class string, ref string) (_retval string, _err error) {
_method := "event.inject"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "class"), class)
if _err != nil {
return
}
_refArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "ref"), ref)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg, _classArg, _refArg)
if _err != nil {
return
}
_retval, _err = convertStringToGo(_method + " -> ", _result.Value)
return
}
// Return the ID of the next event to be generated by the system
func (_class EventClass) GetCurrentID(sessionID SessionRef) (_retval int, _err error) {
_method := "event.get_current_id"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err != nil {
return
}
_retval, _err = convertIntToGo(_method + " -> ", _result.Value)
return
}
// Blocking call which returns a new token and a (possibly empty) batch of events. The returned token can be used in subsequent calls to this function.
//
// Errors:
// SESSION_NOT_REGISTERED - This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed.
// EVENTS_LOST - Some events have been lost from the queue and cannot be retrieved.
func (_class EventClass) From(sessionID SessionRef, classes []string, token string, timeout float64) (_retval []EventRecord, _err error) {
_method := "event.from"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classesArg, _err := convertStringSetToXen(fmt.Sprintf("%s(%s)", _method, "classes"), classes)
if _err != nil {
return
}
_tokenArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "token"), token)
if _err != nil {
return
}
_timeoutArg, _err := convertFloatToXen(fmt.Sprintf("%s(%s)", _method, "timeout"), timeout)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg, _classesArg, _tokenArg, _timeoutArg)
if _err != nil {
return
}
_retval, _err = convertEventRecordSetToGo(_method + " -> ", _result.Value)
return
}
// Blocking call which returns a (possibly empty) batch of events. This method is only recommended for legacy use. New development should use event.from which supercedes this method.
//
// Errors:
// SESSION_NOT_REGISTERED - This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed.
// EVENTS_LOST - Some events have been lost from the queue and cannot be retrieved.
func (_class EventClass) Next(sessionID SessionRef) (_retval []EventRecord, _err error) {
_method := "event.next"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err != nil {
return
}
_retval, _err = convertEventRecordSetToGo(_method + " -> ", _result.Value)
return
}
// Unregisters this session with the event system
func (_class EventClass) Unregister(sessionID SessionRef, classes []string) (_err error) {
_method := "event.unregister"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classesArg, _err := convertStringSetToXen(fmt.Sprintf("%s(%s)", _method, "classes"), classes)
if _err != nil {
return
}
_, _err = _class.client.APICall(_method, _sessionIDArg, _classesArg)
return
}
// Registers this session with the event system. Specifying * as the desired class will register for all classes.
func (_class EventClass) Register(sessionID SessionRef, classes []string) (_err error) {
_method := "event.register"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classesArg, _err := convertStringSetToXen(fmt.Sprintf("%s(%s)", _method, "classes"), classes)
if _err != nil {
return
}
_, _err = _class.client.APICall(_method, _sessionIDArg, _classesArg)
return
}
// Injects an artificial event on the given object and return the corresponding ID
func (_class AsyncEventClass) Inject(sessionID SessionRef, class string, ref string) (_retval TaskRef, _err error) {
_method := "Async.event.inject"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "class"), class)
if _err != nil {
return
}
_refArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "ref"), ref)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg, _classArg, _refArg)
if _err != nil {
return
}
_retval, _err = convertTaskRefToGo(_method + " -> ", _result.Value)
return
}
// Return the ID of the next event to be generated by the system
func (_class AsyncEventClass) GetCurrentID(sessionID SessionRef) (_retval TaskRef, _err error) {
_method := "Async.event.get_current_id"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err != nil {
return
}
_retval, _err = convertTaskRefToGo(_method + " -> ", _result.Value)
return
}
// Blocking call which returns a new token and a (possibly empty) batch of events. The returned token can be used in subsequent calls to this function.
//
// Errors:
// SESSION_NOT_REGISTERED - This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed.
// EVENTS_LOST - Some events have been lost from the queue and cannot be retrieved.
func (_class AsyncEventClass) From(sessionID SessionRef, classes []string, token string, timeout float64) (_retval TaskRef, _err error) {
_method := "Async.event.from"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classesArg, _err := convertStringSetToXen(fmt.Sprintf("%s(%s)", _method, "classes"), classes)
if _err != nil {
return
}
_tokenArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "token"), token)
if _err != nil {
return
}
_timeoutArg, _err := convertFloatToXen(fmt.Sprintf("%s(%s)", _method, "timeout"), timeout)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg, _classesArg, _tokenArg, _timeoutArg)
if _err != nil {
return
}
_retval, _err = convertTaskRefToGo(_method + " -> ", _result.Value)
return
}
// Blocking call which returns a (possibly empty) batch of events. This method is only recommended for legacy use. New development should use event.from which supercedes this method.
//
// Errors:
// SESSION_NOT_REGISTERED - This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed.
// EVENTS_LOST - Some events have been lost from the queue and cannot be retrieved.
func (_class AsyncEventClass) Next(sessionID SessionRef) (_retval TaskRef, _err error) {
_method := "Async.event.next"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg)
if _err != nil {
return
}
_retval, _err = convertTaskRefToGo(_method + " -> ", _result.Value)
return
}
// Unregisters this session with the event system
func (_class AsyncEventClass) Unregister(sessionID SessionRef, classes []string) (_retval TaskRef, _err error) {
_method := "Async.event.unregister"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classesArg, _err := convertStringSetToXen(fmt.Sprintf("%s(%s)", _method, "classes"), classes)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg, _classesArg)
if _err != nil {
return
}
_retval, _err = convertTaskRefToGo(_method + " -> ", _result.Value)
return
}
// Registers this session with the event system. Specifying * as the desired class will register for all classes.
func (_class AsyncEventClass) Register(sessionID SessionRef, classes []string) (_retval TaskRef, _err error) {
_method := "Async.event.register"
_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
if _err != nil {
return
}
_classesArg, _err := convertStringSetToXen(fmt.Sprintf("%s(%s)", _method, "classes"), classes)
if _err != nil {
return
}
_result, _err := _class.client.APICall(_method, _sessionIDArg, _classesArg)
if _err != nil {
return
}
_retval, _err = convertTaskRefToGo(_method + " -> ", _result.Value)
return
}