DeleteVMWithOptions permanently deletes a VM or container with specific options WARNING: This operation is irreversible and will destroy all VM data including disks.
(vm *VM, options *DeleteVMOptions)
| 297 | // DeleteVMWithOptions permanently deletes a VM or container with specific options |
| 298 | // WARNING: This operation is irreversible and will destroy all VM data including disks. |
| 299 | func (c *Client) DeleteVMWithOptions(vm *VM, options *DeleteVMOptions) (string, error) { |
| 300 | path := fmt.Sprintf("/nodes/%s/%s/%d", vm.Node, vm.Type, vm.ID) |
| 301 | |
| 302 | // Build query parameters |
| 303 | params := make(map[string]interface{}) |
| 304 | |
| 305 | if options != nil { |
| 306 | if options.Force { |
| 307 | params["force"] = "1" |
| 308 | } |
| 309 | |
| 310 | if options.SkipLock { |
| 311 | params["skiplock"] = "1" |
| 312 | } |
| 313 | |
| 314 | if options.DestroyUnreferencedDisks { |
| 315 | params["destroy-unreferenced-disks"] = "1" |
| 316 | } |
| 317 | |
| 318 | if options.Purge { |
| 319 | params["purge"] = "1" |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | // Add query parameters to path if any |
| 324 | if len(params) > 0 { |
| 325 | queryParts := make([]string, 0, len(params)) |
| 326 | for key, value := range params { |
| 327 | queryParts = append(queryParts, fmt.Sprintf("%s=%v", key, value)) |
| 328 | } |
| 329 | |
| 330 | path += "?" + strings.Join(queryParts, "&") |
| 331 | } |
| 332 | |
| 333 | var response map[string]interface{} |
| 334 | if err := c.DeleteWithResponse(path, &response); err != nil { |
| 335 | return "", err |
| 336 | } |
| 337 | |
| 338 | return c.extractUPID(response) |
| 339 | } |
no test coverage detected