azure.mgmt.core package

class azure.mgmt.core.ARMPipelineClient(base_url: str, **kwargs: Any)[source]

A pipeline client designed for ARM explicitly.

Parameters:

base_url (str) – URL for the request.

Keyword Arguments:
  • pipeline (Pipeline) – If omitted, a Pipeline object is created and returned.

  • policies (list[HTTPPolicy]) – If omitted, the standard policies of the configuration object is used.

  • per_call_policies (Union[HTTPPolicy, SansIOHTTPPolicy, list[HTTPPolicy], list[SansIOHTTPPolicy]]) – If specified, the policies will be added into the policy list before RetryPolicy

  • per_retry_policies (Union[HTTPPolicy, SansIOHTTPPolicy, list[HTTPPolicy], list[SansIOHTTPPolicy]]) – If specified, the policies will be added into the policy list after RetryPolicy

  • transport (HttpTransport) – If omitted, RequestsTransport is used for synchronous transport.

close() None
delete(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) HttpRequest

Create a DELETE request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

format_url(url_template: str, **kwargs: Any) str

Format request URL with the client base URL, unless the supplied URL is already absolute.

Note that both the base url and the template url can contain query parameters.

Parameters:

url_template (str) – The request URL to be formatted if necessary.

Return type:

str

Returns:

The formatted URL.

get(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) HttpRequest

Create a GET request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

head(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a HEAD request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

merge(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) HttpRequest

Create a MERGE request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

options(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, *, content: bytes | str | Dict[Any, Any] | None = None, form_content: Dict[Any, Any] | None = None, **kwargs: Any) HttpRequest

Create a OPTIONS request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

Keyword Arguments:
  • content – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

patch(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a PATCH request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

post(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a POST request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

put(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a PUT request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

send_request(request: HTTPRequestType, *, stream: bool = False, **kwargs: Any) HTTPResponseType

Method that runs the network request through the client’s chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
Parameters:

request (HttpRequest) – The network request you want to make. Required.

Keyword Arguments:

stream (bool) – Whether the response payload will be streamed. Defaults to False.

Returns:

The response of your network call. Does not do error handling on your response.

Return type:

HttpResponse

class azure.mgmt.core.AsyncARMPipelineClient(base_url: str, **kwargs: Any)[source]

A pipeline client designed for ARM explicitly.

Parameters:

base_url (str) – URL for the request.

Keyword Arguments:
  • pipeline (AsyncPipeline) – If omitted, a Pipeline object is created and returned.

  • policies (list[AsyncHTTPPolicy]) – If omitted, the standard policies of the configuration object is used.

  • per_call_policies (Union[AsyncHTTPPolicy, SansIOHTTPPolicy, list[AsyncHTTPPolicy], list[SansIOHTTPPolicy]]) – If specified, the policies will be added into the policy list before RetryPolicy

  • per_retry_policies (Union[AsyncHTTPPolicy, SansIOHTTPPolicy, list[AsyncHTTPPolicy], list[SansIOHTTPPolicy]]) – If specified, the policies will be added into the policy list after RetryPolicy

  • transport (AsyncHttpTransport) – If omitted, AioHttpTransport is used for asynchronous transport.

async close() None
delete(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) HttpRequest

Create a DELETE request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

format_url(url_template: str, **kwargs: Any) str

Format request URL with the client base URL, unless the supplied URL is already absolute.

Note that both the base url and the template url can contain query parameters.

Parameters:

url_template (str) – The request URL to be formatted if necessary.

Return type:

str

Returns:

The formatted URL.

get(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) HttpRequest

Create a GET request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

head(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a HEAD request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

merge(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) HttpRequest

Create a MERGE request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

options(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, *, content: bytes | str | Dict[Any, Any] | None = None, form_content: Dict[Any, Any] | None = None, **kwargs: Any) HttpRequest

Create a OPTIONS request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

Keyword Arguments:
  • content – The body content

  • form_content (dict) – Form content

Returns:

An HttpRequest object

Return type:

HttpRequest

patch(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a PATCH request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

post(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a POST request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

put(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) HttpRequest

Create a PUT request object.

Parameters:
  • url (str) – The request URL.

  • params (dict) – Request URL parameters.

  • headers (dict) – Headers

  • content (bytes or str or dict) – The body content

  • form_content (dict) – Form content

  • stream_content (stream or generator or asyncgenerator) – The body content as a stream

Returns:

An HttpRequest object

Return type:

HttpRequest

send_request(request: HTTPRequestType, *, stream: bool = False, **kwargs: Any) Awaitable[AsyncHTTPResponseType]

Method that runs the network request through the client’s chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>
Parameters:

request (HttpRequest) – The network request you want to make. Required.

Keyword Arguments:

stream (bool) – Whether the response payload will be streamed. Defaults to False.

Returns:

The response of your network call. Does not do error handling on your response.

Return type:

AsyncHttpResponse

Subpackages

Submodules

azure.mgmt.core.exceptions module

class azure.mgmt.core.exceptions.ARMErrorFormat(json_object: Mapping[str, Any])[source]

Describe error format from ARM, used at the base or inside “details” node.

This format is compatible with ODataV4 format. https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-details.md#error-response-content

message_details() str

Return a detailed string of the error.

Returns:

A string with the details of the error.

Return type:

str

CODE_LABEL = 'code'
DETAILS_LABEL = 'details'
INNERERROR_LABEL = 'innererror'
MESSAGE_LABEL = 'message'
TARGET_LABEL = 'target'
property error: SelfODataV4Format
class azure.mgmt.core.exceptions.TypedErrorInfo(type: str, info: Mapping[str, Any])[source]

Additional info class defined in ARM specification.

https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-details.md#error-response-content

azure.mgmt.core.tools module

azure.mgmt.core.tools.get_arm_endpoints(cloud_setting: AzureClouds) Dict[str, Any][source]

Get the ARM endpoint and ARM credential scopes for the given cloud setting.

Parameters:

cloud_setting (AzureClouds) – The cloud setting for which to get the ARM endpoint.

Returns:

The ARM endpoint and ARM credential scopes.

Return type:

dict[str, Any]

azure.mgmt.core.tools.is_valid_resource_id(rid: str, exception_type: Type[BaseException] | None = None) bool[source]

Validates the given resource id.

Parameters:
  • rid (str) – The resource id being validated.

  • exception_type (Exception) – Raises this Exception if invalid.

Returns:

A boolean describing whether the id is valid.

Return type:

bool

azure.mgmt.core.tools.is_valid_resource_name(rname: str, exception_type: Type[BaseException] | None = None) bool[source]

Validates the given resource name to ARM guidelines, individual services may be more restrictive.

Parameters:
  • rname (str) – The resource name being validated.

  • exception_type (Exception) – Raises this Exception if invalid.

Returns:

A boolean describing whether the name is valid.

Return type:

bool

azure.mgmt.core.tools.parse_resource_id(rid: str) Mapping[str, str | int][source]

Parses a resource_id into its various parts.

Returns a dictionary with a single key-value pair, ‘name’: rid, if invalid resource id.

Parameters:

rid (str) – The resource id being parsed

Returns:

A dictionary with with following key/value pairs (if found):

  • subscription: Subscription id

  • resource_group: Name of resource group

  • namespace: Namespace for the resource provider (i.e. Microsoft.Compute)

  • type: Type of the root resource (i.e. virtualMachines)

  • name: Name of the root resource

  • child_namespace_{level}: Namespace for the child resource of that level

  • child_type_{level}: Type of the child resource of that level

  • child_name_{level}: Name of the child resource of that level

  • last_child_num: Level of the last child

  • resource_parent: Computed parent in the following pattern: providers/{namespace} /{parent}/{type}/{name}

  • resource_namespace: Same as namespace. Note that this may be different than the target resource’s namespace.

  • resource_type: Type of the target resource (not the parent)

  • resource_name: Name of the target resource (not the parent)

Return type:

dict[str,str]

azure.mgmt.core.tools.resource_id(**kwargs: str | None) str[source]

Create a valid resource id string from the given parts.

This method builds the resource id from the left until the next required id parameter to be appended is not found. It then returns the built up id.

Keyword Arguments:
  • subscription (str) – (required) Subscription id

  • resource_group (str) – Name of resource group

  • namespace (str) – Namespace for the resource provider (i.e. Microsoft.Compute)

  • type (str) – Type of the resource (i.e. virtualMachines)

  • name (str) – Name of the resource (or parent if child_name is also specified)

  • child_namespace_{level} (str) – Namespace for the child resource of that level (optional)

  • child_type_{level} (str) – Type of the child resource of that level

  • child_name_{level} (str) – Name of the child resource of that level

Returns:

A resource id built from the given arguments.

Return type:

str