From 693d8c7f0aba750ab4daccfd44c109be67b4e8f6 Mon Sep 17 00:00:00 2001 From: Steven Miller Date: Tue, 11 Nov 2025 12:10:27 -0500 Subject: [PATCH 1/5] Cloud hypervisor client --- .gitignore | 6 + Makefile | 38 +- lib/vmm/README.md | 132 ++ lib/vmm/binaries.go | 63 + lib/vmm/binaries/.gitignore | 3 + lib/vmm/client.go | 98 ++ lib/vmm/client_test.go | 148 ++ lib/vmm/version.go | 41 + oapi-codegen-vmm.yaml | 10 + .../api-v0.3.0/cloud-hypervisor.yaml | 1270 +++++++++++++++++ 10 files changed, 1807 insertions(+), 2 deletions(-) create mode 100644 lib/vmm/README.md create mode 100644 lib/vmm/binaries.go create mode 100644 lib/vmm/binaries/.gitignore create mode 100644 lib/vmm/client.go create mode 100644 lib/vmm/client_test.go create mode 100644 lib/vmm/version.go create mode 100644 oapi-codegen-vmm.yaml create mode 100644 specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml diff --git a/.gitignore b/.gitignore index 7a77684c..3d94d833 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,9 @@ bin/** tmp tmp/** .datadir + +# Cloud Hypervisor binaries (embedded at build time) +lib/vmm/binaries/cloud-hypervisor/*/*/cloud-hypervisor + +# Generated VMM client +lib/vmm/vmm.go diff --git a/Makefile b/Makefile index aa985157..300191b7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -.PHONY: oapi-generate generate-wire generate-all dev build test install-tools gen-jwt +.PHONY: oapi-generate generate-vmm-client generate-wire generate-all dev build test install-tools gen-jwt download-ch-binaries download-ch-spec # Directory where local binaries will be installed BIN_DIR ?= $(CURDIR)/bin @@ -31,6 +31,32 @@ $(GODOTENV): | $(BIN_DIR) install-tools: $(OAPI_CODEGEN) $(AIR) $(WIRE) $(GODOTENV) +# Download Cloud Hypervisor binaries +download-ch-binaries: + @echo "Downloading Cloud Hypervisor binaries..." + @mkdir -p lib/vmm/binaries/cloud-hypervisor/v48.0/{x86_64,aarch64} + @mkdir -p lib/vmm/binaries/cloud-hypervisor/v49.0/{x86_64,aarch64} + @echo "Downloading v48.0..." + @curl -L -o lib/vmm/binaries/cloud-hypervisor/v48.0/x86_64/cloud-hypervisor \ + https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v48.0/cloud-hypervisor-static + @curl -L -o lib/vmm/binaries/cloud-hypervisor/v48.0/aarch64/cloud-hypervisor \ + https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v48.0/cloud-hypervisor-static-aarch64 + @echo "Downloading v49.0..." + @curl -L -o lib/vmm/binaries/cloud-hypervisor/v49.0/x86_64/cloud-hypervisor \ + https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v49.0/cloud-hypervisor-static + @curl -L -o lib/vmm/binaries/cloud-hypervisor/v49.0/aarch64/cloud-hypervisor \ + https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v49.0/cloud-hypervisor-static-aarch64 + @chmod +x lib/vmm/binaries/cloud-hypervisor/v*/*/cloud-hypervisor + @echo "Binaries downloaded successfully" + +# Download Cloud Hypervisor API spec +download-ch-spec: + @echo "Downloading Cloud Hypervisor API spec..." + @mkdir -p specs/cloud-hypervisor/api-v0.3.0 + @curl -L -o specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml \ + https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/refs/tags/v48.0/vmm/src/api/openapi/cloud-hypervisor.yaml + @echo "API spec downloaded" + # Generate Go code from OpenAPI spec oapi-generate: $(OAPI_CODEGEN) @echo "Generating Go code from OpenAPI spec..." @@ -38,13 +64,20 @@ oapi-generate: $(OAPI_CODEGEN) @echo "Formatting generated code..." go fmt ./lib/oapi/oapi.go +# Generate Cloud Hypervisor client from their OpenAPI spec +generate-vmm-client: $(OAPI_CODEGEN) + @echo "Generating Cloud Hypervisor client from spec..." + $(OAPI_CODEGEN) -config ./oapi-codegen-vmm.yaml ./specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml + @echo "Formatting generated code..." + go fmt ./lib/vmm/vmm.go + # Generate wire dependency injection code generate-wire: $(WIRE) @echo "Generating wire code..." cd ./cmd/api && $(WIRE) # Generate all code -generate-all: oapi-generate generate-wire +generate-all: oapi-generate generate-vmm-client generate-wire # Build the binary build: | $(BIN_DIR) @@ -67,4 +100,5 @@ gen-jwt: $(GODOTENV) clean: rm -rf $(BIN_DIR) rm -f lib/oapi/oapi.go + rm -f lib/vmm/vmm.go diff --git a/lib/vmm/README.md b/lib/vmm/README.md new file mode 100644 index 00000000..ee798927 --- /dev/null +++ b/lib/vmm/README.md @@ -0,0 +1,132 @@ +# Cloud Hypervisor VMM Client + +Thin Go wrapper around Cloud Hypervisor's HTTP API (v0.3.0) with embedded binaries. + +## Features + +- Embedded Cloud Hypervisor binaries (v48.0, v49.0) for x86_64 and aarch64 +- Generated HTTP client from official OpenAPI spec +- Automatic binary extraction to data directory +- Unix socket communication +- Version detection and validation + +## Requirements + +**System:** +- Linux with KVM support (`/dev/kvm`) +- User must be in `kvm` group or run as root + +**Add user to kvm group:** +```bash +sudo usermod -aG kvm $USER +# Then log out and back in, or use: sg kvm -c "your-command" +``` + +## Usage + +### Start a VMM Process + +```go +import "github.com/onkernel/hypeman/lib/vmm" + +ctx := context.Background() +dataDir := "/var/lib/hypeman" +socketPath := "/tmp/vmm.sock" + +// Start Cloud Hypervisor VMM (extracts binary if needed) +err := vmm.StartProcess(ctx, dataDir, vmm.V48_0, socketPath) +if err != nil { + log.Fatal(err) +} +``` + +### Connect to Existing VMM + +```go +// Create client for existing VMM socket +client, err := vmm.NewVMM(socketPath) +if err != nil { + log.Fatal(err) +} + +// All generated API methods available directly +resp, err := client.GetVmmPingWithResponse(ctx) +``` + +### Check Binary Version + +```go +binaryPath, _ := vmm.GetBinaryPath(dataDir, vmm.V48_0) +version, err := vmm.ParseVersion(binaryPath) +fmt.Println(version) // "v48.0" +``` + +## Architecture + +``` +lib/vmm/ +├── vmm.go # Generated from OpenAPI spec (DO NOT EDIT) +├── client.go # Thin wrapper: NewVMM, StartProcess +├── binaries.go # Binary embedding and extraction +├── version.go # Version parsing utilities +├── binaries/ # Embedded Cloud Hypervisor binaries +│ └── cloud-hypervisor/ +│ ├── v48.0/ +│ │ ├── x86_64/cloud-hypervisor (4.5MB) +│ │ └── aarch64/cloud-hypervisor (3.3MB) +│ └── v49.0/ +│ ├── x86_64/cloud-hypervisor (4.5MB) +│ └── aarch64/cloud-hypervisor (3.3MB) +└── client_test.go # Tests with real Cloud Hypervisor +``` + +## Supported Versions + +- Cloud Hypervisor v48.0 (API v0.3.0) +- Cloud Hypervisor v49.0 (API v0.3.0) + +## Regenerating Client + +```bash +# Download latest spec (if needed) +make download-ch-spec + +# Regenerate client from spec +make generate-vmm-client +``` + +## Testing + +Tests run against real Cloud Hypervisor binaries (not mocked). + +```bash +# Must be in kvm group +sg kvm -c "go test ./lib/vmm/..." +``` + +## Binary Extraction + +Binaries are automatically extracted from embedded FS to: +``` +{dataDir}/system/binaries/{version}/{arch}/cloud-hypervisor +``` + +Extraction happens once per version. Subsequent calls reuse the extracted binary. + +## API Methods + +All Cloud Hypervisor API methods available via embedded `*ClientWithResponses`: + +- `GetVmmPingWithResponse()` - Check VMM health +- `ShutdownVMMWithResponse()` - Shutdown VMM +- `CreateVMWithResponse()` - Create VM configuration +- `BootVMWithResponse()` - Boot configured VM +- `PauseVMWithResponse()` - Pause running VM +- `ResumeVMWithResponse()` - Resume paused VM +- `VmSnapshotPutWithResponse()` - Create VM snapshot +- `VmRestorePutWithResponse()` - Restore from snapshot +- `VmInfoGetWithResponse()` - Get VM info +- And many more... + +See generated `vmm.go` for full API surface. + diff --git a/lib/vmm/binaries.go b/lib/vmm/binaries.go new file mode 100644 index 00000000..8fb55b0b --- /dev/null +++ b/lib/vmm/binaries.go @@ -0,0 +1,63 @@ +package vmm + +import ( + "embed" + "fmt" + "os" + "path/filepath" + "runtime" +) + +//go:embed binaries/cloud-hypervisor/v48.0/x86_64/cloud-hypervisor +//go:embed binaries/cloud-hypervisor/v48.0/aarch64/cloud-hypervisor +//go:embed binaries/cloud-hypervisor/v49.0/x86_64/cloud-hypervisor +//go:embed binaries/cloud-hypervisor/v49.0/aarch64/cloud-hypervisor +var binaryFS embed.FS + +type CHVersion string + +const ( + V48_0 CHVersion = "v48.0" + V49_0 CHVersion = "v49.0" +) + +var SupportedVersions = []CHVersion{V48_0, V49_0} + +// ExtractBinary extracts the embedded Cloud Hypervisor binary to the data directory +func ExtractBinary(dataDir string, version CHVersion) (string, error) { + arch := runtime.GOARCH + if arch == "amd64" { + arch = "x86_64" + } + + embeddedPath := fmt.Sprintf("binaries/cloud-hypervisor/%s/%s/cloud-hypervisor", version, arch) + extractPath := filepath.Join(dataDir, "system", "binaries", string(version), arch, "cloud-hypervisor") + + // Check if already extracted + if _, err := os.Stat(extractPath); err == nil { + return extractPath, nil + } + + // Create directory + if err := os.MkdirAll(filepath.Dir(extractPath), 0755); err != nil { + return "", fmt.Errorf("create binaries dir: %w", err) + } + + // Read embedded binary + data, err := binaryFS.ReadFile(embeddedPath) + if err != nil { + return "", fmt.Errorf("read embedded binary: %w", err) + } + + // Write to filesystem + if err := os.WriteFile(extractPath, data, 0755); err != nil { + return "", fmt.Errorf("write binary: %w", err) + } + + return extractPath, nil +} + +// GetBinaryPath returns path to extracted binary, extracting if needed +func GetBinaryPath(dataDir string, version CHVersion) (string, error) { + return ExtractBinary(dataDir, version) +} diff --git a/lib/vmm/binaries/.gitignore b/lib/vmm/binaries/.gitignore new file mode 100644 index 00000000..df7ea537 --- /dev/null +++ b/lib/vmm/binaries/.gitignore @@ -0,0 +1,3 @@ +# Ignore all binaries +cloud-hypervisor + diff --git a/lib/vmm/client.go b/lib/vmm/client.go new file mode 100644 index 00000000..c0df342a --- /dev/null +++ b/lib/vmm/client.go @@ -0,0 +1,98 @@ +package vmm + +import ( + "context" + "fmt" + "net" + "net/http" + "os" + "os/exec" + "time" +) + +// VMM wraps the generated Cloud Hypervisor client (API v0.3.0) +type VMM struct { + *ClientWithResponses + socketPath string +} + +// NewVMM creates a Cloud Hypervisor client for an existing VMM socket +func NewVMM(socketPath string) (*VMM, error) { + httpClient := &http.Client{ + Transport: &http.Transport{ + DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { + return net.Dial("unix", socketPath) + }, + }, + Timeout: 30 * time.Second, + } + + client, err := NewClientWithResponses("http://localhost/api/v1", + WithHTTPClient(httpClient)) + if err != nil { + return nil, fmt.Errorf("create client: %w", err) + } + + return &VMM{ + ClientWithResponses: client, + socketPath: socketPath, + }, nil +} + +// StartProcess starts a Cloud Hypervisor VMM process with the given version +// It extracts the embedded binary if needed and starts the VMM +func StartProcess(ctx context.Context, dataDir string, version CHVersion, socketPath string) error { + // Get binary path (extracts if needed) + binaryPath, err := GetBinaryPath(dataDir, version) + if err != nil { + return fmt.Errorf("get binary: %w", err) + } + + // Check if socket is already in use + if isSocketInUse(socketPath) { + return fmt.Errorf("socket already in use, VMM may be running at %s", socketPath) + } + + // Remove stale socket if exists + // Ignore error - if we can't remove it, CH will fail with clearer error + os.Remove(socketPath) + + cmd := exec.CommandContext(ctx, binaryPath, "--api-socket", socketPath) + + if err := cmd.Start(); err != nil { + return fmt.Errorf("start cloud-hypervisor: %w", err) + } + + // Wait for socket to be ready + return waitForSocket(ctx, socketPath, 5*time.Second) +} + +// isSocketInUse checks if a Unix socket is actively being used +func isSocketInUse(socketPath string) bool { + conn, err := net.DialTimeout("unix", socketPath, 100*time.Millisecond) + if err != nil { + return false // Socket doesn't exist or not listening + } + conn.Close() + return true +} + +func waitForSocket(ctx context.Context, path string, timeout time.Duration) error { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + ticker := time.NewTicker(10 * time.Millisecond) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return fmt.Errorf("timeout waiting for socket") + case <-ticker.C: + if conn, err := net.Dial("unix", path); err == nil { + conn.Close() + return nil + } + } + } +} diff --git a/lib/vmm/client_test.go b/lib/vmm/client_test.go new file mode 100644 index 00000000..fced699f --- /dev/null +++ b/lib/vmm/client_test.go @@ -0,0 +1,148 @@ +package vmm + +import ( + "context" + "os" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestExtractBinary(t *testing.T) { + tmpDir := t.TempDir() + + // Test extraction for v48.0 + binaryPath, err := ExtractBinary(tmpDir, V48_0) + require.NoError(t, err) + + // Verify file exists + _, err = os.Stat(binaryPath) + require.NoError(t, err) + + // Verify executable + info, err := os.Stat(binaryPath) + require.NoError(t, err) + assert.Equal(t, os.FileMode(0755), info.Mode().Perm()) + + // Test idempotency - second extraction should succeed and return same path + binaryPath2, err := ExtractBinary(tmpDir, V48_0) + require.NoError(t, err) + assert.Equal(t, binaryPath, binaryPath2) +} + +func TestIsVersionSupported(t *testing.T) { + assert.True(t, IsVersionSupported(V48_0)) + assert.True(t, IsVersionSupported(V49_0)) + assert.False(t, IsVersionSupported("v1.0")) +} + +func TestParseVersion(t *testing.T) { + tmpDir := t.TempDir() + + // Extract binary + binaryPath, err := ExtractBinary(tmpDir, V48_0) + require.NoError(t, err) + + // Parse version + version, err := ParseVersion(binaryPath) + require.NoError(t, err) + assert.Equal(t, V48_0, version) +} + +func TestStartProcessAndShutdown(t *testing.T) { + tmpDir := t.TempDir() + socketPath := filepath.Join(tmpDir, "test.sock") + ctx := context.Background() + + // Start VMM process + err := StartProcess(ctx, tmpDir, V48_0, socketPath) + require.NoError(t, err) + + // Verify socket exists + _, err = os.Stat(socketPath) + require.NoError(t, err) + + // Create client + client, err := NewVMM(socketPath) + require.NoError(t, err) + require.NotNil(t, client) + + // Ping the VMM + pingResp, err := client.GetVmmPingWithResponse(ctx) + require.NoError(t, err) + assert.Equal(t, 200, pingResp.StatusCode()) + + // Shutdown VMM + shutdownResp, err := client.ShutdownVMMWithResponse(ctx) + require.NoError(t, err) + // Note: API spec says 204, but actual implementation returns 200 + assert.True(t, shutdownResp.StatusCode() >= 200 && shutdownResp.StatusCode() < 300, + "Expected 2xx status code, got %d", shutdownResp.StatusCode()) + + // Wait a moment for VMM to actually shut down + time.Sleep(100 * time.Millisecond) +} + +func TestStartProcessSocketInUse(t *testing.T) { + tmpDir := t.TempDir() + socketPath := filepath.Join(tmpDir, "test.sock") + ctx := context.Background() + + // Start first VMM + err := StartProcess(ctx, tmpDir, V48_0, socketPath) + require.NoError(t, err) + + // Try to start second VMM on same socket - should fail + err = StartProcess(ctx, tmpDir, V48_0, socketPath) + require.Error(t, err) + assert.Contains(t, err.Error(), "socket already in use") + + // Cleanup + client, _ := NewVMM(socketPath) + if client != nil { + client.ShutdownVMMWithResponse(ctx) + } +} + +func TestMultipleVersions(t *testing.T) { + tmpDir := t.TempDir() + + tests := []struct { + name string + version CHVersion + }{ + {"v48.0", V48_0}, + {"v49.0", V49_0}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + socketPath := filepath.Join(tmpDir, tt.name+".sock") + ctx := context.Background() + + // Start VMM + err := StartProcess(ctx, tmpDir, tt.version, socketPath) + require.NoError(t, err) + + // Create client and ping + client, err := NewVMM(socketPath) + require.NoError(t, err) + + pingResp, err := client.GetVmmPingWithResponse(ctx) + require.NoError(t, err) + assert.Equal(t, 200, pingResp.StatusCode()) + + // Shutdown + shutdownResp, err := client.ShutdownVMMWithResponse(ctx) + require.NoError(t, err) + // Note: API spec says 204, but actual implementation returns 200 + assert.True(t, shutdownResp.StatusCode() >= 200 && shutdownResp.StatusCode() < 300, + "Expected 2xx status code, got %d", shutdownResp.StatusCode()) + + time.Sleep(100 * time.Millisecond) + }) + } +} diff --git a/lib/vmm/version.go b/lib/vmm/version.go new file mode 100644 index 00000000..f2d256aa --- /dev/null +++ b/lib/vmm/version.go @@ -0,0 +1,41 @@ +package vmm + +import ( + "fmt" + "os/exec" + "regexp" + "strings" +) + +var versionRegex = regexp.MustCompile(`v(\d+)\.(\d+)\.(\d+)`) + +// ParseVersion extracts version from cloud-hypervisor --version output +func ParseVersion(binaryPath string) (CHVersion, error) { + cmd := exec.Command(binaryPath, "--version") + output, err := cmd.Output() + if err != nil { + return "", fmt.Errorf("execute --version: %w", err) + } + + versionStr := strings.TrimSpace(string(output)) + + // Try to match known versions + if strings.Contains(versionStr, "v48.0") { + return V48_0, nil + } + if strings.Contains(versionStr, "v49.0") { + return V49_0, nil + } + + return "", fmt.Errorf("unsupported version: %s", versionStr) +} + +// IsVersionSupported checks if a version is supported by this library +func IsVersionSupported(version CHVersion) bool { + for _, v := range SupportedVersions { + if v == version { + return true + } + } + return false +} diff --git a/oapi-codegen-vmm.yaml b/oapi-codegen-vmm.yaml new file mode 100644 index 00000000..c82428f6 --- /dev/null +++ b/oapi-codegen-vmm.yaml @@ -0,0 +1,10 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json +package: vmm +generate: + client: true + models: true + embedded-spec: false +output: lib/vmm/vmm.go +output-options: + skip-prune: true + diff --git a/specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml b/specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml new file mode 100644 index 00000000..e4a76f6b --- /dev/null +++ b/specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml @@ -0,0 +1,1270 @@ +openapi: 3.0.1 +info: + title: Cloud Hypervisor API + description: Local HTTP based API for managing and inspecting a cloud-hypervisor virtual machine. + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: 0.3.0 + +servers: + - url: http://localhost/api/v1 + +paths: + /vmm.ping: + get: + summary: Ping the VMM to check for API server availability + responses: + 200: + description: The VMM information + content: + application/json: + schema: + $ref: "#/components/schemas/VmmPingResponse" + + /vmm.shutdown: + put: + summary: Shuts the cloud-hypervisor VMM. + operationId: shutdownVMM + responses: + 204: + description: The VMM successfully shutdown. + + /vm.info: + get: + summary: Returns general information about the cloud-hypervisor Virtual Machine (VM) instance. + responses: + 200: + description: The VM information + content: + application/json: + schema: + $ref: "#/components/schemas/VmInfo" + + /vm.counters: + get: + summary: Get counters from the VM + responses: + 200: + description: The VM counters + content: + application/json: + schema: + $ref: "#/components/schemas/VmCounters" + + /vm.create: + put: + summary: Create the cloud-hypervisor Virtual Machine (VM) instance. The instance is not booted, only created. + operationId: createVM + requestBody: + description: The VM configuration + content: + application/json: + schema: + $ref: "#/components/schemas/VmConfig" + required: true + responses: + 204: + description: The VM instance was successfully created. + + /vm.delete: + put: + summary: Delete the cloud-hypervisor Virtual Machine (VM) instance. + operationId: deleteVM + responses: + 204: + description: The VM instance was successfully deleted. + + /vm.boot: + put: + summary: Boot the previously created VM instance. + operationId: bootVM + responses: + 204: + description: The VM instance successfully booted. + 404: + description: The VM instance could not boot because it is not created yet + + /vm.pause: + put: + summary: Pause a previously booted VM instance. + operationId: pauseVM + responses: + 204: + description: The VM instance successfully paused. + 404: + description: The VM instance could not pause because it is not created yet + 405: + description: The VM instance could not pause because it is not booted. + + /vm.resume: + put: + summary: Resume a previously paused VM instance. + operationId: resumeVM + responses: + 204: + description: The VM instance successfully paused. + 404: + description: The VM instance could not resume because it is not booted yet + 405: + description: The VM instance could not resume because it is not paused. + + /vm.shutdown: + put: + summary: Shut the VM instance down. + operationId: shutdownVM + responses: + 204: + description: The VM instance successfully shut down. + 404: + description: The VM instance could not shut down because is not created. + 405: + description: The VM instance could not shut down because it is not started. + + /vm.reboot: + put: + summary: Reboot the VM instance. + operationId: rebootVM + responses: + 204: + description: The VM instance successfully rebooted. + 404: + description: The VM instance could not reboot because it is not created. + 405: + description: The VM instance could not reboot because it is not booted. + + /vm.power-button: + put: + summary: Trigger a power button in the VM + operationId: power-buttonVM + responses: + 204: + description: Power button successfully triggered in the VM + 404: + description: The button could not be triggered because it is not created yet + 405: + description: The button could not be triggered because it is not booted. + + /vm.resize: + put: + summary: Resize the VM + requestBody: + description: The target size for the VM + content: + application/json: + schema: + $ref: "#/components/schemas/VmResize" + required: true + responses: + 204: + description: The VM instance was successfully resized. + 404: + description: The VM instance could not be resized because it is not created. + 429: + description: The VM instance could not be resized because a cpu removal is still pending. + + /vm.resize-zone: + put: + summary: Resize a memory zone + requestBody: + description: The target size for the memory zone + content: + application/json: + schema: + $ref: "#/components/schemas/VmResizeZone" + required: true + responses: + 204: + description: The memory zone was successfully resized. + 500: + description: The memory zone could not be resized. + + /vm.add-device: + put: + summary: Add a new device to the VM + requestBody: + description: The path of the new device + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceConfig" + required: true + responses: + 200: + description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new device was successfully (cold) added to the VM instance. + 404: + description: The new device could not be added to the VM instance. + + /vm.remove-device: + put: + summary: Remove a device from the VM + requestBody: + description: The identifier of the device + content: + application/json: + schema: + $ref: "#/components/schemas/VmRemoveDevice" + required: true + responses: + 204: + description: The device was successfully removed from the VM instance. + 404: + description: The device could not be removed from the VM instance. + + /vm.add-disk: + put: + summary: Add a new disk to the VM + requestBody: + description: The details of the new disk + content: + application/json: + schema: + $ref: "#/components/schemas/DiskConfig" + required: true + responses: + 200: + description: The new disk was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new disk was successfully (cold) added to the VM instance. + 500: + description: The new disk could not be added to the VM instance. + + /vm.add-fs: + put: + summary: Add a new virtio-fs device to the VM + requestBody: + description: The details of the new virtio-fs + content: + application/json: + schema: + $ref: "#/components/schemas/FsConfig" + required: true + responses: + 200: + description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new device was successfully (cold) added to the VM instance. + 500: + description: The new device could not be added to the VM instance. + + /vm.add-pmem: + put: + summary: Add a new pmem device to the VM + requestBody: + description: The details of the new pmem device + content: + application/json: + schema: + $ref: "#/components/schemas/PmemConfig" + required: true + responses: + 200: + description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new device was successfully (cold) added to the VM instance. + 500: + description: The new device could not be added to the VM instance. + + /vm.add-net: + put: + summary: Add a new network device to the VM + requestBody: + description: The details of the new network device + content: + application/json: + schema: + $ref: "#/components/schemas/NetConfig" + required: true + responses: + 200: + description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new device was successfully (cold) added to the VM instance. + 500: + description: The new device could not be added to the VM instance. + + /vm.add-vsock: + put: + summary: Add a new vsock device to the VM + requestBody: + description: The details of the new vsock device + content: + application/json: + schema: + $ref: "#/components/schemas/VsockConfig" + required: true + responses: + 200: + description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new device was successfully (cold) added to the VM instance. + 500: + description: The new device could not be added to the VM instance. + + /vm.add-vdpa: + put: + summary: Add a new vDPA device to the VM + requestBody: + description: The details of the new vDPA device + content: + application/json: + schema: + $ref: "#/components/schemas/VdpaConfig" + required: true + responses: + 200: + description: The new vDPA device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: "#/components/schemas/PciDeviceInfo" + 204: + description: The new vDPA device was successfully (cold) added to the VM instance. + 500: + description: The new vDPA device could not be added to the VM instance. + + /vm.add-user-device: + put: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VmAddUserDevice' + description: The path of the new device + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' + description: The new device was successfully added to the VM instance. + "204": + description: The new device was successfully (cold) added to the VM instance. + "404": + description: The new device could not be added to the VM instance. + summary: Add a new userspace device to the VM + + /vm.snapshot: + put: + summary: Returns a VM snapshot. + requestBody: + description: The snapshot configuration + content: + application/json: + schema: + $ref: "#/components/schemas/VmSnapshotConfig" + required: true + responses: + 204: + description: The VM instance was successfully snapshotted. + 404: + description: The VM instance could not be snapshotted because it is not created. + 405: + description: The VM instance could not be snapshotted because it is not booted. + + /vm.coredump: + put: + summary: Takes a VM coredump. + requestBody: + description: The coredump configuration + content: + application/json: + schema: + $ref: "#/components/schemas/VmCoredumpData" + required: true + responses: + 204: + description: The VM instance was successfully coredumped. + 404: + description: The VM instance could not be coredumped because it is not created. + 405: + description: The VM instance could not be coredumped because it is not booted. + + /vmm.nmi: + put: + summary: Inject an NMI. + responses: + 204: + description: The NMI successfully injected. + + /vm.restore: + put: + summary: Restore a VM from a snapshot. + requestBody: + description: The restore configuration + content: + application/json: + schema: + $ref: "#/components/schemas/RestoreConfig" + required: true + responses: + 204: + description: The VM instance was successfully restored. + 404: + description: The VM instance could not be restored because it is already created. + + /vm.receive-migration: + put: + summary: Receive a VM migration from URL + requestBody: + description: The URL for the reception of migration state + content: + application/json: + schema: + $ref: "#/components/schemas/ReceiveMigrationData" + required: true + responses: + 204: + description: The VM migration was successfully received. + 500: + description: The VM migration could not be received. + + /vm.send-migration: + put: + summary: Send a VM migration to URL + requestBody: + description: The URL for sending the migration state + content: + application/json: + schema: + $ref: "#/components/schemas/SendMigrationData" + required: true + responses: + 204: + description: The VM migration was successfully sent. + 500: + description: The VM migration could not be sent. + +components: + schemas: + VmmPingResponse: + required: + - version + type: object + properties: + build_version: + type: string + version: + type: string + pid: + type: integer + format: int64 + features: + type: array + items: + type: string + description: Virtual Machine Monitor information + + VmInfo: + required: + - config + - state + type: object + properties: + config: + $ref: "#/components/schemas/VmConfig" + state: + type: string + enum: [Created, Running, Shutdown, Paused] + memory_actual_size: + type: integer + format: int64 + device_tree: + type: object + additionalProperties: + $ref: "#/components/schemas/DeviceNode" + description: Virtual Machine information + + DeviceNode: + type: object + properties: + id: + type: string + resources: + type: array + items: + # Rust enum type (with data) which can't be better represented here + type: object + children: + type: array + items: + type: string + pci_bdf: + type: string + + VmCounters: + type: object + additionalProperties: + type: object + additionalProperties: + type: integer + format: int64 + + PciDeviceInfo: + required: + - id + - bdf + type: object + properties: + id: + type: string + bdf: + type: string + description: Information about a PCI device + + PayloadConfig: + type: object + properties: + firmware: + type: string + kernel: + type: string + cmdline: + type: string + initramfs: + type: string + igvm: + type: string + host_data: + type: string + description: Payloads to boot in guest + + VmConfig: + required: + - payload + type: object + properties: + cpus: + $ref: "#/components/schemas/CpusConfig" + memory: + $ref: "#/components/schemas/MemoryConfig" + payload: + $ref: "#/components/schemas/PayloadConfig" + rate_limit_groups: + type: array + items: + $ref: "#/components/schemas/RateLimitGroupConfig" + disks: + type: array + items: + $ref: "#/components/schemas/DiskConfig" + net: + type: array + items: + $ref: "#/components/schemas/NetConfig" + rng: + $ref: "#/components/schemas/RngConfig" + balloon: + $ref: "#/components/schemas/BalloonConfig" + fs: + type: array + items: + $ref: "#/components/schemas/FsConfig" + pmem: + type: array + items: + $ref: "#/components/schemas/PmemConfig" + serial: + $ref: "#/components/schemas/ConsoleConfig" + console: + $ref: "#/components/schemas/ConsoleConfig" + debug_console: + $ref: "#/components/schemas/DebugConsoleConfig" + devices: + type: array + items: + $ref: "#/components/schemas/DeviceConfig" + vdpa: + type: array + items: + $ref: "#/components/schemas/VdpaConfig" + vsock: + $ref: "#/components/schemas/VsockConfig" + numa: + type: array + items: + $ref: "#/components/schemas/NumaConfig" + iommu: + type: boolean + default: false + watchdog: + type: boolean + default: false + pvpanic: + type: boolean + default: false + pci_segments: + type: array + items: + $ref: "#/components/schemas/PciSegmentConfig" + platform: + $ref: "#/components/schemas/PlatformConfig" + tpm: + $ref: "#/components/schemas/TpmConfig" + landlock_enable: + type: boolean + default: false + landlock_rules: + type: array + items: + $ref: "#/components/schemas/LandlockConfig" + description: Virtual machine configuration + + CpuAffinity: + required: + - vcpu + - host_cpus + type: object + properties: + vcpu: + type: integer + host_cpus: + type: array + items: + type: integer + + CpuFeatures: + type: object + properties: + amx: + type: boolean + + CpuTopology: + type: object + properties: + threads_per_core: + type: integer + cores_per_die: + type: integer + dies_per_package: + type: integer + packages: + type: integer + + CpusConfig: + required: + - boot_vcpus + - max_vcpus + type: object + properties: + boot_vcpus: + minimum: 1 + type: integer + max_vcpus: + minimum: 1 + type: integer + topology: + $ref: "#/components/schemas/CpuTopology" + kvm_hyperv: + type: boolean + default: false + max_phys_bits: + type: integer + affinity: + type: array + items: + $ref: "#/components/schemas/CpuAffinity" + features: + $ref: "#/components/schemas/CpuFeatures" + + PciSegmentConfig: + required: + - pci_segment + type: object + properties: + pci_segment: + type: integer + format: int16 + mmio32_aperture_weight: + type: integer + format: int32 + mmio64_aperture_weight: + type: integer + format: int32 + + PlatformConfig: + type: object + properties: + num_pci_segments: + type: integer + format: int16 + iommu_segments: + type: array + items: + type: integer + format: int16 + iommu_address_width: + type: integer + format: uint8 + serial_number: + type: string + uuid: + type: string + oem_strings: + type: array + items: + type: string + tdx: + type: boolean + default: false + sev_snp: + type: boolean + default: false + + MemoryZoneConfig: + required: + - id + - size + type: object + properties: + id: + type: string + size: + type: integer + format: int64 + file: + type: string + mergeable: + type: boolean + default: false + shared: + type: boolean + default: false + hugepages: + type: boolean + default: false + hugepage_size: + type: integer + format: int64 + host_numa_node: + type: integer + format: int32 + hotplug_size: + type: integer + format: int64 + hotplugged_size: + type: integer + format: int64 + prefault: + type: boolean + default: false + + MemoryConfig: + required: + - size + type: object + properties: + size: + type: integer + format: int64 + hotplug_size: + type: integer + format: int64 + hotplugged_size: + type: integer + format: int64 + mergeable: + type: boolean + default: false + hotplug_method: + type: string + default: "Acpi" + shared: + type: boolean + default: false + hugepages: + type: boolean + default: false + hugepage_size: + type: integer + format: int64 + prefault: + type: boolean + default: false + thp: + type: boolean + default: true + zones: + type: array + items: + $ref: "#/components/schemas/MemoryZoneConfig" + + TokenBucket: + required: + - size + - refill_time + type: object + properties: + size: + type: integer + format: int64 + minimum: 0 + description: The total number of tokens this bucket can hold. + one_time_burst: + type: integer + format: int64 + minimum: 0 + description: The initial size of a token bucket. + refill_time: + type: integer + format: int64 + minimum: 0 + description: The amount of milliseconds it takes for the bucket to refill. + description: + Defines a token bucket with a maximum capacity (_size_), an initial burst size + (_one_time_burst_) and an interval for refilling purposes (_refill_time_). + The refill-rate is derived from _size_ and _refill_time_, and it is the constant + rate at which the tokens replenish. The refill process only starts happening after + the initial burst budget is consumed. + Consumption from the token bucket is unbounded in speed which allows for bursts + bound in size by the amount of tokens available. + Once the token bucket is empty, consumption speed is bound by the refill-rate. + + RateLimiterConfig: + type: object + properties: + bandwidth: + $ref: "#/components/schemas/TokenBucket" + ops: + $ref: "#/components/schemas/TokenBucket" + description: + Defines an IO rate limiter with independent bytes/s and ops/s limits. + Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. + + RateLimitGroupConfig: + required: + - id + - rate_limiter_config + type: object + properties: + id: + type: string + rate_limiter_config: + $ref: "#/components/schemas/RateLimiterConfig" + + VirtQueueAffinity: + required: + - queue_index + - host_cpus + type: object + properties: + queue_index: + type: integer + host_cpus: + type: array + items: + type: integer + + DiskConfig: + type: object + properties: + path: + type: string + readonly: + type: boolean + default: false + direct: + type: boolean + default: false + iommu: + type: boolean + default: false + num_queues: + type: integer + default: 1 + queue_size: + type: integer + default: 128 + vhost_user: + type: boolean + default: false + vhost_socket: + type: string + rate_limiter_config: + $ref: "#/components/schemas/RateLimiterConfig" + pci_segment: + type: integer + format: int16 + id: + type: string + serial: + type: string + rate_limit_group: + type: string + queue_affinity: + type: array + items: + $ref: "#/components/schemas/VirtQueueAffinity" + + NetConfig: + type: object + properties: + tap: + type: string + ip: + type: string + default: "192.168.249.1" + description: IPv4 or IPv6 address + mask: + type: string + default: "255.255.255.0" + description: Must be a valid IPv4 netmask if ip is an IPv4 address or a valid IPv6 netmask if ip is an IPv6 address. + mac: + type: string + host_mac: + type: string + mtu: + type: integer + iommu: + type: boolean + default: false + num_queues: + type: integer + default: 2 + queue_size: + type: integer + default: 256 + vhost_user: + type: boolean + default: false + vhost_socket: + type: string + vhost_mode: + type: string + default: "Client" + id: + type: string + pci_segment: + type: integer + format: int16 + rate_limiter_config: + $ref: "#/components/schemas/RateLimiterConfig" + + RngConfig: + required: + - src + type: object + properties: + src: + type: string + iommu: + type: boolean + default: false + + BalloonConfig: + required: + - size + type: object + properties: + size: + type: integer + format: int64 + deflate_on_oom: + type: boolean + default: false + description: Deflate balloon when the guest is under memory pressure. + free_page_reporting: + type: boolean + default: false + description: Enable guest to report free pages. + + FsConfig: + required: + - num_queues + - queue_size + - socket + - tag + type: object + properties: + tag: + type: string + socket: + type: string + num_queues: + type: integer + default: 1 + queue_size: + type: integer + default: 1024 + pci_segment: + type: integer + format: int16 + id: + type: string + + PmemConfig: + required: + - file + type: object + properties: + file: + type: string + size: + type: integer + format: int64 + iommu: + type: boolean + default: false + discard_writes: + type: boolean + default: false + pci_segment: + type: integer + format: int16 + id: + type: string + + ConsoleConfig: + required: + - mode + type: object + properties: + file: + type: string + socket: + type: string + mode: + type: string + enum: ["Off", "Pty", "Tty", "File", "Socket", "Null"] + iommu: + type: boolean + default: false + + DebugConsoleConfig: + required: + - mode + type: object + properties: + file: + type: string + mode: + type: string + enum: ["Off", "Pty", "Tty", "File", "Null"] + iobase: + type: integer + + DeviceConfig: + required: + - path + type: object + properties: + path: + type: string + iommu: + type: boolean + default: false + pci_segment: + type: integer + format: int16 + id: + type: string + x_nv_gpudirect_clique: + type: integer + format: int8 + TpmConfig: + required: + - socket + type: object + properties: + socket: + type: string + + VdpaConfig: + required: + - path + - num_queues + type: object + properties: + path: + type: string + num_queues: + type: integer + default: 1 + iommu: + type: boolean + default: false + pci_segment: + type: integer + format: int16 + id: + type: string + + VsockConfig: + required: + - cid + - socket + type: object + properties: + cid: + type: integer + format: int64 + minimum: 3 + description: Guest Vsock CID + socket: + type: string + description: Path to UNIX domain socket, used to proxy vsock connections. + iommu: + type: boolean + default: false + pci_segment: + type: integer + format: int16 + id: + type: string + + NumaDistance: + required: + - destination + - distance + type: object + properties: + destination: + type: integer + format: int32 + distance: + type: integer + format: int32 + + NumaConfig: + required: + - guest_numa_id + type: object + properties: + guest_numa_id: + type: integer + format: int32 + cpus: + type: array + items: + type: integer + format: int32 + distances: + type: array + items: + $ref: "#/components/schemas/NumaDistance" + memory_zones: + type: array + items: + type: string + pci_segments: + type: array + items: + type: integer + format: int32 + + VmResize: + type: object + properties: + desired_vcpus: + minimum: 1 + type: integer + desired_ram: + description: desired memory ram in bytes + type: integer + format: int64 + desired_balloon: + description: desired balloon size in bytes + type: integer + format: int64 + + VmResizeZone: + type: object + properties: + id: + type: string + desired_ram: + description: desired memory zone size in bytes + type: integer + format: int64 + + VmRemoveDevice: + type: object + properties: + id: + type: string + + VmSnapshotConfig: + type: object + properties: + destination_url: + type: string + + VmCoredumpData: + type: object + properties: + destination_url: + type: string + + RestoreConfig: + required: + - source_url + type: object + properties: + source_url: + type: string + prefault: + type: boolean + + ReceiveMigrationData: + required: + - receiver_url + type: object + properties: + receiver_url: + type: string + + SendMigrationData: + required: + - destination_url + type: object + properties: + destination_url: + type: string + local: + type: boolean + + VmAddUserDevice: + required: + - socket + type: object + properties: + socket: + type: string + + LandlockConfig: + required: + - path + - access + type: object + properties: + path: + type: string + access: + type: string From f56b2c9010957b201304c50989b1059baeb03586 Mon Sep 17 00:00:00 2001 From: Steven Miller Date: Tue, 11 Nov 2025 12:11:51 -0500 Subject: [PATCH 2/5] Update README --- README.md | 9 +++++++-- lib/vmm/README.md | 12 +++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0320d54f..07fce66d 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,18 @@ Run containerized workloads in VMs, powered by [Cloud Hypervisor](https://github ### Prerequisites -**Go 1.25.4+**, **Cloud Hypervisor**, **KVM**, **erofs-utils** +**Go 1.25.4+**, **KVM**, **erofs-utils** ```bash -cloud-hypervisor --version mkfs.erofs --version ``` +**KVM Access:** User must be in `kvm` group for VM access: +```bash +sudo usermod -aG kvm $USER +# Log out and back in, or use: newgrp kvm +``` + ### Configuration #### Environment variables diff --git a/lib/vmm/README.md b/lib/vmm/README.md index ee798927..84dfd21d 100644 --- a/lib/vmm/README.md +++ b/lib/vmm/README.md @@ -1,10 +1,14 @@ # Cloud Hypervisor VMM Client -Thin Go wrapper around Cloud Hypervisor's HTTP API (v0.3.0) with embedded binaries. +Thin Go wrapper around Cloud Hypervisor's HTTP API with embedded binaries. + +Supports multiple versions of the Cloud Hypervisor VMM because instances are version-locked to cloud hypervisor if they are in standby. We can switch them to the latest version if we shutdown / reboot the VM. + +Embeds the binaries to make it easier to install, instead of managing multiple versions of the Cloud Hypervisor CLI externally + configuring it. ## Features -- Embedded Cloud Hypervisor binaries (v48.0, v49.0) for x86_64 and aarch64 +- Embedded Cloud Hypervisor binaries of multiple versions - Generated HTTP client from official OpenAPI spec - Automatic binary extraction to data directory - Unix socket communication @@ -77,6 +81,7 @@ lib/vmm/ │ └── v49.0/ │ ├── x86_64/cloud-hypervisor (4.5MB) │ └── aarch64/cloud-hypervisor (3.3MB) +| # There will be additional versions in the future... └── client_test.go # Tests with real Cloud Hypervisor ``` @@ -85,6 +90,8 @@ lib/vmm/ - Cloud Hypervisor v48.0 (API v0.3.0) - Cloud Hypervisor v49.0 (API v0.3.0) +There may be additional versions in the future. Cloud hypervisor versions may update frequently, while the API updates less frequently. + ## Regenerating Client ```bash @@ -129,4 +136,3 @@ All Cloud Hypervisor API methods available via embedded `*ClientWithResponses`: - And many more... See generated `vmm.go` for full API surface. - From 933378345d2ededc5f32a43625a4886ac949b520 Mon Sep 17 00:00:00 2001 From: Steven Miller Date: Tue, 11 Nov 2025 12:32:11 -0500 Subject: [PATCH 3/5] Use self hosted runner --- .github/workflows/test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e828044d..4f58e514 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: [self-hosted, linux, x64, kvm] steps: - uses: actions/checkout@v4 @@ -17,7 +17,10 @@ jobs: - name: Install dependencies run: | set -xe - sudo apt-get install -y erofs-utils + if ! command -v mkfs.erofs &> /dev/null; then + sudo apt-get update + sudo apt-get install -y erofs-utils + fi go mod download # Avoids rate limits when running the tests @@ -33,4 +36,3 @@ jobs: - name: Build run: make build - From b83473f31a4c08b30290e3d02d1462db7fc43f15 Mon Sep 17 00:00:00 2001 From: Steven Miller Date: Tue, 11 Nov 2025 12:35:55 -0500 Subject: [PATCH 4/5] Download binaries before test and build --- Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 300191b7..485e1f5f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -.PHONY: oapi-generate generate-vmm-client generate-wire generate-all dev build test install-tools gen-jwt download-ch-binaries download-ch-spec +.PHONY: oapi-generate generate-vmm-client generate-wire generate-all dev build test install-tools gen-jwt download-ch-binaries download-ch-spec ensure-ch-binaries # Directory where local binaries will be installed BIN_DIR ?= $(CURDIR)/bin @@ -79,8 +79,16 @@ generate-wire: $(WIRE) # Generate all code generate-all: oapi-generate generate-vmm-client generate-wire +# Check if binaries exist, download if missing +.PHONY: ensure-ch-binaries +ensure-ch-binaries: + @if [ ! -f lib/vmm/binaries/cloud-hypervisor/v48.0/x86_64/cloud-hypervisor ]; then \ + echo "Cloud Hypervisor binaries not found, downloading..."; \ + $(MAKE) download-ch-binaries; \ + fi + # Build the binary -build: | $(BIN_DIR) +build: ensure-ch-binaries | $(BIN_DIR) go build -tags containers_image_openpgp -o $(BIN_DIR)/hypeman ./cmd/api # Run in development mode with hot reload @@ -88,7 +96,7 @@ dev: $(AIR) $(AIR) -c .air.toml # Run tests -test: +test: ensure-ch-binaries go test -tags containers_image_openpgp -v -timeout 30s ./... # Generate JWT token for testing From c10815ae2352b80983be0bd89082b5660f628075 Mon Sep 17 00:00:00 2001 From: Steven Miller Date: Tue, 11 Nov 2025 12:39:26 -0500 Subject: [PATCH 5/5] Include generated code --- .gitignore | 3 - lib/vmm/vmm.go | 4004 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 4004 insertions(+), 3 deletions(-) create mode 100644 lib/vmm/vmm.go diff --git a/.gitignore b/.gitignore index 3d94d833..9c30de60 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,3 @@ tmp/** # Cloud Hypervisor binaries (embedded at build time) lib/vmm/binaries/cloud-hypervisor/*/*/cloud-hypervisor - -# Generated VMM client -lib/vmm/vmm.go diff --git a/lib/vmm/vmm.go b/lib/vmm/vmm.go new file mode 100644 index 00000000..ad328206 --- /dev/null +++ b/lib/vmm/vmm.go @@ -0,0 +1,4004 @@ +// Package vmm provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.1 DO NOT EDIT. +package vmm + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" +) + +// Defines values for ConsoleConfigMode. +const ( + ConsoleConfigModeFile ConsoleConfigMode = "File" + ConsoleConfigModeNull ConsoleConfigMode = "Null" + ConsoleConfigModeOff ConsoleConfigMode = "Off" + ConsoleConfigModePty ConsoleConfigMode = "Pty" + ConsoleConfigModeSocket ConsoleConfigMode = "Socket" + ConsoleConfigModeTty ConsoleConfigMode = "Tty" +) + +// Defines values for DebugConsoleConfigMode. +const ( + DebugConsoleConfigModeFile DebugConsoleConfigMode = "File" + DebugConsoleConfigModeNull DebugConsoleConfigMode = "Null" + DebugConsoleConfigModeOff DebugConsoleConfigMode = "Off" + DebugConsoleConfigModePty DebugConsoleConfigMode = "Pty" + DebugConsoleConfigModeTty DebugConsoleConfigMode = "Tty" +) + +// Defines values for VmInfoState. +const ( + Created VmInfoState = "Created" + Paused VmInfoState = "Paused" + Running VmInfoState = "Running" + Shutdown VmInfoState = "Shutdown" +) + +// BalloonConfig defines model for BalloonConfig. +type BalloonConfig struct { + // DeflateOnOom Deflate balloon when the guest is under memory pressure. + DeflateOnOom *bool `json:"deflate_on_oom,omitempty"` + + // FreePageReporting Enable guest to report free pages. + FreePageReporting *bool `json:"free_page_reporting,omitempty"` + Size int64 `json:"size"` +} + +// ConsoleConfig defines model for ConsoleConfig. +type ConsoleConfig struct { + File *string `json:"file,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + Mode ConsoleConfigMode `json:"mode"` + Socket *string `json:"socket,omitempty"` +} + +// ConsoleConfigMode defines model for ConsoleConfig.Mode. +type ConsoleConfigMode string + +// CpuAffinity defines model for CpuAffinity. +type CpuAffinity struct { + HostCpus []int `json:"host_cpus"` + Vcpu int `json:"vcpu"` +} + +// CpuFeatures defines model for CpuFeatures. +type CpuFeatures struct { + Amx *bool `json:"amx,omitempty"` +} + +// CpuTopology defines model for CpuTopology. +type CpuTopology struct { + CoresPerDie *int `json:"cores_per_die,omitempty"` + DiesPerPackage *int `json:"dies_per_package,omitempty"` + Packages *int `json:"packages,omitempty"` + ThreadsPerCore *int `json:"threads_per_core,omitempty"` +} + +// CpusConfig defines model for CpusConfig. +type CpusConfig struct { + Affinity *[]CpuAffinity `json:"affinity,omitempty"` + BootVcpus int `json:"boot_vcpus"` + Features *CpuFeatures `json:"features,omitempty"` + KvmHyperv *bool `json:"kvm_hyperv,omitempty"` + MaxPhysBits *int `json:"max_phys_bits,omitempty"` + MaxVcpus int `json:"max_vcpus"` + Topology *CpuTopology `json:"topology,omitempty"` +} + +// DebugConsoleConfig defines model for DebugConsoleConfig. +type DebugConsoleConfig struct { + File *string `json:"file,omitempty"` + Iobase *int `json:"iobase,omitempty"` + Mode DebugConsoleConfigMode `json:"mode"` +} + +// DebugConsoleConfigMode defines model for DebugConsoleConfig.Mode. +type DebugConsoleConfigMode string + +// DeviceConfig defines model for DeviceConfig. +type DeviceConfig struct { + Id *string `json:"id,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + Path string `json:"path"` + PciSegment *int16 `json:"pci_segment,omitempty"` + XNvGpudirectClique *int8 `json:"x_nv_gpudirect_clique,omitempty"` +} + +// DeviceNode defines model for DeviceNode. +type DeviceNode struct { + Children *[]string `json:"children,omitempty"` + Id *string `json:"id,omitempty"` + PciBdf *string `json:"pci_bdf,omitempty"` + Resources *[]map[string]interface{} `json:"resources,omitempty"` +} + +// DiskConfig defines model for DiskConfig. +type DiskConfig struct { + Direct *bool `json:"direct,omitempty"` + Id *string `json:"id,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + NumQueues *int `json:"num_queues,omitempty"` + Path *string `json:"path,omitempty"` + PciSegment *int16 `json:"pci_segment,omitempty"` + QueueAffinity *[]VirtQueueAffinity `json:"queue_affinity,omitempty"` + QueueSize *int `json:"queue_size,omitempty"` + RateLimitGroup *string `json:"rate_limit_group,omitempty"` + + // RateLimiterConfig Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. + RateLimiterConfig *RateLimiterConfig `json:"rate_limiter_config,omitempty"` + Readonly *bool `json:"readonly,omitempty"` + Serial *string `json:"serial,omitempty"` + VhostSocket *string `json:"vhost_socket,omitempty"` + VhostUser *bool `json:"vhost_user,omitempty"` +} + +// FsConfig defines model for FsConfig. +type FsConfig struct { + Id *string `json:"id,omitempty"` + NumQueues int `json:"num_queues"` + PciSegment *int16 `json:"pci_segment,omitempty"` + QueueSize int `json:"queue_size"` + Socket string `json:"socket"` + Tag string `json:"tag"` +} + +// LandlockConfig defines model for LandlockConfig. +type LandlockConfig struct { + Access string `json:"access"` + Path string `json:"path"` +} + +// MemoryConfig defines model for MemoryConfig. +type MemoryConfig struct { + HotplugMethod *string `json:"hotplug_method,omitempty"` + HotplugSize *int64 `json:"hotplug_size,omitempty"` + HotpluggedSize *int64 `json:"hotplugged_size,omitempty"` + HugepageSize *int64 `json:"hugepage_size,omitempty"` + Hugepages *bool `json:"hugepages,omitempty"` + Mergeable *bool `json:"mergeable,omitempty"` + Prefault *bool `json:"prefault,omitempty"` + Shared *bool `json:"shared,omitempty"` + Size int64 `json:"size"` + Thp *bool `json:"thp,omitempty"` + Zones *[]MemoryZoneConfig `json:"zones,omitempty"` +} + +// MemoryZoneConfig defines model for MemoryZoneConfig. +type MemoryZoneConfig struct { + File *string `json:"file,omitempty"` + HostNumaNode *int32 `json:"host_numa_node,omitempty"` + HotplugSize *int64 `json:"hotplug_size,omitempty"` + HotpluggedSize *int64 `json:"hotplugged_size,omitempty"` + HugepageSize *int64 `json:"hugepage_size,omitempty"` + Hugepages *bool `json:"hugepages,omitempty"` + Id string `json:"id"` + Mergeable *bool `json:"mergeable,omitempty"` + Prefault *bool `json:"prefault,omitempty"` + Shared *bool `json:"shared,omitempty"` + Size int64 `json:"size"` +} + +// NetConfig defines model for NetConfig. +type NetConfig struct { + HostMac *string `json:"host_mac,omitempty"` + Id *string `json:"id,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + + // Ip IPv4 or IPv6 address + Ip *string `json:"ip,omitempty"` + Mac *string `json:"mac,omitempty"` + + // Mask Must be a valid IPv4 netmask if ip is an IPv4 address or a valid IPv6 netmask if ip is an IPv6 address. + Mask *string `json:"mask,omitempty"` + Mtu *int `json:"mtu,omitempty"` + NumQueues *int `json:"num_queues,omitempty"` + PciSegment *int16 `json:"pci_segment,omitempty"` + QueueSize *int `json:"queue_size,omitempty"` + + // RateLimiterConfig Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. + RateLimiterConfig *RateLimiterConfig `json:"rate_limiter_config,omitempty"` + Tap *string `json:"tap,omitempty"` + VhostMode *string `json:"vhost_mode,omitempty"` + VhostSocket *string `json:"vhost_socket,omitempty"` + VhostUser *bool `json:"vhost_user,omitempty"` +} + +// NumaConfig defines model for NumaConfig. +type NumaConfig struct { + Cpus *[]int32 `json:"cpus,omitempty"` + Distances *[]NumaDistance `json:"distances,omitempty"` + GuestNumaId int32 `json:"guest_numa_id"` + MemoryZones *[]string `json:"memory_zones,omitempty"` + PciSegments *[]int32 `json:"pci_segments,omitempty"` +} + +// NumaDistance defines model for NumaDistance. +type NumaDistance struct { + Destination int32 `json:"destination"` + Distance int32 `json:"distance"` +} + +// PayloadConfig Payloads to boot in guest +type PayloadConfig struct { + Cmdline *string `json:"cmdline,omitempty"` + Firmware *string `json:"firmware,omitempty"` + HostData *string `json:"host_data,omitempty"` + Igvm *string `json:"igvm,omitempty"` + Initramfs *string `json:"initramfs,omitempty"` + Kernel *string `json:"kernel,omitempty"` +} + +// PciDeviceInfo Information about a PCI device +type PciDeviceInfo struct { + Bdf string `json:"bdf"` + Id string `json:"id"` +} + +// PciSegmentConfig defines model for PciSegmentConfig. +type PciSegmentConfig struct { + Mmio32ApertureWeight *int32 `json:"mmio32_aperture_weight,omitempty"` + Mmio64ApertureWeight *int32 `json:"mmio64_aperture_weight,omitempty"` + PciSegment int16 `json:"pci_segment"` +} + +// PlatformConfig defines model for PlatformConfig. +type PlatformConfig struct { + IommuAddressWidth *uint8 `json:"iommu_address_width,omitempty"` + IommuSegments *[]int16 `json:"iommu_segments,omitempty"` + NumPciSegments *int16 `json:"num_pci_segments,omitempty"` + OemStrings *[]string `json:"oem_strings,omitempty"` + SerialNumber *string `json:"serial_number,omitempty"` + SevSnp *bool `json:"sev_snp,omitempty"` + Tdx *bool `json:"tdx,omitempty"` + Uuid *string `json:"uuid,omitempty"` +} + +// PmemConfig defines model for PmemConfig. +type PmemConfig struct { + DiscardWrites *bool `json:"discard_writes,omitempty"` + File string `json:"file"` + Id *string `json:"id,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + PciSegment *int16 `json:"pci_segment,omitempty"` + Size *int64 `json:"size,omitempty"` +} + +// RateLimitGroupConfig defines model for RateLimitGroupConfig. +type RateLimitGroupConfig struct { + Id string `json:"id"` + + // RateLimiterConfig Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. + RateLimiterConfig RateLimiterConfig `json:"rate_limiter_config"` +} + +// RateLimiterConfig Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. +type RateLimiterConfig struct { + // Bandwidth Defines a token bucket with a maximum capacity (_size_), an initial burst size (_one_time_burst_) and an interval for refilling purposes (_refill_time_). The refill-rate is derived from _size_ and _refill_time_, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate. + Bandwidth *TokenBucket `json:"bandwidth,omitempty"` + + // Ops Defines a token bucket with a maximum capacity (_size_), an initial burst size (_one_time_burst_) and an interval for refilling purposes (_refill_time_). The refill-rate is derived from _size_ and _refill_time_, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate. + Ops *TokenBucket `json:"ops,omitempty"` +} + +// ReceiveMigrationData defines model for ReceiveMigrationData. +type ReceiveMigrationData struct { + ReceiverUrl string `json:"receiver_url"` +} + +// RestoreConfig defines model for RestoreConfig. +type RestoreConfig struct { + Prefault *bool `json:"prefault,omitempty"` + SourceUrl string `json:"source_url"` +} + +// RngConfig defines model for RngConfig. +type RngConfig struct { + Iommu *bool `json:"iommu,omitempty"` + Src string `json:"src"` +} + +// SendMigrationData defines model for SendMigrationData. +type SendMigrationData struct { + DestinationUrl string `json:"destination_url"` + Local *bool `json:"local,omitempty"` +} + +// TokenBucket Defines a token bucket with a maximum capacity (_size_), an initial burst size (_one_time_burst_) and an interval for refilling purposes (_refill_time_). The refill-rate is derived from _size_ and _refill_time_, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate. +type TokenBucket struct { + // OneTimeBurst The initial size of a token bucket. + OneTimeBurst *int64 `json:"one_time_burst,omitempty"` + + // RefillTime The amount of milliseconds it takes for the bucket to refill. + RefillTime int64 `json:"refill_time"` + + // Size The total number of tokens this bucket can hold. + Size int64 `json:"size"` +} + +// TpmConfig defines model for TpmConfig. +type TpmConfig struct { + Socket string `json:"socket"` +} + +// VdpaConfig defines model for VdpaConfig. +type VdpaConfig struct { + Id *string `json:"id,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + NumQueues int `json:"num_queues"` + Path string `json:"path"` + PciSegment *int16 `json:"pci_segment,omitempty"` +} + +// VirtQueueAffinity defines model for VirtQueueAffinity. +type VirtQueueAffinity struct { + HostCpus []int `json:"host_cpus"` + QueueIndex int `json:"queue_index"` +} + +// VmAddUserDevice defines model for VmAddUserDevice. +type VmAddUserDevice struct { + Socket string `json:"socket"` +} + +// VmConfig Virtual machine configuration +type VmConfig struct { + Balloon *BalloonConfig `json:"balloon,omitempty"` + Console *ConsoleConfig `json:"console,omitempty"` + Cpus *CpusConfig `json:"cpus,omitempty"` + DebugConsole *DebugConsoleConfig `json:"debug_console,omitempty"` + Devices *[]DeviceConfig `json:"devices,omitempty"` + Disks *[]DiskConfig `json:"disks,omitempty"` + Fs *[]FsConfig `json:"fs,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + LandlockEnable *bool `json:"landlock_enable,omitempty"` + LandlockRules *[]LandlockConfig `json:"landlock_rules,omitempty"` + Memory *MemoryConfig `json:"memory,omitempty"` + Net *[]NetConfig `json:"net,omitempty"` + Numa *[]NumaConfig `json:"numa,omitempty"` + + // Payload Payloads to boot in guest + Payload PayloadConfig `json:"payload"` + PciSegments *[]PciSegmentConfig `json:"pci_segments,omitempty"` + Platform *PlatformConfig `json:"platform,omitempty"` + Pmem *[]PmemConfig `json:"pmem,omitempty"` + Pvpanic *bool `json:"pvpanic,omitempty"` + RateLimitGroups *[]RateLimitGroupConfig `json:"rate_limit_groups,omitempty"` + Rng *RngConfig `json:"rng,omitempty"` + Serial *ConsoleConfig `json:"serial,omitempty"` + Tpm *TpmConfig `json:"tpm,omitempty"` + Vdpa *[]VdpaConfig `json:"vdpa,omitempty"` + Vsock *VsockConfig `json:"vsock,omitempty"` + Watchdog *bool `json:"watchdog,omitempty"` +} + +// VmCoredumpData defines model for VmCoredumpData. +type VmCoredumpData struct { + DestinationUrl *string `json:"destination_url,omitempty"` +} + +// VmCounters defines model for VmCounters. +type VmCounters map[string]map[string]int64 + +// VmInfo Virtual Machine information +type VmInfo struct { + // Config Virtual machine configuration + Config VmConfig `json:"config"` + DeviceTree *map[string]DeviceNode `json:"device_tree,omitempty"` + MemoryActualSize *int64 `json:"memory_actual_size,omitempty"` + State VmInfoState `json:"state"` +} + +// VmInfoState defines model for VmInfo.State. +type VmInfoState string + +// VmRemoveDevice defines model for VmRemoveDevice. +type VmRemoveDevice struct { + Id *string `json:"id,omitempty"` +} + +// VmResize defines model for VmResize. +type VmResize struct { + // DesiredBalloon desired balloon size in bytes + DesiredBalloon *int64 `json:"desired_balloon,omitempty"` + + // DesiredRam desired memory ram in bytes + DesiredRam *int64 `json:"desired_ram,omitempty"` + DesiredVcpus *int `json:"desired_vcpus,omitempty"` +} + +// VmResizeZone defines model for VmResizeZone. +type VmResizeZone struct { + // DesiredRam desired memory zone size in bytes + DesiredRam *int64 `json:"desired_ram,omitempty"` + Id *string `json:"id,omitempty"` +} + +// VmSnapshotConfig defines model for VmSnapshotConfig. +type VmSnapshotConfig struct { + DestinationUrl *string `json:"destination_url,omitempty"` +} + +// VmmPingResponse Virtual Machine Monitor information +type VmmPingResponse struct { + BuildVersion *string `json:"build_version,omitempty"` + Features *[]string `json:"features,omitempty"` + Pid *int64 `json:"pid,omitempty"` + Version string `json:"version"` +} + +// VsockConfig defines model for VsockConfig. +type VsockConfig struct { + // Cid Guest Vsock CID + Cid int64 `json:"cid"` + Id *string `json:"id,omitempty"` + Iommu *bool `json:"iommu,omitempty"` + PciSegment *int16 `json:"pci_segment,omitempty"` + + // Socket Path to UNIX domain socket, used to proxy vsock connections. + Socket string `json:"socket"` +} + +// PutVmAddDeviceJSONRequestBody defines body for PutVmAddDevice for application/json ContentType. +type PutVmAddDeviceJSONRequestBody = DeviceConfig + +// PutVmAddDiskJSONRequestBody defines body for PutVmAddDisk for application/json ContentType. +type PutVmAddDiskJSONRequestBody = DiskConfig + +// PutVmAddFsJSONRequestBody defines body for PutVmAddFs for application/json ContentType. +type PutVmAddFsJSONRequestBody = FsConfig + +// PutVmAddNetJSONRequestBody defines body for PutVmAddNet for application/json ContentType. +type PutVmAddNetJSONRequestBody = NetConfig + +// PutVmAddPmemJSONRequestBody defines body for PutVmAddPmem for application/json ContentType. +type PutVmAddPmemJSONRequestBody = PmemConfig + +// PutVmAddUserDeviceJSONRequestBody defines body for PutVmAddUserDevice for application/json ContentType. +type PutVmAddUserDeviceJSONRequestBody = VmAddUserDevice + +// PutVmAddVdpaJSONRequestBody defines body for PutVmAddVdpa for application/json ContentType. +type PutVmAddVdpaJSONRequestBody = VdpaConfig + +// PutVmAddVsockJSONRequestBody defines body for PutVmAddVsock for application/json ContentType. +type PutVmAddVsockJSONRequestBody = VsockConfig + +// PutVmCoredumpJSONRequestBody defines body for PutVmCoredump for application/json ContentType. +type PutVmCoredumpJSONRequestBody = VmCoredumpData + +// CreateVMJSONRequestBody defines body for CreateVM for application/json ContentType. +type CreateVMJSONRequestBody = VmConfig + +// PutVmReceiveMigrationJSONRequestBody defines body for PutVmReceiveMigration for application/json ContentType. +type PutVmReceiveMigrationJSONRequestBody = ReceiveMigrationData + +// PutVmRemoveDeviceJSONRequestBody defines body for PutVmRemoveDevice for application/json ContentType. +type PutVmRemoveDeviceJSONRequestBody = VmRemoveDevice + +// PutVmResizeJSONRequestBody defines body for PutVmResize for application/json ContentType. +type PutVmResizeJSONRequestBody = VmResize + +// PutVmResizeZoneJSONRequestBody defines body for PutVmResizeZone for application/json ContentType. +type PutVmResizeZoneJSONRequestBody = VmResizeZone + +// PutVmRestoreJSONRequestBody defines body for PutVmRestore for application/json ContentType. +type PutVmRestoreJSONRequestBody = RestoreConfig + +// PutVmSendMigrationJSONRequestBody defines body for PutVmSendMigration for application/json ContentType. +type PutVmSendMigrationJSONRequestBody = SendMigrationData + +// PutVmSnapshotJSONRequestBody defines body for PutVmSnapshot for application/json ContentType. +type PutVmSnapshotJSONRequestBody = VmSnapshotConfig + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // PutVmAddDeviceWithBody request with any body + PutVmAddDeviceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddDevice(ctx context.Context, body PutVmAddDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddDiskWithBody request with any body + PutVmAddDiskWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddDisk(ctx context.Context, body PutVmAddDiskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddFsWithBody request with any body + PutVmAddFsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddFs(ctx context.Context, body PutVmAddFsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddNetWithBody request with any body + PutVmAddNetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddNet(ctx context.Context, body PutVmAddNetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddPmemWithBody request with any body + PutVmAddPmemWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddPmem(ctx context.Context, body PutVmAddPmemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddUserDeviceWithBody request with any body + PutVmAddUserDeviceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddUserDevice(ctx context.Context, body PutVmAddUserDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddVdpaWithBody request with any body + PutVmAddVdpaWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddVdpa(ctx context.Context, body PutVmAddVdpaJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmAddVsockWithBody request with any body + PutVmAddVsockWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmAddVsock(ctx context.Context, body PutVmAddVsockJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BootVM request + BootVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmCoredumpWithBody request with any body + PutVmCoredumpWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmCoredump(ctx context.Context, body PutVmCoredumpJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetVmCounters request + GetVmCounters(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateVMWithBody request with any body + CreateVMWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateVM(ctx context.Context, body CreateVMJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteVM request + DeleteVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetVmInfo request + GetVmInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PauseVM request + PauseVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PowerButtonVM request + PowerButtonVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RebootVM request + RebootVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmReceiveMigrationWithBody request with any body + PutVmReceiveMigrationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmReceiveMigration(ctx context.Context, body PutVmReceiveMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmRemoveDeviceWithBody request with any body + PutVmRemoveDeviceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmRemoveDevice(ctx context.Context, body PutVmRemoveDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmResizeWithBody request with any body + PutVmResizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmResize(ctx context.Context, body PutVmResizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmResizeZoneWithBody request with any body + PutVmResizeZoneWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmResizeZone(ctx context.Context, body PutVmResizeZoneJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmRestoreWithBody request with any body + PutVmRestoreWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmRestore(ctx context.Context, body PutVmRestoreJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResumeVM request + ResumeVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmSendMigrationWithBody request with any body + PutVmSendMigrationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmSendMigration(ctx context.Context, body PutVmSendMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ShutdownVM request + ShutdownVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmSnapshotWithBody request with any body + PutVmSnapshotWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutVmSnapshot(ctx context.Context, body PutVmSnapshotJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutVmmNmi request + PutVmmNmi(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetVmmPing request + GetVmmPing(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ShutdownVMM request + ShutdownVMM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) PutVmAddDeviceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddDeviceRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddDevice(ctx context.Context, body PutVmAddDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddDeviceRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddDiskWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddDiskRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddDisk(ctx context.Context, body PutVmAddDiskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddDiskRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddFsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddFsRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddFs(ctx context.Context, body PutVmAddFsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddFsRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddNetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddNetRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddNet(ctx context.Context, body PutVmAddNetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddNetRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddPmemWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddPmemRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddPmem(ctx context.Context, body PutVmAddPmemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddPmemRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddUserDeviceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddUserDeviceRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddUserDevice(ctx context.Context, body PutVmAddUserDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddUserDeviceRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddVdpaWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddVdpaRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddVdpa(ctx context.Context, body PutVmAddVdpaJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddVdpaRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddVsockWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddVsockRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmAddVsock(ctx context.Context, body PutVmAddVsockJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmAddVsockRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) BootVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBootVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmCoredumpWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmCoredumpRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmCoredump(ctx context.Context, body PutVmCoredumpJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmCoredumpRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetVmCounters(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVmCountersRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateVMWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateVMRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateVM(ctx context.Context, body CreateVMJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateVMRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetVmInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVmInfoRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PauseVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPauseVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PowerButtonVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPowerButtonVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RebootVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRebootVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmReceiveMigrationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmReceiveMigrationRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmReceiveMigration(ctx context.Context, body PutVmReceiveMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmReceiveMigrationRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmRemoveDeviceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmRemoveDeviceRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmRemoveDevice(ctx context.Context, body PutVmRemoveDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmRemoveDeviceRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmResizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmResizeRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmResize(ctx context.Context, body PutVmResizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmResizeRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmResizeZoneWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmResizeZoneRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmResizeZone(ctx context.Context, body PutVmResizeZoneJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmResizeZoneRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmRestoreWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmRestoreRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmRestore(ctx context.Context, body PutVmRestoreJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmRestoreRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ResumeVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResumeVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmSendMigrationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmSendMigrationRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmSendMigration(ctx context.Context, body PutVmSendMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmSendMigrationRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ShutdownVM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewShutdownVMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmSnapshotWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmSnapshotRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmSnapshot(ctx context.Context, body PutVmSnapshotJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmSnapshotRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PutVmmNmi(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutVmmNmiRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetVmmPing(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVmmPingRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ShutdownVMM(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewShutdownVMMRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewPutVmAddDeviceRequest calls the generic PutVmAddDevice builder with application/json body +func NewPutVmAddDeviceRequest(server string, body PutVmAddDeviceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddDeviceRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddDeviceRequestWithBody generates requests for PutVmAddDevice with any type of body +func NewPutVmAddDeviceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-device") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddDiskRequest calls the generic PutVmAddDisk builder with application/json body +func NewPutVmAddDiskRequest(server string, body PutVmAddDiskJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddDiskRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddDiskRequestWithBody generates requests for PutVmAddDisk with any type of body +func NewPutVmAddDiskRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-disk") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddFsRequest calls the generic PutVmAddFs builder with application/json body +func NewPutVmAddFsRequest(server string, body PutVmAddFsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddFsRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddFsRequestWithBody generates requests for PutVmAddFs with any type of body +func NewPutVmAddFsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-fs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddNetRequest calls the generic PutVmAddNet builder with application/json body +func NewPutVmAddNetRequest(server string, body PutVmAddNetJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddNetRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddNetRequestWithBody generates requests for PutVmAddNet with any type of body +func NewPutVmAddNetRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-net") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddPmemRequest calls the generic PutVmAddPmem builder with application/json body +func NewPutVmAddPmemRequest(server string, body PutVmAddPmemJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddPmemRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddPmemRequestWithBody generates requests for PutVmAddPmem with any type of body +func NewPutVmAddPmemRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-pmem") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddUserDeviceRequest calls the generic PutVmAddUserDevice builder with application/json body +func NewPutVmAddUserDeviceRequest(server string, body PutVmAddUserDeviceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddUserDeviceRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddUserDeviceRequestWithBody generates requests for PutVmAddUserDevice with any type of body +func NewPutVmAddUserDeviceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-user-device") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddVdpaRequest calls the generic PutVmAddVdpa builder with application/json body +func NewPutVmAddVdpaRequest(server string, body PutVmAddVdpaJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddVdpaRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddVdpaRequestWithBody generates requests for PutVmAddVdpa with any type of body +func NewPutVmAddVdpaRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-vdpa") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmAddVsockRequest calls the generic PutVmAddVsock builder with application/json body +func NewPutVmAddVsockRequest(server string, body PutVmAddVsockJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmAddVsockRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmAddVsockRequestWithBody generates requests for PutVmAddVsock with any type of body +func NewPutVmAddVsockRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.add-vsock") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewBootVMRequest generates requests for BootVM +func NewBootVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.boot") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutVmCoredumpRequest calls the generic PutVmCoredump builder with application/json body +func NewPutVmCoredumpRequest(server string, body PutVmCoredumpJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmCoredumpRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmCoredumpRequestWithBody generates requests for PutVmCoredump with any type of body +func NewPutVmCoredumpRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.coredump") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetVmCountersRequest generates requests for GetVmCounters +func NewGetVmCountersRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.counters") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateVMRequest calls the generic CreateVM builder with application/json body +func NewCreateVMRequest(server string, body CreateVMJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateVMRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateVMRequestWithBody generates requests for CreateVM with any type of body +func NewCreateVMRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.create") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteVMRequest generates requests for DeleteVM +func NewDeleteVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.delete") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetVmInfoRequest generates requests for GetVmInfo +func NewGetVmInfoRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.info") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPauseVMRequest generates requests for PauseVM +func NewPauseVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.pause") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPowerButtonVMRequest generates requests for PowerButtonVM +func NewPowerButtonVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.power-button") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRebootVMRequest generates requests for RebootVM +func NewRebootVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.reboot") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutVmReceiveMigrationRequest calls the generic PutVmReceiveMigration builder with application/json body +func NewPutVmReceiveMigrationRequest(server string, body PutVmReceiveMigrationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmReceiveMigrationRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmReceiveMigrationRequestWithBody generates requests for PutVmReceiveMigration with any type of body +func NewPutVmReceiveMigrationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.receive-migration") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmRemoveDeviceRequest calls the generic PutVmRemoveDevice builder with application/json body +func NewPutVmRemoveDeviceRequest(server string, body PutVmRemoveDeviceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmRemoveDeviceRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmRemoveDeviceRequestWithBody generates requests for PutVmRemoveDevice with any type of body +func NewPutVmRemoveDeviceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.remove-device") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmResizeRequest calls the generic PutVmResize builder with application/json body +func NewPutVmResizeRequest(server string, body PutVmResizeJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmResizeRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmResizeRequestWithBody generates requests for PutVmResize with any type of body +func NewPutVmResizeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.resize") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmResizeZoneRequest calls the generic PutVmResizeZone builder with application/json body +func NewPutVmResizeZoneRequest(server string, body PutVmResizeZoneJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmResizeZoneRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmResizeZoneRequestWithBody generates requests for PutVmResizeZone with any type of body +func NewPutVmResizeZoneRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.resize-zone") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmRestoreRequest calls the generic PutVmRestore builder with application/json body +func NewPutVmRestoreRequest(server string, body PutVmRestoreJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmRestoreRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmRestoreRequestWithBody generates requests for PutVmRestore with any type of body +func NewPutVmRestoreRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.restore") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewResumeVMRequest generates requests for ResumeVM +func NewResumeVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.resume") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutVmSendMigrationRequest calls the generic PutVmSendMigration builder with application/json body +func NewPutVmSendMigrationRequest(server string, body PutVmSendMigrationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmSendMigrationRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmSendMigrationRequestWithBody generates requests for PutVmSendMigration with any type of body +func NewPutVmSendMigrationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.send-migration") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewShutdownVMRequest generates requests for ShutdownVM +func NewShutdownVMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.shutdown") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutVmSnapshotRequest calls the generic PutVmSnapshot builder with application/json body +func NewPutVmSnapshotRequest(server string, body PutVmSnapshotJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutVmSnapshotRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutVmSnapshotRequestWithBody generates requests for PutVmSnapshot with any type of body +func NewPutVmSnapshotRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vm.snapshot") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutVmmNmiRequest generates requests for PutVmmNmi +func NewPutVmmNmiRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vmm.nmi") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetVmmPingRequest generates requests for GetVmmPing +func NewGetVmmPingRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vmm.ping") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewShutdownVMMRequest generates requests for ShutdownVMM +func NewShutdownVMMRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/vmm.shutdown") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // PutVmAddDeviceWithBodyWithResponse request with any body + PutVmAddDeviceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddDeviceResponse, error) + + PutVmAddDeviceWithResponse(ctx context.Context, body PutVmAddDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddDeviceResponse, error) + + // PutVmAddDiskWithBodyWithResponse request with any body + PutVmAddDiskWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddDiskResponse, error) + + PutVmAddDiskWithResponse(ctx context.Context, body PutVmAddDiskJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddDiskResponse, error) + + // PutVmAddFsWithBodyWithResponse request with any body + PutVmAddFsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddFsResponse, error) + + PutVmAddFsWithResponse(ctx context.Context, body PutVmAddFsJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddFsResponse, error) + + // PutVmAddNetWithBodyWithResponse request with any body + PutVmAddNetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddNetResponse, error) + + PutVmAddNetWithResponse(ctx context.Context, body PutVmAddNetJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddNetResponse, error) + + // PutVmAddPmemWithBodyWithResponse request with any body + PutVmAddPmemWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddPmemResponse, error) + + PutVmAddPmemWithResponse(ctx context.Context, body PutVmAddPmemJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddPmemResponse, error) + + // PutVmAddUserDeviceWithBodyWithResponse request with any body + PutVmAddUserDeviceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddUserDeviceResponse, error) + + PutVmAddUserDeviceWithResponse(ctx context.Context, body PutVmAddUserDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddUserDeviceResponse, error) + + // PutVmAddVdpaWithBodyWithResponse request with any body + PutVmAddVdpaWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddVdpaResponse, error) + + PutVmAddVdpaWithResponse(ctx context.Context, body PutVmAddVdpaJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddVdpaResponse, error) + + // PutVmAddVsockWithBodyWithResponse request with any body + PutVmAddVsockWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddVsockResponse, error) + + PutVmAddVsockWithResponse(ctx context.Context, body PutVmAddVsockJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddVsockResponse, error) + + // BootVMWithResponse request + BootVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BootVMResponse, error) + + // PutVmCoredumpWithBodyWithResponse request with any body + PutVmCoredumpWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmCoredumpResponse, error) + + PutVmCoredumpWithResponse(ctx context.Context, body PutVmCoredumpJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmCoredumpResponse, error) + + // GetVmCountersWithResponse request + GetVmCountersWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVmCountersResponse, error) + + // CreateVMWithBodyWithResponse request with any body + CreateVMWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateVMResponse, error) + + CreateVMWithResponse(ctx context.Context, body CreateVMJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateVMResponse, error) + + // DeleteVMWithResponse request + DeleteVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DeleteVMResponse, error) + + // GetVmInfoWithResponse request + GetVmInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVmInfoResponse, error) + + // PauseVMWithResponse request + PauseVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PauseVMResponse, error) + + // PowerButtonVMWithResponse request + PowerButtonVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PowerButtonVMResponse, error) + + // RebootVMWithResponse request + RebootVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RebootVMResponse, error) + + // PutVmReceiveMigrationWithBodyWithResponse request with any body + PutVmReceiveMigrationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmReceiveMigrationResponse, error) + + PutVmReceiveMigrationWithResponse(ctx context.Context, body PutVmReceiveMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmReceiveMigrationResponse, error) + + // PutVmRemoveDeviceWithBodyWithResponse request with any body + PutVmRemoveDeviceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmRemoveDeviceResponse, error) + + PutVmRemoveDeviceWithResponse(ctx context.Context, body PutVmRemoveDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmRemoveDeviceResponse, error) + + // PutVmResizeWithBodyWithResponse request with any body + PutVmResizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmResizeResponse, error) + + PutVmResizeWithResponse(ctx context.Context, body PutVmResizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmResizeResponse, error) + + // PutVmResizeZoneWithBodyWithResponse request with any body + PutVmResizeZoneWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmResizeZoneResponse, error) + + PutVmResizeZoneWithResponse(ctx context.Context, body PutVmResizeZoneJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmResizeZoneResponse, error) + + // PutVmRestoreWithBodyWithResponse request with any body + PutVmRestoreWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmRestoreResponse, error) + + PutVmRestoreWithResponse(ctx context.Context, body PutVmRestoreJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmRestoreResponse, error) + + // ResumeVMWithResponse request + ResumeVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ResumeVMResponse, error) + + // PutVmSendMigrationWithBodyWithResponse request with any body + PutVmSendMigrationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmSendMigrationResponse, error) + + PutVmSendMigrationWithResponse(ctx context.Context, body PutVmSendMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmSendMigrationResponse, error) + + // ShutdownVMWithResponse request + ShutdownVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ShutdownVMResponse, error) + + // PutVmSnapshotWithBodyWithResponse request with any body + PutVmSnapshotWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmSnapshotResponse, error) + + PutVmSnapshotWithResponse(ctx context.Context, body PutVmSnapshotJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmSnapshotResponse, error) + + // PutVmmNmiWithResponse request + PutVmmNmiWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PutVmmNmiResponse, error) + + // GetVmmPingWithResponse request + GetVmmPingWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVmmPingResponse, error) + + // ShutdownVMMWithResponse request + ShutdownVMMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ShutdownVMMResponse, error) +} + +type PutVmAddDeviceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddDeviceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddDeviceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddDiskResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddDiskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddDiskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddFsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddFsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddFsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddNetResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddNetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddNetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddPmemResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddPmemResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddPmemResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddUserDeviceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddUserDeviceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddUserDeviceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddVdpaResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddVdpaResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddVdpaResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmAddVsockResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *PciDeviceInfo +} + +// Status returns HTTPResponse.Status +func (r PutVmAddVsockResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmAddVsockResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BootVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r BootVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BootVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmCoredumpResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmCoredumpResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmCoredumpResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetVmCountersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VmCounters +} + +// Status returns HTTPResponse.Status +func (r GetVmCountersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetVmCountersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CreateVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r CreateVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r DeleteVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetVmInfoResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VmInfo +} + +// Status returns HTTPResponse.Status +func (r GetVmInfoResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetVmInfoResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PauseVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PauseVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PauseVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PowerButtonVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PowerButtonVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PowerButtonVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RebootVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r RebootVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RebootVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmReceiveMigrationResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmReceiveMigrationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmReceiveMigrationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmRemoveDeviceResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmRemoveDeviceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmRemoveDeviceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmResizeResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmResizeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmResizeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmResizeZoneResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmResizeZoneResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmResizeZoneResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmRestoreResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmRestoreResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmRestoreResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ResumeVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ResumeVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ResumeVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmSendMigrationResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmSendMigrationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmSendMigrationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ShutdownVMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ShutdownVMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ShutdownVMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmSnapshotResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmSnapshotResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmSnapshotResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutVmmNmiResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutVmmNmiResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutVmmNmiResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetVmmPingResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VmmPingResponse +} + +// Status returns HTTPResponse.Status +func (r GetVmmPingResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetVmmPingResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ShutdownVMMResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ShutdownVMMResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ShutdownVMMResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// PutVmAddDeviceWithBodyWithResponse request with arbitrary body returning *PutVmAddDeviceResponse +func (c *ClientWithResponses) PutVmAddDeviceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddDeviceResponse, error) { + rsp, err := c.PutVmAddDeviceWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddDeviceResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddDeviceWithResponse(ctx context.Context, body PutVmAddDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddDeviceResponse, error) { + rsp, err := c.PutVmAddDevice(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddDeviceResponse(rsp) +} + +// PutVmAddDiskWithBodyWithResponse request with arbitrary body returning *PutVmAddDiskResponse +func (c *ClientWithResponses) PutVmAddDiskWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddDiskResponse, error) { + rsp, err := c.PutVmAddDiskWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddDiskResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddDiskWithResponse(ctx context.Context, body PutVmAddDiskJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddDiskResponse, error) { + rsp, err := c.PutVmAddDisk(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddDiskResponse(rsp) +} + +// PutVmAddFsWithBodyWithResponse request with arbitrary body returning *PutVmAddFsResponse +func (c *ClientWithResponses) PutVmAddFsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddFsResponse, error) { + rsp, err := c.PutVmAddFsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddFsResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddFsWithResponse(ctx context.Context, body PutVmAddFsJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddFsResponse, error) { + rsp, err := c.PutVmAddFs(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddFsResponse(rsp) +} + +// PutVmAddNetWithBodyWithResponse request with arbitrary body returning *PutVmAddNetResponse +func (c *ClientWithResponses) PutVmAddNetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddNetResponse, error) { + rsp, err := c.PutVmAddNetWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddNetResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddNetWithResponse(ctx context.Context, body PutVmAddNetJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddNetResponse, error) { + rsp, err := c.PutVmAddNet(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddNetResponse(rsp) +} + +// PutVmAddPmemWithBodyWithResponse request with arbitrary body returning *PutVmAddPmemResponse +func (c *ClientWithResponses) PutVmAddPmemWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddPmemResponse, error) { + rsp, err := c.PutVmAddPmemWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddPmemResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddPmemWithResponse(ctx context.Context, body PutVmAddPmemJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddPmemResponse, error) { + rsp, err := c.PutVmAddPmem(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddPmemResponse(rsp) +} + +// PutVmAddUserDeviceWithBodyWithResponse request with arbitrary body returning *PutVmAddUserDeviceResponse +func (c *ClientWithResponses) PutVmAddUserDeviceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddUserDeviceResponse, error) { + rsp, err := c.PutVmAddUserDeviceWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddUserDeviceResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddUserDeviceWithResponse(ctx context.Context, body PutVmAddUserDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddUserDeviceResponse, error) { + rsp, err := c.PutVmAddUserDevice(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddUserDeviceResponse(rsp) +} + +// PutVmAddVdpaWithBodyWithResponse request with arbitrary body returning *PutVmAddVdpaResponse +func (c *ClientWithResponses) PutVmAddVdpaWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddVdpaResponse, error) { + rsp, err := c.PutVmAddVdpaWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddVdpaResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddVdpaWithResponse(ctx context.Context, body PutVmAddVdpaJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddVdpaResponse, error) { + rsp, err := c.PutVmAddVdpa(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddVdpaResponse(rsp) +} + +// PutVmAddVsockWithBodyWithResponse request with arbitrary body returning *PutVmAddVsockResponse +func (c *ClientWithResponses) PutVmAddVsockWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmAddVsockResponse, error) { + rsp, err := c.PutVmAddVsockWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddVsockResponse(rsp) +} + +func (c *ClientWithResponses) PutVmAddVsockWithResponse(ctx context.Context, body PutVmAddVsockJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmAddVsockResponse, error) { + rsp, err := c.PutVmAddVsock(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmAddVsockResponse(rsp) +} + +// BootVMWithResponse request returning *BootVMResponse +func (c *ClientWithResponses) BootVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BootVMResponse, error) { + rsp, err := c.BootVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseBootVMResponse(rsp) +} + +// PutVmCoredumpWithBodyWithResponse request with arbitrary body returning *PutVmCoredumpResponse +func (c *ClientWithResponses) PutVmCoredumpWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmCoredumpResponse, error) { + rsp, err := c.PutVmCoredumpWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmCoredumpResponse(rsp) +} + +func (c *ClientWithResponses) PutVmCoredumpWithResponse(ctx context.Context, body PutVmCoredumpJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmCoredumpResponse, error) { + rsp, err := c.PutVmCoredump(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmCoredumpResponse(rsp) +} + +// GetVmCountersWithResponse request returning *GetVmCountersResponse +func (c *ClientWithResponses) GetVmCountersWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVmCountersResponse, error) { + rsp, err := c.GetVmCounters(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVmCountersResponse(rsp) +} + +// CreateVMWithBodyWithResponse request with arbitrary body returning *CreateVMResponse +func (c *ClientWithResponses) CreateVMWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateVMResponse, error) { + rsp, err := c.CreateVMWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateVMResponse(rsp) +} + +func (c *ClientWithResponses) CreateVMWithResponse(ctx context.Context, body CreateVMJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateVMResponse, error) { + rsp, err := c.CreateVM(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateVMResponse(rsp) +} + +// DeleteVMWithResponse request returning *DeleteVMResponse +func (c *ClientWithResponses) DeleteVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DeleteVMResponse, error) { + rsp, err := c.DeleteVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteVMResponse(rsp) +} + +// GetVmInfoWithResponse request returning *GetVmInfoResponse +func (c *ClientWithResponses) GetVmInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVmInfoResponse, error) { + rsp, err := c.GetVmInfo(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVmInfoResponse(rsp) +} + +// PauseVMWithResponse request returning *PauseVMResponse +func (c *ClientWithResponses) PauseVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PauseVMResponse, error) { + rsp, err := c.PauseVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParsePauseVMResponse(rsp) +} + +// PowerButtonVMWithResponse request returning *PowerButtonVMResponse +func (c *ClientWithResponses) PowerButtonVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PowerButtonVMResponse, error) { + rsp, err := c.PowerButtonVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParsePowerButtonVMResponse(rsp) +} + +// RebootVMWithResponse request returning *RebootVMResponse +func (c *ClientWithResponses) RebootVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RebootVMResponse, error) { + rsp, err := c.RebootVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseRebootVMResponse(rsp) +} + +// PutVmReceiveMigrationWithBodyWithResponse request with arbitrary body returning *PutVmReceiveMigrationResponse +func (c *ClientWithResponses) PutVmReceiveMigrationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmReceiveMigrationResponse, error) { + rsp, err := c.PutVmReceiveMigrationWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmReceiveMigrationResponse(rsp) +} + +func (c *ClientWithResponses) PutVmReceiveMigrationWithResponse(ctx context.Context, body PutVmReceiveMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmReceiveMigrationResponse, error) { + rsp, err := c.PutVmReceiveMigration(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmReceiveMigrationResponse(rsp) +} + +// PutVmRemoveDeviceWithBodyWithResponse request with arbitrary body returning *PutVmRemoveDeviceResponse +func (c *ClientWithResponses) PutVmRemoveDeviceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmRemoveDeviceResponse, error) { + rsp, err := c.PutVmRemoveDeviceWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmRemoveDeviceResponse(rsp) +} + +func (c *ClientWithResponses) PutVmRemoveDeviceWithResponse(ctx context.Context, body PutVmRemoveDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmRemoveDeviceResponse, error) { + rsp, err := c.PutVmRemoveDevice(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmRemoveDeviceResponse(rsp) +} + +// PutVmResizeWithBodyWithResponse request with arbitrary body returning *PutVmResizeResponse +func (c *ClientWithResponses) PutVmResizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmResizeResponse, error) { + rsp, err := c.PutVmResizeWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmResizeResponse(rsp) +} + +func (c *ClientWithResponses) PutVmResizeWithResponse(ctx context.Context, body PutVmResizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmResizeResponse, error) { + rsp, err := c.PutVmResize(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmResizeResponse(rsp) +} + +// PutVmResizeZoneWithBodyWithResponse request with arbitrary body returning *PutVmResizeZoneResponse +func (c *ClientWithResponses) PutVmResizeZoneWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmResizeZoneResponse, error) { + rsp, err := c.PutVmResizeZoneWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmResizeZoneResponse(rsp) +} + +func (c *ClientWithResponses) PutVmResizeZoneWithResponse(ctx context.Context, body PutVmResizeZoneJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmResizeZoneResponse, error) { + rsp, err := c.PutVmResizeZone(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmResizeZoneResponse(rsp) +} + +// PutVmRestoreWithBodyWithResponse request with arbitrary body returning *PutVmRestoreResponse +func (c *ClientWithResponses) PutVmRestoreWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmRestoreResponse, error) { + rsp, err := c.PutVmRestoreWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmRestoreResponse(rsp) +} + +func (c *ClientWithResponses) PutVmRestoreWithResponse(ctx context.Context, body PutVmRestoreJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmRestoreResponse, error) { + rsp, err := c.PutVmRestore(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmRestoreResponse(rsp) +} + +// ResumeVMWithResponse request returning *ResumeVMResponse +func (c *ClientWithResponses) ResumeVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ResumeVMResponse, error) { + rsp, err := c.ResumeVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseResumeVMResponse(rsp) +} + +// PutVmSendMigrationWithBodyWithResponse request with arbitrary body returning *PutVmSendMigrationResponse +func (c *ClientWithResponses) PutVmSendMigrationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmSendMigrationResponse, error) { + rsp, err := c.PutVmSendMigrationWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmSendMigrationResponse(rsp) +} + +func (c *ClientWithResponses) PutVmSendMigrationWithResponse(ctx context.Context, body PutVmSendMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmSendMigrationResponse, error) { + rsp, err := c.PutVmSendMigration(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmSendMigrationResponse(rsp) +} + +// ShutdownVMWithResponse request returning *ShutdownVMResponse +func (c *ClientWithResponses) ShutdownVMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ShutdownVMResponse, error) { + rsp, err := c.ShutdownVM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseShutdownVMResponse(rsp) +} + +// PutVmSnapshotWithBodyWithResponse request with arbitrary body returning *PutVmSnapshotResponse +func (c *ClientWithResponses) PutVmSnapshotWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutVmSnapshotResponse, error) { + rsp, err := c.PutVmSnapshotWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmSnapshotResponse(rsp) +} + +func (c *ClientWithResponses) PutVmSnapshotWithResponse(ctx context.Context, body PutVmSnapshotJSONRequestBody, reqEditors ...RequestEditorFn) (*PutVmSnapshotResponse, error) { + rsp, err := c.PutVmSnapshot(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmSnapshotResponse(rsp) +} + +// PutVmmNmiWithResponse request returning *PutVmmNmiResponse +func (c *ClientWithResponses) PutVmmNmiWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PutVmmNmiResponse, error) { + rsp, err := c.PutVmmNmi(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutVmmNmiResponse(rsp) +} + +// GetVmmPingWithResponse request returning *GetVmmPingResponse +func (c *ClientWithResponses) GetVmmPingWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVmmPingResponse, error) { + rsp, err := c.GetVmmPing(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVmmPingResponse(rsp) +} + +// ShutdownVMMWithResponse request returning *ShutdownVMMResponse +func (c *ClientWithResponses) ShutdownVMMWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ShutdownVMMResponse, error) { + rsp, err := c.ShutdownVMM(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseShutdownVMMResponse(rsp) +} + +// ParsePutVmAddDeviceResponse parses an HTTP response from a PutVmAddDeviceWithResponse call +func ParsePutVmAddDeviceResponse(rsp *http.Response) (*PutVmAddDeviceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddDeviceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddDiskResponse parses an HTTP response from a PutVmAddDiskWithResponse call +func ParsePutVmAddDiskResponse(rsp *http.Response) (*PutVmAddDiskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddDiskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddFsResponse parses an HTTP response from a PutVmAddFsWithResponse call +func ParsePutVmAddFsResponse(rsp *http.Response) (*PutVmAddFsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddFsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddNetResponse parses an HTTP response from a PutVmAddNetWithResponse call +func ParsePutVmAddNetResponse(rsp *http.Response) (*PutVmAddNetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddNetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddPmemResponse parses an HTTP response from a PutVmAddPmemWithResponse call +func ParsePutVmAddPmemResponse(rsp *http.Response) (*PutVmAddPmemResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddPmemResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddUserDeviceResponse parses an HTTP response from a PutVmAddUserDeviceWithResponse call +func ParsePutVmAddUserDeviceResponse(rsp *http.Response) (*PutVmAddUserDeviceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddUserDeviceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddVdpaResponse parses an HTTP response from a PutVmAddVdpaWithResponse call +func ParsePutVmAddVdpaResponse(rsp *http.Response) (*PutVmAddVdpaResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddVdpaResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutVmAddVsockResponse parses an HTTP response from a PutVmAddVsockWithResponse call +func ParsePutVmAddVsockResponse(rsp *http.Response) (*PutVmAddVsockResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmAddVsockResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PciDeviceInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseBootVMResponse parses an HTTP response from a BootVMWithResponse call +func ParseBootVMResponse(rsp *http.Response) (*BootVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BootVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmCoredumpResponse parses an HTTP response from a PutVmCoredumpWithResponse call +func ParsePutVmCoredumpResponse(rsp *http.Response) (*PutVmCoredumpResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmCoredumpResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetVmCountersResponse parses an HTTP response from a GetVmCountersWithResponse call +func ParseGetVmCountersResponse(rsp *http.Response) (*GetVmCountersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetVmCountersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VmCounters + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseCreateVMResponse parses an HTTP response from a CreateVMWithResponse call +func ParseCreateVMResponse(rsp *http.Response) (*CreateVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseDeleteVMResponse parses an HTTP response from a DeleteVMWithResponse call +func ParseDeleteVMResponse(rsp *http.Response) (*DeleteVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetVmInfoResponse parses an HTTP response from a GetVmInfoWithResponse call +func ParseGetVmInfoResponse(rsp *http.Response) (*GetVmInfoResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetVmInfoResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VmInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePauseVMResponse parses an HTTP response from a PauseVMWithResponse call +func ParsePauseVMResponse(rsp *http.Response) (*PauseVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PauseVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePowerButtonVMResponse parses an HTTP response from a PowerButtonVMWithResponse call +func ParsePowerButtonVMResponse(rsp *http.Response) (*PowerButtonVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PowerButtonVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseRebootVMResponse parses an HTTP response from a RebootVMWithResponse call +func ParseRebootVMResponse(rsp *http.Response) (*RebootVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RebootVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmReceiveMigrationResponse parses an HTTP response from a PutVmReceiveMigrationWithResponse call +func ParsePutVmReceiveMigrationResponse(rsp *http.Response) (*PutVmReceiveMigrationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmReceiveMigrationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmRemoveDeviceResponse parses an HTTP response from a PutVmRemoveDeviceWithResponse call +func ParsePutVmRemoveDeviceResponse(rsp *http.Response) (*PutVmRemoveDeviceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmRemoveDeviceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmResizeResponse parses an HTTP response from a PutVmResizeWithResponse call +func ParsePutVmResizeResponse(rsp *http.Response) (*PutVmResizeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmResizeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmResizeZoneResponse parses an HTTP response from a PutVmResizeZoneWithResponse call +func ParsePutVmResizeZoneResponse(rsp *http.Response) (*PutVmResizeZoneResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmResizeZoneResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmRestoreResponse parses an HTTP response from a PutVmRestoreWithResponse call +func ParsePutVmRestoreResponse(rsp *http.Response) (*PutVmRestoreResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmRestoreResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseResumeVMResponse parses an HTTP response from a ResumeVMWithResponse call +func ParseResumeVMResponse(rsp *http.Response) (*ResumeVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResumeVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmSendMigrationResponse parses an HTTP response from a PutVmSendMigrationWithResponse call +func ParsePutVmSendMigrationResponse(rsp *http.Response) (*PutVmSendMigrationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmSendMigrationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseShutdownVMResponse parses an HTTP response from a ShutdownVMWithResponse call +func ParseShutdownVMResponse(rsp *http.Response) (*ShutdownVMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ShutdownVMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmSnapshotResponse parses an HTTP response from a PutVmSnapshotWithResponse call +func ParsePutVmSnapshotResponse(rsp *http.Response) (*PutVmSnapshotResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmSnapshotResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePutVmmNmiResponse parses an HTTP response from a PutVmmNmiWithResponse call +func ParsePutVmmNmiResponse(rsp *http.Response) (*PutVmmNmiResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutVmmNmiResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetVmmPingResponse parses an HTTP response from a GetVmmPingWithResponse call +func ParseGetVmmPingResponse(rsp *http.Response) (*GetVmmPingResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetVmmPingResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VmmPingResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseShutdownVMMResponse parses an HTTP response from a ShutdownVMMWithResponse call +func ParseShutdownVMMResponse(rsp *http.Response) (*ShutdownVMMResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ShutdownVMMResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +}