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