This commit is contained in:
2024-09-15 10:51:48 +10:00
parent 934c082ba1
commit 1cb36be02c
10 changed files with 203 additions and 28 deletions

View File

@@ -0,0 +1,21 @@
package handler
import (
"fmt"
"io"
"net/http"
)
// VmUpdate receives the CloudEvent for a VM modification or move
func (h *Handler) VmDelete(w http.ResponseWriter, r *http.Request) {
reqBody, err := io.ReadAll(r.Body)
if err != nil {
fmt.Fprintf(w, "Invalid data received")
w.WriteHeader(http.StatusInternalServerError)
return
}
h.Logger.Debug("received delete request", "body", string(reqBody))
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Delete Request (%d): %v\n", len(reqBody), string(reqBody))
}

View File

@@ -0,0 +1,21 @@
package handler
import (
"fmt"
"io"
"net/http"
)
// VmImport is used for bulk import of existing VMs
func (h *Handler) VmImport(w http.ResponseWriter, r *http.Request) {
reqBody, err := io.ReadAll(r.Body)
if err != nil {
fmt.Fprintf(w, "Invalid data received")
w.WriteHeader(http.StatusInternalServerError)
return
}
h.Logger.Debug("received import request", "body", string(reqBody))
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Import Request (%d): %v\n", len(reqBody), string(reqBody))
}

View File

@@ -6,8 +6,8 @@ import (
"net/http"
)
// VmUpdate receives the CloudEvent for a VM modification or move
func (h *Handler) VmUpdate(w http.ResponseWriter, r *http.Request) {
// VmModify receives the CloudEvent for a VM modification or move
func (h *Handler) VmModify(w http.ResponseWriter, r *http.Request) {
reqBody, err := io.ReadAll(r.Body)
if err != nil {
fmt.Fprintf(w, "Invalid data received")