You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`pipeline`| While `PipelineClient` will create a default pipeline, users can opt to use their own pipeline by passing in a `Pipeline` object. If passed in, the other configurations will be ignored. |
97
+
|`policies`| While `PipelineClient` will create a default list of `policies`, users can opt to use their own policies by passing in a `policies` object. If passed in, `config` will be ignored |
96
98
|`config`| While `PipelineClient` will create a default `Configuration`, users can opt to use their own configuration by passing in a `Configuration` object. If passed in, it will be used to create a `Pipeline` object. |
99
+
|`per_call_policies`| If a default `pipeline` is needed and no `policies` is passed in, `per_call_policies` will be added before the `Retry` policy |
100
+
|`per_retry_policies`| If a default `pipeline` is needed and no `policies` is passed in, `per_retry_policies` will be added after the `Retry` policy. If there is no `RetryPolicy` in the pipeline, a `ValueError` will be raised |
97
101
|`transport`| While `PipelineClient` will create a default `RequestsTransport`, users can opt to use their own transport by passing in a `RequestsTransport` object. If it is omitted, `PipelineClient` will honor the other described [transport customizations](#transport). |
98
102
99
-
100
103
### Transport
101
104
102
105
Various combinations of sync/async HTTP libraries as well as alternative event loop implementations are available. Therefore to support the widest range of customer scenarios, we must allow a customer to easily swap out the HTTP transport layer to one of those supported.
103
106
104
107
The transport is the last node in the pipeline, and adheres to the same basic API as any policy within the pipeline.
105
108
The only currently available transport for synchronous pipelines uses the `Requests` library:
109
+
106
110
```python
107
111
from azure.core.pipeline.transport import RequestsTransport
108
112
synchronous_transport = RequestsTransport()
109
113
```
110
114
111
115
For asynchronous pipelines a couple of transport options are available. Each of these transports are interchangable depending on whether the user has installed various 3rd party dependencies (i.e. aiohttp or trio), and the user
112
116
should easily be able to specify their chosen transport. SDK developers should use the `aiohttp` transport as the default for asynchronous pipelines where the user has not specified an alternative.
The HttpRequest and HttpResponse objects represent a generic concept of HTTP request and response constructs and are in no way tied to a particular transport or HTTP library.
191
197
192
198
The HttpRequest has the following API. It does not vary between transports:
199
+
193
200
```python
194
201
classHttpRequest(object):
195
202
@@ -240,6 +247,7 @@ This is to accomodate how the data is extracted for the object returned by the H
240
247
There is also an async flavor: AsyncHttpResponse. This is to allow for the asynchronous streaming of
241
248
data from the response.
242
249
For example:
250
+
243
251
```python
244
252
from azure.core.pipeline.transport import (
245
253
RequestsTransportResponse, # HttpResponse
@@ -248,10 +256,12 @@ from azure.core.pipeline.transport import (
SansIOHTTPPolicy methods can be declared as coroutines, but then they can only be used with a AsyncPipeline.
346
358
347
359
Current provided sans IO policies include:
360
+
348
361
```python
349
362
from azure.core.pipeline.policies import (
350
363
HeadersPolicy, # Add custom headers to all requests
@@ -364,6 +377,7 @@ Some policies are more complex, like retry strategy, and need to have control of
364
377
In the current version, they are subclasses of HTTPPolicy or AsyncHTTPPolicy, and can be used only their corresponding synchronous or asynchronous pipeline type.
365
378
366
379
An HTTPPolicy or AsyncHTTPPolicy must implement the `send` method, and this implementation must in include a call to process the next policy in the pipeline:
380
+
367
381
```python
368
382
classCustomPolicy(HTTPPolicy):
369
383
@@ -384,6 +398,7 @@ class CustomAsyncPolicy(AsyncHTTPPolicy):
384
398
```
385
399
386
400
Currently provided HTTP policies include:
401
+
387
402
```python
388
403
from azure.core.pipeline.policies import (
389
404
RetryPolicy,
@@ -449,7 +464,6 @@ from azure.core.pipeline.policies import (
449
464
||| retry_mode | x | x | Fixed or exponential delay between attemps, default is exponential. |
450
465
||| timeout | x | x | Timeout setting for the operation in seconds, default is `604800s` (7 days). |
451
466
452
-
453
467
### The Pipeline
454
468
455
469
The pipeline itself represents a chain of policies where the final node in the chain is the HTTP transport.
0 commit comments