-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror.py
More file actions
58 lines (41 loc) · 1.54 KB
/
Copy patherror.py
File metadata and controls
58 lines (41 loc) · 1.54 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
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from dataclasses import dataclass, field
import httpx
from plex_api_client.models.errors import PlexAPIError
from plex_api_client.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
class ErrorsTypedDict(TypedDict):
code: NotRequired[int]
message: NotRequired[str]
status: NotRequired[int]
class Errors(BaseModel):
code: Optional[int] = None
message: Optional[str] = None
status: Optional[int] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["code", "message", "status"])
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m
class ErrorData(BaseModel):
errors: Optional[List[Errors]] = None
@dataclass(unsafe_hash=True)
class Error(PlexAPIError):
r"""Unauthorized"""
data: ErrorData = field(hash=False)
def __init__(
self, data: ErrorData, raw_response: httpx.Response, body: Optional[str] = None
):
message = body or raw_response.text
super().__init__(message, raw_response, body)
object.__setattr__(self, "data", data)