mirror of
https://github.com/GlueOps/autoglue.git
synced 2026-02-13 04:40:05 +01:00
fix: clean cache and go mod tidy for go1.25.3
This commit is contained in:
@@ -17,24 +17,25 @@ import (
|
||||
)
|
||||
|
||||
// ListAnnotations godoc
|
||||
// @ID ListAnnotations
|
||||
// @Summary List annotations (org scoped)
|
||||
// @Description Returns annotations for the organization in X-Org-ID. Filters: `key`, `value`, and `q` (key contains). Add `include=node_pools` to include linked node pools.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param key query string false "Exact key"
|
||||
// @Param value query string false "Exact value"
|
||||
// @Param q query string false "key contains (case-insensitive)"
|
||||
// @Success 200 {array} dto.AnnotationResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list annotations"
|
||||
// @Router /annotations [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID ListAnnotations
|
||||
// @Summary List annotations (org scoped)
|
||||
// @Description Returns annotations for the organization in X-Org-ID. Filters: `key`, `value`, and `q` (key contains). Add `include=node_pools` to include linked node pools.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param key query string false "Exact key"
|
||||
// @Param value query string false "Exact value"
|
||||
// @Param q query string false "key contains (case-insensitive)"
|
||||
// @Success 200 {array} dto.AnnotationResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list annotations"
|
||||
// @Router /annotations [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func ListAnnotations(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -69,24 +70,25 @@ func ListAnnotations(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GetAnnotation godoc
|
||||
// @ID GetAnnotation
|
||||
// @Summary Get annotation by ID (org scoped)
|
||||
// @Description Returns one annotation. Add `include=node_pools` to include node pools.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Annotation ID (UUID)"
|
||||
// @Success 200 {object} dto.AnnotationResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /annotations/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID GetAnnotation
|
||||
// @Summary Get annotation by ID (org scoped)
|
||||
// @Description Returns one annotation. Add `include=node_pools` to include node pools.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Annotation ID (UUID)"
|
||||
// @Success 200 {object} dto.AnnotationResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /annotations/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func GetAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -115,23 +117,24 @@ func GetAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// CreateAnnotation godoc
|
||||
// @ID CreateAnnotation
|
||||
// @Summary Create annotation (org scoped)
|
||||
// @Description Creates an annotation.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateAnnotationRequest true "Annotation payload"
|
||||
// @Success 201 {object} dto.AnnotationResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /annotations [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID CreateAnnotation
|
||||
// @Summary Create annotation (org scoped)
|
||||
// @Description Creates an annotation.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateAnnotationRequest true "Annotation payload"
|
||||
// @Success 201 {object} dto.AnnotationResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /annotations [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func CreateAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -175,25 +178,26 @@ func CreateAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// UpdateAnnotation godoc
|
||||
// @ID UpdateAnnotation
|
||||
// @Summary Update annotation (org scoped)
|
||||
// @Description Partially update annotation fields.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Annotation ID (UUID)"
|
||||
// @Param body body dto.UpdateAnnotationRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.AnnotationResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /annotations/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID UpdateAnnotation
|
||||
// @Summary Update annotation (org scoped)
|
||||
// @Description Partially update annotation fields.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Annotation ID (UUID)"
|
||||
// @Param body body dto.UpdateAnnotationRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.AnnotationResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /annotations/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func UpdateAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -246,23 +250,24 @@ func UpdateAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteAnnotation godoc
|
||||
// @ID DeleteAnnotation
|
||||
// @Summary Delete annotation (org scoped)
|
||||
// @Description Permanently deletes the annotation.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Annotation ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /annotations/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID DeleteAnnotation
|
||||
// @Summary Delete annotation (org scoped)
|
||||
// @Description Permanently deletes the annotation.
|
||||
// @Tags Annotations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Annotation ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /annotations/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func DeleteAnnotation(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
|
||||
@@ -51,14 +51,15 @@ func providerConfig(cfg config.Config, name string) (oauthProvider, bool) {
|
||||
}
|
||||
|
||||
// AuthStart godoc
|
||||
// @ID AuthStart
|
||||
// @Summary Begin social login
|
||||
// @Description Returns provider authorization URL for the frontend to redirect
|
||||
// @Tags Auth
|
||||
// @Param provider path string true "google|github"
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.AuthStartResponse
|
||||
// @Router /auth/{provider}/start [post]
|
||||
//
|
||||
// @ID AuthStart
|
||||
// @Summary Begin social login
|
||||
// @Description Returns provider authorization URL for the frontend to redirect
|
||||
// @Tags Auth
|
||||
// @Param provider path string true "google|github"
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.AuthStartResponse
|
||||
// @Router /auth/{provider}/start [post]
|
||||
func AuthStart(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
cfg, _ := config.Load()
|
||||
@@ -118,13 +119,14 @@ func AuthStart(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// AuthCallback godoc
|
||||
// @ID AuthCallback
|
||||
// @Summary Handle social login callback
|
||||
// @Tags Auth
|
||||
// @Param provider path string true "google|github"
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.TokenPair
|
||||
// @Router /auth/{provider}/callback [get]
|
||||
//
|
||||
// @ID AuthCallback
|
||||
// @Summary Handle social login callback
|
||||
// @Tags Auth
|
||||
// @Param provider path string true "google|github"
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.TokenPair
|
||||
// @Router /auth/{provider}/callback [get]
|
||||
func AuthCallback(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
cfg, _ := config.Load()
|
||||
@@ -306,14 +308,15 @@ func AuthCallback(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// Refresh godoc
|
||||
// @ID Refresh
|
||||
// @Summary Rotate refresh token
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.RefreshRequest true "Refresh token"
|
||||
// @Success 200 {object} dto.TokenPair
|
||||
// @Router /auth/refresh [post]
|
||||
//
|
||||
// @ID Refresh
|
||||
// @Summary Rotate refresh token
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.RefreshRequest true "Refresh token"
|
||||
// @Success 200 {object} dto.TokenPair
|
||||
// @Router /auth/refresh [post]
|
||||
func Refresh(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
cfg, _ := config.Load()
|
||||
@@ -363,14 +366,15 @@ func Refresh(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// Logout godoc
|
||||
// @ID Logout
|
||||
// @Summary Revoke refresh token family (logout everywhere)
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.LogoutRequest true "Refresh token"
|
||||
// @Success 204 "No Content"
|
||||
// @Router /auth/logout [post]
|
||||
//
|
||||
// @ID Logout
|
||||
// @Summary Revoke refresh token family (logout everywhere)
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.LogoutRequest true "Refresh token"
|
||||
// @Success 204 "No Content"
|
||||
// @Router /auth/logout [post]
|
||||
func Logout(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req dto.LogoutRequest
|
||||
|
||||
@@ -11,14 +11,15 @@ type HealthStatus struct {
|
||||
}
|
||||
|
||||
// HealthCheck godoc
|
||||
// @Summary Basic health check
|
||||
// @Description Returns 200 OK when the service is up
|
||||
// @Tags Health
|
||||
// @ID HealthCheck // operationId
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} HealthStatus
|
||||
// @Router /healthz [get]
|
||||
//
|
||||
// @Summary Basic health check
|
||||
// @Description Returns 200 OK when the service is up
|
||||
// @Tags Health
|
||||
// @ID HealthCheck // operationId
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} HealthStatus
|
||||
// @Router /healthz [get]
|
||||
func HealthCheck(w http.ResponseWriter, r *http.Request) {
|
||||
utils.WriteJSON(w, http.StatusOK, HealthStatus{Status: "ok"})
|
||||
}
|
||||
|
||||
@@ -20,23 +20,24 @@ import (
|
||||
)
|
||||
|
||||
// AdminListArcherJobs godoc
|
||||
// @ID AdminListArcherJobs
|
||||
// @Summary List Archer jobs (admin)
|
||||
// @Description Paginated background jobs with optional filters. Search `q` may match id, type, error, payload (implementation-dependent).
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query string false "Filter by status" Enums(queued,running,succeeded,failed,canceled,retrying,scheduled)
|
||||
// @Param queue query string false "Filter by queue name / worker name"
|
||||
// @Param q query string false "Free-text search"
|
||||
// @Param page query int false "Page number" default(1)
|
||||
// @Param page_size query int false "Items per page" minimum(1) maximum(100) default(25)
|
||||
// @Success 200 {object} dto.PageJob
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal error"
|
||||
// @Router /admin/archer/jobs [get]
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID AdminListArcherJobs
|
||||
// @Summary List Archer jobs (admin)
|
||||
// @Description Paginated background jobs with optional filters. Search `q` may match id, type, error, payload (implementation-dependent).
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query string false "Filter by status" Enums(queued,running,succeeded,failed,canceled,retrying,scheduled)
|
||||
// @Param queue query string false "Filter by queue name / worker name"
|
||||
// @Param q query string false "Free-text search"
|
||||
// @Param page query int false "Page number" default(1)
|
||||
// @Param page_size query int false "Items per page" minimum(1) maximum(100) default(25)
|
||||
// @Success 200 {object} dto.PageJob
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal error"
|
||||
// @Router /admin/archer/jobs [get]
|
||||
// @Security BearerAuth
|
||||
func AdminListArcherJobs(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
status := strings.TrimSpace(r.URL.Query().Get("status"))
|
||||
@@ -90,20 +91,21 @@ func AdminListArcherJobs(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// AdminEnqueueArcherJob godoc
|
||||
// @ID AdminEnqueueArcherJob
|
||||
// @Summary Enqueue a new Archer job (admin)
|
||||
// @Description Create a job immediately or schedule it for the future via `run_at`.
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.EnqueueRequest true "Job parameters"
|
||||
// @Success 200 {object} dto.Job
|
||||
// @Failure 400 {string} string "invalid json or missing fields"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal error"
|
||||
// @Router /admin/archer/jobs [post]
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID AdminEnqueueArcherJob
|
||||
// @Summary Enqueue a new Archer job (admin)
|
||||
// @Description Create a job immediately or schedule it for the future via `run_at`.
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.EnqueueRequest true "Job parameters"
|
||||
// @Success 200 {object} dto.Job
|
||||
// @Failure 400 {string} string "invalid json or missing fields"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal error"
|
||||
// @Router /admin/archer/jobs [post]
|
||||
// @Security BearerAuth
|
||||
func AdminEnqueueArcherJob(db *gorm.DB, jobs *bg.Jobs) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var in dto.EnqueueRequest
|
||||
@@ -168,20 +170,21 @@ func AdminEnqueueArcherJob(db *gorm.DB, jobs *bg.Jobs) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// AdminRetryArcherJob godoc
|
||||
// @ID AdminRetryArcherJob
|
||||
// @Summary Retry a failed/canceled Archer job (admin)
|
||||
// @Description Marks the job retriable (DB flip). Swap this for an Archer admin call if you expose one.
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Job ID"
|
||||
// @Success 200 {object} dto.Job
|
||||
// @Failure 400 {string} string "invalid job or not eligible"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Router /admin/archer/jobs/{id}/retry [post]
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID AdminRetryArcherJob
|
||||
// @Summary Retry a failed/canceled Archer job (admin)
|
||||
// @Description Marks the job retriable (DB flip). Swap this for an Archer admin call if you expose one.
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Job ID"
|
||||
// @Success 200 {object} dto.Job
|
||||
// @Failure 400 {string} string "invalid job or not eligible"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Router /admin/archer/jobs/{id}/retry [post]
|
||||
// @Security BearerAuth
|
||||
func AdminRetryArcherJob(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
id := chi.URLParam(r, "id")
|
||||
@@ -222,20 +225,21 @@ func AdminRetryArcherJob(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// AdminCancelArcherJob godoc
|
||||
// @ID AdminCancelArcherJob
|
||||
// @Summary Cancel an Archer job (admin)
|
||||
// @Description Set job status to canceled if cancellable. For running jobs, this only affects future picks; wire to Archer if you need active kill.
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Job ID"
|
||||
// @Success 200 {object} dto.Job
|
||||
// @Failure 400 {string} string "invalid job or not cancellable"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Router /admin/archer/jobs/{id}/cancel [post]
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID AdminCancelArcherJob
|
||||
// @Summary Cancel an Archer job (admin)
|
||||
// @Description Set job status to canceled if cancellable. For running jobs, this only affects future picks; wire to Archer if you need active kill.
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Job ID"
|
||||
// @Success 200 {object} dto.Job
|
||||
// @Failure 400 {string} string "invalid job or not cancellable"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Router /admin/archer/jobs/{id}/cancel [post]
|
||||
// @Security BearerAuth
|
||||
func AdminCancelArcherJob(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
id := chi.URLParam(r, "id")
|
||||
@@ -274,18 +278,19 @@ func AdminCancelArcherJob(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// AdminListArcherQueues godoc
|
||||
// @ID AdminListArcherQueues
|
||||
// @Summary List Archer queues (admin)
|
||||
// @Description Summary metrics per queue (pending, running, failed, scheduled).
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.QueueInfo
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal error"
|
||||
// @Router /admin/archer/queues [get]
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID AdminListArcherQueues
|
||||
// @Summary List Archer queues (admin)
|
||||
// @Description Summary metrics per queue (pending, running, failed, scheduled).
|
||||
// @Tags ArcherAdmin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.QueueInfo
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal error"
|
||||
// @Router /admin/archer/queues [get]
|
||||
// @Security BearerAuth
|
||||
func AdminListArcherQueues(db *gorm.DB) http.HandlerFunc {
|
||||
type row struct {
|
||||
QueueName string
|
||||
|
||||
@@ -23,13 +23,14 @@ type jwks struct {
|
||||
}
|
||||
|
||||
// JWKSHandler godoc
|
||||
// @ID getJWKS
|
||||
// @Summary Get JWKS
|
||||
// @Description Returns the JSON Web Key Set for token verification
|
||||
// @Tags Auth
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.JWKS
|
||||
// @Router /.well-known/jwks.json [get]
|
||||
//
|
||||
// @ID getJWKS
|
||||
// @Summary Get JWKS
|
||||
// @Description Returns the JSON Web Key Set for token verification
|
||||
// @Tags Auth
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.JWKS
|
||||
// @Router /.well-known/jwks.json [get]
|
||||
func JWKSHandler(w http.ResponseWriter, _ *http.Request) {
|
||||
out := dto.JWKS{Keys: make([]dto.JWK, 0)}
|
||||
|
||||
|
||||
@@ -17,24 +17,25 @@ import (
|
||||
)
|
||||
|
||||
// ListLabels godoc
|
||||
// @ID ListLabels
|
||||
// @Summary List node labels (org scoped)
|
||||
// @Description Returns node labels for the organization in X-Org-ID. Filters: `key`, `value`, and `q` (key contains). Add `include=node_pools` to include linked node groups.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param key query string false "Exact key"
|
||||
// @Param value query string false "Exact value"
|
||||
// @Param q query string false "Key contains (case-insensitive)"
|
||||
// @Success 200 {array} dto.LabelResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list node taints"
|
||||
// @Router /labels [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID ListLabels
|
||||
// @Summary List node labels (org scoped)
|
||||
// @Description Returns node labels for the organization in X-Org-ID. Filters: `key`, `value`, and `q` (key contains). Add `include=node_pools` to include linked node groups.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param key query string false "Exact key"
|
||||
// @Param value query string false "Exact value"
|
||||
// @Param q query string false "Key contains (case-insensitive)"
|
||||
// @Success 200 {array} dto.LabelResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list node taints"
|
||||
// @Router /labels [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func ListLabels(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -68,24 +69,25 @@ func ListLabels(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GetLabel godoc
|
||||
// @ID GetLabel
|
||||
// @Summary Get label by ID (org scoped)
|
||||
// @Description Returns one label.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Label ID (UUID)"
|
||||
// @Success 200 {object} dto.LabelResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /labels/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID GetLabel
|
||||
// @Summary Get label by ID (org scoped)
|
||||
// @Description Returns one label.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Label ID (UUID)"
|
||||
// @Success 200 {object} dto.LabelResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /labels/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func GetLabel(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -113,23 +115,24 @@ func GetLabel(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// CreateLabel godoc
|
||||
// @ID CreateLabel
|
||||
// @Summary Create label (org scoped)
|
||||
// @Description Creates a label.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateLabelRequest true "Label payload"
|
||||
// @Success 201 {object} dto.LabelResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields / invalid node_pool_ids"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /labels [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID CreateLabel
|
||||
// @Summary Create label (org scoped)
|
||||
// @Description Creates a label.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateLabelRequest true "Label payload"
|
||||
// @Success 201 {object} dto.LabelResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields / invalid node_pool_ids"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /labels [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func CreateLabel(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -173,25 +176,26 @@ func CreateLabel(db *gorm.DB) http.HandlerFunc {
|
||||
|
||||
// UpdateLabel godoc
|
||||
// UpdateLabel godoc
|
||||
// @ID UpdateLabel
|
||||
// @Summary Update label (org scoped)
|
||||
// @Description Partially update label fields.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Label ID (UUID)"
|
||||
// @Param body body dto.UpdateLabelRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.LabelResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /labels/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID UpdateLabel
|
||||
// @Summary Update label (org scoped)
|
||||
// @Description Partially update label fields.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Label ID (UUID)"
|
||||
// @Param body body dto.UpdateLabelRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.LabelResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /labels/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func UpdateLabel(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -244,23 +248,24 @@ func UpdateLabel(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteLabel godoc
|
||||
// @ID DeleteLabel
|
||||
// @Summary Delete label (org scoped)
|
||||
// @Description Permanently deletes the label.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Label ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /labels/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID DeleteLabel
|
||||
// @Summary Delete label (org scoped)
|
||||
// @Description Permanently deletes the label.
|
||||
// @Tags Labels
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Label ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /labels/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func DeleteLabel(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
|
||||
@@ -17,14 +17,15 @@ type meResponse struct {
|
||||
}
|
||||
|
||||
// GetMe godoc
|
||||
// @ID GetMe
|
||||
// @Summary Get current user profile
|
||||
// @Tags Me
|
||||
// @Produce json
|
||||
// @Success 200 {object} meResponse
|
||||
// @Router /me [get]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
//
|
||||
// @ID GetMe
|
||||
// @Summary Get current user profile
|
||||
// @Tags Me
|
||||
// @Produce json
|
||||
// @Success 200 {object} meResponse
|
||||
// @Router /me [get]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
func GetMe(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := httpmiddleware.UserFrom(r.Context())
|
||||
@@ -69,16 +70,17 @@ type updateMeRequest struct {
|
||||
}
|
||||
|
||||
// UpdateMe godoc
|
||||
// @ID UpdateMe
|
||||
// @Summary Update current user profile
|
||||
// @Tags Me
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body updateMeRequest true "Patch profile"
|
||||
// @Success 200 {object} models.User
|
||||
// @Router /me [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
//
|
||||
// @ID UpdateMe
|
||||
// @Summary Update current user profile
|
||||
// @Tags Me
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body updateMeRequest true "Patch profile"
|
||||
// @Success 200 {object} models.User
|
||||
// @Router /me [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
func UpdateMe(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := httpmiddleware.UserFrom(r.Context())
|
||||
|
||||
@@ -27,14 +27,15 @@ type userAPIKeyOut struct {
|
||||
}
|
||||
|
||||
// ListUserAPIKeys godoc
|
||||
// @ID ListUserAPIKeys
|
||||
// @Summary List my API keys
|
||||
// @Tags MeAPIKeys
|
||||
// @Produce json
|
||||
// @Success 200 {array} userAPIKeyOut
|
||||
// @Router /me/api-keys [get]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
//
|
||||
// @ID ListUserAPIKeys
|
||||
// @Summary List my API keys
|
||||
// @Tags MeAPIKeys
|
||||
// @Produce json
|
||||
// @Success 200 {array} userAPIKeyOut
|
||||
// @Router /me/api-keys [get]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
func ListUserAPIKeys(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := httpmiddleware.UserFrom(r.Context())
|
||||
@@ -64,17 +65,18 @@ type createUserKeyRequest struct {
|
||||
}
|
||||
|
||||
// CreateUserAPIKey godoc
|
||||
// @ID CreateUserAPIKey
|
||||
// @Summary Create a new user API key
|
||||
// @Description Returns the plaintext key once. Store it securely on the client side.
|
||||
// @Tags MeAPIKeys
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createUserKeyRequest true "Key options"
|
||||
// @Success 201 {object} userAPIKeyOut
|
||||
// @Router /me/api-keys [post]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
//
|
||||
// @ID CreateUserAPIKey
|
||||
// @Summary Create a new user API key
|
||||
// @Description Returns the plaintext key once. Store it securely on the client side.
|
||||
// @Tags MeAPIKeys
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body createUserKeyRequest true "Key options"
|
||||
// @Success 201 {object} userAPIKeyOut
|
||||
// @Router /me/api-keys [post]
|
||||
// @Security BearerAuth
|
||||
// @Security ApiKeyAuth
|
||||
func CreateUserAPIKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := httpmiddleware.UserFrom(r.Context())
|
||||
@@ -118,14 +120,15 @@ func CreateUserAPIKey(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteUserAPIKey godoc
|
||||
// @ID DeleteUserAPIKey
|
||||
// @Summary Delete a user API key
|
||||
// @Tags MeAPIKeys
|
||||
// @Produce json
|
||||
// @Param id path string true "Key ID (UUID)"
|
||||
// @Success 204 "No Content"
|
||||
// @Router /me/api-keys/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID DeleteUserAPIKey
|
||||
// @Summary Delete a user API key
|
||||
// @Tags MeAPIKeys
|
||||
// @Produce json
|
||||
// @Param id path string true "Key ID (UUID)"
|
||||
// @Success 204 "No Content"
|
||||
// @Router /me/api-keys/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
func DeleteUserAPIKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := httpmiddleware.UserFrom(r.Context())
|
||||
|
||||
@@ -59,19 +59,20 @@ type orgCreateReq struct {
|
||||
}
|
||||
|
||||
// CreateOrg godoc
|
||||
// @ID CreateOrg
|
||||
// @Summary Create organization
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body orgCreateReq true "Org payload"
|
||||
// @Success 201 {object} models.Organization
|
||||
// @Failure 400 {object} utils.ErrorResponse
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 409 {object} utils.ErrorResponse
|
||||
// @Router /orgs [post]
|
||||
// @ID createOrg
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID CreateOrg
|
||||
// @Summary Create organization
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body orgCreateReq true "Org payload"
|
||||
// @Success 201 {object} models.Organization
|
||||
// @Failure 400 {object} utils.ErrorResponse
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 409 {object} utils.ErrorResponse
|
||||
// @Router /orgs [post]
|
||||
// @ID createOrg
|
||||
// @Security BearerAuth
|
||||
func CreateOrg(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -111,15 +112,16 @@ func CreateOrg(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// ListMyOrgs godoc
|
||||
// @ID ListMyOrgs
|
||||
// @Summary List organizations I belong to
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Success 200 {array} models.Organization
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs [get]
|
||||
// @ID listMyOrgs
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID ListMyOrgs
|
||||
// @Summary List organizations I belong to
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Success 200 {array} models.Organization
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs [get]
|
||||
// @ID listMyOrgs
|
||||
// @Security BearerAuth
|
||||
func ListMyOrgs(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -142,17 +144,18 @@ func ListMyOrgs(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GetOrg godoc
|
||||
// @ID GetOrg
|
||||
// @Summary Get organization
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 200 {object} models.Organization
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 404 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id} [get]
|
||||
// @ID getOrg
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID GetOrg
|
||||
// @Summary Get organization
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 200 {object} models.Organization
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 404 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id} [get]
|
||||
// @ID getOrg
|
||||
// @Security BearerAuth
|
||||
func GetOrg(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -184,19 +187,20 @@ type orgUpdateReq struct {
|
||||
}
|
||||
|
||||
// UpdateOrg godoc
|
||||
// @ID UpdateOrg
|
||||
// @Summary Update organization (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param body body orgUpdateReq true "Update payload"
|
||||
// @Success 200 {object} models.Organization
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 404 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id} [patch]
|
||||
// @ID updateOrg
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID UpdateOrg
|
||||
// @Summary Update organization (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param body body orgUpdateReq true "Update payload"
|
||||
// @Success 200 {object} models.Organization
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 404 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id} [patch]
|
||||
// @ID updateOrg
|
||||
// @Security BearerAuth
|
||||
func UpdateOrg(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -242,17 +246,18 @@ func UpdateOrg(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteOrg godoc
|
||||
// @ID DeleteOrg
|
||||
// @Summary Delete organization (owner)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 204 "Deleted"
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 404 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id} [delete]
|
||||
// @ID deleteOrg
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID DeleteOrg
|
||||
// @Summary Delete organization (owner)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 204 "Deleted"
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Failure 404 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id} [delete]
|
||||
// @ID deleteOrg
|
||||
// @Security BearerAuth
|
||||
func DeleteOrg(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -297,16 +302,17 @@ type memberUpsertReq struct {
|
||||
}
|
||||
|
||||
// ListMembers godoc
|
||||
// @ID ListMembers
|
||||
// @Summary List members in org
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 200 {array} memberOut
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/members [get]
|
||||
// @ID listMembers
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID ListMembers
|
||||
// @Summary List members in org
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 200 {array} memberOut
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/members [get]
|
||||
// @ID listMembers
|
||||
// @Security BearerAuth
|
||||
func ListMembers(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -352,18 +358,19 @@ func ListMembers(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// AddOrUpdateMember godoc
|
||||
// @ID AddOrUpdateMember
|
||||
// @Summary Add or update a member (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param body body memberUpsertReq true "User & role"
|
||||
// @Success 200 {object} memberOut
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/members [post]
|
||||
// @ID addOrUpdateMember
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID AddOrUpdateMember
|
||||
// @Summary Add or update a member (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param body body memberUpsertReq true "User & role"
|
||||
// @Success 200 {object} memberOut
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/members [post]
|
||||
// @ID addOrUpdateMember
|
||||
// @Security BearerAuth
|
||||
func AddOrUpdateMember(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -419,17 +426,18 @@ func AddOrUpdateMember(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// RemoveMember godoc
|
||||
// @ID RemoveMember
|
||||
// @Summary Remove a member (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param user_id path string true "User ID (UUID)"
|
||||
// @Success 204 "Removed"
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/members/{user_id} [delete]
|
||||
// @ID removeMember
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID RemoveMember
|
||||
// @Summary Remove a member (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param user_id path string true "User ID (UUID)"
|
||||
// @Success 204 "Removed"
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/members/{user_id} [delete]
|
||||
// @ID removeMember
|
||||
// @Security BearerAuth
|
||||
func RemoveMember(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -478,16 +486,17 @@ type orgKeyCreateResp struct {
|
||||
}
|
||||
|
||||
// ListOrgKeys godoc
|
||||
// @ID ListOrgKeys
|
||||
// @Summary List org-scoped API keys (no secrets)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 200 {array} models.APIKey
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/api-keys [get]
|
||||
// @ID listOrgKeys
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID ListOrgKeys
|
||||
// @Summary List org-scoped API keys (no secrets)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Success 200 {array} models.APIKey
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/api-keys [get]
|
||||
// @ID listOrgKeys
|
||||
// @Security BearerAuth
|
||||
func ListOrgKeys(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -513,18 +522,19 @@ func ListOrgKeys(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// CreateOrgKey godoc
|
||||
// @ID CreateOrgKey
|
||||
// @Summary Create org key/secret pair (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param body body orgKeyCreateReq true "Key name + optional expiry"
|
||||
// @Success 201 {object} orgKeyCreateResp
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/api-keys [post]
|
||||
// @ID createOrgKey
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID CreateOrgKey
|
||||
// @Summary Create org key/secret pair (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param body body orgKeyCreateReq true "Key name + optional expiry"
|
||||
// @Success 201 {object} orgKeyCreateResp
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/api-keys [post]
|
||||
// @ID createOrgKey
|
||||
// @Security BearerAuth
|
||||
func CreateOrgKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
@@ -601,17 +611,18 @@ func CreateOrgKey(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteOrgKey godoc
|
||||
// @ID DeleteOrgKey
|
||||
// @Summary Delete org key (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param key_id path string true "Key ID (UUID)"
|
||||
// @Success 204 "Deleted"
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/api-keys/{key_id} [delete]
|
||||
// @ID deleteOrgKey
|
||||
// @Security BearerAuth
|
||||
//
|
||||
// @ID DeleteOrgKey
|
||||
// @Summary Delete org key (owner/admin)
|
||||
// @Tags Orgs
|
||||
// @Produce json
|
||||
// @Param id path string true "Org ID (UUID)"
|
||||
// @Param key_id path string true "Key ID (UUID)"
|
||||
// @Success 204 "Deleted"
|
||||
// @Failure 401 {object} utils.ErrorResponse
|
||||
// @Router /orgs/{id}/api-keys/{key_id} [delete]
|
||||
// @ID deleteOrgKey
|
||||
// @Security BearerAuth
|
||||
func DeleteOrgKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
u, ok := mustUser(r)
|
||||
|
||||
@@ -17,23 +17,24 @@ import (
|
||||
)
|
||||
|
||||
// ListServers godoc
|
||||
// @ID ListServers
|
||||
// @Summary List servers (org scoped)
|
||||
// @Description Returns servers for the organization in X-Org-ID. Optional filters: status, role.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param status query string false "Filter by status (pending|provisioning|ready|failed)"
|
||||
// @Param role query string false "Filter by role"
|
||||
// @Success 200 {array} dto.ServerResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list servers"
|
||||
// @Router /servers [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID ListServers
|
||||
// @Summary List servers (org scoped)
|
||||
// @Description Returns servers for the organization in X-Org-ID. Optional filters: status, role.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param status query string false "Filter by status (pending|provisioning|ready|failed)"
|
||||
// @Param role query string false "Filter by role"
|
||||
// @Success 200 {array} dto.ServerResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list servers"
|
||||
// @Router /servers [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func ListServers(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -83,24 +84,25 @@ func ListServers(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GetServer godoc
|
||||
// @ID GetServer
|
||||
// @Summary Get server by ID (org scoped)
|
||||
// @Description Returns one server in the given organization.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Server ID (UUID)"
|
||||
// @Success 200 {object} dto.ServerResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /servers/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID GetServer
|
||||
// @Summary Get server by ID (org scoped)
|
||||
// @Description Returns one server in the given organization.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Server ID (UUID)"
|
||||
// @Success 200 {object} dto.ServerResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /servers/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func GetServer(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -130,23 +132,24 @@ func GetServer(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// CreateServer godoc
|
||||
// @ID CreateServer
|
||||
// @Summary Create server (org scoped)
|
||||
// @Description Creates a server bound to the org in X-Org-ID. Validates that ssh_key_id belongs to the org.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateServerRequest true "Server payload"
|
||||
// @Success 201 {object} dto.ServerResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields / invalid status / invalid ssh_key_id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /servers [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID CreateServer
|
||||
// @Summary Create server (org scoped)
|
||||
// @Description Creates a server bound to the org in X-Org-ID. Validates that ssh_key_id belongs to the org.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateServerRequest true "Server payload"
|
||||
// @Success 201 {object} dto.ServerResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields / invalid status / invalid ssh_key_id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /servers [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func CreateServer(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -218,25 +221,26 @@ func CreateServer(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// UpdateServer godoc
|
||||
// @ID UpdateServer
|
||||
// @Summary Update server (org scoped)
|
||||
// @Description Partially update fields; changing ssh_key_id validates ownership.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Server ID (UUID)"
|
||||
// @Param body body dto.UpdateServerRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.ServerResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json / invalid status / invalid ssh_key_id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /servers/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID UpdateServer
|
||||
// @Summary Update server (org scoped)
|
||||
// @Description Partially update fields; changing ssh_key_id validates ownership.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Server ID (UUID)"
|
||||
// @Param body body dto.UpdateServerRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.ServerResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json / invalid status / invalid ssh_key_id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /servers/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func UpdateServer(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -320,23 +324,24 @@ func UpdateServer(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteServer godoc
|
||||
// @ID DeleteServer
|
||||
// @Summary Delete server (org scoped)
|
||||
// @Description Permanently deletes the server.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Server ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /servers/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID DeleteServer
|
||||
// @Summary Delete server (org scoped)
|
||||
// @Description Permanently deletes the server.
|
||||
// @Tags Servers
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Server ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /servers/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func DeleteServer(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
|
||||
@@ -26,21 +26,22 @@ import (
|
||||
)
|
||||
|
||||
// ListPublicSshKeys godoc
|
||||
// @ID ListPublicSshKeys
|
||||
// @Summary List ssh keys (org scoped)
|
||||
// @Description Returns ssh keys for the organization in X-Org-ID.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Success 200 {array} dto.SshResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list keys"
|
||||
// @Router /ssh [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID ListPublicSshKeys
|
||||
// @Summary List ssh keys (org scoped)
|
||||
// @Description Returns ssh keys for the organization in X-Org-ID.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Success 200 {array} dto.SshResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list keys"
|
||||
// @Router /ssh [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func ListPublicSshKeys(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -66,23 +67,24 @@ func ListPublicSshKeys(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// CreateSSHKey
|
||||
// @ID CreateSSHKey
|
||||
// @Summary Create ssh keypair (org scoped)
|
||||
// @Description Generates an RSA or ED25519 keypair, saves it, and returns metadata. For RSA you may set bits (2048/3072/4096). Default is 4096. ED25519 ignores bits.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateSSHRequest true "Key generation options"
|
||||
// @Success 201 {object} dto.SshResponse
|
||||
// @Failure 400 {string} string "invalid json / invalid bits"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "generation/create failed"
|
||||
// @Router /ssh [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID CreateSSHKey
|
||||
// @Summary Create ssh keypair (org scoped)
|
||||
// @Description Generates an RSA or ED25519 keypair, saves it, and returns metadata. For RSA you may set bits (2048/3072/4096). Default is 4096. ED25519 ignores bits.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateSSHRequest true "Key generation options"
|
||||
// @Success 201 {object} dto.SshResponse
|
||||
// @Failure 400 {string} string "invalid json / invalid bits"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "generation/create failed"
|
||||
// @Router /ssh [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func CreateSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -179,26 +181,27 @@ func CreateSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GetSSHKey godoc
|
||||
// @ID GetSSHKey
|
||||
// @Summary Get ssh key by ID (org scoped)
|
||||
// @Description Returns public key fields. Append `?reveal=true` to include the private key PEM.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "SSH Key ID (UUID)"
|
||||
// @Param reveal query bool false "Reveal private key PEM"
|
||||
// @Success 200 {object} dto.SshResponse
|
||||
// @Success 200 {object} dto.SshRevealResponse "When reveal=true"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /ssh/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID GetSSHKey
|
||||
// @Summary Get ssh key by ID (org scoped)
|
||||
// @Description Returns public key fields. Append `?reveal=true` to include the private key PEM.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "SSH Key ID (UUID)"
|
||||
// @Param reveal query bool false "Reveal private key PEM"
|
||||
// @Success 200 {object} dto.SshResponse
|
||||
// @Success 200 {object} dto.SshRevealResponse "When reveal=true"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /ssh/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func GetSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -272,23 +275,24 @@ func GetSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteSSHKey godoc
|
||||
// @ID DeleteSSHKey
|
||||
// @Summary Delete ssh keypair (org scoped)
|
||||
// @Description Permanently deletes a keypair.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "SSH Key ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /ssh/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID DeleteSSHKey
|
||||
// @Summary Delete ssh keypair (org scoped)
|
||||
// @Description Permanently deletes a keypair.
|
||||
// @Tags Ssh
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "SSH Key ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /ssh/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func DeleteSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -318,24 +322,25 @@ func DeleteSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DownloadSSHKey godoc
|
||||
// @ID DownloadSSHKey
|
||||
// @Summary Download ssh key files by ID (org scoped)
|
||||
// @Description Download `part=public|private|both` of the keypair. `both` returns a zip file.
|
||||
// @Tags Ssh
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string true "Organization UUID"
|
||||
// @Param id path string true "SSH Key ID (UUID)"
|
||||
// @Param part query string true "Which part to download" Enums(public,private,both)
|
||||
// @Success 200 {string} string "file content"
|
||||
// @Failure 400 {string} string "invalid id / invalid part"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "download failed"
|
||||
// @Router /ssh/{id}/download [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID DownloadSSHKey
|
||||
// @Summary Download ssh key files by ID (org scoped)
|
||||
// @Description Download `part=public|private|both` of the keypair. `both` returns a zip file.
|
||||
// @Tags Ssh
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string true "Organization UUID"
|
||||
// @Param id path string true "SSH Key ID (UUID)"
|
||||
// @Param part query string true "Which part to download" Enums(public,private,both)
|
||||
// @Success 200 {string} string "file content"
|
||||
// @Failure 400 {string} string "invalid id / invalid part"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "download failed"
|
||||
// @Router /ssh/{id}/download [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func DownloadSSHKey(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
|
||||
@@ -17,24 +17,25 @@ import (
|
||||
)
|
||||
|
||||
// ListTaints godoc
|
||||
// @ID ListTaints
|
||||
// @Summary List node pool taints (org scoped)
|
||||
// @Description Returns node taints for the organization in X-Org-ID. Filters: `key`, `value`, and `q` (key contains). Add `include=node_pools` to include linked node pools.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param key query string false "Exact key"
|
||||
// @Param value query string false "Exact value"
|
||||
// @Param q query string false "key contains (case-insensitive)"
|
||||
// @Success 200 {array} dto.TaintResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list node taints"
|
||||
// @Router /taints [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID ListTaints
|
||||
// @Summary List node pool taints (org scoped)
|
||||
// @Description Returns node taints for the organization in X-Org-ID. Filters: `key`, `value`, and `q` (key contains). Add `include=node_pools` to include linked node pools.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param key query string false "Exact key"
|
||||
// @Param value query string false "Exact value"
|
||||
// @Param q query string false "key contains (case-insensitive)"
|
||||
// @Success 200 {array} dto.TaintResponse
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "failed to list node taints"
|
||||
// @Router /taints [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func ListTaints(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -65,23 +66,24 @@ func ListTaints(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GetTaint godoc
|
||||
// @ID GetTaint
|
||||
// @Summary Get node taint by ID (org scoped)
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Node Taint ID (UUID)"
|
||||
// @Success 200 {object} dto.TaintResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /taints/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID GetTaint
|
||||
// @Summary Get node taint by ID (org scoped)
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Node Taint ID (UUID)"
|
||||
// @Success 200 {object} dto.TaintResponse
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "fetch failed"
|
||||
// @Router /taints/{id} [get]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func GetTaint(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -111,23 +113,24 @@ func GetTaint(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// CreateTaint godoc
|
||||
// @ID CreateTaint
|
||||
// @Summary Create node taint (org scoped)
|
||||
// @Description Creates a taint.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateTaintRequest true "Taint payload"
|
||||
// @Success 201 {object} dto.TaintResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields / invalid node_pool_ids"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /taints [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID CreateTaint
|
||||
// @Summary Create node taint (org scoped)
|
||||
// @Description Creates a taint.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param body body dto.CreateTaintRequest true "Taint payload"
|
||||
// @Success 201 {object} dto.TaintResponse
|
||||
// @Failure 400 {string} string "invalid json / missing fields / invalid node_pool_ids"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "create failed"
|
||||
// @Router /taints [post]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func CreateTaint(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -181,25 +184,26 @@ func CreateTaint(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// UpdateTaint godoc
|
||||
// @ID UpdateTaint
|
||||
// @Summary Update node taint (org scoped)
|
||||
// @Description Partially update taint fields.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Node Taint ID (UUID)"
|
||||
// @Param body body dto.UpdateTaintRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.TaintResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /taints/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID UpdateTaint
|
||||
// @Summary Update node taint (org scoped)
|
||||
// @Description Partially update taint fields.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Node Taint ID (UUID)"
|
||||
// @Param body body dto.UpdateTaintRequest true "Fields to update"
|
||||
// @Success 200 {object} dto.TaintResponse
|
||||
// @Failure 400 {string} string "invalid id / invalid json"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 500 {string} string "update failed"
|
||||
// @Router /taints/{id} [patch]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func UpdateTaint(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
@@ -270,23 +274,24 @@ func UpdateTaint(db *gorm.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// DeleteTaint godoc
|
||||
// @ID DeleteTaint
|
||||
// @Summary Delete taint (org scoped)
|
||||
// @Description Permanently deletes the taint.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Node Taint ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /taints/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
//
|
||||
// @ID DeleteTaint
|
||||
// @Summary Delete taint (org scoped)
|
||||
// @Description Permanently deletes the taint.
|
||||
// @Tags Taints
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param X-Org-ID header string false "Organization UUID"
|
||||
// @Param id path string true "Node Taint ID (UUID)"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {string} string "invalid id"
|
||||
// @Failure 401 {string} string "Unauthorized"
|
||||
// @Failure 403 {string} string "organization required"
|
||||
// @Failure 500 {string} string "delete failed"
|
||||
// @Router /taints/{id} [delete]
|
||||
// @Security BearerAuth
|
||||
// @Security OrgKeyAuth
|
||||
// @Security OrgSecretAuth
|
||||
func DeleteTaint(db *gorm.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||
|
||||
Reference in New Issue
Block a user