libcloud.common.azure_arm module

class libcloud.common.azure_arm.AzureAuthJsonResponse(response, connection)[source]

Bases: JsonResponse

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

  • connection (Connection) – Parent connection object.

parse_error()[source]

Parse the error messages.

Override in a provider’s subclass.

Returns:

Parsed error.

Return type:

str

class libcloud.common.azure_arm.AzureBaseDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **kwargs)[source]

Bases: BaseDriver

Parameters:
  • key (str) – API key or username to be used (required)

  • secret (str) – Secret password to be used (required)

  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.

  • host (str) – Override hostname used for connections.

  • port (int) – Override port used for connections.

  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.

  • region (str) – Optional driver region. Only used by drivers which support multiple regions.

Return type:

None

name = 'Microsoft Azure Resource Management API'
class libcloud.common.azure_arm.AzureJsonResponse(response, connection)[source]

Bases: JsonResponse

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

  • connection (Connection) – Parent connection object.

parse_error()[source]

Parse the error messages.

Override in a provider’s subclass.

Returns:

Parsed error.

Return type:

str

class libcloud.common.azure_arm.AzureResourceManagementConnection(key, secret, secure=True, tenant_id=None, subscription_id=None, cloud_environment=None, **kwargs)[source]

Bases: ConnectionUserAndKey

Represents a single connection to Azure

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.

conn_class

alias of LibcloudConnection

connect(**kwargs)[source]

Establish a connection with the API server.

Parameters:
  • host (str) – Optional host to override our default

  • port (int) – Optional port to override our default

Returns:

A connection

driver

alias of AzureBaseDriver

encode_data(data)[source]

Encode data to JSON

get_token_from_credentials()[source]

Log in and get bearer token used to authorize API requests.

name = 'Azure AD Auth'
rawResponseCls

alias of RawResponse

request(action, params=None, data=None, headers=None, method='GET', raw=False)[source]

Request a given action.

Basically a wrapper around the connection object’s request that does some helpful pre-processing.

Parameters:
  • action (str) – A path. This can include arguments. If included, any extra parameters are appended to the existing ones.

  • params (dict) – Optional mapping of additional parameters to send. If None, leave as an empty dict.

  • data (unicode) – A body of data to send with the request.

  • headers (dict) – Extra headers to add to the request None, leave as an empty dict.

  • method (str) – An HTTP method such as “GET” or “POST”.

  • raw (bool) – True to perform a “raw” request aka only send the headers and use the rawResponseCls class. This is used with storage API when uploading a file.

  • stream (bool) – True to return an iterator in Response.iter_content and allow streaming of the response data (for downloading large files)

  • retry_failed – True if failed requests should be retried. This argument can override module level constant and environment variable value on per-request basis.

Returns:

An Response instance.

Return type:

Response instance

responseCls

alias of AzureJsonResponse