azure.core package

Submodules

azure.core.async_paging module

class azure.core.async_paging.AsyncItemPaged(*args, **kwargs)[source]

Bases: AsyncIterator[azure.core.async_paging.ReturnType]

Return an async iterator of items.

args and kwargs will be passed to the AsyncPageIterator constructor directly, except page_iterator_class

by_page(continuation_token: Optional[str] = None) → AsyncIterator[AsyncIterator[ReturnType]][source]

Get an async iterator of pages of objects, instead of an async iterator of objects.

Parameters

continuation_token (str) – An opaque continuation token. This value can be retrieved from the continuation_token field of a previous generator object. If specified, this generator will begin returning results from this point.

Returns

An async iterator of pages (themselves async iterator of objects)

class azure.core.async_paging.AsyncPageIterator(get_next: Callable[[Optional[str]], Awaitable[ResponseType]], extract_data: Callable[[ResponseType], Awaitable[Tuple[str, AsyncIterator[ReturnType]]]], continuation_token: Optional[str] = None)[source]

Bases: AsyncIterator[AsyncIterator[azure.core.async_paging.ReturnType]]

Return an async iterator of pages.

Parameters
  • get_next – Callable that take the continuation token and return a HTTP response

  • extract_data – Callable that take an HTTP response and return a tuple continuation token, list of ReturnType

  • continuation_token (str) – The continuation token needed by get_next

azure.core.credentials module

class azure.core.credentials.AccessToken(token, expires_on)

Bases: tuple

Create new instance of AccessToken(token, expires_on)

expires_on

Alias for field number 1

token

Alias for field number 0

class azure.core.credentials.AzureKeyCredential(key: str)[source]

Bases: object

Credential type used for authenticating to an Azure service. It provides the ability to update the key without creating a new client.

Parameters

key (str) – The key used to authenticate to an Azure service

Raises

TypeError

update(key: str) → None[source]

Update the key.

This can be used when you’ve regenerated your service key and want to update long-lived clients.

Parameters

key (str) – The key used to authenticate to an Azure service

Raises

ValueError or TypeError

property key

The value of the configured key.

Return type

str

azure.core.exceptions module

exception azure.core.exceptions.AzureError(message, *args, **kwargs)[source]

Bases: Exception

Base exception for all errors.

Parameters

message – The message object stringified as ‘message’ attribute

Keyword Arguments

error (Exception) – The original exception if any

Variables
  • inner_exception – The exception passed with the ‘error’ kwarg

  • exc_type – The exc_type from sys.exc_info()

  • exc_value – The exc_value from sys.exc_info()

  • exc_traceback – The exc_traceback from sys.exc_info()

  • exc_msg – A string formatting of message parameter, exc_type and exc_value

  • message (str) – A stringified version of the message parameter

raise_with_traceback()[source]
exception azure.core.exceptions.ClientAuthenticationError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

An error response with status code 4xx. This will not be raised directly by the Azure core pipeline.

exception azure.core.exceptions.DecodeError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

Error raised during response deserialization.

exception azure.core.exceptions.HttpResponseError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.AzureError

A request was made, and a non-success status code was received from the service.

Parameters
  • message (string) – HttpResponse’s error message

  • response (HttpResponse or AsyncHttpResponse) – The response that triggered the exception.

Variables
  • reason – The HTTP response reason

  • status_code – HttpResponse’s status code

  • response – The response that triggered the exception.

exception azure.core.exceptions.ODataV4Error(response: _HttpResponseBase, **kwargs: Any)[source]

Bases: azure.core.exceptions.HttpResponseError

An HTTP response error where the JSON is decoded as OData V4 error format.

http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html#_Toc372793091

Variables
  • odata_json (dict) – The parsed JSON body as attribute for convenience.

  • code (str) – Its value is a service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response.

  • message (str) – Human-readable, language-dependent representation of the error.

  • target (str) – The target of the particular error (for example, the name of the property in error). This field is optional and may be None.

  • details (list[ODataV4Format]) – Array of ODataV4Format instances that MUST contain name/value pairs for code and message, and MAY contain a name/value pair for target, as described above.

  • innererror (dict) – An object. The contents of this object are service-defined. Usually this object contains information that will help debug the service.

exception azure.core.exceptions.ResourceExistsError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

An error response with status code 4xx. This will not be raised directly by the Azure core pipeline.

exception azure.core.exceptions.ResourceModifiedError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

An error response with status code 4xx, typically 412 Conflict. This will not be raised directly by the Azure core pipeline.

exception azure.core.exceptions.ResourceNotFoundError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

An error response, typically triggered by a 412 response (for update) or 404 (for get/post)

exception azure.core.exceptions.ResourceNotModifiedError(message=None, response=None, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

An error response with status code 304. This will not be raised directly by the Azure core pipeline.

exception azure.core.exceptions.ServiceRequestError(message, *args, **kwargs)[source]

Bases: azure.core.exceptions.AzureError

An error occurred while attempt to make a request to the service. No request was sent.

exception azure.core.exceptions.ServiceResponseError(message, *args, **kwargs)[source]

Bases: azure.core.exceptions.AzureError

The request was sent, but the client failed to understand the response. The connection may have timed out. These errors can be retried for idempotent or safe operations

exception azure.core.exceptions.TooManyRedirectsError(history, *args, **kwargs)[source]

Bases: azure.core.exceptions.HttpResponseError

Reached the maximum number of redirect attempts.

class azure.core.exceptions.ODataV4Format(json_object)[source]

Bases: object

Class to describe OData V4 error format.

http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html#_Toc372793091

Parameters

json_object (dict) – A Python dict representing a ODataV4 JSON

Variables
  • code (str) – Its value is a service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response.

  • message (str) – Human-readable, language-dependent representation of the error.

  • target (str) – The target of the particular error (for example, the name of the property in error). This field is optional and may be None.

  • details (list[ODataV4Format]) – Array of ODataV4Format instances that MUST contain name/value pairs for code and message, and MAY contain a name/value pair for target, as described above.

  • innererror (dict) – An object. The contents of this object are service-defined. Usually this object contains information that will help debug the service.

message_details()[source]

Return a detailled string of the error.

CODE_LABEL = 'code'
DETAILS_LABEL = 'details'
INNERERROR_LABEL = 'innererror'
MESSAGE_LABEL = 'message'
TARGET_LABEL = 'target'
property error

azure.core.paging module

class azure.core.paging.ItemPaged(*args, **kwargs)[source]

Bases: Iterator[azure.core.paging.ReturnType]

Return an iterator of items.

args and kwargs will be passed to the PageIterator constructor directly, except page_iterator_class

by_page(continuation_token: Optional[str] = None) → Iterator[Iterator[ReturnType]][source]

Get an iterator of pages of objects, instead of an iterator of objects.

Parameters

continuation_token (str) – An opaque continuation token. This value can be retrieved from the continuation_token field of a previous generator object. If specified, this generator will begin returning results from this point.

Returns

An iterator of pages (themselves iterator of objects)

next()

Return the next item from the iterator. When exhausted, raise StopIteration

class azure.core.paging.PageIterator(get_next, extract_data, continuation_token=None)[source]

Bases: Iterator[Iterator[azure.core.paging.ReturnType]]

Return an iterator of pages.

Parameters
  • get_next – Callable that take the continuation token and return a HTTP response

  • extract_data – Callable that take an HTTP response and return a tuple continuation token, list of ReturnType

  • continuation_token (str) – The continuation token needed by get_next

next() → Iterator[ReturnType]

Return the next item from the iterator. When exhausted, raise StopIteration

azure.core.settings module

Module contents