From dd61cafa5746a33a0f6bc0fcb59e129c72b0a3cb Mon Sep 17 00:00:00 2001 From: sjwmoveon Date: Tue, 18 Mar 2025 16:15:49 -0400 Subject: [PATCH 1/2] Add background_request option to taggings --- parsons/action_network/action_network.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/parsons/action_network/action_network.py b/parsons/action_network/action_network.py index aa87880f52..60b79fc592 100644 --- a/parsons/action_network/action_network.py +++ b/parsons/action_network/action_network.py @@ -1846,7 +1846,7 @@ def get_tagging(self, tag_id, tagging_id): """ return self.api.get_request(f"tags/{tag_id}/taggings/{tagging_id}") - def create_tagging(self, tag_id, payload): + def create_tagging(self, tag_id, payload, background_processing=False): """ `Args:` tag_id: @@ -1858,26 +1858,42 @@ def create_tagging(self, tag_id, payload): "osdi:person" : { "href" : "https://actionnetwork.org/api/v2/people/id" } } } + background_processing: bool + If set `true`, utilize ActionNetwork's "background processing". This will return + an immediate success, with an empty JSON body, and send your request to the + background queue for eventual processing. + https://actionnetwork.org/docs/v2/#background-processing `Returns:` A JSON response after creating the tagging `Documentation Reference`: https://actionnetwork.org/docs/v2/taggings """ - return self.api.post_request(f"tags/{tag_id}/taggings", data=json.dumps(payload)) + url = f"tags/{tag_id}/taggings" + if background_processing: + url = f"{url}?background_processing={background_processing}" + return self.api.post_request(url, data=json.dumps(payload)) - def delete_tagging(self, tag_id, tagging_id): + def delete_tagging(self, tag_id, tagging_id, background_processing=False): """ `Args:` tag_id: The unique id of the tag tagging_id: The unique id of the tagging to be deleted + background_processing: bool + If set `true`, utilize ActionNetwork's "background processing". This will return + an immediate success, with an empty JSON body, and send your request to the + background queue for eventual processing. + https://actionnetwork.org/docs/v2/#background-processing `Returns:` A JSON response after deleting the tagging `Documentation Reference`: https://actionnetwork.org/docs/v2/taggings """ - return self.api.delete_request(f"tags/{tag_id}/taggings/{tagging_id}") + url = f"tags/{tag_id}/taggings/{tagging_id}" + if background_processing: + url = f"{url}?background_processing={background_processing}" + return self.api.delete_request(url) # Wrappers def get_wrappers(self, limit=None, per_page=25, page=None, filter=None): From 57a539437f9886d60f09733c6998b5b41e9ec3f7 Mon Sep 17 00:00:00 2001 From: Sophie Waldman <62553142+sjwmoveon@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:43:57 -0400 Subject: [PATCH 2/2] Pass background_processing=true hardcoded --- parsons/action_network/action_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsons/action_network/action_network.py b/parsons/action_network/action_network.py index 60b79fc592..7858f3e3f6 100644 --- a/parsons/action_network/action_network.py +++ b/parsons/action_network/action_network.py @@ -1870,7 +1870,7 @@ def create_tagging(self, tag_id, payload, background_processing=False): """ url = f"tags/{tag_id}/taggings" if background_processing: - url = f"{url}?background_processing={background_processing}" + url = f"{url}?background_processing=true" return self.api.post_request(url, data=json.dumps(payload)) def delete_tagging(self, tag_id, tagging_id, background_processing=False): @@ -1892,7 +1892,7 @@ def delete_tagging(self, tag_id, tagging_id, background_processing=False): """ url = f"tags/{tag_id}/taggings/{tagging_id}" if background_processing: - url = f"{url}?background_processing={background_processing}" + url = f"{url}?background_processing=true" return self.api.delete_request(url) # Wrappers