Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add delete_project and bulk_delete_project #95

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion sonarqube/rest/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
API_PROJECTS_CREATE_PROJECT_ENDPOINT
)
Expand Down Expand Up @@ -63,6 +65,7 @@ def search_projects(

:return:
"""

@POST(API_PROJECTS_CREATE_PROJECT_ENDPOINT)
def create_project(
self,
Expand All @@ -80,4 +83,36 @@ def create_project(
Possible values
* private
* public
"""
"""

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the undefined name POST.

The POST decorator is undefined. Ensure it is imported or defined.

+ from sonarqube.utils.common import POST
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@POST(API_PROJECTS_DELETE_ENDPOINT)
+ from sonarqube.utils.common import POST
@POST(API_PROJECTS_DELETE_ENDPOINT)
Tools
Ruff

88-88: Undefined name POST

(F821)

@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:
"""
2 changes: 2 additions & 0 deletions sonarqube/utils/config.py
Original file line number Diff line number Diff line change
@@ -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_PROJECTS_CREATE_PROJECT_ENDPOINT = "/api/projects/create"

Expand Down
Loading