From b685d7ab27b7b840756b30490f4fd0e98e2c0c29 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:28:12 +0200 Subject: [PATCH 1/7] modified docstrings --- ayon_api/server_api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 5b3631757..fa7ef322b 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7765,9 +7765,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 @@ -7802,7 +7803,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: From ba885c980acfd9fcd4835105f1c3aba96ed4085d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:28:38 +0200 Subject: [PATCH 2/7] added deprecation warnings for thumbnail id --- ayon_api/server_api.py | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index fa7ef322b..167c4149b 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7827,7 +7827,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", @@ -7861,8 +7867,16 @@ 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_version_thumbnail( @@ -7885,8 +7899,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( @@ -7909,8 +7931,16 @@ 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( From 6f3d4a1bcd8ce8eb8003770f1957736701561dde Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:28:46 +0200 Subject: [PATCH 3/7] added dedicated method for task --- ayon_api/server_api.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 167c4149b..96ebf55a7 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7879,6 +7879,24 @@ def get_folder_thumbnail( 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, "folder", folder_id) + def get_version_thumbnail( self, project_name: str, From 0440bf28ceae8763657a0e9e7538bf152752e9f6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:29:33 +0200 Subject: [PATCH 4/7] fix variable name --- ayon_api/server_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 96ebf55a7..8715bb600 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7895,7 +7895,7 @@ def get_task_thumbnail( valid. """ - return self.get_thumbnail(project_name, "folder", folder_id) + return self.get_thumbnail(project_name, "folder", task_id) def get_version_thumbnail( self, From 7bf3707d3d037a26856a75a55599ce66bbadfb85 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:33:12 +0200 Subject: [PATCH 5/7] update public api --- ayon_api/__init__.py | 2 ++ ayon_api/_api.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) 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, From f16b5839a4ad151735e1fafc559a1e0b4b53b4d5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:48:51 +0200 Subject: [PATCH 6/7] fix line length --- ayon_api/server_api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 8715bb600..9c4fece17 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7952,8 +7952,9 @@ def get_workfile_thumbnail( if thumbnail_id: warnings.warn( ( - "Function 'get_workfile_thumbnail' got 'thumbnail_id' which" - " is deprecated and will be removed in future version." + "Function 'get_workfile_thumbnail' got 'thumbnail_id'" + " which is deprecated and will be removed in future" + " version." ), DeprecationWarning ) From f431d4cf5f10ea43710199a1d7e555455a4271fe Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Apr 2025 13:22:48 +0200 Subject: [PATCH 7/7] fix endpoint for task method --- ayon_api/server_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 6bd535a00..b1e286549 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -7899,7 +7899,7 @@ def get_task_thumbnail( valid. """ - return self.get_thumbnail(project_name, "folder", task_id) + return self.get_thumbnail(project_name, "task", task_id) def get_version_thumbnail( self,