From dd9f5c13a32ca4983b1bd5e7d3472d48970c8557 Mon Sep 17 00:00:00 2001 From: yelysenk Date: Fri, 13 Jun 2025 14:41:57 +0300 Subject: [PATCH] Added bulk_trash_user method to move user/s to trash --- duo_client/admin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/duo_client/admin.py b/duo_client/admin.py index 7deb218..b59630f 100644 --- a/duo_client/admin.py +++ b/duo_client/admin.py @@ -955,6 +955,17 @@ def delete_user(self, user_id): path = '/admin/v1/users/' + user_id return self.json_api_call('DELETE', path, {}) + def bulk_trash_user(self, user_ids: list): + """ + Move user/s to trash. + user_ids - List of user ids + Returns a list of dicts with the 'success' and 'user_id' data. + Raises RuntimeError on error. + """ + user_ids = [urllib.parse.quote_plus(str(user_id)) for user_id in user_ids] + path = '/admin/v1/users/bulk_send_to_trash' + return self.json_api_call('POST', path, {"user_id_list": json.dumps(user_ids)}) + def enroll_user(self, username, email, valid_secs=None): """ Enroll a user and send them an enrollment email.