Skip to content

Commit b59102d

Browse files
Copilotjohanste
andcommitted
Add all pipeline policy parameters to RequestParameters TypedDict
Update RequestParameters in both azure-ai-projects and azure-mgmt-compute to include the complete set of per-request parameters consumed by pipeline policies and transports: - Request construction: request_id - Response handling: decompress - Hooks: raw_request_hook, raw_response_hook (CustomHookPolicy) - Logging: logging_enable (HttpLoggingPolicy) - Retry: retry_total, retry_connect, retry_read, retry_status, retry_backoff_factor, retry_backoff_max, retry_on_methods, timeout - Redirect: permit_redirects, redirect_max - Tracing: network_span_namer, tracing_attributes - Transport: connection_timeout, read_timeout, connection_verify, connection_cert, proxy Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
1 parent 33920db commit b59102d

3 files changed

Lines changed: 270 additions & 24 deletions

File tree

doc/dev/request_parameters_migration_guide.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,49 @@ There are three tiers of TypedDict, reflecting the three categories of operation
2929

3030
```python
3131
# types.py
32-
from typing import Any, Callable, Dict, Optional, Union
32+
from typing import Callable, Dict, List, Union
3333

34-
from typing_extensions import NotRequired, TypedDict
34+
from typing_extensions import TypedDict
3535

36-
from azure.core.pipeline import PipelineResponse
36+
from azure.core.pipeline import PipelineRequest, PipelineResponse
3737
from azure.core.polling import PollingMethod
38-
from azure.core.rest import HttpRequest, HttpResponse
3938

4039

4140
class RequestParameters(TypedDict, total=False):
4241
"""Common parameters for all service client operations.
4342
4443
These parameters control how the HTTP request is constructed and sent
45-
through the Azure SDK pipeline.
44+
through the Azure SDK pipeline, including retry, redirect, tracing,
45+
logging, and transport-level behavior.
4646
"""
4747

4848
api_version: str
49-
"""Override the API version used for this request."""
50-
5149
headers: Dict[str, str]
52-
"""Custom HTTP headers to include in the request."""
53-
5450
params: Dict[str, str]
55-
"""Custom query parameters to include in the request."""
56-
5751
content_type: str
58-
"""Override the Content-Type header for the request."""
59-
52+
request_id: str
6053
stream: bool
61-
"""Whether to stream the response body instead of loading it into memory."""
54+
decompress: bool
55+
raw_request_hook: Callable[[PipelineRequest], None]
56+
raw_response_hook: Callable[[PipelineResponse], None]
57+
logging_enable: bool
58+
retry_total: int
59+
retry_connect: int
60+
retry_read: int
61+
retry_status: int
62+
retry_backoff_factor: float
63+
retry_backoff_max: int
64+
retry_on_methods: List[str]
65+
timeout: int
66+
permit_redirects: bool
67+
redirect_max: int
68+
network_span_namer: Callable
69+
tracing_attributes: Dict[str, str]
70+
connection_timeout: float
71+
read_timeout: float
72+
connection_verify: Union[bool, str]
73+
connection_cert: Union[str, tuple]
74+
proxy: str
6275

6376

6477
class LRORequestParameters(RequestParameters, total=False):
@@ -68,14 +81,8 @@ class LRORequestParameters(RequestParameters, total=False):
6881
"""
6982

7083
polling: Union[bool, PollingMethod]
71-
"""Polling strategy. True for default polling, False for no polling,
72-
or a custom PollingMethod instance."""
73-
7484
polling_interval: int
75-
"""Time in seconds between polling requests. Overrides the client default."""
76-
7785
continuation_token: str
78-
"""Token to resume a previously started long-running operation."""
7986
```
8087

8188
### Step 2: Export types from the package

sdk/ai/azure-ai-projects/azure/ai/projects/types.py

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@
1111
better discoverability and type-checking support.
1212
"""
1313

14-
from typing import Dict, Union
14+
from typing import Callable, Dict, List, Union
1515

1616
from typing_extensions import TypedDict
1717

18+
from azure.core.pipeline import PipelineRequest, PipelineResponse
1819
from azure.core.polling import PollingMethod
1920

2021

2122
class RequestParameters(TypedDict, total=False):
2223
"""Common parameters for all service client operations.
2324
2425
These parameters control how the HTTP request is constructed and sent
25-
through the Azure SDK pipeline.
26+
through the Azure SDK pipeline, including retry, redirect, tracing,
27+
logging, and transport-level behavior.
2628
"""
2729

30+
# -- Request construction --
31+
2832
api_version: str
2933
"""Override the API version used for this request."""
3034

@@ -37,9 +41,123 @@ class RequestParameters(TypedDict, total=False):
3741
content_type: str
3842
"""Override the Content-Type header for the request."""
3943

44+
request_id: str
45+
"""Custom request ID to set in the request header
46+
(consumed by :class:`~azure.core.pipeline.policies.RequestIdPolicy`)."""
47+
48+
# -- Response handling --
49+
4050
stream: bool
4151
"""Whether to stream the response body instead of loading it into memory."""
4252

53+
decompress: bool
54+
"""Whether to decompress the response body. Defaults to ``True``."""
55+
56+
# -- Hooks --
57+
58+
raw_request_hook: Callable[[PipelineRequest], None]
59+
"""Callback invoked with the :class:`~azure.core.pipeline.PipelineRequest`
60+
before the request is sent
61+
(consumed by :class:`~azure.core.pipeline.policies.CustomHookPolicy`)."""
62+
63+
raw_response_hook: Callable[[PipelineResponse], None]
64+
"""Callback invoked with the :class:`~azure.core.pipeline.PipelineResponse`
65+
after the response is received
66+
(consumed by :class:`~azure.core.pipeline.policies.CustomHookPolicy`)."""
67+
68+
# -- Logging --
69+
70+
logging_enable: bool
71+
"""Enable HTTP logging for this request
72+
(consumed by :class:`~azure.core.pipeline.policies.HttpLoggingPolicy`).
73+
Defaults to ``False``."""
74+
75+
# -- Retry policy --
76+
77+
retry_total: int
78+
"""Total number of retries to allow
79+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
80+
Defaults to ``10``."""
81+
82+
retry_connect: int
83+
"""Number of connection-related retries
84+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
85+
Defaults to ``3``."""
86+
87+
retry_read: int
88+
"""Number of retries on read errors
89+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
90+
Defaults to ``3``."""
91+
92+
retry_status: int
93+
"""Number of retries on bad status codes
94+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
95+
Defaults to ``3``."""
96+
97+
retry_backoff_factor: float
98+
"""Backoff factor for retry delays
99+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
100+
Defaults to ``0.8``."""
101+
102+
retry_backoff_max: int
103+
"""Maximum backoff time in seconds
104+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
105+
Defaults to ``120``."""
106+
107+
retry_on_methods: List[str]
108+
"""HTTP methods that are eligible for retry
109+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`)."""
110+
111+
timeout: int
112+
"""Overall timeout for the operation in seconds, including all retries
113+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
114+
Defaults to ``604800`` (7 days)."""
115+
116+
# -- Redirect policy --
117+
118+
permit_redirects: bool
119+
"""Whether to follow redirects
120+
(consumed by :class:`~azure.core.pipeline.policies.RedirectPolicy`).
121+
Defaults to ``True``."""
122+
123+
redirect_max: int
124+
"""Maximum number of redirects to follow
125+
(consumed by :class:`~azure.core.pipeline.policies.RedirectPolicy`).
126+
Defaults to ``30``."""
127+
128+
# -- Distributed tracing --
129+
130+
network_span_namer: Callable[..., str]
131+
"""Callable that receives the HTTP request and returns a span name string
132+
(consumed by :class:`~azure.core.pipeline.policies.DistributedTracingPolicy`)."""
133+
134+
tracing_attributes: Dict[str, str]
135+
"""Extra attributes to set on the tracing span
136+
(consumed by :class:`~azure.core.pipeline.policies.DistributedTracingPolicy`)."""
137+
138+
# -- Transport / connection --
139+
140+
connection_timeout: float
141+
"""Connection timeout in seconds
142+
(consumed by the HTTP transport)."""
143+
144+
read_timeout: float
145+
"""Read timeout in seconds
146+
(consumed by the HTTP transport)."""
147+
148+
connection_verify: Union[bool, str]
149+
"""SSL certificate verification. Pass ``False`` to disable,
150+
or a path to a CA bundle
151+
(consumed by the HTTP transport)."""
152+
153+
connection_cert: Union[str, tuple]
154+
"""Client-side certificate. A path to a file or a ``(cert, key)`` tuple
155+
(consumed by the HTTP transport)."""
156+
157+
proxy: str
158+
"""Proxy URL for this request
159+
(consumed by the HTTP transport)."""
160+
43161

44162
class LRORequestParameters(RequestParameters, total=False):
45163
"""Parameters for long-running operations (``begin_*`` methods).

sdk/compute/azure-mgmt-compute/azure/mgmt/compute/types.py

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@
1111
better discoverability and type-checking support.
1212
"""
1313

14-
from typing import Dict, Union
14+
from typing import Callable, Dict, List, Union
1515

1616
from typing_extensions import TypedDict
1717

18+
from azure.core.pipeline import PipelineRequest, PipelineResponse
1819
from azure.core.polling import PollingMethod
1920

2021

2122
class RequestParameters(TypedDict, total=False):
2223
"""Common parameters for all service client operations.
2324
2425
These parameters control how the HTTP request is constructed and sent
25-
through the Azure SDK pipeline.
26+
through the Azure SDK pipeline, including retry, redirect, tracing,
27+
logging, and transport-level behavior.
2628
"""
2729

30+
# -- Request construction --
31+
2832
api_version: str
2933
"""Override the API version used for this request."""
3034

@@ -37,6 +41,123 @@ class RequestParameters(TypedDict, total=False):
3741
content_type: str
3842
"""Override the Content-Type header for the request."""
3943

44+
request_id: str
45+
"""Custom request ID to set in the request header
46+
(consumed by :class:`~azure.core.pipeline.policies.RequestIdPolicy`)."""
47+
48+
# -- Response handling --
49+
50+
stream: bool
51+
"""Whether to stream the response body instead of loading it into memory."""
52+
53+
decompress: bool
54+
"""Whether to decompress the response body. Defaults to ``True``."""
55+
56+
# -- Hooks --
57+
58+
raw_request_hook: Callable[[PipelineRequest], None]
59+
"""Callback invoked with the :class:`~azure.core.pipeline.PipelineRequest`
60+
before the request is sent
61+
(consumed by :class:`~azure.core.pipeline.policies.CustomHookPolicy`)."""
62+
63+
raw_response_hook: Callable[[PipelineResponse], None]
64+
"""Callback invoked with the :class:`~azure.core.pipeline.PipelineResponse`
65+
after the response is received
66+
(consumed by :class:`~azure.core.pipeline.policies.CustomHookPolicy`)."""
67+
68+
# -- Logging --
69+
70+
logging_enable: bool
71+
"""Enable HTTP logging for this request
72+
(consumed by :class:`~azure.core.pipeline.policies.HttpLoggingPolicy`).
73+
Defaults to ``False``."""
74+
75+
# -- Retry policy --
76+
77+
retry_total: int
78+
"""Total number of retries to allow
79+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
80+
Defaults to ``10``."""
81+
82+
retry_connect: int
83+
"""Number of connection-related retries
84+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
85+
Defaults to ``3``."""
86+
87+
retry_read: int
88+
"""Number of retries on read errors
89+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
90+
Defaults to ``3``."""
91+
92+
retry_status: int
93+
"""Number of retries on bad status codes
94+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
95+
Defaults to ``3``."""
96+
97+
retry_backoff_factor: float
98+
"""Backoff factor for retry delays
99+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
100+
Defaults to ``0.8``."""
101+
102+
retry_backoff_max: int
103+
"""Maximum backoff time in seconds
104+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
105+
Defaults to ``120``."""
106+
107+
retry_on_methods: List[str]
108+
"""HTTP methods that are eligible for retry
109+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`)."""
110+
111+
timeout: int
112+
"""Overall timeout for the operation in seconds, including all retries
113+
(consumed by :class:`~azure.core.pipeline.policies.RetryPolicy`).
114+
Defaults to ``604800`` (7 days)."""
115+
116+
# -- Redirect policy --
117+
118+
permit_redirects: bool
119+
"""Whether to follow redirects
120+
(consumed by :class:`~azure.core.pipeline.policies.RedirectPolicy`).
121+
Defaults to ``True``."""
122+
123+
redirect_max: int
124+
"""Maximum number of redirects to follow
125+
(consumed by :class:`~azure.core.pipeline.policies.RedirectPolicy`).
126+
Defaults to ``30``."""
127+
128+
# -- Distributed tracing --
129+
130+
network_span_namer: Callable[..., str]
131+
"""Callable that receives the HTTP request and returns a span name string
132+
(consumed by :class:`~azure.core.pipeline.policies.DistributedTracingPolicy`)."""
133+
134+
tracing_attributes: Dict[str, str]
135+
"""Extra attributes to set on the tracing span
136+
(consumed by :class:`~azure.core.pipeline.policies.DistributedTracingPolicy`)."""
137+
138+
# -- Transport / connection --
139+
140+
connection_timeout: float
141+
"""Connection timeout in seconds
142+
(consumed by the HTTP transport)."""
143+
144+
read_timeout: float
145+
"""Read timeout in seconds
146+
(consumed by the HTTP transport)."""
147+
148+
connection_verify: Union[bool, str]
149+
"""SSL certificate verification. Pass ``False`` to disable,
150+
or a path to a CA bundle
151+
(consumed by the HTTP transport)."""
152+
153+
connection_cert: Union[str, tuple]
154+
"""Client-side certificate. A path to a file or a ``(cert, key)`` tuple
155+
(consumed by the HTTP transport)."""
156+
157+
proxy: str
158+
"""Proxy URL for this request
159+
(consumed by the HTTP transport)."""
160+
40161

41162
class LRORequestParameters(RequestParameters, total=False):
42163
"""Parameters for long-running operations (``begin_*`` methods).

0 commit comments

Comments
 (0)