Class: OvirtSDK4::HttpRequest

Inherits:
Object
  • Object
show all
Defined in:
ext/ovirtsdk4c/ov_http_request.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'ext/ovirtsdk4c/ov_http_request.c', line 315

static VALUE ov_http_request_initialize(int argc, VALUE* argv, VALUE self) {
    VALUE opts;

    /* Check the number of arguments: */
    if (argc > 1) {
      rb_raise(ov_error_class, "Expected at most one argument, 'opts', but received %d", argc);
    }
    opts = argc > 0? argv[0]: Qnil;
    if (NIL_P(opts)) {
        opts = rb_hash_new();
    }
    else {
        Check_Type(opts, T_HASH);
    }

    /* Get the values of the options: */
    ov_http_request_set_method(self, rb_hash_aref(opts, METHOD_SYMBOL));
    ov_http_request_set_url(self, rb_hash_aref(opts, URL_SYMBOL));
    ov_http_request_set_query(self, rb_hash_aref(opts, QUERY_SYMBOL));
    ov_http_request_set_headers(self, rb_hash_aref(opts, HEADERS_SYMBOL));
    ov_http_request_set_username(self, rb_hash_aref(opts, USERNAME_SYMBOL));
    ov_http_request_set_password(self, rb_hash_aref(opts, PASSWORD_SYMBOL));
    ov_http_request_set_token(self, rb_hash_aref(opts, TOKEN_SYMBOL));
    ov_http_request_set_body(self, rb_hash_aref(opts, BODY_SYMBOL));
    ov_http_request_set_timeout(self, rb_hash_aref(opts, TIMEOUT_SYMBOL));
    ov_http_request_set_connect_timeout(self, rb_hash_aref(opts, CONNECT_TIMEOUT_SYMBOL));

    return self;
}

Instance Method Details

#bodyObject



249
250
251
252
253
254
# File 'ext/ovirtsdk4c/ov_http_request.c', line 249

static VALUE ov_http_request_get_body(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->body;
}

#body=(value) ⇒ Object



256
257
258
259
260
261
262
263
264
265
# File 'ext/ovirtsdk4c/ov_http_request.c', line 256

static VALUE ov_http_request_set_body(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->body = value;
    return Qnil;
}

#connect_timeoutObject



285
286
287
288
289
290
# File 'ext/ovirtsdk4c/ov_http_request.c', line 285

static VALUE ov_http_request_get_connect_timeout(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->connect_timeout;
}

#connect_timeout=(value) ⇒ Object



292
293
294
295
296
297
298
299
300
301
# File 'ext/ovirtsdk4c/ov_http_request.c', line 292

static VALUE ov_http_request_set_connect_timeout(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_FIXNUM);
    }
    ptr->connect_timeout = value;
    return Qnil;
}

#headersObject



159
160
161
162
163
164
# File 'ext/ovirtsdk4c/ov_http_request.c', line 159

static VALUE ov_http_request_get_headers(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->headers;
}

#headers=(value) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'ext/ovirtsdk4c/ov_http_request.c', line 166

static VALUE ov_http_request_set_headers(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (NIL_P(value)) {
        ptr->headers = rb_hash_new();
    }
    else {
        Check_Type(value, T_HASH);
        ptr->headers = value;
    }
    return Qnil;
}

#inspectObject



303
304
305
306
307
308
309
310
311
312
313
# File 'ext/ovirtsdk4c/ov_http_request.c', line 303

static VALUE ov_http_request_inspect(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return rb_sprintf(
        "#<%"PRIsVALUE":%"PRIsVALUE" %"PRIsVALUE">",
        ov_http_request_class,
        ptr->method,
        ptr->url
    );
}

#kerberosObject



234
235
236
237
238
239
# File 'ext/ovirtsdk4c/ov_http_request.c', line 234

static VALUE ov_http_request_get_kerberos(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->kerberos;
}

#kerberos=(value) ⇒ Object



241
242
243
244
245
246
247
# File 'ext/ovirtsdk4c/ov_http_request.c', line 241

static VALUE ov_http_request_set_kerberos(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    ptr->kerberos = RTEST(value);
    return Qnil;
}

#methodObject

Define the methods:



102
103
104
105
106
107
# File 'ext/ovirtsdk4c/ov_http_request.c', line 102

static VALUE ov_http_request_get_method(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->method;
}

#method=(value) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'ext/ovirtsdk4c/ov_http_request.c', line 109

static VALUE ov_http_request_set_method(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (NIL_P(value)) {
        ptr->method = GET_SYMBOL;
    }
    else {
        Check_Type(value, T_SYMBOL);
        ptr->method = value;
    }
    return Qnil;
}

#passwordObject



198
199
200
201
202
203
# File 'ext/ovirtsdk4c/ov_http_request.c', line 198

static VALUE ov_http_request_get_password(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->password;
}

#password=(value) ⇒ Object



205
206
207
208
209
210
211
212
213
214
# File 'ext/ovirtsdk4c/ov_http_request.c', line 205

static VALUE ov_http_request_set_password(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->password = value;
    return Qnil;
}

#queryObject



141
142
143
144
145
146
# File 'ext/ovirtsdk4c/ov_http_request.c', line 141

static VALUE ov_http_request_get_query(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->query;
}

#query=(value) ⇒ Object



148
149
150
151
152
153
154
155
156
157
# File 'ext/ovirtsdk4c/ov_http_request.c', line 148

static VALUE ov_http_request_set_query(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_HASH);
    }
    ptr->query = value;
    return Qnil;
}

#timeoutObject



267
268
269
270
271
272
# File 'ext/ovirtsdk4c/ov_http_request.c', line 267

static VALUE ov_http_request_get_timeout(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->timeout;
}

#timeout=(value) ⇒ Object



274
275
276
277
278
279
280
281
282
283
# File 'ext/ovirtsdk4c/ov_http_request.c', line 274

static VALUE ov_http_request_set_timeout(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_FIXNUM);
    }
    ptr->timeout = value;
    return Qnil;
}

#to_sObject



303
304
305
306
307
308
309
310
311
312
313
# File 'ext/ovirtsdk4c/ov_http_request.c', line 303

static VALUE ov_http_request_inspect(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return rb_sprintf(
        "#<%"PRIsVALUE":%"PRIsVALUE" %"PRIsVALUE">",
        ov_http_request_class,
        ptr->method,
        ptr->url
    );
}

#tokenObject



216
217
218
219
220
221
# File 'ext/ovirtsdk4c/ov_http_request.c', line 216

static VALUE ov_http_request_get_token(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->token;
}

#token=(value) ⇒ Object



223
224
225
226
227
228
229
230
231
232
# File 'ext/ovirtsdk4c/ov_http_request.c', line 223

static VALUE ov_http_request_set_token(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->token = value;
    return Qnil;
}

#urlObject



123
124
125
126
127
128
# File 'ext/ovirtsdk4c/ov_http_request.c', line 123

static VALUE ov_http_request_get_url(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->url;
}

#url=(value) ⇒ Object



130
131
132
133
134
135
136
137
138
139
# File 'ext/ovirtsdk4c/ov_http_request.c', line 130

static VALUE ov_http_request_set_url(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->url = value;
    return Qnil;
}

#usernameObject



180
181
182
183
184
185
# File 'ext/ovirtsdk4c/ov_http_request.c', line 180

static VALUE ov_http_request_get_username(VALUE self) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    return ptr->username;
}

#username=(value) ⇒ Object



187
188
189
190
191
192
193
194
195
196
# File 'ext/ovirtsdk4c/ov_http_request.c', line 187

static VALUE ov_http_request_set_username(VALUE self, VALUE value) {
    ov_http_request_object* ptr;

    ov_http_request_ptr(self, ptr);
    if (!NIL_P(value)) {
        Check_Type(value, T_STRING);
    }
    ptr->username = value;
    return Qnil;
}