azure.mgmt.core.policies package

class azure.mgmt.core.policies.ARMAutoResourceProviderRegistrationPolicy[source]

Auto register an ARM resource provider if not done yet.

send(request: PipelineRequest[HttpRequest | HttpRequest]) PipelineResponse[HttpRequest | HttpRequest, HttpResponse | HttpResponse][source]

Abstract send method for a synchronous pipeline. Mutates the request.

Context content is dependent on the HttpTransport.

Parameters:

request (PipelineRequest) – The pipeline request object

Returns:

The pipeline response object.

Return type:

PipelineResponse

next: HTTPPolicy[HttpRequest | HttpRequest, HttpResponse | HttpResponse]

Pointer to the next policy or a transport (wrapped as a policy). Will be set at pipeline creation.

class azure.mgmt.core.policies.ARMChallengeAuthenticationPolicy(credential: TokenCredential | SupportsTokenInfo, *scopes: str, **kwargs: Any)[source]

Adds a bearer token Authorization header to requests.

This policy internally handles Continuous Access Evaluation (CAE) challenges. When it can’t complete a challenge, it will return the 401 (unauthorized) response from ARM.

Parameters:
  • credential (TokenCredential) – credential for authorizing requests

  • scopes (str) – required authentication scopes

authorize_request(request: PipelineRequest[HTTPRequestType], *scopes: str, **kwargs: Any) None

Acquire a token from the credential and authorize the request with it.

Keyword arguments are passed to the credential’s get_token method. The token will be cached and used to authorize future requests.

Parameters:
  • request (PipelineRequest) – the request

  • scopes (str) – required scopes of authentication

on_challenge(request: PipelineRequest[HttpRequest | HttpRequest], response: PipelineResponse[HttpRequest | HttpRequest, HttpResponse | HttpResponse]) bool[source]

Authorize request according to an ARM authentication challenge

Parameters:
Returns:

a bool indicating whether the policy should send the request

Return type:

bool

on_exception(request: PipelineRequest[HTTPRequestType]) None

Executed when an exception is raised while executing the next policy.

This method is executed inside the exception handler.

Parameters:

request (PipelineRequest) – The Pipeline request object

on_request(request: PipelineRequest[HTTPRequestType]) None

Called before the policy sends a request.

The base implementation authorizes the request with a bearer token.

Parameters:

request (PipelineRequest) – the request

on_response(request: PipelineRequest[HTTPRequestType], response: PipelineResponse[HTTPRequestType, HTTPResponseType]) None

Executed after the request comes back from the next policy.

Parameters:
send(request: PipelineRequest[HTTPRequestType]) PipelineResponse[HTTPRequestType, HTTPResponseType]

Authorize request with a bearer token and send it to the next policy

Parameters:

request (PipelineRequest) – The pipeline request object

Returns:

The pipeline response object

Return type:

PipelineResponse

next: HTTPPolicy[HTTPRequestType, HTTPResponseType]

Pointer to the next policy or a transport (wrapped as a policy). Will be set at pipeline creation.

class azure.mgmt.core.policies.ARMHttpLoggingPolicy(logger: Logger | None = None, **kwargs: Any)[source]

HttpLoggingPolicy with ARM specific safe headers fopr loggers.

on_exception(request: PipelineRequest[HTTPRequestType]) None

Is executed if an exception is raised while executing the next policy.

This method is executed inside the exception handler.

Parameters:

request (PipelineRequest) – The Pipeline request object

on_request(request: PipelineRequest[HttpRequest | HttpRequest]) None

Logs HTTP method, url and headers. :param request: The PipelineRequest object. :type request: ~azure.core.pipeline.PipelineRequest

on_response(request: PipelineRequest[HttpRequest | HttpRequest], response: PipelineResponse[HttpRequest | HttpRequest, _HttpResponseBase | _HttpResponseBase]) None

Is executed after the request comes back from the policy.

Parameters:
DEFAULT_HEADERS_ALLOWLIST: Set[str] = {'Accept', 'Cache-Control', 'Connection', 'Content-Length', 'Content-Type', 'Date', 'ETag', 'Expires', 'If-Match', 'If-Modified-Since', 'If-None-Match', 'If-Unmodified-Since', 'Last-Modified', 'Pragma', 'Request-Id', 'Retry-After', 'Server', 'Transfer-Encoding', 'User-Agent', 'WWW-Authenticate', 'traceparent', 'x-ms-client-request-id', 'x-ms-error-code', 'x-ms-ratelimit-remaining-resource', 'x-ms-ratelimit-remaining-subscription-reads', 'x-ms-ratelimit-remaining-subscription-resource-entities-read', 'x-ms-ratelimit-remaining-subscription-resource-requests', 'x-ms-ratelimit-remaining-subscription-writes', 'x-ms-ratelimit-remaining-tenant-reads', 'x-ms-ratelimit-remaining-tenant-resource-entities-read', 'x-ms-ratelimit-remaining-tenant-resource-requests', 'x-ms-ratelimit-remaining-tenant-writes', 'x-ms-request-charge', 'x-ms-request-id', 'x-ms-return-client-request-id', 'x-msedge-ref', 'x-vss-e2eid'}
MULTI_RECORD_LOG: str = 'AZURE_SDK_LOGGING_MULTIRECORD'
REDACTED_PLACEHOLDER: str = 'REDACTED'
class azure.mgmt.core.policies.AsyncARMAutoResourceProviderRegistrationPolicy[source]

Auto register an ARM resource provider if not done yet.

async send(request: PipelineRequest[HttpRequest | HttpRequest]) PipelineResponse[HttpRequest | HttpRequest, AsyncHttpResponse | AsyncHttpResponse][source]

Abstract send method for a asynchronous pipeline. Mutates the request.

Context content is dependent on the HttpTransport.

Parameters:

request (PipelineRequest) – The pipeline request object.

Returns:

The pipeline response object.

Return type:

PipelineResponse

next: AsyncHTTPPolicy[HttpRequest | HttpRequest, AsyncHttpResponse | AsyncHttpResponse]

Pointer to the next policy or a transport (wrapped as a policy). Will be set at pipeline creation.

class azure.mgmt.core.policies.AsyncARMChallengeAuthenticationPolicy(credential: AsyncTokenCredential | AsyncSupportsTokenInfo, *scopes: str, **kwargs: Any)[source]

Adds a bearer token Authorization header to requests.

This policy internally handles Continuous Access Evaluation (CAE) challenges. When it can’t complete a challenge, it will return the 401 (unauthorized) response from ARM.

Parameters:
  • credential (TokenCredential) – credential for authorizing requests

  • scopes (str) – required authentication scopes

async authorize_request(request: PipelineRequest[HTTPRequestType], *scopes: str, **kwargs: Any) None

Acquire a token from the credential and authorize the request with it.

Keyword arguments are passed to the credential’s get_token method. The token will be cached and used to authorize future requests.

Parameters:
  • request (PipelineRequest) – the request

  • scopes (str) – required scopes of authentication

async on_challenge(request: PipelineRequest[HttpRequest | HttpRequest], response: PipelineResponse[HttpRequest | HttpRequest, AsyncHttpResponse | AsyncHttpResponse]) bool[source]

Authorize request according to an ARM authentication challenge

Parameters:
Returns:

a bool indicating whether the policy should send the request

Return type:

bool

on_exception(request: PipelineRequest[HTTPRequestType]) None

Executed when an exception is raised while executing the next policy.

This method is executed inside the exception handler.

Parameters:

request (PipelineRequest) – The Pipeline request object

async on_request(request: PipelineRequest[HTTPRequestType]) None

Adds a bearer token Authorization header to request and sends request to next policy.

Parameters:

request (PipelineRequest) – The pipeline request object to be modified.

Raises:

ServiceRequestError

on_response(request: PipelineRequest[HTTPRequestType], response: PipelineResponse[HTTPRequestType, AsyncHTTPResponseType]) Awaitable[None] | None

Executed after the request comes back from the next policy.

Parameters:
async send(request: PipelineRequest[HTTPRequestType]) PipelineResponse[HTTPRequestType, AsyncHTTPResponseType]

Authorize request with a bearer token and send it to the next policy

Parameters:

request (PipelineRequest) – The pipeline request object

Returns:

The pipeline response object

Return type:

PipelineResponse

next: AsyncHTTPPolicy[HTTPRequestType, AsyncHTTPResponseType]

Pointer to the next policy or a transport (wrapped as a policy). Will be set at pipeline creation.

class azure.mgmt.core.policies.AsyncAuxiliaryAuthenticationPolicy(auxiliary_credentials: Sequence[TokenCredentialType], *scopes: str, **kwargs: Any)[source]
on_exception(request: PipelineRequest[HttpRequest | HttpRequest]) None[source]

Executed when an exception is raised while executing the next policy.

This method is executed inside the exception handler.

Parameters:

request (PipelineRequest) – The Pipeline request object

async on_request(request: PipelineRequest[HttpRequest | HttpRequest]) None[source]

Called before the policy sends a request.

The base implementation authorizes the request with an auxiliary authorization token.

Parameters:

request (PipelineRequest) – the request

on_response(request: PipelineRequest[HttpRequest | HttpRequest], response: PipelineResponse[HttpRequest | HttpRequest, AsyncHttpResponse | AsyncHttpResponse]) Awaitable[None] | None[source]

Executed after the request comes back from the next policy.

Parameters:
async send(request: PipelineRequest[HttpRequest | HttpRequest]) PipelineResponse[HttpRequest | HttpRequest, AsyncHttpResponse | AsyncHttpResponse][source]

Authorize request with a bearer token and send it to the next policy

Parameters:

request (PipelineRequest) – The pipeline request object

Returns:

The pipeline response object

Return type:

PipelineResponse

next: AsyncHTTPPolicy[HttpRequest | HttpRequest, AsyncHttpResponse | AsyncHttpResponse]

Pointer to the next policy or a transport (wrapped as a policy). Will be set at pipeline creation.

class azure.mgmt.core.policies.AuxiliaryAuthenticationPolicy(auxiliary_credentials: Sequence[TokenCredentialType], *scopes: str, **kwargs: Any)[source]
on_exception(request: PipelineRequest[HTTPRequestType]) None

Is executed if an exception is raised while executing the next policy.

This method is executed inside the exception handler.

Parameters:

request (PipelineRequest) – The Pipeline request object

on_request(request: PipelineRequest[HttpRequest | HttpRequest]) None[source]

Called before the policy sends a request.

The base implementation authorizes the request with an auxiliary authorization token.

Parameters:

request (PipelineRequest) – the request

on_response(request: PipelineRequest[HTTPRequestType], response: PipelineResponse[HTTPRequestType, HTTPResponseType]) None | Awaitable[None]

Is executed after the request comes back from the policy.

Parameters: