package httpapp import ( "encoding/json" "net/http" "gitea.avt.data-center.id/othman.suseno/atlas/internal/models" ) // pathParam is now in router_helpers.go // ZFS Pool Handlers func (a *App) handleListPools(w http.ResponseWriter, r *http.Request) { // TODO: Implement ZFS pool listing pools := []models.Pool{} // Stub writeJSON(w, http.StatusOK, pools) } func (a *App) handleCreatePool(w http.ResponseWriter, r *http.Request) { // TODO: Implement pool creation writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetPool(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/pools/") // TODO: Implement pool retrieval writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } func (a *App) handleDeletePool(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/pools/") // TODO: Implement pool deletion writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } func (a *App) handleScrubPool(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/pools/") // TODO: Implement pool scrub writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } // Dataset Handlers func (a *App) handleListDatasets(w http.ResponseWriter, r *http.Request) { datasets := []models.Dataset{} // Stub writeJSON(w, http.StatusOK, datasets) } func (a *App) handleCreateDataset(w http.ResponseWriter, r *http.Request) { var req struct { Name string `json:"name"` Pool string `json:"pool"` } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid request"}) return } // TODO: Implement dataset creation writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetDataset(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/datasets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } func (a *App) handleUpdateDataset(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/datasets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } func (a *App) handleDeleteDataset(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/datasets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } // ZVOL Handlers func (a *App) handleListZVOLs(w http.ResponseWriter, r *http.Request) { zvols := []models.ZVOL{} // Stub writeJSON(w, http.StatusOK, zvols) } func (a *App) handleCreateZVOL(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetZVOL(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/zvols/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } func (a *App) handleDeleteZVOL(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/zvols/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } // Snapshot Handlers func (a *App) handleListSnapshots(w http.ResponseWriter, r *http.Request) { snapshots := []models.Snapshot{} // Stub writeJSON(w, http.StatusOK, snapshots) } func (a *App) handleCreateSnapshot(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetSnapshot(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/snapshots/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } func (a *App) handleDeleteSnapshot(w http.ResponseWriter, r *http.Request) { name := pathParam(r, "/api/v1/snapshots/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "name": name}) } // Snapshot Policy Handlers func (a *App) handleListSnapshotPolicies(w http.ResponseWriter, r *http.Request) { policies := []models.SnapshotPolicy{} // Stub writeJSON(w, http.StatusOK, policies) } func (a *App) handleCreateSnapshotPolicy(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetSnapshotPolicy(w http.ResponseWriter, r *http.Request) { dataset := pathParam(r, "/api/v1/snapshot-policies/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "dataset": dataset}) } func (a *App) handleUpdateSnapshotPolicy(w http.ResponseWriter, r *http.Request) { dataset := pathParam(r, "/api/v1/snapshot-policies/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "dataset": dataset}) } func (a *App) handleDeleteSnapshotPolicy(w http.ResponseWriter, r *http.Request) { dataset := pathParam(r, "/api/v1/snapshot-policies/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "dataset": dataset}) } // SMB Share Handlers func (a *App) handleListSMBShares(w http.ResponseWriter, r *http.Request) { shares := []models.SMBShare{} // Stub writeJSON(w, http.StatusOK, shares) } func (a *App) handleCreateSMBShare(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetSMBShare(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/shares/smb/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleUpdateSMBShare(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/shares/smb/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleDeleteSMBShare(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/shares/smb/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } // NFS Export Handlers func (a *App) handleListNFSExports(w http.ResponseWriter, r *http.Request) { exports := []models.NFSExport{} // Stub writeJSON(w, http.StatusOK, exports) } func (a *App) handleCreateNFSExport(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetNFSExport(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/exports/nfs/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleUpdateNFSExport(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/exports/nfs/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleDeleteNFSExport(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/exports/nfs/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } // iSCSI Handlers func (a *App) handleListISCSITargets(w http.ResponseWriter, r *http.Request) { targets := []models.ISCSITarget{} // Stub writeJSON(w, http.StatusOK, targets) } func (a *App) handleCreateISCSITarget(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetISCSITarget(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/iscsi/targets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleUpdateISCSITarget(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/iscsi/targets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleDeleteISCSITarget(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/iscsi/targets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleAddLUN(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/iscsi/targets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleRemoveLUN(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/iscsi/targets/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } // Job Handlers func (a *App) handleListJobs(w http.ResponseWriter, r *http.Request) { jobs := []models.Job{} // Stub writeJSON(w, http.StatusOK, jobs) } func (a *App) handleGetJob(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/jobs/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleCancelJob(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/jobs/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } // Auth Handlers (stubs) func (a *App) handleLogin(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleLogout(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, map[string]string{"message": "logged out"}) } // User Handlers func (a *App) handleListUsers(w http.ResponseWriter, r *http.Request) { users := []models.User{} // Stub writeJSON(w, http.StatusOK, users) } func (a *App) handleCreateUser(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented"}) } func (a *App) handleGetUser(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/users/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleUpdateUser(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/users/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } func (a *App) handleDeleteUser(w http.ResponseWriter, r *http.Request) { id := pathParam(r, "/api/v1/users/") writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "not implemented", "id": id}) } // Audit Log Handlers func (a *App) handleListAuditLogs(w http.ResponseWriter, r *http.Request) { logs := []models.AuditLog{} // Stub writeJSON(w, http.StatusOK, logs) }