-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathunauthorized.py
More file actions
139 lines (97 loc) · 4.71 KB
/
unauthorized.py
File metadata and controls
139 lines (97 loc) · 4.71 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
"""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
from typing import Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
class DetailRequestTypedDict(TypedDict):
r"""HTTP request details"""
class DetailRequest(BaseModel):
r"""HTTP request details"""
class DetailResponseTypedDict(TypedDict):
r"""HTTP response details"""
class DetailResponse(BaseModel):
r"""HTTP response details"""
class DetailDebugTypedDict(TypedDict):
r"""Debug information including request/response details and OAuth timing metadata"""
request: NotRequired[DetailRequestTypedDict]
r"""HTTP request details"""
response: NotRequired[DetailResponseTypedDict]
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 DetailDebug(BaseModel):
r"""Debug information including request/response details and OAuth timing metadata"""
request: Optional[DetailRequest] = None
r"""HTTP request details"""
response: Optional[DetailResponse] = 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 DetailUnauthorized2TypedDict(TypedDict):
type: NotRequired[str]
r"""Error type identifier"""
message: NotRequired[str]
r"""Detailed error message"""
debug: NotRequired[DetailDebugTypedDict]
r"""Debug information including request/response details and OAuth timing metadata"""
class DetailUnauthorized2(BaseModel):
type: Optional[str] = None
r"""Error type identifier"""
message: Optional[str] = None
r"""Detailed error message"""
debug: Optional[DetailDebug] = None
r"""Debug information including request/response details and OAuth timing metadata"""
UnauthorizedDetailTypedDict = TypeAliasType(
"UnauthorizedDetailTypedDict", Union[DetailUnauthorized2TypedDict, str]
)
r"""Contains parameter or domain specific information related to the error and why it occurred."""
UnauthorizedDetail = TypeAliasType(
"UnauthorizedDetail", Union[DetailUnauthorized2, str]
)
r"""Contains parameter or domain specific information related to the error and why it occurred."""
class UnauthorizedData(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[UnauthorizedDetail] = 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 Unauthorized(ApideckError):
r"""Unauthorized"""
data: UnauthorizedData = field(hash=False)
def __init__(
self,
data: UnauthorizedData,
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)