diff --git a/ayon_api/__init__.py b/ayon_api/__init__.py index fdec19cce..373cbad88 100644 --- a/ayon_api/__init__.py +++ b/ayon_api/__init__.py @@ -214,6 +214,7 @@ get_thumbnail_by_id, get_thumbnail, get_folder_thumbnail, + get_task_thumbnail, get_version_thumbnail, get_workfile_thumbnail, create_thumbnail, @@ -459,6 +460,7 @@ "get_thumbnail_by_id", "get_thumbnail", "get_folder_thumbnail", + "get_task_thumbnail", "get_version_thumbnail", "get_workfile_thumbnail", "create_thumbnail", diff --git a/ayon_api/_api.py b/ayon_api/_api.py index 3b9fc9823..9dbbc05b9 100644 --- a/ayon_api/_api.py +++ b/ayon_api/_api.py @@ -5698,9 +5698,10 @@ def get_thumbnail_by_id( ) -> ThumbnailContent: """Get thumbnail from server by id. - Permissions of thumbnails are related to entities so thumbnails must - be queried per entity. So an entity type and entity type is required - to be passed. + Warnings: + Please keep in mind that used endpoint is allowed only for admins + and managers. Use 'get_thumbnail' with entity type and id + to allow access for artists. Notes: It is recommended to use one of prepared entity type specific @@ -5736,7 +5737,7 @@ def get_thumbnail( """Get thumbnail from server. Permissions of thumbnails are related to entities so thumbnails must - be queried per entity. So an entity type and entity type is required + be queried per entity. So an entity type and entity id is required to be passed. Notes: @@ -5794,6 +5795,28 @@ def get_folder_thumbnail( ) +def get_task_thumbnail( + project_name: str, + task_id: str, +) -> ThumbnailContent: + """Prepared method to receive thumbnail for task entity. + + Args: + project_name (str): Project under which the entity is located. + task_id (str): Folder id for which thumbnail should be returned. + + Returns: + ThumbnailContent: Thumbnail content wrapper. Does not have to be + valid. + + """ + con = get_server_api_connection() + return con.get_task_thumbnail( + project_name=project_name, + task_id=task_id, + ) + + def get_version_thumbnail( project_name: str, version_id: str, diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 87f939e45..b1e286549 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7769,9 +7769,10 @@ def get_thumbnail_by_id( ) -> ThumbnailContent: """Get thumbnail from server by id. - Permissions of thumbnails are related to entities so thumbnails must - be queried per entity. So an entity type and entity type is required - to be passed. + Warnings: + Please keep in mind that used endpoint is allowed only for admins + and managers. Use 'get_thumbnail' with entity type and id + to allow access for artists. Notes: It is recommended to use one of prepared entity type specific @@ -7806,7 +7807,7 @@ def get_thumbnail( """Get thumbnail from server. Permissions of thumbnails are related to entities so thumbnails must - be queried per entity. So an entity type and entity type is required + be queried per entity. So an entity type and entity id is required to be passed. Notes: @@ -7830,7 +7831,13 @@ def get_thumbnail( """ if thumbnail_id: - return self.get_thumbnail_by_id(project_name, thumbnail_id) + warnings.warn( + ( + "Function 'get_thumbnail' got 'thumbnail_id' which" + " is deprecated and will be removed in future version." + ), + DeprecationWarning + ) if entity_type in ( "folder", @@ -7864,10 +7871,36 @@ def get_folder_thumbnail( valid. """ + if thumbnail_id: + warnings.warn( + ( + "Function 'get_folder_thumbnail' got 'thumbnail_id' which" + " is deprecated and will be removed in future version." + ), + DeprecationWarning + ) return self.get_thumbnail( - project_name, "folder", folder_id, thumbnail_id + project_name, "folder", folder_id ) + def get_task_thumbnail( + self, + project_name: str, + task_id: str, + ) -> ThumbnailContent: + """Prepared method to receive thumbnail for task entity. + + Args: + project_name (str): Project under which the entity is located. + task_id (str): Folder id for which thumbnail should be returned. + + Returns: + ThumbnailContent: Thumbnail content wrapper. Does not have to be + valid. + + """ + return self.get_thumbnail(project_name, "task", task_id) + def get_version_thumbnail( self, project_name: str, @@ -7888,8 +7921,16 @@ def get_version_thumbnail( valid. """ + if thumbnail_id: + warnings.warn( + ( + "Function 'get_version_thumbnail' got 'thumbnail_id' which" + " is deprecated and will be removed in future version." + ), + DeprecationWarning + ) return self.get_thumbnail( - project_name, "version", version_id, thumbnail_id + project_name, "version", version_id ) def get_workfile_thumbnail( @@ -7912,8 +7953,17 @@ def get_workfile_thumbnail( valid. """ + if thumbnail_id: + warnings.warn( + ( + "Function 'get_workfile_thumbnail' got 'thumbnail_id'" + " which is deprecated and will be removed in future" + " version." + ), + DeprecationWarning + ) return self.get_thumbnail( - project_name, "workfile", workfile_id, thumbnail_id + project_name, "workfile", workfile_id ) def create_thumbnail(