libcloud.common.linode module

class libcloud.common.linode.LinodeConnection(key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]

Bases: ConnectionKey

A connection to the Linode API

Wraps SSL connections to the Linode API, automagically injecting the parameters that the API needs for each request.

Initialize user_id and key; set secure to an int based on passed value.

add_default_params(params)[source]

Add parameters that are necessary for every request

This method adds api_key and api_responseFormat to the request.

host: str = 'api.linode.com'
responseCls

alias of LinodeResponse

class libcloud.common.linode.LinodeConnectionV4(key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]

Bases: ConnectionKey

A connection to the Linode API

Wraps SSL connections to the Linode API

Initialize user_id and key; set secure to an int based on passed value.

add_default_headers(headers)[source]

Add headers that are necessary for every request

This method adds token to the request.

add_default_params(params)[source]

Add parameters that are necessary for every request

This method adds page_size to the request to reduce the total number of paginated requests to the API.

host: str = 'api.linode.com'
responseCls

alias of LinodeResponseV4

class libcloud.common.linode.LinodeDisk(id, state, name, filesystem, driver, size, extra=None)[source]

Bases: BaseObject

exception libcloud.common.linode.LinodeException(code, message)[source]

Bases: Exception

Error originating from the Linode API

This class wraps a Linode API error, a list of which is available in the API documentation. All Linode API errors are a numeric code and a human-readable description.

exception libcloud.common.linode.LinodeExceptionV4(message)[source]

Bases: Exception

class libcloud.common.linode.LinodeIPAddress(inet, public, version, driver, extra=None)[source]

Bases: object

class libcloud.common.linode.LinodeResponse(response, connection)[source]

Bases: JsonResponse

Linode API response

Wraps the HTTP response returned by the Linode API.

libcloud does not take advantage of batching, so a response will always reflect the above format. A few weird quirks are caught here as well.

Instantiate a LinodeResponse from the HTTP response

Parameters:

response – The raw response returned by urllib

Returns:

parsed LinodeResponse

objects = None
parse_body()[source]

Parse the body of the response into JSON objects

If the response chokes the parser, action and data will be returned as None and errorarray will indicate an invalid JSON exception.

Returns:

list of objects and list of errors

success()[source]

Check the response for success

The way we determine success is by the presence of an error in ERRORARRAY. If one is there, we assume the whole request failed.

Returns:

bool indicating a successful request

class libcloud.common.linode.LinodeResponseV4(response, connection)[source]

Bases: JsonResponse

Parameters:
  • response (httplib.HTTPResponse) – HTTP response object. (optional)

  • connection (Connection) – Parent connection object.

parse_body()[source]

Parse the body of the response into JSON objects :return: dict of objects

parse_error()[source]

Parse the error body and raise the appropriate exception

success()[source]

Check the response for success :return: bool indicating a successful request

valid_response_codes = [<HTTPStatus.OK: 200>, <HTTPStatus.NO_CONTENT: 204>]