ovirt-engine-sdk 4.0.10 → 4.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.adoc +16 -0
- data/ext/ovirtsdk4c/ov_http_client.c +36 -0
- data/lib/ovirtsdk4/connection.rb +15 -0
- data/lib/ovirtsdk4/reader.rb +40 -0
- data/lib/ovirtsdk4/readers.rb +107 -107
- data/lib/ovirtsdk4/services.rb +3952 -972
- data/lib/ovirtsdk4/version.rb +1 -1
- data/lib/ovirtsdk4/writers.rb +24 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef3151a5a4fdf9357755606aa19a21ac6190df9e
|
4
|
+
data.tar.gz: e3a3afbb4b946fe05f8fc51147d56d1dea1bb0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3195ac3fc190a9ce0aae6a0ccc89ae4a53bcc6fcd9c1fbe8c64b7727d1a5dddda50a16084e3136bafc5089a5296382ec69fd1bd4352072e15eb583afa72df7e1
|
7
|
+
data.tar.gz: e3ee355131e9bef66cf67fab83f493155b614ac31083271c41def40fef19d8ffa1b4e4932f5b5ff818796f74cdf720c12048b8cc15552e1b4d734d3516b2196e
|
data/CHANGES.adoc
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
This document describes the relevant changes between releases of the SDK.
|
4
4
|
|
5
|
+
== 4.0.11 / Mar 2 2017
|
6
|
+
|
7
|
+
New features:
|
8
|
+
|
9
|
+
* Add support for custom headers and query parameters.
|
10
|
+
|
11
|
+
* Ignore unsupported enum values.
|
12
|
+
|
13
|
+
* Check that URL has been provided.
|
14
|
+
|
15
|
+
* Send INFO log messages with summaries of requests and responses.
|
16
|
+
|
17
|
+
Bug fixes:
|
18
|
+
|
19
|
+
* Fix writing of lists of structs.
|
20
|
+
|
5
21
|
== 4.0.10 / Feb 9 2017
|
6
22
|
|
7
23
|
Bug fixes:
|
@@ -19,6 +19,7 @@ limitations under the License.
|
|
19
19
|
|
20
20
|
#include <ctype.h>
|
21
21
|
#include <curl/curl.h>
|
22
|
+
#include <stdarg.h>
|
22
23
|
#include <stdbool.h>
|
23
24
|
#include <stdlib.h>
|
24
25
|
#include <string.h>
|
@@ -48,6 +49,8 @@ static VALUE PROXY_PASSWORD_SYMBOL;
|
|
48
49
|
/* Method identifiers: */
|
49
50
|
static ID DEBUG_ID;
|
50
51
|
static ID ENCODE_WWW_FORM_ID;
|
52
|
+
static ID INFO_ID;
|
53
|
+
static ID INFO_Q_ID;
|
51
54
|
static ID READ_ID;
|
52
55
|
static ID STRING_ID;
|
53
56
|
static ID STRING_IO_ID;
|
@@ -549,6 +552,22 @@ static void ov_http_client_perform_cancel(void* data) {
|
|
549
552
|
perform_context->cancel = true;
|
550
553
|
}
|
551
554
|
|
555
|
+
static void ov_http_client_log_info(VALUE log, const char* format, ...) {
|
556
|
+
VALUE enabled;
|
557
|
+
VALUE message;
|
558
|
+
va_list args;
|
559
|
+
|
560
|
+
if (!NIL_P(log)) {
|
561
|
+
enabled = rb_funcall(log, INFO_Q_ID, 0);
|
562
|
+
if (RTEST(enabled)) {
|
563
|
+
va_start(args, format);
|
564
|
+
message = rb_vsprintf(format, args);
|
565
|
+
rb_funcall(log, INFO_ID, 1, message);
|
566
|
+
va_end(args);
|
567
|
+
}
|
568
|
+
}
|
569
|
+
}
|
570
|
+
|
552
571
|
static VALUE ov_http_client_send(VALUE self, VALUE request, VALUE response) {
|
553
572
|
VALUE header;
|
554
573
|
VALUE url;
|
@@ -626,6 +645,14 @@ static VALUE ov_http_client_send(VALUE self, VALUE request, VALUE response) {
|
|
626
645
|
}
|
627
646
|
curl_easy_setopt(object->curl, CURLOPT_HTTPHEADER, headers);
|
628
647
|
|
648
|
+
/* Send a summary of the request to the log: */
|
649
|
+
ov_http_client_log_info(
|
650
|
+
object->log,
|
651
|
+
"Sending '%"PRIsVALUE"' request to URL '%"PRIsVALUE"'.",
|
652
|
+
request_object->method,
|
653
|
+
url
|
654
|
+
);
|
655
|
+
|
629
656
|
/* Performing the request is a potentially lengthy and blocking operation, so we need to make sure that it runs
|
630
657
|
without the global interpreter lock acquired as much as possible: */
|
631
658
|
perform_context.object = object;
|
@@ -674,6 +701,13 @@ static VALUE ov_http_client_send(VALUE self, VALUE request, VALUE response) {
|
|
674
701
|
/* Get the response body: */
|
675
702
|
response_object->body = rb_funcall(perform_context.out, STRING_ID, 0);
|
676
703
|
|
704
|
+
/* Send a summary of the response to the log: */
|
705
|
+
ov_http_client_log_info(
|
706
|
+
object->log,
|
707
|
+
"Received response code '%"PRIsVALUE"'.",
|
708
|
+
response_object->code
|
709
|
+
);
|
710
|
+
|
677
711
|
return Qnil;
|
678
712
|
}
|
679
713
|
|
@@ -712,6 +746,8 @@ void ov_http_client_define(void) {
|
|
712
746
|
/* Define the method identifiers: */
|
713
747
|
DEBUG_ID = rb_intern("debug");
|
714
748
|
ENCODE_WWW_FORM_ID = rb_intern("encode_www_form");
|
749
|
+
INFO_ID = rb_intern("info");
|
750
|
+
INFO_Q_ID = rb_intern("info?");
|
715
751
|
READ_ID = rb_intern("read");
|
716
752
|
STRING_ID = rb_intern("string");
|
717
753
|
STRING_IO_ID = rb_intern("StringIO");
|
data/lib/ovirtsdk4/connection.rb
CHANGED
@@ -90,6 +90,11 @@ module OvirtSDK4
|
|
90
90
|
#
|
91
91
|
# @option opts [String] :proxy_password The password of the user to authenticate to the proxy server.
|
92
92
|
#
|
93
|
+
# @option opts [Hash] :headers Custom HTTP headers to send with all requests. The keys of the hash can be
|
94
|
+
# strings of symbols, and they will be used as the names of the headers. The values of the hash will be used
|
95
|
+
# as the names of the headers. If the same header is provided here and in the `headers` parameter of a specific
|
96
|
+
# method call, then the `headers` parameter of the specific method call will have precendence.
|
97
|
+
#
|
93
98
|
def initialize(opts = {})
|
94
99
|
# Get the values of the parameters and assign default values:
|
95
100
|
@url = opts[:url]
|
@@ -107,6 +112,10 @@ module OvirtSDK4
|
|
107
112
|
@proxy_url = opts[:proxy_url]
|
108
113
|
@proxy_username = opts[:proxy_username]
|
109
114
|
@proxy_password = opts[:proxy_password]
|
115
|
+
@headers = opts[:headers]
|
116
|
+
|
117
|
+
# Check that the URL has been provided:
|
118
|
+
raise ArgumentError, "The 'url' option is mandatory" unless @url
|
110
119
|
|
111
120
|
# Create a temporary file to store the CA certificates, and populate it with the contents of the 'ca_file' and
|
112
121
|
# 'ca_certs' options. The file will be removed when the connection is closed.
|
@@ -186,6 +195,9 @@ module OvirtSDK4
|
|
186
195
|
request.headers['All-Content'] = all_content unless all_content.nil?
|
187
196
|
end
|
188
197
|
|
198
|
+
# Add the global headers, but without replacing the values that may already exist:
|
199
|
+
request.headers.merge!(@headers) { |_name, local, _global| local } if @headers
|
200
|
+
|
189
201
|
# Set the authentication token:
|
190
202
|
@token ||= create_access_token
|
191
203
|
request.token = @token
|
@@ -266,6 +278,9 @@ module OvirtSDK4
|
|
266
278
|
body: URI.encode_www_form(parameters)
|
267
279
|
)
|
268
280
|
|
281
|
+
# Add the global headers:
|
282
|
+
request.headers.merge!(@headers) if @headers
|
283
|
+
|
269
284
|
# Create an empty response:
|
270
285
|
response = HttpResponse.new
|
271
286
|
|
data/lib/ovirtsdk4/reader.rb
CHANGED
@@ -189,6 +189,46 @@ module OvirtSDK4
|
|
189
189
|
reader.read_elements.map { |text| Reader.parse_date(text) }
|
190
190
|
end
|
191
191
|
|
192
|
+
#
|
193
|
+
# Converts the given text to an enum.
|
194
|
+
#
|
195
|
+
# @param enum_type [module]
|
196
|
+
# @param text [String]
|
197
|
+
# @return [String]
|
198
|
+
#
|
199
|
+
def self.parse_enum(enum_type, text)
|
200
|
+
return nil unless text
|
201
|
+
begin
|
202
|
+
text if enum_type.constants.map(&:downcase).include?(text.to_sym)
|
203
|
+
rescue
|
204
|
+
nil
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
#
|
209
|
+
# Reads a enum value, assuming that the cursor is positioned at the
|
210
|
+
# start element that contains the value.
|
211
|
+
#
|
212
|
+
# @param enum_type [module]
|
213
|
+
# @param reader [XmlReader]
|
214
|
+
# @return [Array<String>]
|
215
|
+
#
|
216
|
+
def self.read_enum(enum_type, reader)
|
217
|
+
Reader.parse_enum(enum_type, reader.read_element)
|
218
|
+
end
|
219
|
+
|
220
|
+
#
|
221
|
+
# Reads a list of enum values, assuming that the cursor is positioned
|
222
|
+
# at the start element of the element that contains the first value.
|
223
|
+
#
|
224
|
+
# @param enum_type [module]
|
225
|
+
# @param reader [XmlReader]
|
226
|
+
# @return [Array<String>]
|
227
|
+
#
|
228
|
+
def self.read_enums(enum_type, reader)
|
229
|
+
reader.read_elements.map { |text| Reader.parse_enum(enum_type, text) }
|
230
|
+
end
|
231
|
+
|
192
232
|
#
|
193
233
|
# This hash stores for each known tag a reference to the method that read the object corresponding for that tag. For
|
194
234
|
# example, for the `vm` tag it will contain a reference to the `VmReader.read_one` method, and for the `vms` tag
|