Debian Codegraph @

asusrouter/const.py

raw
1 """Constants module for AsusRouter."""
2
3 from enum import IntEnum, StrEnum
4
5 from asusrouter.tools.enum import FromIntMixin
6
7 UNKNOWN_MEMBER = -999
8 UNKNOWN_MEMBER_STR = "unknown"
9
10
11 # Enums
12 class ContentType(StrEnum):
13 """Content type enum."""
14
15 UNKNOWN = "unknown"
16
17 BINARY = "application/octet-stream"
18 HTML = "text/html"
19 JSON = "application/json"
20 TEXT = "text/plain"
21 XML = "application/xml"
22
23
24 class RequestType(StrEnum):
25 """Request type enum."""
26
27 GET = "get"
28 POST = "post"
29
30
31 class HTTPStatus(FromIntMixin, IntEnum):
32 """HTTP status codes."""
33
34 UNKNOWN = UNKNOWN_MEMBER
35
36 OK = 200
37 CREATED = 201
38 ACCEPTED = 202
39 NO_CONTENT = 204
40 BAD_REQUEST = 400
41 UNAUTHORIZED = 401
42 FORBIDDEN = 403
43 NOT_FOUND = 404
44 METHOD_NOT_ALLOWED = 405
45 CONFLICT = 409
46 INTERNAL_SERVER_ERROR = 500
47 JSON_BAD_FORMAT = 4002
48 JSON_BAD_REQUEST = 4003
49
50
51 # Asus constants
52 USER_AGENT = "asusrouter--DUTUtil-"
53 DEFAULT_PORT_HTTP = 80
54 DEFAULT_PORT_HTTPS = 8443
55
56 # AsusRouter definitions
57 AR_CALL_GET_STATE = "get_state"
58 AR_CALL_SET_STATE = "set_state"
59 AR_CALL_TRANSLATE_STATE = "translate_state"
60
61 # Library defaults
62 DEFAULT_CACHE_TIME = 5.0
63 DEFAULT_SLEEP_TIME = 0.1
64 DEFAULT_TIMEOUT = 15
65 DEFAULT_TIMEOUT_FALLBACK = 5
66
67 DEFAULT_RESULT_SUCCESS = {"statusCode": "200"}
68
69 # --------------------
70 # Value maps -->
71 # --------------------
72 # These maps are used to read data from the device
73 # into the correct variables and apply a converter if needed
74
75
76 # --------------------
77 # <-- Value maps
78 # --------------------