Cat Feeder  1.0.0
The Cat feeder project
Loading...
Searching...
No Matches
endpoint_manager.py
Go to the documentation of this file.
1r"""
2# +==== BEGIN CatFeeder =================+
3# LOGO:
4# ..............(..../\
5# ...............)..(.')
6# ..............(../..)
7# ...............\‍(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
10# animals/cats
11# /STOP
12# PROJECT: CatFeeder
13# FILE: endpoints_routes.py
14# CREATION DATE: 11-10-2025
15# LAST Modified: 18:52:11 31-01-2026
16# DESCRIPTION:
17# This is the backend server in charge of making the actual website work.
18# /STOP
19# COPYRIGHT: (c) Cat Feeder
20# PURPOSE: This is the file in charge of storing the endpoints_initialised ready to be imported into the server class.
21# // AR
22# +==== END CatFeeder =================+
23"""
24from typing import Optional
25from display_tty import Disp, initialise_logger
26from . import endpoint_constants as ENDPOINT_CONST
27from .endpoints import Bonus
28from .endpoints import CatEndpoints
29from .endpoints import UserEndpoints
30from .endpoints import AdminEndpoints
31from .endpoints import TokenEndpoints
32from .endpoints import FrontEndManager
33from .endpoints import TestingEndpoints
34from ..path_manager import PathManager, decorators
35from ..core import FinalClass
36from ..utils.password_handling import PasswordHandling
37from ..core.runtime_manager import RuntimeManager, RI
38from ..utils.oauth_authentication import OAuthAuthentication
39
40
41class EndpointManager(metaclass=FinalClass):
42 """_summary_
43 """
44
45 disp: Disp = initialise_logger(__qualname__, False)
46
47 def __init__(self, success: int = 0, error: int = 84, debug: bool = False) -> None:
48 """_summary_
49
50 Args:
51 runtime_data (RuntimeData): _description_
52 success (int, optional): _description_. Defaults to 0.
53 error (int, optional): _description_. Defaults to 84.
54 debug (bool, optional): _description_. Defaults to False.
55 """
56 # ------------------------ The logging function ------------------------
57 self.disp.update_disp_debug(debug)
58 self.disp.log_debug("Initialising...")
59 # -------------------------- Inherited values --------------------------
60 self.debug: bool = debug
61 self.success: int = success
62 self.error: int = error
63 self.runtime_manager: RuntimeManager = RI
65 self.error,
66 self.success,
67 self.debug
68 )
69 self.paths_initialisedpaths_initialised: Optional[PathManager] = None
71 self.oauth_authentication_initialisedoauth_authentication_initialised: Optional[OAuthAuthentication] = self.runtime_manager.get_if_exists(
72 OAuthAuthentication,
73 None
74 )
75 self.disp.update_disp_debug(self.debug)
76 # ------------------- Initialize endpoints sub-classes ------------------
77 self.user: UserEndpoints = UserEndpoints(
78 success=self.success,
79 error=self.error,
80 debug=self.debug
81 )
82 self.bonus: Bonus = Bonus(
83 success=success,
84 error=error,
85 debug=debug
86 )
87 self.cat_endpoints: CatEndpoints = CatEndpoints(
88 success=success,
89 error=error,
90 debug=debug
91 )
92 self.admin: AdminEndpoints = AdminEndpoints(
93 success=success,
94 error=error,
95 debug=debug
96 )
97 self.testing_endpoints: TestingEndpoints = TestingEndpoints(
98 success=self.success,
99 error=self.error,
100 debug=self.debug
101 )
102 self.front_end_manager: FrontEndManager = FrontEndManager(
103 success=self.success,
104 error=self.error,
105 debug=self.debug
106 )
107 self.token_endpoints: TokenEndpoints = TokenEndpoints(
108 success=self.success,
109 error=self.error,
110 debug=self.debug
111 )
112 # ------------------------- Endpoint Prefixing -------------------------
113 self.api_str: str = "/api"
114 self.v1_str: str = f"{self.api_str}/v1"
115 self.oauth_str: str = f"{self.v1_str}/oauth"
116 self.test_endpoint: str = "/testing"
117 self.sql_endpoint: str = f"{self.test_endpoint}/sql"
118 self.bucket_endpoint: str = f"{self.test_endpoint}/bucket"
119 self.favicon_endpoint: str = f"{self.v1_str}/favicons"
120 self.user_favicon_endpoint: str = f"{self.v1_str}/user_favicon"
121 self.token_endpoint: str = f"{self.v1_str}/token"
122 self.disp.log_debug("Initialised")
123
124 def _retrieve_path_manager(self) -> Optional[PathManager]:
125 if self.paths_initialisedpaths_initialised is not None:
127 if self.runtime_manager.exists(PathManager):
128 self.paths_initialisedpaths_initialised = self.runtime_manager.get(PathManager)
130 return None
131
132 def inject_routes(self) -> None:
133 """_summary_
134 """
137 err_msg: str = "PathManager could not be found"
138 self.disp.log_critical(err_msg)
139 raise RuntimeError(err_msg)
140
141 # User Endpoints
142 # |- connection
144 f"{self.v1_str}/register", self.user.post_register, ["POST"],
145 decorators=[decorators.public_endpoint(), decorators.user_endpoint]
146 )
147
149 f"{self.v1_str}/login", self.user.post_login, ["POST"],
150 decorators=[decorators.public_endpoint(), decorators.user_endpoint]
151 )
152
154 f"{self.v1_str}/logout", self.user.post_logout, ["POST"],
155 decorators=[decorators.auth_endpoint(), decorators.user_endpoint]
156 )
157
158 # |- e-mail verification
160 f"{self.v1_str}/send_email_verification", self.user.post_send_email_verification,
161 ["POST"], decorators=[decorators.auth_endpoint(), decorators.user_endpoint]
162 )
163
164 # |- password reset
166 f"{self.v1_str}/reset_password", self.user.put_reset_password,
167 ["PUT"], decorators=[decorators.public_endpoint(), decorators.user_endpoint]
168 )
169
170 # |- user update
172 f"{self.v1_str}/user", self.user.put_user, ["PUT"],
173 decorators=[decorators.auth_endpoint(), decorators.user_endpoint]
174 )
176 f"{self.v1_str}/user", self.user.patch_user, ["PATCH"],
177 decorators=[decorators.auth_endpoint(), decorators.user_endpoint]
178 )
179
180 # |- info querying
182 f"{self.v1_str}/user", self.user.get_user, ["GET"],
183 decorators=[decorators.auth_endpoint(), decorators.user_endpoint]
184 )
186 f"{self.v1_str}/user_id", self.user.get_user_id, ["GET"],
187 decorators=[decorators.auth_endpoint(), decorators.user_endpoint]
188 )
189
190 # |- user removal
192 f"{self.v1_str}/user", self.user.delete_user, ["DELETE"],
193 decorators=[decorators.admin_endpoint(), decorators.user_endpoint]
194 )
195
196 # Cat Endpoints
198 f"{self.v1_str}/feeder", self.cat_endpoints.put_register_feeder, "PUT",
199 decorators=[
200 decorators.auth_endpoint(),
201 decorators.cat_endpoint,
202 decorators.json_body(
203 "Register a new cat feeder with location and details",
204 example={
205 "latitude": 48.8566,
206 "longitude": 2.3522,
207 "city_locality": "Paris",
208 "country": "France",
209 "mac": "AA:BB:CC:DD:EE:FF",
210 "name": "My Feeder"
211 }
212 )
213 ]
214 )
216 f"{self.v1_str}/feeder", self.cat_endpoints.patch_feeder, "PATCH",
217 decorators=[
218 decorators.auth_endpoint(),
219 decorators.cat_endpoint,
220 decorators.json_body(
221 "Update feeder details - provide id or mac, and fields to update",
222 example={
223 "mac": "AA:BB:CC:DD:EE:FF",
224 "name": "Updated Feeder Name",
225 "latitude": 48.8566,
226 "longitude": 2.3522
227 }
228 )
229 ]
230 )
232 f"{self.v1_str}/feeder", self.cat_endpoints.get_feeder, "GET",
233 decorators=[
234 decorators.auth_endpoint(),
235 decorators.cat_endpoint,
236 decorators.json_body(
237 "Get feeder status by mac, name, or id",
238 example={"mac": "AA:BB:CC:DD:EE:FF"}
239 )
240 ]
241 )
243 f"{self.v1_str}/feeder/status", self.cat_endpoints.get_feeder_status, "GET",
244 decorators=[
245 decorators.auth_endpoint(),
246 decorators.cat_endpoint,
247 decorators.json_body(
248 "Get feeder status by mac, name, or id",
249 example={"mac": "AA:BB:CC:DD:EE:FF"}
250 )
251 ]
252 )
254 f"{self.v1_str}/feeder", self.cat_endpoints.delete_feeder, "DELETE",
255 decorators=[
256 decorators.auth_endpoint(),
257 decorators.cat_endpoint,
258 decorators.json_body(
259 "Remove a feeder based on it's mac or id",
260 example={"mac": "AA:BB:CC:DD:EE:FF"}
261 )
262 ]
263 )
265 f"{self.v1_str}/feeders", self.cat_endpoints.get_feeders, "GET",
266 decorators=[
267 decorators.auth_endpoint(),
268 decorators.cat_endpoint,
269 decorators.set_operation_id("get_feeders"),
270 decorators.set_summary("Get all feeders"),
271 decorators.set_description(
272 "Retrieve a list of all feeders registered by the authenticated user")
273 ]
274 )
276 f"{self.v1_str}/feeder/fed", self.cat_endpoints.get_distribute_food, "GET",
277 decorators=[
278 decorators.auth_endpoint(),
279 decorators.cat_endpoint,
280 decorators.json_body(
281 "Get food distribution status",
282 example={"beacon_mac": "AA:BB:CC:DD:EE:FF"}
283 )
284 ]
285 )
287 f"{self.v1_str}/feeder/fed", self.cat_endpoints.post_distribute_food, "POST",
288 decorators=[
289 decorators.auth_endpoint(),
290 decorators.cat_endpoint,
291 decorators.json_body(
292 "Distribute food to feeder",
293 example={
294 "beacon_mac": "AA:BB:CC:DD:EE:FF",
295 "feeder_mac": "11:22:33:44:55:66",
296 "amount": 50
297 }
298 )
299 ]
300 )
302 f"{self.v1_str}/feeder/ip", self.cat_endpoints.put_feeder_ip, "PUT",
303 decorators=[
304 decorators.public_endpoint(), # Changed: feeder calls this directly
305 decorators.cat_endpoint,
306 decorators.json_body(
307 "Feeder IP update - called by feeder itself after reboot",
308 example={
309 "mac": "AA:BB:CC:DD:EE:FF",
310 "ip": "192.168.1.100"
311 }
312 ),
313 decorators.set_operation_id("update_feeder_ip_address"),
314 decorators.set_summary("Update feeder IP address"),
315 decorators.set_description(
316 "Allows feeder to update its IP address after reboot")
317 ]
318 )
319 # Beacon routes
321 f"{self.v1_str}/feeder/beacon", self.cat_endpoints.put_register_beacon, "PUT",
322 decorators=[
323 decorators.auth_endpoint(),
324 decorators.cat_endpoint,
325 decorators.json_body(
326 "Register a new beacon for a feeder",
327 example={
328 "mac": "AA:BB:CC:DD:EE:FF",
329 "name": "Beacon1"
330 }
331 )
332 ]
333 )
335 f"{self.v1_str}/feeder/beacon/status", self.cat_endpoints.get_beacon_status, "GET",
336 decorators=[
337 decorators.auth_endpoint(),
338 decorators.cat_endpoint,
339 decorators.json_body(
340 "Get beacon status by mac, name, or id",
341 example={"mac": "AA:BB:CC:DD:EE:FF"}
342 )
343 ]
344 )
346 f"{self.v1_str}/feeder/beacon", self.cat_endpoints.patch_beacon, "PATCH",
347 decorators=[
348 decorators.auth_endpoint(),
349 decorators.cat_endpoint,
350 decorators.json_body(
351 "Update beacon details - provide id or name, and fields to update",
352 example={
353 "id": 123,
354 "name": "Updated Beacon"
355 }
356 )
357 ]
358 )
360 f"{self.v1_str}/feeder/beacon", self.cat_endpoints.delete_beacon, "DELETE",
361 decorators=[
362 decorators.auth_endpoint(),
363 decorators.cat_endpoint,
364 decorators.json_body(
365 "Remove a beacon based on it's id",
366 example={"id": 123}
367 )
368 ]
369 )
371 f"{self.v1_str}/beacons", self.cat_endpoints.get_beacons, "GET",
372 decorators=[
373 decorators.auth_endpoint(),
374 decorators.cat_endpoint,
375 decorators.set_operation_id("get_beacons"),
376 decorators.set_summary("Get all beacons"),
377 decorators.set_description(
378 "Retrieve a list of all beacons registered by the authenticated user")
379 ]
380 )
381 # location endpoints
383 f"{self.v1_str}/feeder/beacon/locations", self.cat_endpoints.get_beacon_locations, "GET",
384 decorators=[
385 decorators.auth_endpoint(),
386 decorators.cat_endpoint,
387 decorators.json_body(
388 "Get beacon location history",
389 example={"mac": "AA:BB:CC:DD:EE:FF"}
390 )
391 ]
392 )
394 f"{self.v1_str}/feeder/beacon/location", self.cat_endpoints.post_beacon_location, "POST",
395 decorators=[
396 decorators.auth_endpoint(),
397 decorators.cat_endpoint,
398 decorators.json_body(
399 "Post new beacon location",
400 example={
401 "beacon_mac": "AA:BB:CC:DD:EE:FF",
402 "feeder_mac": "11:22:33:44:55:66"
403 }
404 )
405 ]
406 )
408 f"{self.v1_str}/feeder/visits", self.cat_endpoints.get_feeder_visits, "GET",
409 decorators=[
410 decorators.auth_endpoint(),
411 decorators.cat_endpoint,
412 decorators.json_body(
413 "Get feeder visit history",
414 example={"mac": "AA:BB:CC:DD:EE:FF"}
415 )
416 ]
417 )
419 f"{self.v1_str}/feeder/visit", self.cat_endpoints.post_feeder_visit, "POST",
420 decorators=[
421 decorators.auth_endpoint(),
422 decorators.cat_endpoint,
423 decorators.json_body(
424 "Record a feeder visit by a pet",
425 example={
426 "feeder_mac": "11:22:33:44:55:66",
427 "beacon_mac": "AA:BB:CC:DD:EE:FF"
428 }
429 )
430 ]
431 )
432
433 # Pet endpoints
435 f"{self.v1_str}/pet", self.cat_endpoints.put_register_pet, "PUT",
436 decorators=[
437 decorators.auth_endpoint(),
438 decorators.cat_endpoint,
439 decorators.json_body(
440 "Pet registration data with beacon_mac and name",
441 example={
442 "beacon_mac": "AA:BB:CC:DD:EE:FF",
443 "name": "Whiskers",
444 "food_max": 100,
445 "time_reset_hours": 24
446 }
447 ),
448 decorators.requires_bearer_auth()
449 ]
450 )
452 f"{self.v1_str}/pet", self.cat_endpoints.patch_pet, "PATCH",
453 decorators=[
454 decorators.auth_endpoint(),
455 decorators.cat_endpoint,
456 decorators.json_body(
457 "Pet update data with id and fields to update",
458 example={
459 "id": 123,
460 "name": "Whiskers Updated",
461 "food_max": 150
462 }
463 ),
464 decorators.requires_bearer_auth()
465 ]
466 )
468 f"{self.v1_str}/pet", self.cat_endpoints.get_pet, "GET",
469 decorators=[
470 decorators.auth_endpoint(),
471 decorators.cat_endpoint,
472 decorators.json_body(
473 "JSON body with pet ID to retrieve",
474 example={"id": 123}
475 ),
476 decorators.requires_bearer_auth()
477 ]
478 )
480 f"{self.v1_str}/pet", self.cat_endpoints.delete_pet, "DELETE",
481 decorators=[
482 decorators.auth_endpoint(),
483 decorators.cat_endpoint,
484 decorators.json_body(
485 "JSON body with pet ID to delete",
486 example={"id": 123}
487 ),
488 decorators.requires_bearer_auth()
489 ]
490 )
492 f"{self.v1_str}/pets", self.cat_endpoints.get_pets, "GET",
493 decorators=[
494 decorators.auth_endpoint(),
495 decorators.cat_endpoint,
496 decorators.set_operation_id("get_pets"),
497 decorators.set_summary("Get all pets"),
498 decorators.set_description(
499 "Retrieve a list of all pets registered by the authenticated user")
500 ]
501 )
502
503 # Front-end endpoints
505
506 # Bonus routes - BEACON ENDPOINTS: Use individual functions to avoid Operation ID conflicts
507 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
508 "", self.bonus.root_beacon_get, "GET",
509 decorators=[decorators.public_endpoint(),
510 decorators.system_endpoint]
511 )
512 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
513 "", self.bonus.root_beacon_post, "POST",
514 decorators=[decorators.public_endpoint(),
515 decorators.system_endpoint]
516 )
517 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
518 "", self.bonus.root_beacon_put, "PUT",
519 decorators=[decorators.public_endpoint(),
520 decorators.system_endpoint]
521 )
522 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
523 "", self.bonus.root_beacon_patch, "PATCH",
524 decorators=[decorators.public_endpoint(),
525 decorators.system_endpoint]
526 )
527 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
528 "", self.bonus.root_beacon_delete, "DELETE",
529 decorators=[decorators.public_endpoint(),
530 decorators.system_endpoint]
531 )
532 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
533 "", self.bonus.root_beacon_head, "HEAD",
534 decorators=[decorators.public_endpoint(),
535 decorators.system_endpoint]
536 )
537 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
538 "", self.bonus.root_beacon_options, "OPTIONS",
539 decorators=[decorators.public_endpoint(),
540 decorators.system_endpoint]
541 )
542
543 # Home beacon endpoints
544 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
545 "/", self.bonus.home_beacon_get, "GET",
546 decorators=[decorators.public_endpoint(),
547 decorators.system_endpoint]
548 )
549 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
550 "/", self.bonus.home_beacon_post, "POST",
551 decorators=[decorators.public_endpoint(),
552 decorators.system_endpoint]
553 )
554 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
555 "/", self.bonus.home_beacon_put, "PUT",
556 decorators=[decorators.public_endpoint(),
557 decorators.system_endpoint]
558 )
559 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
560 "/", self.bonus.home_beacon_patch, "PATCH",
561 decorators=[decorators.public_endpoint(),
562 decorators.system_endpoint]
563 )
564 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
565 "/", self.bonus.home_beacon_delete, "DELETE",
566 decorators=[decorators.public_endpoint(),
567 decorators.system_endpoint]
568 )
569 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
570 "/", self.bonus.home_beacon_head, "HEAD",
571 decorators=[decorators.public_endpoint(),
572 decorators.system_endpoint]
573 )
574 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
575 "/", self.bonus.home_beacon_options, "OPTIONS",
576 decorators=[decorators.public_endpoint(),
577 decorators.system_endpoint]
578 )
579
580 # API v1 beacon endpoints
581 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
582 f"{self.v1_str}/", self.bonus.api_v1_beacon_get, "GET",
583 decorators=[decorators.public_endpoint(),
584 decorators.system_endpoint]
585 )
586 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
587 f"{self.v1_str}/", self.bonus.api_v1_beacon_post, "POST",
588 decorators=[decorators.public_endpoint(),
589 decorators.system_endpoint]
590 )
591 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
592 f"{self.v1_str}/", self.bonus.api_v1_beacon_put, "PUT",
593 decorators=[decorators.public_endpoint(),
594 decorators.system_endpoint]
595 )
596 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
597 f"{self.v1_str}/", self.bonus.api_v1_beacon_patch, "PATCH",
598 decorators=[decorators.public_endpoint(),
599 decorators.system_endpoint]
600 )
601 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
602 f"{self.v1_str}/", self.bonus.api_v1_beacon_delete, "DELETE",
603 decorators=[decorators.public_endpoint(),
604 decorators.system_endpoint]
605 )
606 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
607 f"{self.v1_str}/", self.bonus.api_v1_beacon_head, "HEAD",
608 decorators=[decorators.public_endpoint(),
609 decorators.system_endpoint]
610 )
611 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
612 f"{self.v1_str}/", self.bonus.api_v1_beacon_options, "OPTIONS",
613 decorators=[decorators.public_endpoint(),
614 decorators.system_endpoint]
615 )
616
617 # The endpoint to stop the server
618 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
619 f"{self.v1_str}/stop", self.bonus.post_stop_server, "PUT",
620 decorators=[
621 decorators.admin_endpoint(),
622 decorators.system_endpoint
623 ]
624 )
625
626 # Health check endpoint - use conditional registration
627 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
628 "/health", self.bonus.get_health, "GET",
629 decorators=[
630 decorators.public_endpoint(),
631 decorators.system_endpoint
632 ]
633 )
634
635 # favicon.ico support
636 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
637 "/favicon.ico", self.bonus.get_favicon, "GET",
638 decorators=[
639 decorators.public_endpoint(),
640 decorators.system_endpoint
641 ]
642 )
643
644 # /static/logo.png support
645 self.paths_initialisedpaths_initialised.add_path_if_not_exists(
646 "/static/logo.png", self.bonus.get_static_logo, "GET",
647 decorators=[
648 decorators.public_endpoint(),
649 decorators.system_endpoint
650 ]
651 )
652
653 # Oauth routes
655 OAuthAuthentication,
657 )
659 self.disp.log_error("OAuth Authentication is missing")
660 raise RuntimeError("Token validation service unavailable")
662 f"{self.oauth_str}/login", self.oauth_authentication_initialisedoauth_authentication_initialised.oauth_login, "POST",
663 # No () for oauth_endpoint
664 decorators=[decorators.public_endpoint(),
665 decorators.oauth_endpoint]
666 )
668 f"{self.oauth_str}/callback", self.oauth_authentication_initialisedoauth_authentication_initialised.oauth_callback, "POST",
669 # No () for oauth_endpoint
670 decorators=[decorators.public_endpoint(),
671 decorators.oauth_endpoint]
672 )
674 f"{self.oauth_str}/{'{provider}'}",
676 # No () for oauth_endpoint
677 decorators=[decorators.admin_endpoint(), decorators.oauth_endpoint]
678 )
680 f"{self.oauth_str}/{'{provider}'}",
681 self.oauth_authentication_initialisedoauth_authentication_initialised.update_oauth_provider_data, "PUT",
682 # No () for oauth_endpoint
683 decorators=[decorators.admin_endpoint(), decorators.oauth_endpoint]
684 )
686 f"{self.oauth_str}/{'{provider}'}",
687 self.oauth_authentication_initialisedoauth_authentication_initialised.patch_oauth_provider_data, "PATCH",
688 # No () for oauth_endpoint
689 decorators=[decorators.admin_endpoint(), decorators.oauth_endpoint]
690 )
692 f"{self.oauth_str}/{'{provider}'}",
693 self.oauth_authentication_initialisedoauth_authentication_initialised.delete_oauth_provider, "DELETE",
694 # No () for oauth_endpoint
695 decorators=[decorators.admin_endpoint(), decorators.oauth_endpoint]
696 )
697
698 # Token route
700 f"{self.token_endpoint}/valid", self.token_endpoints.get_token_valid, "GET",
701 # No () for token_endpoint
702 decorators=[decorators.auth_endpoint(), decorators.token_endpoint]
703 )
705 f"{self.token_endpoint}/admin", self.token_endpoints.get_admin, "GET",
706 # No () for token_endpoint
707 decorators=[decorators.admin_endpoint(), decorators.token_endpoint]
708 )
710 f"{self.token_endpoint}/ttl", self.token_endpoints.get_time_to_live, "GET",
711 # No () for token_endpoint
712 decorators=[decorators.auth_endpoint(), decorators.token_endpoint]
713 )
715 f"{self.token_endpoint}/info", self.token_endpoints.get_token_info, "GET",
716 # No () for token_endpoint
717 decorators=[decorators.auth_endpoint(), decorators.token_endpoint]
718 )
720 f"{self.token_endpoint}/refresh", self.token_endpoints.post_refresh_token, "POST",
721 # No () for token_endpoint
722 decorators=[decorators.auth_endpoint(), decorators.token_endpoint]
723 )
725 f"{self.token_endpoint}/revoke_account_tokens", self.token_endpoints.delete_revoke_account_token, "DELETE",
726 # No () for token_endpoint
727 decorators=[decorators.admin_endpoint(), decorators.token_endpoint]
728 )
729
730 # Testing endpoints (only if enabled in configuration)
731 if ENDPOINT_CONST.TEST_ENABLE_TESTING_ENDPOINTS:
732 self.disp.log_debug("Testing endpoints enabled")
733 # SQL testing endpoints
735 f"{self.sql_endpoint}/tables", self.testing_endpoints.get_tables, "GET",
736 decorators=[decorators.test_endpoint(
737 ), decorators.admin_endpoint()]
738 )
740 f"{self.sql_endpoint}/table/columns", self.testing_endpoints.get_table_columns, "GET",
741 decorators=[decorators.test_endpoint(
742 ), decorators.admin_endpoint()]
743 )
745 f"{self.sql_endpoint}/table/describe", self.testing_endpoints.describe_table, "GET",
746 decorators=[decorators.test_endpoint(
747 ), decorators.admin_endpoint()]
748 )
750 f"{self.sql_endpoint}/table/size", self.testing_endpoints.get_table_size, "GET",
751 decorators=[decorators.test_endpoint(
752 ), decorators.admin_endpoint()]
753 )
755 f"{self.sql_endpoint}/version", self.testing_endpoints.get_database_version, "GET",
756 decorators=[decorators.test_endpoint(
757 ), decorators.admin_endpoint()]
758 )
760 f"{self.sql_endpoint}/connected", self.testing_endpoints.test_sql_connection, "GET",
761 decorators=[decorators.test_endpoint(
762 ), decorators.admin_endpoint()]
763 )
765 f"{self.sql_endpoint}/triggers", self.testing_endpoints.get_triggers, "GET",
766 decorators=[decorators.test_endpoint(
767 ), decorators.admin_endpoint()]
768 )
770 f"{self.sql_endpoint}/triggers/names", self.testing_endpoints.get_trigger_names, "GET",
771 decorators=[decorators.test_endpoint(
772 ), decorators.admin_endpoint()]
773 )
775 f"{self.sql_endpoint}/datetime/now", self.testing_endpoints.get_current_datetime, "GET",
776 decorators=[decorators.test_endpoint(
777 ), decorators.admin_endpoint()]
778 )
780 f"{self.sql_endpoint}/datetime/today", self.testing_endpoints.get_current_date, "GET",
781 decorators=[decorators.test_endpoint(
782 ), decorators.admin_endpoint()]
783 )
785 f"{self.sql_endpoint}/datetime/to-string", self.testing_endpoints.convert_datetime_to_string, "GET",
786 decorators=[decorators.test_endpoint(
787 ), decorators.admin_endpoint()]
788 )
790 f"{self.sql_endpoint}/datetime/from-string", self.testing_endpoints.convert_string_to_datetime, "GET",
791 decorators=[decorators.test_endpoint(
792 ), decorators.admin_endpoint()]
793 )
794 # Bucket testing endpoints
796 f"{self.bucket_endpoint}/buckets", self.testing_endpoints.get_buckets, "GET",
797 decorators=[decorators.test_endpoint(
798 ), decorators.admin_endpoint()]
799 )
801 f"{self.bucket_endpoint}/connected", self.testing_endpoints.test_bucket_connection, "GET",
802 decorators=[decorators.test_endpoint(
803 ), decorators.admin_endpoint()]
804 )
806 f"{self.bucket_endpoint}/create", self.testing_endpoints.create_test_bucket, "POST",
807 decorators=[decorators.test_endpoint(
808 ), decorators.admin_endpoint()]
809 )
811 f"{self.bucket_endpoint}/upload", self.testing_endpoints.upload_test_file_stream, "POST",
812 decorators=[decorators.test_endpoint(
813 ), decorators.admin_endpoint()]
814 )
816 f"{self.bucket_endpoint}/files", self.testing_endpoints.get_bucket_files, "GET",
817 decorators=[decorators.test_endpoint(
818 ), decorators.admin_endpoint()]
819 )
821 f"{self.bucket_endpoint}/files/info", self.testing_endpoints.get_bucket_file_info, "GET",
822 decorators=[decorators.test_endpoint(
823 ), decorators.admin_endpoint()]
824 )
826 f"{self.bucket_endpoint}/download", self.testing_endpoints.download_test_file_stream, "GET",
827 decorators=[decorators.test_endpoint(
828 ), decorators.admin_endpoint()]
829 )
831 f"{self.bucket_endpoint}/delete", self.testing_endpoints.delete_test_bucket, "DELETE",
832 decorators=[decorators.test_endpoint(
833 ), decorators.admin_endpoint()]
834 )
836 f"{self.bucket_endpoint}/delete-file", self.testing_endpoints.delete_test_file, "DELETE",
837 decorators=[decorators.test_endpoint(
838 ), decorators.admin_endpoint()]
839 )
840 else:
841 self.disp.log_debug("Testing endpoints disabled")
None __init__(self, int success=0, int error=84, bool debug=False)