From 1c9fd77b0c06f7855fdd5f459f9d48c4fa877a4d Mon Sep 17 00:00:00 2001 From: Alvaro Tinoco Date: Tue, 16 Jul 2024 13:35:52 +0200 Subject: [PATCH] Implement workflow operations --- osidb_bindings/session.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/osidb_bindings/session.py b/osidb_bindings/session.py index c2fefbd..78ad66d 100644 --- a/osidb_bindings/session.py +++ b/osidb_bindings/session.py @@ -174,6 +174,8 @@ def __init__(self, base_url, auth=None, verify_ssl=True): "list", "create", "search", + "promote", + "reject" ), subresources={ "comments": {"allowed_operations": ["retrieve", "list", "create"]}, @@ -524,6 +526,35 @@ def bulk_delete(self, form_data: Dict[str, Any], *args, **kwargs): else: self.__raise_operation_unsupported("bulk_delete") + def promote(self, id, *args, **kwargs): + if "promote" in self.allowed_operations: + method_module = self.__get_method_module( + resource_name=self.resource_name, method="promote_create" + ) + sync_fn = get_sync_function(method_module) + return sync_fn( + id, + *args, + client=self.client(), + **kwargs, + ) + else: + self.__raise_operation_unsupported("promote") + + def reject(self, id, *args, **kwargs): + if "reject" in self.allowed_operations: + method_module = self.__get_method_module( + resource_name=self.resource_name, method="reject_create" + ) + sync_fn = get_sync_function(method_module) + return sync_fn( + id, + *args, + client=self.client(), + **kwargs, + ) + else: + self.__raise_operation_unsupported("reject") # Extra operations def count(self, *args, **kwargs):