Pipeline Class

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.

Inheritance
Pipeline

Constructor

Pipeline(transport: HttpTransport[HTTPRequestType, HTTPResponseType], policies: Iterable[HTTPPolicy[HTTPRequestType, HTTPResponseType] | SansIOHTTPPolicy[HTTPRequestType, HTTPResponseType]] | None = None)

Parameters

Name Description
transport
Required

The Http Transport instance

policies

List of configured policies.

default value: None

Examples

Builds the pipeline for synchronous transport.


   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)

Methods

run

Runs the HTTP Request through the chained policies.

run

Runs the HTTP Request through the chained policies.

run(request: HTTPRequestType, **kwargs: Any) -> PipelineResponse[HTTPRequestType, HTTPResponseType]

Parameters

Name Description
request
Required

The HTTP request object.

Returns

Type Description

The PipelineResponse object