libcloud.common.vultr module

class libcloud.common.vultr.VultrConnection(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 Vultr API

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

add_default_headers(headers)[source]

Returns default headers such as content-type. Returns a dictionary.

add_default_params(params)[source]

Returns default params such as api_key which is needed to perform an action.Returns a dictionary. Example:/v1/server/upgrade_plan?api_key=self.key

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

alias of VultrResponse

set_path()[source]
class libcloud.common.vultr.VultrConnectionV2(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 Vultr API v2

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

add_default_headers(headers)[source]

Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers

Should return a dictionary.

add_default_params(params)[source]

Adds default parameters (such as API key, version, etc.) to the passed params

Should return a dictionary.

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

alias of VultrResponseV2

exception libcloud.common.vultr.VultrException(code, message)[source]

Bases: Exception

Error originating from the Vultr API

class libcloud.common.vultr.VultrNetwork(id: str, cidr_block: str, location: str, extra: Dict[str, Any] | None = None)[source]

Bases: object

Represents information about a Vultr private network.

class libcloud.common.vultr.VultrNodeSnapshot(id: str, driver: NodeDriver, size: int | None = None, extra: Dict | None = None, created: datetime | None = None, state: StorageVolumeState | None = None, name: str | None = None)[source]

Bases: VolumeSnapshot

VolumeSnapshot constructor.

Parameters:
  • id (str) – Snapshot ID.

  • driver (NodeDriver) – The driver that represents a connection to the provider

  • size (int) – A snapshot size in GB.

  • extra (dict) – Provider depends parameters for snapshot.

  • created (datetime.datetime) – A datetime object that represents when the snapshot was created

  • state (StorageVolumeState) – A string representing the state the snapshot is in. See libcloud.compute.types.StorageVolumeState.

  • name (str) – A string representing the name of the snapshot

class libcloud.common.vultr.VultrResponse(response, connection)[source]

Bases: JsonResponse

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

  • connection (Connection) – Parent connection object.

ERROR_CODE_MAP = {400: 'Invalid API location. Check the URL that you are using.', 403: 'Invalid or missing API key. Check that your API key is present and matches your assigned key.', 405: 'Invalid HTTP method. Check that the method (POST|GET) matches what the documentation indicates.', 412: 'Request failed. Check the response body for a more detailed description.', 500: 'Internal server error. Try again at a later time.', 503: 'Rate limit hit. API requests are limited to an average of 1/s. Try your request again later.'}
error_dict: Dict[str, str] = {}
errors = None
objects = None
parse_body_and_errors()[source]

Returns JSON data in a python list.

success()[source]

Determine if our request was successful.

The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?

Return type:

bool

Returns:

True or False

class libcloud.common.vultr.VultrResponseV2(response, connection)[source]

Bases: JsonResponse

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

  • connection (Connection) – Parent connection object.

parse_error()[source]

Parse the error body and raise the appropriate exception

success()[source]

Check the response for success

Returns:

bool indicating a successful request

valid_response_codes = [<HTTPStatus.OK: 200>, <HTTPStatus.CREATED: 201>, <HTTPStatus.ACCEPTED: 202>, <HTTPStatus.NO_CONTENT: 204>]