From 7c3cc839328958838be95f3b243efe97e4af8d98 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:06:09 +0100 Subject: [PATCH 1/3] update public api arguments --- ayon_api/_api.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ayon_api/_api.py b/ayon_api/_api.py index d18a1b67e..726ee9f7a 100644 --- a/ayon_api/_api.py +++ b/ayon_api/_api.py @@ -881,6 +881,8 @@ def get_events( newer_than: Optional[str] = None, older_than: Optional[str] = None, fields: Optional[Iterable[str]] = None, + limit: Optional[int] = None, + order: "Optional[ayon_api.utils.SortOrder]" = None, states: Optional[Iterable[str]] = None, ): """Get events from server with filtering options. @@ -905,6 +907,10 @@ def get_events( iso datetime string. fields (Optional[Iterable[str]]): Fields that should be received for each event. + limit (Optional[int]): Limit number of events to be fetched. + order (Optional[SortOrder]): Order events in ascending + or descending order. It is recommended to set 'limit' + when used descending. states (Optional[Iterable[str]]): DEPRECATED Filtering by states. Use 'statuses' instead. @@ -924,6 +930,8 @@ def get_events( newer_than=newer_than, older_than=older_than, fields=fields, + limit=limit, + order=order, states=states, ) @@ -1140,6 +1148,8 @@ def get_activities( changed_before: Optional[str] = None, reference_types: Optional[Iterable["ActivityReferenceType"]] = None, fields: Optional[Iterable[str]] = None, + limit: Optional[int] = None, + order: "Optional[ayon_api.utils.SortOrder]" = None, ) -> Generator[Dict[str, Any], None, None]: """Get activities from server with filtering options. @@ -1158,6 +1168,10 @@ def get_activities( Reference types filter. Defaults to `['origin']`. fields (Optional[Iterable[str]]): Fields that should be received for each activity. + limit (Optional[int]): Limit number of activities to be fetched. + order (Optional[SortOrder]): Order activities in ascending + or descending order. It is recommended to set 'limit' + when used descending. Returns: Generator[dict[str, Any]]: Available activities matching filters. @@ -1175,6 +1189,8 @@ def get_activities( changed_before=changed_before, reference_types=reference_types, fields=fields, + limit=limit, + order=order, ) From 8791324c00016db4d84cc14f24512641d643273f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:07:42 +0100 Subject: [PATCH 2/3] fix version comparison --- 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 5f1355079..7a8cd47e3 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -1799,7 +1799,7 @@ def enroll_event_job( ): kwargs["ignoreOlderThan"] = ignore_older_than if ignore_sender_types is not None: - if (major, minor, patch) > (1, 5, 4): + if (major, minor, patch) <= (1, 5, 4): raise ValueError( "Ignore sender types are not supported for" f" your version of server {self.server_version}." From 11a5432dc9360bad334aa3b37ded1f21b73ada1d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:22:05 +0100 Subject: [PATCH 3/3] fix automated api again --- automated_api.py | 11 +++++++++-- ayon_api/_api.py | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/automated_api.py b/automated_api.py index a764663c2..73b33d668 100644 --- a/automated_api.py +++ b/automated_api.py @@ -120,15 +120,22 @@ def _get_typehint(annotation, api_globals): typehint = ( str(annotation) - .replace("typing.", "") .replace("NoneType", "None") ) + full_path_regex = re.compile( + r"(?P(?P[a-zA-Z0-9_\.]+))" + ) + for item in full_path_regex.finditer(str(typehint)): + groups = item.groupdict() + name = groups["name"].split(".")[-1] + typehint = typehint.replace(groups["full"], name) + forwardref_regex = re.compile( r"(?PForwardRef\('(?P[a-zA-Z0-9]+)'\))" ) for item in forwardref_regex.finditer(str(typehint)): groups = item.groupdict() - name = groups["name"] + name = groups["name"].split(".")[-1] typehint = typehint.replace(groups["full"], f'"{name}"') try: diff --git a/ayon_api/_api.py b/ayon_api/_api.py index 726ee9f7a..1ef1e8d2b 100644 --- a/ayon_api/_api.py +++ b/ayon_api/_api.py @@ -22,6 +22,7 @@ from .exceptions import FailedServiceInit from .utils import ( NOT_SET, + SortOrder, get_default_settings_variant as _get_default_settings_variant, ) @@ -882,7 +883,7 @@ def get_events( older_than: Optional[str] = None, fields: Optional[Iterable[str]] = None, limit: Optional[int] = None, - order: "Optional[ayon_api.utils.SortOrder]" = None, + order: Optional[SortOrder] = None, states: Optional[Iterable[str]] = None, ): """Get events from server with filtering options. @@ -1149,7 +1150,7 @@ def get_activities( reference_types: Optional[Iterable["ActivityReferenceType"]] = None, fields: Optional[Iterable[str]] = None, limit: Optional[int] = None, - order: "Optional[ayon_api.utils.SortOrder]" = None, + order: Optional[SortOrder] = None, ) -> Generator[Dict[str, Any], None, None]: """Get activities from server with filtering options.