Skip to content

Commit

Permalink
client: Add DeleteProjectForce
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Bolton <[email protected]>
  • Loading branch information
boltmark committed Dec 9, 2024
1 parent 9f46a08 commit 2ca9fa8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ type InstanceServer interface {
UpdateProject(name string, project api.ProjectPut, ETag string) (err error)
RenameProject(name string, project api.ProjectPost) (op Operation, err error)
DeleteProject(name string) (err error)
DeleteProjectForce(name string) (err error)

// Storage pool functions ("storage" API extension)
GetStoragePoolNames() (names []string, err error)
Expand Down
15 changes: 15 additions & 0 deletions client/lxd_projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,18 @@ func (r *ProtocolLXD) DeleteProject(name string) error {

return nil
}

// DeleteProjectForce deletes a project and everything inside of it.
func (r *ProtocolLXD) DeleteProjectForce(name string) error {
if !r.HasExtension("projects_force_delete") {
return fmt.Errorf("The server is missing the required \"projects_force_delete\" API extension")
}

// Send the request.
_, _, err := r.query("DELETE", fmt.Sprintf("/projects/%s?force=1", url.PathEscape(name)), nil, "")
if err != nil {
return err
}

return nil
}

0 comments on commit 2ca9fa8

Please sign in to comment.