Welcome to aioazure’s documentation!

aioazure

aioazure package

Subpackages

aioazure.interfaces package
class aioazure.interfaces.Proxy[source]

Bases: object

class aioazure.interfaces.ProxyDecorator(proxy: aioazure.interfaces._proxy.Proxy)[source]

Bases: aioazure.interfaces._proxy.Proxy

aioazure.resources package

Submodules

aioazure.auth module
class aioazure.auth.Authenticator(app_id: str, password: str, tenant_id: str)[source]

Bases: object

get_token() → str[source]
is_token_valid
aioazure.client module
class aioazure.client.AzureClient(api_url: str, subscription_id: str, resource_group_name: str, auth: aioazure.auth.Authenticator, timeout: int = 60)[source]

Bases: object

aioazure.decorator module
class aioazure.decorator.AsyncOperationDecorator(proxy: Proxy)[source]

Bases: aioazure.interfaces._decorator.ProxyDecorator

async_polling(url, retry_after)[source]
class aioazure.decorator.AuthDecorator(proxy: Proxy, auth: aioazure.auth.Authenticator)[source]

Bases: aioazure.interfaces._decorator.ProxyDecorator

class aioazure.decorator.PagingDecorator(proxy: Proxy)[source]

Bases: aioazure.interfaces._decorator.ProxyDecorator

static get_next_page(next_link: str)[source]
get_pages(response)[source]
class aioazure.decorator.ResponseDecorator(proxy: Proxy)[source]

Bases: aioazure.interfaces._decorator.ProxyDecorator

aioazure.proxy module
class aioazure.proxy.ApiProxy(api: simple_rest_client.api.API, auth: aioazure.auth.Authenticator)[source]

Bases: aioazure.interfaces._proxy.Proxy

add_resource(api_root_url=None, resource_name=None, resource_class=None, params=None, headers=None, timeout=None, append_slash=False, json_encode_body=False)[source]
class aioazure.proxy.ResourceProxy(resource: simple_rest_client.resource.AsyncResource)[source]

Bases: aioazure.interfaces._proxy.Proxy

pass_through_parameters = ['api_root_url', 'resource_name', 'params', 'headers', 'timeout', 'append_slash', 'json_encode_body', 'ssl_verify']

aioazure

aioazure is a simplistic python REST client for the Microsoft Azure REST API utilizing asyncio. The client itself has been developed against the Microsoft Azure REST API documentation.

Installation

The goal is to distribute this package via PyPi, so a simple

pip install aioazure

would be needed to install the package. The release will happen once the client has been tested with Azure.

How to use aioazure

from aioazure.auth import Authenticator
from aioazure.client import AzureClient

auth = Authenticator(app_id="your_app_id",
                     password="your_secret",
                     tenant_id="your_tenant_id")

client = AzureClient(api_url="url_of_the_azure_api",
                     subscription_id="your_subscription_id",
                     resource_group_name="your_resource_group_name",
                     auth=auth,
                     timeout=60)  # <- this is optional

await client.compute.virtualmachines.create_or_update("my-vm-name",
                                                      location="Antarctica")

await client.compute.virtualmachines.instance_view("my-vm-name")

await client.compute.virtualmachines.power_off("my-vm-name")

await client.compute.virtualmachines.delete("my-vm-name")

Currently supported Azure services, operation groups and operations

Adding further Azure services, operation groups and operations

Each Azure service (compute, storage services, etc.) is represented by a yaml file in the models directory. This yaml file contains mapping nodes for each operation group (virtualmachines, manageddisks, etc.). Each operation group consists of two mapping nodes, the version of api to use (api_version) and the supported operations (actions) in this operation group.

rest_operation_group:
  api_version: "2018-06-01"
  actions:
    action_1:
      method: GET
      url: Microsoft.Compute/rest_operations_group/{}
    ...
    action_n:
      method: POST
      url: Microsoft.Compute/rest_operations_group/{}
rest_operation_group_2:
  ...

The Azure service, operation groups and operation can than be called in Python as described below.

await client.<service_name>.<rest_operation_group>.<action>(args, kwargs)

In case you add additional services, operation groups and operations, please submit a pull request so that others can profit as well from the work you have done. Thank you!

Indices and tables