From d864e0d62eaead8db714b092d27c45be709a1e6c Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 9 Mar 2024 09:53:27 +0800 Subject: [PATCH] add delete_project and bulk_delete_project --- sonarqube/rest/projects.py | 33 +++++++++++++++++++++++++++++++++ sonarqube/utils/config.py | 2 ++ 2 files changed, 35 insertions(+) diff --git a/sonarqube/rest/projects.py b/sonarqube/rest/projects.py index 7bda1ea..5c27a94 100644 --- a/sonarqube/rest/projects.py +++ b/sonarqube/rest/projects.py @@ -3,6 +3,8 @@ # @Author: Jialiang Shi from sonarqube.utils.rest_client import RestClient from sonarqube.utils.config import ( + API_PROJECTS_BULK_DELETE_ENDPOINT, + API_PROJECTS_DELETE_ENDPOINT, API_PROJECTS_SEARCH_ENDPOINT, ) from sonarqube.utils.common import GET, POST @@ -67,3 +69,34 @@ def search_projects( :return: """ + @POST(API_PROJECTS_DELETE_ENDPOINT) + def delete_project(self, key): + """ + SINCE 5.2 + Delete a project + + :param key: Project key + :return: + """ + + @POST(API_PROJECTS_BULK_DELETE_ENDPOINT) + def bulk_delete_project( + self, + analyzedBefore=None, + onProvisionedOnly=False, + projects=None, q=None, + qualifiers=None): + """ + SINCE 5.2 + Delete one or several projects. + + :param analyzedBefore: Filter the projects for which last analysis of any branch is older than the given date (exclusive). + Either a date (server timezone) or datetime can be provided. + :param onProvisionedOnly: Filter the projects that are provisioned + :param projects: Comma-separated list of project keys + :param q: Limit to: + component names that contain the supplied string + component keys that contain the supplied string + :param qualifiers: Comma-separated list of component qualifiers. Filter the results with the specified qualifiers + :return: + """ diff --git a/sonarqube/utils/config.py b/sonarqube/utils/config.py index 91df5aa..5bc5127 100644 --- a/sonarqube/utils/config.py +++ b/sonarqube/utils/config.py @@ -1,5 +1,7 @@ API_COMPONENTS_SHOW_ENDPOINT = "/api/components/show" +API_PROJECTS_BULK_DELETE_ENDPOINT = "/api/projects/bulk_delete" +API_PROJECTS_DELETE_ENDPOINT = "/api/projects/delete" API_PROJECTS_SEARCH_ENDPOINT = "/api/projects/search" API_USERS_SEARCH_ENDPOINT = "/api/users/search"