-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathunauthorizedresponse.py
More file actions
154 lines (109 loc) · 5.16 KB
/
unauthorizedresponse.py
File metadata and controls
154 lines (109 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from apideck_unify.models import ApideckError
from apideck_unify.types import BaseModel
from dataclasses import dataclass, field
import httpx
import pydantic
from pydantic import ConfigDict
from typing import Any, Dict, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
class RequestTypedDict(TypedDict):
r"""HTTP request details"""
class Request(BaseModel):
r"""HTTP request details"""
class ResponseTypedDict(TypedDict):
r"""HTTP response details"""
class Response(BaseModel):
r"""HTTP response details"""
class DebugTypedDict(TypedDict):
r"""Debug information including request/response details and OAuth timing metadata"""
request: NotRequired[RequestTypedDict]
r"""HTTP request details"""
response: NotRequired[ResponseTypedDict]
r"""HTTP response details"""
message: NotRequired[str]
r"""Error message from downstream provider or network layer"""
code: NotRequired[str]
r"""Error code (e.g., ETIMEDOUT, ECONNREFUSED)"""
credentials_expire_at_ms: NotRequired[float]
r"""Unix timestamp (milliseconds) when credentials will be deleted if not refreshed. Only present for non-recoverable errors (401, 400). Credentials are preserved indefinitely for recoverable/network errors."""
retry_after_ms: NotRequired[float]
r"""Unix timestamp (milliseconds) when token refresh retry is allowed after cooldown period expires."""
cooldown_remaining_ms: NotRequired[float]
r"""Milliseconds remaining in cooldown period before retry is allowed."""
class Debug(BaseModel):
r"""Debug information including request/response details and OAuth timing metadata"""
request: Optional[Request] = None
r"""HTTP request details"""
response: Optional[Response] = None
r"""HTTP response details"""
message: Optional[str] = None
r"""Error message from downstream provider or network layer"""
code: Optional[str] = None
r"""Error code (e.g., ETIMEDOUT, ECONNREFUSED)"""
credentials_expire_at_ms: Optional[float] = None
r"""Unix timestamp (milliseconds) when credentials will be deleted if not refreshed. Only present for non-recoverable errors (401, 400). Credentials are preserved indefinitely for recoverable/network errors."""
retry_after_ms: Optional[float] = None
r"""Unix timestamp (milliseconds) when token refresh retry is allowed after cooldown period expires."""
cooldown_remaining_ms: Optional[float] = None
r"""Milliseconds remaining in cooldown period before retry is allowed."""
class Detail2TypedDict(TypedDict):
type: NotRequired[str]
r"""Error type identifier"""
message: NotRequired[str]
r"""Detailed error message"""
debug: NotRequired[DebugTypedDict]
r"""Debug information including request/response details and OAuth timing metadata"""
class Detail2(BaseModel):
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False)
type: Optional[str] = None
r"""Error type identifier"""
message: Optional[str] = None
r"""Detailed error message"""
debug: Optional[Debug] = None
r"""Debug information including request/response details and OAuth timing metadata"""
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
UnauthorizedResponseDetailTypedDict = TypeAliasType(
"UnauthorizedResponseDetailTypedDict", Union[Detail2TypedDict, str]
)
r"""Contains parameter or domain specific information related to the error and why it occurred."""
UnauthorizedResponseDetail = TypeAliasType(
"UnauthorizedResponseDetail", Union[Detail2, str]
)
r"""Contains parameter or domain specific information related to the error and why it occurred."""
class UnauthorizedResponseData(BaseModel):
status_code: Optional[float] = None
r"""HTTP status code"""
error: Optional[str] = None
r"""Contains an explanation of the status_code as defined in HTTP/1.1 standard (RFC 7231)"""
type_name: Optional[str] = None
r"""The type of error returned"""
message: Optional[str] = None
r"""A human-readable message providing more details about the error."""
detail: Optional[UnauthorizedResponseDetail] = None
r"""Contains parameter or domain specific information related to the error and why it occurred."""
ref: Optional[str] = None
r"""Link to documentation of error type"""
@dataclass(unsafe_hash=True)
class UnauthorizedResponse(ApideckError):
r"""Unauthorized"""
data: UnauthorizedResponseData = field(hash=False)
def __init__(
self,
data: UnauthorizedResponseData,
raw_response: httpx.Response,
body: Optional[str] = None,
):
fallback = body or raw_response.text
message = str(data.message) or fallback
super().__init__(message, raw_response, body)
object.__setattr__(self, "data", data)