Models.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Copyright (c) 2019 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Optional, Dict, Any
  4. class BaseModel:
  5. def __init__(self, **kwargs: Any) -> None:
  6. self.__dict__.update(kwargs)
  7. class OAuth2Settings(BaseModel):
  8. """OAuth OAuth2Settings data template."""
  9. CALLBACK_PORT = None # type: Optional[int]
  10. OAUTH_SERVER_URL = None # type: Optional[str]
  11. CLIENT_ID = None # type: Optional[str]
  12. CLIENT_SCOPES = None # type: Optional[str]
  13. CALLBACK_URL = None # type: Optional[str]
  14. AUTH_DATA_PREFERENCE_KEY = "" # type: str
  15. AUTH_SUCCESS_REDIRECT = "https://ultimaker.com" # type: str
  16. AUTH_FAILED_REDIRECT = "https://ultimaker.com" # type: str
  17. class UserProfile(BaseModel):
  18. """User profile data template."""
  19. user_id = None # type: Optional[str]
  20. username = None # type: Optional[str]
  21. profile_image_url = None # type: Optional[str]
  22. class AuthenticationResponse(BaseModel):
  23. """Authentication data template."""
  24. # Data comes from the token response with success flag and error message added.
  25. success = True # type: bool
  26. token_type = None # type: Optional[str]
  27. access_token = None # type: Optional[str]
  28. refresh_token = None # type: Optional[str]
  29. expires_in = None # type: Optional[str]
  30. scope = None # type: Optional[str]
  31. err_message = None # type: Optional[str]
  32. received_at = None # type: Optional[str]
  33. class ResponseStatus(BaseModel):
  34. """Response status template."""
  35. code = 200 # type: int
  36. message = "" # type: str
  37. class ResponseData(BaseModel):
  38. """Response data template."""
  39. status = None # type: ResponseStatus
  40. data_stream = None # type: Optional[bytes]
  41. redirect_uri = None # type: Optional[str]
  42. content_type = "text/html" # type: str
  43. HTTP_STATUS = {
  44. """Possible HTTP responses."""
  45. "OK": ResponseStatus(code = 200, message = "OK"),
  46. "NOT_FOUND": ResponseStatus(code = 404, message = "NOT FOUND"),
  47. "REDIRECT": ResponseStatus(code = 302, message = "REDIRECT")
  48. } # type: Dict[str, ResponseStatus]