Models.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Optional
  4. class BaseModel:
  5. def __init__(self, **kwargs):
  6. self.__dict__.update(kwargs)
  7. # OAuth OAuth2Settings data template.
  8. class OAuth2Settings(BaseModel):
  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. # User profile data template.
  18. class UserProfile(BaseModel):
  19. user_id = None # type: Optional[str]
  20. username = None # type: Optional[str]
  21. profile_image_url = None # type: Optional[str]
  22. # Authentication data template.
  23. class AuthenticationResponse(BaseModel):
  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. # Response status template.
  33. class ResponseStatus(BaseModel):
  34. code = 200 # type: int
  35. message = "" # type str
  36. # Response data template.
  37. class ResponseData(BaseModel):
  38. status = None # type: ResponseStatus
  39. data_stream = None # type: Optional[bytes]
  40. redirect_uri = None # type: Optional[str]
  41. content_type = "text/html" # type: str
  42. # Possible HTTP responses.
  43. HTTP_STATUS = {
  44. "OK": ResponseStatus(code=200, message="OK"),
  45. "NOT_FOUND": ResponseStatus(code=404, message="NOT FOUND"),
  46. "REDIRECT": ResponseStatus(code=302, message="REDIRECT")
  47. }