azure.core.pipeline¶
- class azure.core.pipeline.AsyncPipeline(transport: AsyncHttpTransport[HTTPRequestType, AsyncHTTPResponseType], policies: Iterable[AsyncHTTPPolicy[HTTPRequestType, AsyncHTTPResponseType] | SansIOHTTPPolicy[HTTPRequestType, AsyncHTTPResponseType]] | None = None)[source]¶
Async pipeline implementation.
This is implemented as a context manager, that will activate the context of the HTTP sender.
- Parameters:
transport (AsyncHttpTransport) – The async Http Transport instance.
policies (list) – List of configured policies.
Example:
from azure.core.pipeline import AsyncPipeline from azure.core.pipeline.policies import AsyncRedirectPolicy, UserAgentPolicy from azure.core.pipeline.transport import AioHttpTransport from azure.core.rest import HttpRequest # example: create request and policies request = HttpRequest("GET", "https://bing.com") policies: Iterable[Union[AsyncHTTPPolicy, SansIOHTTPPolicy]] = [ UserAgentPolicy("myuseragent"), AsyncRedirectPolicy(), ] # run the pipeline async with AsyncPipeline(transport=AioHttpTransport(), policies=policies) as pipeline: response = await pipeline.run(request)
- async run(request: HTTPRequestType, **kwargs: Any) PipelineResponse[HTTPRequestType, AsyncHTTPResponseType] [source]¶
Runs the HTTP Request through the chained policies.
- Parameters:
request (HttpRequest) – The HTTP request object.
- Returns:
The PipelineResponse object.
- Return type:
- class azure.core.pipeline.Pipeline(transport: HttpTransport[HTTPRequestType, HTTPResponseType], policies: Iterable[HTTPPolicy[HTTPRequestType, HTTPResponseType] | SansIOHTTPPolicy[HTTPRequestType, HTTPResponseType]] | None = None)[source]¶
A pipeline implementation.
This is implemented as a context manager, that will activate the context of the HTTP sender. The transport is the last node in the pipeline.
- Parameters:
transport (HttpTransport) – The Http Transport instance
policies (list) – List of configured policies.
Example:
from azure.core.pipeline import Pipeline from azure.core.pipeline.policies import RedirectPolicy, UserAgentPolicy from azure.core.rest import HttpRequest from azure.core.pipeline.transport import RequestsTransport # example: create request and policies request = HttpRequest("GET", "https://bing.com") policies: Iterable[Union[HTTPPolicy, SansIOHTTPPolicy]] = [UserAgentPolicy("myuseragent"), RedirectPolicy()] # run the pipeline with Pipeline(transport=RequestsTransport(), policies=policies) as pipeline: response = pipeline.run(request)
- run(request: HTTPRequestType, **kwargs: Any) PipelineResponse[HTTPRequestType, HTTPResponseType] [source]¶
Runs the HTTP Request through the chained policies.
- Parameters:
request (HttpRequest) – The HTTP request object.
- Returns:
The PipelineResponse object
- Return type:
- class azure.core.pipeline.PipelineContext(transport: TransportType | None, **kwargs: Any)[source]¶
A context object carried by the pipeline request and response containers.
This is transport specific and can contain data persisted between pipeline requests (for example reusing an open connection pool or “session”), as well as used by the SDK developer to carry arbitrary data through the pipeline.
- Parameters:
transport (HttpTransport or AsyncHttpTransport) – The HTTP transport type.
kwargs (any) – Developer-defined keyword arguments.
- copy() a shallow copy of D ¶
- fromkeys(value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- pop(__key: str) Any [source]¶
- pop(__key: str, __default: Any | None) Any
Removes specified key and returns the value.
- Parameters:
args (str) – The key to remove.
- Returns:
The value for this key.
- Return type:
any
- Raises:
ValueError If the key is in the protected list.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update(*args: Any, **kwargs: Any) None [source]¶
Context objects cannot be updated.
- Raises:
TypeError
- values() an object providing a view on D's values ¶
- class azure.core.pipeline.PipelineRequest(http_request: HTTPRequestType, context: PipelineContext)[source]¶
A pipeline request object.
Container for moving the HttpRequest through the pipeline. Universal for all transports, both synchronous and asynchronous.
- Parameters:
http_request (HttpRequest) – The request object.
context (PipelineContext) – Contains the context - data persisted between pipeline requests.
- class azure.core.pipeline.PipelineResponse(http_request: HTTPRequestType, http_response: HTTPResponseType, context: PipelineContext)[source]¶
A pipeline response object.
The PipelineResponse interface exposes an HTTP response object as it returns through the pipeline of Policy objects. This ensures that Policy objects have access to the HTTP response.
This also has a “context” object where policy can put additional fields. Policy SHOULD update the “context” with additional post-processed field if they create them. However, nothing prevents a policy to actually sub-class this class a return it instead of the initial instance.
- Parameters:
http_request (HttpRequest) – The request object.
http_response (HttpResponse) – The response object.
context (PipelineContext) – Contains the context - data persisted between pipeline requests.
Subpackages¶
- azure.core.pipeline.policies
AsyncBearerTokenCredentialPolicy
AsyncBearerTokenCredentialPolicy.authorize_request()
AsyncBearerTokenCredentialPolicy.on_challenge()
AsyncBearerTokenCredentialPolicy.on_exception()
AsyncBearerTokenCredentialPolicy.on_request()
AsyncBearerTokenCredentialPolicy.on_response()
AsyncBearerTokenCredentialPolicy.send()
AsyncBearerTokenCredentialPolicy.next
AsyncHTTPPolicy
AsyncRedirectPolicy
AsyncRetryPolicy
AsyncRetryPolicy.configure_retries()
AsyncRetryPolicy.get_backoff_time()
AsyncRetryPolicy.get_retry_after()
AsyncRetryPolicy.increment()
AsyncRetryPolicy.is_exhausted()
AsyncRetryPolicy.is_retry()
AsyncRetryPolicy.no_retries()
AsyncRetryPolicy.parse_retry_after()
AsyncRetryPolicy.send()
AsyncRetryPolicy.sleep()
AsyncRetryPolicy.update_context()
AsyncRetryPolicy.BACKOFF_MAX
AsyncRetryPolicy.next
AzureKeyCredentialPolicy
AzureSasCredentialPolicy
BearerTokenCredentialPolicy
ContentDecodePolicy
CustomHookPolicy
DistributedTracingPolicy
HTTPPolicy
HeadersPolicy
HttpLoggingPolicy
NetworkTraceLoggingPolicy
ProxyPolicy
RedirectPolicy
RequestHistory
RequestIdPolicy
RetryMode
RetryMode.capitalize()
RetryMode.casefold()
RetryMode.center()
RetryMode.count()
RetryMode.encode()
RetryMode.endswith()
RetryMode.expandtabs()
RetryMode.find()
RetryMode.format()
RetryMode.format_map()
RetryMode.index()
RetryMode.isalnum()
RetryMode.isalpha()
RetryMode.isascii()
RetryMode.isdecimal()
RetryMode.isdigit()
RetryMode.isidentifier()
RetryMode.islower()
RetryMode.isnumeric()
RetryMode.isprintable()
RetryMode.isspace()
RetryMode.istitle()
RetryMode.isupper()
RetryMode.join()
RetryMode.ljust()
RetryMode.lower()
RetryMode.lstrip()
RetryMode.maketrans()
RetryMode.partition()
RetryMode.removeprefix()
RetryMode.removesuffix()
RetryMode.replace()
RetryMode.rfind()
RetryMode.rindex()
RetryMode.rjust()
RetryMode.rpartition()
RetryMode.rsplit()
RetryMode.rstrip()
RetryMode.split()
RetryMode.splitlines()
RetryMode.startswith()
RetryMode.strip()
RetryMode.swapcase()
RetryMode.title()
RetryMode.translate()
RetryMode.upper()
RetryMode.zfill()
RetryMode.Exponential
RetryMode.Fixed
RetryPolicy
RetryPolicy.configure_retries()
RetryPolicy.get_backoff_time()
RetryPolicy.get_retry_after()
RetryPolicy.increment()
RetryPolicy.is_exhausted()
RetryPolicy.is_retry()
RetryPolicy.no_retries()
RetryPolicy.parse_retry_after()
RetryPolicy.send()
RetryPolicy.sleep()
RetryPolicy.update_context()
RetryPolicy.BACKOFF_MAX
RetryPolicy.next
SansIOHTTPPolicy
SensitiveHeaderCleanupPolicy
UserAgentPolicy
- azure.core.pipeline.transport
AioHttpTransport
AioHttpTransportResponse
AsyncHttpResponse
AsyncHttpTransport
AsyncioRequestsTransport
AsyncioRequestsTransportResponse
HttpRequest
HttpRequest.format_parameters()
HttpRequest.prepare_multipart_body()
HttpRequest.serialize()
HttpRequest.set_bytes_body()
HttpRequest.set_formdata_body()
HttpRequest.set_json_body()
HttpRequest.set_multipart_mixed()
HttpRequest.set_streamed_data_body()
HttpRequest.set_text_body()
HttpRequest.set_xml_body()
HttpRequest.body
HttpRequest.query
HttpResponse
HttpTransport
RequestsTransport
RequestsTransportResponse
TrioRequestsTransport
TrioRequestsTransportResponse