DFLibraryFileUploadResponse.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (c) 2021 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from datetime import datetime
  4. from typing import Optional
  5. from .BaseModel import BaseModel
  6. class DFLibraryFileUploadResponse(BaseModel):
  7. """
  8. Model that represents the response received from the Digital Factory after requesting to upload a file in a Library project
  9. """
  10. def __init__(self, client_id: str, content_type: str, file_id: str, file_name: str, library_project_id: str,
  11. status: str, uploaded_at: str, user_id: str, username: str, download_url: Optional[str] = None,
  12. file_size: Optional[int] = None, status_description: Optional[str] = None,
  13. upload_url: Optional[str] = None, **kwargs) -> None:
  14. """
  15. :param client_id: The ID of the OAuth2 client that uploaded this file
  16. :param content_type: The content type of the Digital Library project file
  17. :param file_id: The ID of the library project file
  18. :param file_name: The name of the file
  19. :param library_project_id: The ID of the library project, in which the file will be uploaded
  20. :param status: The status of the Digital Library project file
  21. :param uploaded_at: The time on which the file was uploaded
  22. :param user_id: The ID of the user that uploaded this file
  23. :param username: The user's unique username
  24. :param download_url: A signed URL to download the resulting file. Only available when the job is finished
  25. :param file_size: The size of the uploaded file (in bytes)
  26. :param status_description: Contains more details about the status, e.g. the cause of failures
  27. :param upload_url: The one-time use URL where the file must be uploaded to (only if status is uploading)
  28. :param kwargs: Other keyword arguments that may be included in the response
  29. """
  30. self.client_id = client_id # type: str
  31. self.content_type = content_type # type: str
  32. self.file_id = file_id # type: str
  33. self.file_name = file_name # type: str
  34. self.library_project_id = library_project_id # type: str
  35. self.status = status # type: str
  36. self.uploaded_at = self.parseDate(uploaded_at) # type: datetime
  37. self.user_id = user_id # type: str
  38. self.username = username # type: str
  39. self.download_url = download_url # type: Optional[str]
  40. self.file_size = file_size # type: Optional[int]
  41. self.status_description = status_description # type: Optional[str]
  42. self.upload_url = upload_url # type: Optional[str]
  43. super().__init__(**kwargs)