l.c.b.PollingConnection(Connection) : class documentation

Part of libcloud.common.base View Source View In Hierarchy

Known subclasses: libcloud.common.cloudstack.CloudStackConnection, libcloud.dns.drivers.rackspace.RackspaceDNSConnection, libcloud.loadbalancer.drivers.rackspace.RackspaceConnection

Connection class which can also work with the async APIs.

After initial requests, this class periodically polls for jobs status and waits until the job has finished. If job doesn't finish in timeout seconds, an Exception thrown.

Method async_request No summary
Method get_request_kwargs Arguments which are passed to the initial request() call inside async_request.
Method get_poll_request_kwargs Return keyword arguments which are passed to the request() method when polling for the job status.
Method has_completed Return job completion status.

Inherited from Connection:

Method __init__ Undocumented
Method set_context Undocumented
Method connect Establish a connection with the API server.
Method user_agent_append Append a token to a user agent string.
Method request Request a given `action`.
Method morph_action_hook Undocumented
Method add_default_params Adds default parameters (such as API key, version, etc.) to the passed `params`
Method add_default_headers Adds default headers (such as Authorization, X-Foo-Bar) to the passed `headers`
Method pre_connect_hook A hook which is called before connecting to the remote server. This hook can perform a final manipulation on the params, headers and url parameters.
Method encode_data Encode body data.
Method _tuple_from_url Undocumented
Method _user_agent Undocumented
def async_request(self, action, params=None, data='', headers=None, method='GET', context=None): (source)
Perform an 'async' request to the specified path. Keep in mind that
this function is *blocking* and 'async' in this case means that the
hit URL only returns a job ID which is the periodically polled until
the job has completed.

This function works like this:

- Perform a request to the specified path. Response should contain a
  'job_id'.

- Returned 'job_id' is then used to construct a URL which is used for
  retrieving job status. Constructed URL is then periodically polled
  until the response indicates that the job has completed or the timeout
  of 'self.timeout' seconds has been reached.

@type action: C{str}
@param action: A path

@type params: C{dict}
@param params: Optional mapping of additional parameters to send. If
    None, leave as an empty C{dict}.

@type data: C{unicode}
@param data: A body of data to send with the request.

@type headers: C{dict}
@param headers: Extra headers to add to the request
    None, leave as an empty C{dict}.

@type method: C{str}
@param method: An HTTP method such as "GET" or "POST".

@type context: C{dict}
@param context: Context dictionary which is passed to the functions
which construct initial and poll URL.

@return: An instance of type I{responseCls}
def get_request_kwargs(self, action, params=None, data='', headers=None, method='GET', context=None): (source)
Arguments which are passed to the initial request() call inside async_request.
def get_poll_request_kwargs(self, response, context, request_kwargs): (source)
Return keyword arguments which are passed to the request() method when
polling for the job status.

@param response: Response object returned by poll request.
@type response: C{HTTPResponse}

@param request_kwargs: Kwargs previously used to initiate the
                          poll request.
@type response: C{dict}

@return C{dict} Keyword arguments
def has_completed(self, response): (source)
Return job completion status.

@param response: Response object returned by poll request.
@type response: C{HTTPResponse}

@return C{bool} True if the job has completed, False otherwise.
API Documentation for libcloud, generated by pydoctor at 2012-07-15 18:10:03.