| 936 | |
| 937 | @final |
| 938 | class FinalRequestOptions(pydantic.BaseModel): |
| 939 | method: str |
| 940 | url: str |
| 941 | params: Query = {} |
| 942 | headers: Union[Headers, NotGiven] = NotGiven() |
| 943 | max_retries: Union[int, NotGiven] = NotGiven() |
| 944 | timeout: Union[float, Timeout, None, NotGiven] = NotGiven() |
| 945 | files: Union[HttpxRequestFiles, None] = None |
| 946 | idempotency_key: Union[str, None] = None |
| 947 | post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven() |
| 948 | follow_redirects: Union[bool, None] = None |
| 949 | security: SecurityOptions = { |
| 950 | class="st">"bearer_auth": True, |
| 951 | class="st">"admin_api_key_auth": True, |
| 952 | } |
| 953 | synthesize_event_and_data: Optional[bool] = None |
| 954 | |
| 955 | content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None |
| 956 | class="cm"># It should be noted that we cannot use `json` here as that would override |
| 957 | class="cm"># a BaseModel method in an incompatible fashion. |
| 958 | json_data: Union[Body, None] = None |
| 959 | extra_json: Union[AnyMapping, None] = None |
| 960 | |
| 961 | if PYDANTIC_V1: |
| 962 | |
| 963 | class Config(pydantic.BaseConfig): class="cm"># pyright: ignore[reportDeprecated] |
| 964 | arbitrary_types_allowed: bool = True |
| 965 | else: |
| 966 | model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True) |
| 967 | |
| 968 | def get_max_retries(self, max_retries: int) -> int: |
| 969 | if isinstance(self.max_retries, NotGiven): |
| 970 | return max_retries |
| 971 | return self.max_retries |
| 972 | |
| 973 | def _strip_raw_response_header(self) -> None: |
| 974 | if not is_given(self.headers): |
| 975 | return |
| 976 | |
| 977 | if self.headers.get(RAW_RESPONSE_HEADER): |
| 978 | self.headers = {**self.headers} |
| 979 | self.headers.pop(RAW_RESPONSE_HEADER) |
| 980 | |
| 981 | class="cm"># override the `construct` method so that we can run custom transformations. |
| 982 | class="cm"># this is necessary as we don't want to do any actual runtime type checking |
| 983 | class="cm"># (which means we can't use validators) but we do want to ensure that `NotGiven` |
| 984 | class="cm"># values are not present |
| 985 | class="cm"># |
| 986 | class="cm"># type ignore required because we're adding explicit types to `**values` |
| 987 | @classmethod |
| 988 | def construct( class="cm"># type: ignore |
| 989 | cls, |
| 990 | _fields_set: set[str] | None = None, |
| 991 | **values: Unpack[FinalRequestOptionsInput], |
| 992 | ) -> FinalRequestOptions: |
| 993 | kwargs: dict[str, Any] = { |
| 994 | class="cm"># we unconditionally call `strip_not_given` on any value |
| 995 | class="cm"># as it will just ignore any non-mapping types |