update to support postgresql and add godocs
This commit is contained in:
@@ -7,6 +7,16 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// EncryptData encrypts a plaintext value and returns the ciphertext.
|
||||
// @Summary Encrypt data
|
||||
// @Description Encrypts a plaintext value and returns the ciphertext.
|
||||
// @Tags crypto
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param payload body map[string]string true "Plaintext payload"
|
||||
// @Success 200 {object} map[string]string "Ciphertext response"
|
||||
// @Failure 500 {object} map[string]string "Server error"
|
||||
// @Router /api/encrypt [post]
|
||||
func (h *Handler) EncryptData(w http.ResponseWriter, r *http.Request) {
|
||||
//ctx := context.Background()
|
||||
var cipherText string
|
||||
|
||||
@@ -5,7 +5,14 @@ import (
|
||||
"vctp/components/views"
|
||||
)
|
||||
|
||||
// Home handles the home page.
|
||||
// Home renders the web UI home page.
|
||||
// @Summary Home page
|
||||
// @Description Renders the main UI page.
|
||||
// @Tags ui
|
||||
// @Produce text/html
|
||||
// @Success 200 {string} string "HTML page"
|
||||
// @Failure 500 {string} string "Render failed"
|
||||
// @Router / [get]
|
||||
func (h *Handler) Home(w http.ResponseWriter, r *http.Request) {
|
||||
//h.html(r.Context(), w, http.StatusOK, core.HTML("Example Site", home.Home()))
|
||||
|
||||
|
||||
@@ -8,6 +8,14 @@ import (
|
||||
"vctp/internal/report"
|
||||
)
|
||||
|
||||
// InventoryReportDownload returns the inventory report as an XLSX download.
|
||||
// @Summary Download inventory report
|
||||
// @Description Generates an inventory XLSX report and returns it as a file download.
|
||||
// @Tags reports
|
||||
// @Produce application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
// @Success 200 {file} file "Inventory XLSX report"
|
||||
// @Failure 500 {object} map[string]string "Report generation failed"
|
||||
// @Router /api/report/inventory [get]
|
||||
func (h *Handler) InventoryReportDownload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -34,6 +42,14 @@ func (h *Handler) InventoryReportDownload(w http.ResponseWriter, r *http.Request
|
||||
w.Write(reportData)
|
||||
}
|
||||
|
||||
// UpdateReportDownload returns the updates report as an XLSX download.
|
||||
// @Summary Download updates report
|
||||
// @Description Generates an updates XLSX report and returns it as a file download.
|
||||
// @Tags reports
|
||||
// @Produce application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
// @Success 200 {file} file "Updates XLSX report"
|
||||
// @Failure 500 {object} map[string]string "Report generation failed"
|
||||
// @Router /api/report/updates [get]
|
||||
func (h *Handler) UpdateReportDownload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -6,7 +6,14 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// VmUpdate receives the CloudEvent for a VM modification or move
|
||||
// UpdateCleanup removes orphaned update records.
|
||||
// @Summary Cleanup updates
|
||||
// @Description Removes update records that are no longer associated with a VM.
|
||||
// @Tags maintenance
|
||||
// @Produce text/plain
|
||||
// @Success 200 {string} string "Cleanup completed"
|
||||
// @Failure 500 {string} string "Server error"
|
||||
// @Router /api/cleanup/updates [delete]
|
||||
func (h *Handler) UpdateCleanup(w http.ResponseWriter, r *http.Request) {
|
||||
/*
|
||||
// Get the current time
|
||||
|
||||
@@ -9,7 +9,15 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Remove a specified VM from the inventory
|
||||
// VcCleanup removes inventory entries for a vCenter instance.
|
||||
// @Summary Cleanup vCenter inventory
|
||||
// @Description Removes all inventory entries associated with a vCenter URL.
|
||||
// @Tags maintenance
|
||||
// @Produce json
|
||||
// @Param vc_url query string true "vCenter URL"
|
||||
// @Success 200 {object} map[string]string "Cleanup completed"
|
||||
// @Failure 400 {object} map[string]string "Invalid request"
|
||||
// @Router /api/cleanup/vcenter [delete]
|
||||
func (h *Handler) VcCleanup(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := context.Background()
|
||||
|
||||
|
||||
@@ -10,7 +10,16 @@ import (
|
||||
"vctp/db/queries"
|
||||
)
|
||||
|
||||
// Remove a specified VM from the inventory
|
||||
// VmCleanup removes a VM from inventory by ID and datacenter.
|
||||
// @Summary Cleanup VM inventory entry
|
||||
// @Description Removes a VM inventory entry by VM ID and datacenter name.
|
||||
// @Tags inventory
|
||||
// @Produce json
|
||||
// @Param vm_id query string true "VM ID"
|
||||
// @Param datacenter_name query string true "Datacenter name"
|
||||
// @Success 200 {object} map[string]string "Cleanup completed"
|
||||
// @Failure 400 {object} map[string]string "Invalid request"
|
||||
// @Router /api/inventory/vm/delete [delete]
|
||||
func (h *Handler) VmCleanup(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := context.Background()
|
||||
|
||||
|
||||
@@ -14,7 +14,17 @@ import (
|
||||
models "vctp/server/models"
|
||||
)
|
||||
|
||||
// VmCreateEvent receives the CloudEvent for a VM creation
|
||||
// VmCreateEvent records a VM creation CloudEvent.
|
||||
// @Summary Record VM create event
|
||||
// @Description Parses a VM create CloudEvent and stores the event data.
|
||||
// @Tags events
|
||||
// @Accept json
|
||||
// @Produce text/plain
|
||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||
// @Success 200 {string} string "Create event processed"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Server error"
|
||||
// @Router /api/event/vm/create [post]
|
||||
func (h *Handler) VmCreateEvent(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
unixTimestamp int64
|
||||
|
||||
@@ -12,7 +12,17 @@ import (
|
||||
models "vctp/server/models"
|
||||
)
|
||||
|
||||
// VmUpdate receives the CloudEvent for a VM modification or move
|
||||
// VmDeleteEvent records a VM deletion CloudEvent in the inventory.
|
||||
// @Summary Record VM delete event
|
||||
// @Description Parses a VM delete CloudEvent and marks the VM as deleted in inventory.
|
||||
// @Tags events
|
||||
// @Accept json
|
||||
// @Produce text/plain
|
||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||
// @Success 200 {string} string "Delete event processed"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Server error"
|
||||
// @Router /api/event/vm/delete [post]
|
||||
func (h *Handler) VmDeleteEvent(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
deletedTimestamp int64
|
||||
|
||||
@@ -13,7 +13,16 @@ import (
|
||||
models "vctp/server/models"
|
||||
)
|
||||
|
||||
// VmImport is used for bulk import of existing VMs
|
||||
// VmImport ingests a bulk VM import payload.
|
||||
// @Summary Import VMs
|
||||
// @Description Imports existing VM inventory data in bulk.
|
||||
// @Tags inventory
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param import body models.ImportReceived true "Bulk import payload"
|
||||
// @Success 200 {object} map[string]string "Import processed"
|
||||
// @Failure 500 {object} map[string]string "Server error"
|
||||
// @Router /api/import/vm [post]
|
||||
func (h *Handler) VmImport(w http.ResponseWriter, r *http.Request) {
|
||||
// Read request body
|
||||
reqBody, err := io.ReadAll(r.Body)
|
||||
|
||||
@@ -19,7 +19,17 @@ import (
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
// VmModifyEvent receives the CloudEvent for a VM modification or move
|
||||
// VmModifyEvent records a VM modification CloudEvent.
|
||||
// @Summary Record VM modify event
|
||||
// @Description Parses a VM modify CloudEvent and creates an update record when relevant changes are detected.
|
||||
// @Tags events
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||
// @Success 200 {object} map[string]string "Modify event processed"
|
||||
// @Success 202 {object} map[string]string "No relevant changes"
|
||||
// @Failure 500 {object} map[string]string "Server error"
|
||||
// @Router /api/event/vm/modify [post]
|
||||
func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
var configChanges []map[string]string
|
||||
params := queries.CreateUpdateParams{}
|
||||
|
||||
@@ -14,6 +14,17 @@ import (
|
||||
models "vctp/server/models"
|
||||
)
|
||||
|
||||
// VmMoveEvent records a VM move CloudEvent as an update.
|
||||
// @Summary Record VM move event
|
||||
// @Description Parses a VM move CloudEvent and creates an update record.
|
||||
// @Tags events
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||
// @Success 200 {object} map[string]string "Move event processed"
|
||||
// @Failure 400 {object} map[string]string "Invalid request"
|
||||
// @Failure 500 {object} map[string]string "Server error"
|
||||
// @Router /api/event/vm/move [post]
|
||||
func (h *Handler) VmMoveEvent(w http.ResponseWriter, r *http.Request) {
|
||||
params := queries.CreateUpdateParams{}
|
||||
var unixTimestamp int64
|
||||
|
||||
@@ -9,7 +9,14 @@ import (
|
||||
"vctp/internal/vcenter"
|
||||
)
|
||||
|
||||
// VmUpdate receives the CloudEvent for a VM modification or move
|
||||
// VmUpdateDetails refreshes inventory metadata from vCenter.
|
||||
// @Summary Refresh VM details
|
||||
// @Description Queries vCenter and updates inventory records with missing details.
|
||||
// @Tags inventory
|
||||
// @Produce text/plain
|
||||
// @Success 200 {string} string "Update completed"
|
||||
// @Failure 500 {string} string "Server error"
|
||||
// @Router /api/inventory/vm/update [post]
|
||||
func (h *Handler) VmUpdateDetails(w http.ResponseWriter, r *http.Request) {
|
||||
var matchFound bool
|
||||
var inventoryId int64
|
||||
|
||||
Reference in New Issue
Block a user