ovirt-engine-sdk 4.1.5 → 4.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.adoc +37 -0
- data/ext/ovirtsdk4c/ov_http_client.c +531 -353
- data/ext/ovirtsdk4c/ov_http_client.h +39 -2
- data/ext/ovirtsdk4c/ov_http_request.c +130 -102
- data/ext/ovirtsdk4c/ov_http_request.h +10 -2
- data/ext/ovirtsdk4c/ov_http_response.c +63 -50
- data/ext/ovirtsdk4c/ov_http_response.h +9 -2
- data/ext/ovirtsdk4c/ov_http_transfer.c +80 -0
- data/ext/ovirtsdk4c/ov_http_transfer.h +47 -0
- data/ext/ovirtsdk4c/ov_string.c +43 -0
- data/ext/ovirtsdk4c/ov_string.h +25 -0
- data/ext/ovirtsdk4c/ov_xml_reader.c +115 -99
- data/ext/ovirtsdk4c/ov_xml_reader.h +20 -3
- data/ext/ovirtsdk4c/ov_xml_writer.c +95 -77
- data/ext/ovirtsdk4c/ov_xml_writer.h +18 -3
- data/ext/ovirtsdk4c/ovirtsdk4c.c +2 -0
- data/lib/ovirtsdk4.rb +1 -0
- data/lib/ovirtsdk4/connection.rb +176 -26
- data/lib/ovirtsdk4/error.rb +38 -0
- data/lib/ovirtsdk4/probe.rb +4 -7
- data/lib/ovirtsdk4/readers.rb +9 -1
- data/lib/ovirtsdk4/service.rb +267 -36
- data/lib/ovirtsdk4/services.rb +7342 -15734
- data/lib/ovirtsdk4/types.rb +50 -4
- data/lib/ovirtsdk4/version.rb +1 -1
- data/lib/ovirtsdk4/writer.rb +27 -1
- data/lib/ovirtsdk4/writers.rb +3 -1
- metadata +7 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2016 Red Hat, Inc.
|
2
|
+
Copyright (c) 2016-2017 Red Hat, Inc.
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
@@ -17,9 +17,46 @@ limitations under the License.
|
|
17
17
|
#ifndef __OV_HTTP_CLIENT_H__
|
18
18
|
#define __OV_HTTP_CLIENT_H__
|
19
19
|
|
20
|
-
|
20
|
+
#include <ruby.h>
|
21
|
+
|
22
|
+
#include <curl/curl.h>
|
23
|
+
#include <stdbool.h>
|
24
|
+
|
25
|
+
/* Data type and class: */
|
26
|
+
extern rb_data_type_t ov_http_client_type;
|
21
27
|
extern VALUE ov_http_client_class;
|
22
28
|
|
29
|
+
/* Content: */
|
30
|
+
typedef struct {
|
31
|
+
/* The libcurl multi handle: */
|
32
|
+
CURLM* handle;
|
33
|
+
|
34
|
+
/* The logger: */
|
35
|
+
VALUE log;
|
36
|
+
|
37
|
+
/* This hash store the transfers that are pending. The key of the hash is the request that initiated the transfer,
|
38
|
+
and the value is the transfer itself. */
|
39
|
+
VALUE pending;
|
40
|
+
|
41
|
+
/* This hash stores the completed transfers. The key of the hash is the request, and the value is either the
|
42
|
+
response to that request, or else the exception that was generated while trying to process it. */
|
43
|
+
VALUE completed;
|
44
|
+
|
45
|
+
/* Copies of the options passed to the constructor: */
|
46
|
+
bool compress;
|
47
|
+
bool debug;
|
48
|
+
bool insecure;
|
49
|
+
char* ca_file;
|
50
|
+
char* proxy_url;
|
51
|
+
char* proxy_username;
|
52
|
+
char* proxy_password;
|
53
|
+
int timeout;
|
54
|
+
} ov_http_client_object;
|
55
|
+
|
56
|
+
/* Macro to get the pointer: */
|
57
|
+
#define ov_http_client_ptr(object, ptr) \
|
58
|
+
TypedData_Get_Struct((object), ov_http_client_object, &ov_http_client_type, (ptr))
|
59
|
+
|
23
60
|
/* Initialization function: */
|
24
61
|
extern void ov_http_client_define(void);
|
25
62
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2016 Red Hat, Inc.
|
2
|
+
Copyright (c) 2016-2017 Red Hat, Inc.
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
@@ -39,219 +39,243 @@ static VALUE PASSWORD_SYMBOL;
|
|
39
39
|
static VALUE TOKEN_SYMBOL;
|
40
40
|
static VALUE KERBEROS_SYMBOL;
|
41
41
|
static VALUE BODY_SYMBOL;
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
}
|
59
|
-
if (!NIL_P(object->password)) {
|
60
|
-
rb_gc_mark(object->password);
|
61
|
-
}
|
62
|
-
if (!NIL_P(object->token)) {
|
63
|
-
rb_gc_mark(object->token);
|
64
|
-
}
|
65
|
-
if (!NIL_P(object->kerberos)) {
|
66
|
-
rb_gc_mark(object->kerberos);
|
67
|
-
}
|
68
|
-
if (!NIL_P(object->body)) {
|
69
|
-
rb_gc_mark(object->body);
|
70
|
-
}
|
42
|
+
static VALUE TIMEOUT_SYMBOL;
|
43
|
+
|
44
|
+
static void ov_http_request_mark(void* vptr) {
|
45
|
+
ov_http_request_object* ptr;
|
46
|
+
|
47
|
+
ptr = vptr;
|
48
|
+
rb_gc_mark(ptr->method);
|
49
|
+
rb_gc_mark(ptr->url);
|
50
|
+
rb_gc_mark(ptr->query);
|
51
|
+
rb_gc_mark(ptr->headers);
|
52
|
+
rb_gc_mark(ptr->username);
|
53
|
+
rb_gc_mark(ptr->password);
|
54
|
+
rb_gc_mark(ptr->token);
|
55
|
+
rb_gc_mark(ptr->kerberos);
|
56
|
+
rb_gc_mark(ptr->body);
|
57
|
+
rb_gc_mark(ptr->timeout);
|
71
58
|
}
|
72
59
|
|
73
|
-
static void ov_http_request_free(
|
74
|
-
|
60
|
+
static void ov_http_request_free(void* vptr) {
|
61
|
+
ov_http_request_object* ptr;
|
62
|
+
|
63
|
+
ptr = vptr;
|
64
|
+
xfree(ptr);
|
75
65
|
}
|
76
66
|
|
67
|
+
rb_data_type_t ov_http_request_type = {
|
68
|
+
.wrap_struct_name = "OVHTTPREQUEST",
|
69
|
+
.function = {
|
70
|
+
.dmark = ov_http_request_mark,
|
71
|
+
.dfree = ov_http_request_free,
|
72
|
+
.dsize = NULL,
|
73
|
+
.reserved = { NULL, NULL }
|
74
|
+
},
|
75
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
76
|
+
.parent = NULL,
|
77
|
+
.data = NULL,
|
78
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
79
|
+
#endif
|
80
|
+
};
|
81
|
+
|
77
82
|
static VALUE ov_http_request_alloc(VALUE klass) {
|
78
|
-
ov_http_request_object*
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
83
|
+
ov_http_request_object* ptr;
|
84
|
+
|
85
|
+
ptr = ALLOC(ov_http_request_object);
|
86
|
+
ptr->method = Qnil;
|
87
|
+
ptr->url = Qnil;
|
88
|
+
ptr->query = Qnil;
|
89
|
+
ptr->headers = Qnil;
|
90
|
+
ptr->username = Qnil;
|
91
|
+
ptr->password = Qnil;
|
92
|
+
ptr->token = Qnil;
|
93
|
+
ptr->kerberos = Qnil;
|
94
|
+
ptr->body = Qnil;
|
95
|
+
ptr->timeout = Qnil;
|
96
|
+
return TypedData_Wrap_Struct(klass, &ov_http_request_type, ptr);
|
91
97
|
}
|
92
98
|
|
93
99
|
static VALUE ov_http_request_get_method(VALUE self) {
|
94
|
-
ov_http_request_object*
|
100
|
+
ov_http_request_object* ptr;
|
95
101
|
|
96
|
-
|
97
|
-
return
|
102
|
+
ov_http_request_ptr(self, ptr);
|
103
|
+
return ptr->method;
|
98
104
|
}
|
99
105
|
|
100
106
|
static VALUE ov_http_request_set_method(VALUE self, VALUE value) {
|
101
|
-
ov_http_request_object*
|
107
|
+
ov_http_request_object* ptr;
|
102
108
|
|
103
|
-
|
109
|
+
ov_http_request_ptr(self, ptr);
|
104
110
|
if (NIL_P(value)) {
|
105
|
-
|
111
|
+
ptr->method = GET_SYMBOL;
|
106
112
|
}
|
107
113
|
else {
|
108
114
|
Check_Type(value, T_SYMBOL);
|
109
|
-
|
115
|
+
ptr->method = value;
|
110
116
|
}
|
111
117
|
return Qnil;
|
112
118
|
}
|
113
119
|
|
114
120
|
static VALUE ov_http_request_get_url(VALUE self) {
|
115
|
-
ov_http_request_object*
|
121
|
+
ov_http_request_object* ptr;
|
116
122
|
|
117
|
-
|
118
|
-
return
|
123
|
+
ov_http_request_ptr(self, ptr);
|
124
|
+
return ptr->url;
|
119
125
|
}
|
120
126
|
|
121
127
|
static VALUE ov_http_request_set_url(VALUE self, VALUE value) {
|
122
|
-
ov_http_request_object*
|
128
|
+
ov_http_request_object* ptr;
|
123
129
|
|
124
|
-
|
130
|
+
ov_http_request_ptr(self, ptr);
|
125
131
|
if (!NIL_P(value)) {
|
126
132
|
Check_Type(value, T_STRING);
|
127
133
|
}
|
128
|
-
|
134
|
+
ptr->url = value;
|
129
135
|
return Qnil;
|
130
136
|
}
|
131
137
|
|
132
138
|
static VALUE ov_http_request_get_query(VALUE self) {
|
133
|
-
ov_http_request_object*
|
139
|
+
ov_http_request_object* ptr;
|
134
140
|
|
135
|
-
|
136
|
-
return
|
141
|
+
ov_http_request_ptr(self, ptr);
|
142
|
+
return ptr->query;
|
137
143
|
}
|
138
144
|
|
139
145
|
static VALUE ov_http_request_set_query(VALUE self, VALUE value) {
|
140
|
-
ov_http_request_object*
|
146
|
+
ov_http_request_object* ptr;
|
141
147
|
|
142
|
-
|
148
|
+
ov_http_request_ptr(self, ptr);
|
143
149
|
if (!NIL_P(value)) {
|
144
150
|
Check_Type(value, T_HASH);
|
145
151
|
}
|
146
|
-
|
152
|
+
ptr->query = value;
|
147
153
|
return Qnil;
|
148
154
|
}
|
149
155
|
|
150
156
|
static VALUE ov_http_request_get_headers(VALUE self) {
|
151
|
-
ov_http_request_object*
|
157
|
+
ov_http_request_object* ptr;
|
152
158
|
|
153
|
-
|
154
|
-
return
|
159
|
+
ov_http_request_ptr(self, ptr);
|
160
|
+
return ptr->headers;
|
155
161
|
}
|
156
162
|
|
157
163
|
static VALUE ov_http_request_set_headers(VALUE self, VALUE value) {
|
158
|
-
ov_http_request_object*
|
164
|
+
ov_http_request_object* ptr;
|
159
165
|
|
160
|
-
|
166
|
+
ov_http_request_ptr(self, ptr);
|
161
167
|
if (NIL_P(value)) {
|
162
|
-
|
168
|
+
ptr->headers = rb_hash_new();
|
163
169
|
}
|
164
170
|
else {
|
165
171
|
Check_Type(value, T_HASH);
|
166
|
-
|
172
|
+
ptr->headers = value;
|
167
173
|
}
|
168
174
|
return Qnil;
|
169
175
|
}
|
170
176
|
|
171
177
|
static VALUE ov_http_request_get_username(VALUE self) {
|
172
|
-
ov_http_request_object*
|
178
|
+
ov_http_request_object* ptr;
|
173
179
|
|
174
|
-
|
175
|
-
return
|
180
|
+
ov_http_request_ptr(self, ptr);
|
181
|
+
return ptr->username;
|
176
182
|
}
|
177
183
|
|
178
184
|
static VALUE ov_http_request_set_username(VALUE self, VALUE value) {
|
179
|
-
ov_http_request_object*
|
185
|
+
ov_http_request_object* ptr;
|
180
186
|
|
181
|
-
|
187
|
+
ov_http_request_ptr(self, ptr);
|
182
188
|
if (!NIL_P(value)) {
|
183
189
|
Check_Type(value, T_STRING);
|
184
190
|
}
|
185
|
-
|
191
|
+
ptr->username = value;
|
186
192
|
return Qnil;
|
187
193
|
}
|
188
194
|
|
189
195
|
static VALUE ov_http_request_get_password(VALUE self) {
|
190
|
-
ov_http_request_object*
|
196
|
+
ov_http_request_object* ptr;
|
191
197
|
|
192
|
-
|
193
|
-
return
|
198
|
+
ov_http_request_ptr(self, ptr);
|
199
|
+
return ptr->password;
|
194
200
|
}
|
195
201
|
|
196
202
|
static VALUE ov_http_request_set_password(VALUE self, VALUE value) {
|
197
|
-
ov_http_request_object*
|
203
|
+
ov_http_request_object* ptr;
|
198
204
|
|
199
|
-
|
205
|
+
ov_http_request_ptr(self, ptr);
|
200
206
|
if (!NIL_P(value)) {
|
201
207
|
Check_Type(value, T_STRING);
|
202
208
|
}
|
203
|
-
|
209
|
+
ptr->password = value;
|
204
210
|
return Qnil;
|
205
211
|
}
|
206
212
|
|
207
213
|
static VALUE ov_http_request_get_token(VALUE self) {
|
208
|
-
ov_http_request_object*
|
214
|
+
ov_http_request_object* ptr;
|
209
215
|
|
210
|
-
|
211
|
-
return
|
216
|
+
ov_http_request_ptr(self, ptr);
|
217
|
+
return ptr->token;
|
212
218
|
}
|
213
219
|
|
214
220
|
static VALUE ov_http_request_set_token(VALUE self, VALUE value) {
|
215
|
-
ov_http_request_object*
|
221
|
+
ov_http_request_object* ptr;
|
216
222
|
|
217
|
-
|
223
|
+
ov_http_request_ptr(self, ptr);
|
218
224
|
if (!NIL_P(value)) {
|
219
225
|
Check_Type(value, T_STRING);
|
220
226
|
}
|
221
|
-
|
227
|
+
ptr->token = value;
|
222
228
|
return Qnil;
|
223
229
|
}
|
224
230
|
|
225
231
|
static VALUE ov_http_request_get_kerberos(VALUE self) {
|
226
|
-
ov_http_request_object*
|
232
|
+
ov_http_request_object* ptr;
|
227
233
|
|
228
|
-
|
229
|
-
return
|
234
|
+
ov_http_request_ptr(self, ptr);
|
235
|
+
return ptr->kerberos;
|
230
236
|
}
|
231
237
|
|
232
238
|
static VALUE ov_http_request_set_kerberos(VALUE self, VALUE value) {
|
233
|
-
ov_http_request_object*
|
239
|
+
ov_http_request_object* ptr;
|
234
240
|
|
235
|
-
|
236
|
-
|
241
|
+
ov_http_request_ptr(self, ptr);
|
242
|
+
ptr->kerberos = RTEST(value);
|
237
243
|
return Qnil;
|
238
244
|
}
|
239
245
|
|
240
246
|
static VALUE ov_http_request_get_body(VALUE self) {
|
241
|
-
ov_http_request_object*
|
247
|
+
ov_http_request_object* ptr;
|
242
248
|
|
243
|
-
|
244
|
-
return
|
249
|
+
ov_http_request_ptr(self, ptr);
|
250
|
+
return ptr->body;
|
245
251
|
}
|
246
252
|
|
247
253
|
static VALUE ov_http_request_set_body(VALUE self, VALUE value) {
|
248
|
-
ov_http_request_object*
|
254
|
+
ov_http_request_object* ptr;
|
249
255
|
|
250
|
-
|
256
|
+
ov_http_request_ptr(self, ptr);
|
251
257
|
if (!NIL_P(value)) {
|
252
258
|
Check_Type(value, T_STRING);
|
253
259
|
}
|
254
|
-
|
260
|
+
ptr->body = value;
|
261
|
+
return Qnil;
|
262
|
+
}
|
263
|
+
|
264
|
+
static VALUE ov_http_request_get_timeout(VALUE self) {
|
265
|
+
ov_http_request_object* ptr;
|
266
|
+
|
267
|
+
ov_http_request_ptr(self, ptr);
|
268
|
+
return ptr->timeout;
|
269
|
+
}
|
270
|
+
|
271
|
+
static VALUE ov_http_request_set_timeout(VALUE self, VALUE value) {
|
272
|
+
ov_http_request_object* ptr;
|
273
|
+
|
274
|
+
ov_http_request_ptr(self, ptr);
|
275
|
+
if (!NIL_P(value)) {
|
276
|
+
Check_Type(value, T_FIXNUM);
|
277
|
+
}
|
278
|
+
ptr->timeout = value;
|
255
279
|
return Qnil;
|
256
280
|
}
|
257
281
|
|
@@ -279,13 +303,14 @@ static VALUE ov_http_request_initialize(int argc, VALUE* argv, VALUE self) {
|
|
279
303
|
ov_http_request_set_password(self, rb_hash_aref(opts, PASSWORD_SYMBOL));
|
280
304
|
ov_http_request_set_token(self, rb_hash_aref(opts, TOKEN_SYMBOL));
|
281
305
|
ov_http_request_set_body(self, rb_hash_aref(opts, BODY_SYMBOL));
|
306
|
+
ov_http_request_set_timeout(self, rb_hash_aref(opts, TIMEOUT_SYMBOL));
|
282
307
|
|
283
308
|
return self;
|
284
309
|
}
|
285
310
|
|
286
311
|
void ov_http_request_define(void) {
|
287
312
|
/* Define the class: */
|
288
|
-
ov_http_request_class = rb_define_class_under(ov_module, "HttpRequest",
|
313
|
+
ov_http_request_class = rb_define_class_under(ov_module, "HttpRequest", rb_cData);
|
289
314
|
|
290
315
|
/* Define the constructor: */
|
291
316
|
rb_define_alloc_func(ov_http_request_class, ov_http_request_alloc);
|
@@ -310,6 +335,8 @@ void ov_http_request_define(void) {
|
|
310
335
|
rb_define_method(ov_http_request_class, "kerberos=", ov_http_request_set_kerberos, 1);
|
311
336
|
rb_define_method(ov_http_request_class, "body", ov_http_request_get_body, 0);
|
312
337
|
rb_define_method(ov_http_request_class, "body=", ov_http_request_set_body, 1);
|
338
|
+
rb_define_method(ov_http_request_class, "timeout", ov_http_request_get_timeout, 0);
|
339
|
+
rb_define_method(ov_http_request_class, "timeout=", ov_http_request_set_timeout, 1);
|
313
340
|
|
314
341
|
/* Define the symbols for the attributes: */
|
315
342
|
URL_SYMBOL = ID2SYM(rb_intern("url"));
|
@@ -321,6 +348,7 @@ void ov_http_request_define(void) {
|
|
321
348
|
TOKEN_SYMBOL = ID2SYM(rb_intern("token"));
|
322
349
|
KERBEROS_SYMBOL = ID2SYM(rb_intern("kerberos"));
|
323
350
|
BODY_SYMBOL = ID2SYM(rb_intern("body"));
|
351
|
+
TIMEOUT_SYMBOL = ID2SYM(rb_intern("timeout"));
|
324
352
|
|
325
353
|
/* Define the symbols for the HTTP methods: */
|
326
354
|
GET_SYMBOL = ID2SYM(rb_intern("GET"));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2016 Red Hat, Inc.
|
2
|
+
Copyright (c) 2016-2017 Red Hat, Inc.
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
@@ -17,7 +17,10 @@ limitations under the License.
|
|
17
17
|
#ifndef __OV_HTTP_REQUEST_H__
|
18
18
|
#define __OV_HTTP_REQUEST_H__
|
19
19
|
|
20
|
-
|
20
|
+
#include <ruby.h>
|
21
|
+
|
22
|
+
/* Data type and class: */
|
23
|
+
extern rb_data_type_t ov_http_request_type;
|
21
24
|
extern VALUE ov_http_request_class;
|
22
25
|
|
23
26
|
/* Symbols for HTTP methods: */
|
@@ -37,8 +40,13 @@ typedef struct {
|
|
37
40
|
VALUE token; /* String */
|
38
41
|
VALUE kerberos; /* Boolean */
|
39
42
|
VALUE body; /* String */
|
43
|
+
VALUE timeout; /* Integer */
|
40
44
|
} ov_http_request_object;
|
41
45
|
|
46
|
+
/* Macro to get the pointer: */
|
47
|
+
#define ov_http_request_ptr(object, ptr) \
|
48
|
+
TypedData_Get_Struct((object), ov_http_request_object, &ov_http_request_type, (ptr))
|
49
|
+
|
42
50
|
/* Initialization function: */
|
43
51
|
extern void ov_http_request_define(void);
|
44
52
|
|