Skip to content

Commit

Permalink
Breaking change: New options when calling DeleteProject
Browse files Browse the repository at this point in the history
  • Loading branch information
heidiberry committed Sep 8, 2024
1 parent afb6163 commit 113bdaf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
16 changes: 13 additions & 3 deletions projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,18 +1159,28 @@ func (s *ProjectsService) UnarchiveProject(pid interface{}, options ...RequestOp
return p, resp, nil
}

// DeleteProjectOptions represents options to delete a project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/projects.html#delete-project
type DeleteProjectOptions struct {
FullPath *string `url:"full_path" json:"full_path"`
PermanentlyRemove *bool `url:"permanently_remove" json:"permanently_remove"`
}

// DeleteProject removes a project including all associated resources
// (issues, merge requests etc.)
//
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#delete-project
func (s *ProjectsService) DeleteProject(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/projects.html#delete-project
func (s *ProjectsService) DeleteProject(pid interface{}, opt *DeleteProjectOptions, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s", PathEscape(project))

req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
return nil, err
}
Expand Down
18 changes: 18 additions & 0 deletions projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,24 @@ func TestListProjectForks(t *testing.T) {
}
}

func TestDeleteProject(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/projects/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodDelete)
})

opt := &DeleteProjectOptions{
FullPath: Ptr("group/project"),
PermanentlyRemove: Ptr(true),
}

_, err := client.Projects.DeleteProject(1, opt)
if err != nil {
t.Errorf("Projects.DeleteProject returned error: %v", err)
}
}

func TestShareProjectWithGroup(t *testing.T) {
mux, client := setup(t)

Expand Down

0 comments on commit 113bdaf

Please sign in to comment.