Rest.ProxyCall

g GObject.Object GObject.Object Rest.ProxyCall Rest.ProxyCall GObject.Object->Rest.ProxyCall

Subclasses:

Rest.OAuth2ProxyCall

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

add_header (header, value)

add_param (name, value)

add_param_full (param)

get_function ()

get_method ()

get_params ()

get_payload ()

get_payload_length ()

get_response_headers ()

get_status_code ()

get_status_message ()

invoke_async (cancellable, callback, *user_data)

invoke_finish (result)

lookup_header (header)

lookup_param (name)

lookup_response_header (header)

remove_header (header)

remove_param (name)

serialize_params ()

set_function (function)

set_method (method)

sync ()

upload (callback, weak_object, *userdata)

Virtual Methods

Inherited:

GObject.Object (7)

do_prepare ()

do_serialize_params ()

Properties

Name

Type

Flags

Short Description

proxy

Rest.Proxy

r/w/co

Proxy for this call

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Rest.ProxyCall(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Rest.ProxyCallClass

Rest.ProxyCall has no publicly available members.

add_header(header, value)
Parameters:
  • header (str) – The name of the header to set

  • value (str) – The value of the header

Add a header called header with the value value to the call. If a header with this name already exists, the new value will replace the old.

add_param(name, value)
Parameters:
  • name (str) – The name of the parameter to set

  • value (str) – The value of the parameter

Add a query parameter called param with the string value value to the call. If a parameter with this name already exists, the new value will replace the old.

add_param_full(param)
Parameters:

param (Rest.Param) – A Rest.Param

Add a query parameter param to the call. If a parameter with this name already exists, the new value will replace the old.

get_function()
Returns:

The REST “function” for the current call, see also Rest.ProxyCall.set_function(). This string is owned by the Rest.ProxyCall and should not be freed.

Return type:

str

Get the REST function that is going to be called on the proxy.

New in version 0.7.92.

get_method()
Returns:

the HTTP method

Return type:

str

Get the HTTP method to use when making the call, for example GET or POST.

get_params()
Returns:

A Rest.Params.

Return type:

Rest.Params

Get the parameters as a Rest.Params of parameter names to values. The returned value is owned by the Rest.ProxyCall instance and should not be freed by the caller.

get_payload()
Returns:

A pointer to the payload. This is owned by Rest.ProxyCall and should not be freed.

Return type:

str

Get the return payload.

get_payload_length()
Returns:

the length of the payload in bytes.

Return type:

int

Get the length of the return payload.

get_response_headers()
Returns:

pointer to a hash table of headers. This hash table must not be changed. You should call GLib.HashTable.unref() when you have finished with it.

Return type:

{str: str}

get_status_code()
Return type:

int

Get the HTTP status code for the call.

get_status_message()
Returns:

The status message. This string is owned by Rest.ProxyCall and should not be freed.

Return type:

str

Get the human-readable HTTP status message for the call.

invoke_async(cancellable, callback, *user_data)
Parameters:
invoke_finish(result)
Parameters:

result (Gio.AsyncResult) – the result from the Gio.AsyncReadyCallback

Raises:

GLib.Error

Returns:

True on success

Return type:

bool

lookup_header(header)
Parameters:

header (str) – The header name

Returns:

The header value, or None if it does not exist. This string is owned by the Rest.ProxyCall and should not be freed.

Return type:

str

Get the value of the header called header.

lookup_param(name)
Parameters:

name (str) – The paramter name

Returns:

The parameter value, or None if it does not exist. This string is owned by the Rest.ProxyCall and should not be freed.

Return type:

Rest.Param or None

Get the value of the parameter called name.

lookup_response_header(header)
Parameters:

header (str) – The name of the header to lookup.

Return type:

str

Get the string value of the header header or None if that header is not present or there are no headers.

remove_header(header)
Parameters:

header (str) – The header name

Remove the header named header from the call.

remove_param(name)
Parameters:

name (str) – The paramter name

Remove the parameter named name from the call.

serialize_params()
Raises:

GLib.Error

Returns:

True if the serialization was successful, False otherwise.

content_type:

Content type of the payload

content:

The payload

content_len:

Length of the payload data

Return type:

(bool, content_type: str, content: str, content_len: int)

Invoker for a virtual method to serialize the parameters for this Rest.ProxyCall.

set_function(function)
Parameters:

function (str) – The function to call

Set the REST “function” to call on the proxy. This is appended to the URL, so that for example a proxy with the URL http://www.example.com/ and the function test would actually access the URL http://www.example.com/test

set_method(method)
Parameters:

method (str) – The HTTP method to use

Set the HTTP method to use when making the call, for example GET or POST.

sync()
Raises:

GLib.Error

Returns:

True on success, False if a failure occurred, in which case error_out will be set.

Return type:

bool

Synchronously invokes self. After this function has returned, Rest.ProxyCall.get_payload() will return the result of this call.

Note that this will block an undefined amount of time, so Rest.ProxyCall.invoke_async() is generally recommended.

upload(callback, weak_object, *userdata)
Parameters:
Raises:

GLib.Error

Return type:

bool

Asynchronously invoke self but expect to have the callback invoked every time a chunk of our request’s body is written.

When the callback is invoked with the uploaded byte count equaling the message byte count, the call has completed.

If weak_object is disposed during the call then this call will be cancelled. If the call is cancelled then the callback will be invoked with an error state.

You may unref the call after calling this function since there is an internal reference, or you may unref in the callback.

do_prepare() virtual
Return type:

bool

do_serialize_params() virtual
Returns:

True if the serialization was successful, False otherwise.

content_type:

Content type of the payload

content:

The payload

content_len:

Length of the payload data

Return type:

(bool, content_type: str, content: str, content_len: int)

Invoker for a virtual method to serialize the parameters for this Rest.ProxyCall.

Property Details

Rest.ProxyCall.props.proxy
Name:

proxy

Type:

Rest.Proxy

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Proxy for this call