Files
ServerKit/backend/app/api/container_status.py
T
Juan DenisandClaude Opus 4.8 f47d0e1428 feat: Phase 1 foundation — status aggregator, API scopes, onboarding, template magic vars
Four foundational enhancements toward the deploy-code developer experience:

- Container status aggregator (C7): new ContainerStatusService applies a
  deterministic priority hierarchy (degraded > restarting > running:unhealthy >
  starting > running:healthy > exited > unknown) over an app's containers,
  cached with a short TTL. Exposed at /api/v1/status and pushed over a new
  container_status Socket.IO channel; Applications page now renders an
  aggregated ContainerStatusPill with sub-status tooltip.

- API token scopes + sensitive data masking (C10): require_scope() decorator
  enforces fine-grained scopes for API-key requests (pass-through for JWT),
  a canonical SCOPES catalog at /api/v1/api-keys/scopes, and a reusable
  sensitive_data_filter (mask_sensitive) honoring secrets:read. Frontend gains
  a grouped ApiKeyScopesModal picker and per-key scope pills.

- Server onboarding state machine (C8): new onboarding lifecycle
  (pending -> validating -> installing_prerequisites -> installing_docker ->
  pairing_agent -> ready/failed) with ServerOnboardingService, a
  server_onboarding_logs table, servers.onboarding_* columns, REST endpoints,
  and an OnboardingWizard surfaced on the server detail overview.

- Declarative template catalog (C5): documented catalog schema and
  magic-variable resolution (SERVICE_PASSWORD_/USER_/FQDN_/URL_/BASE64_*)
  layered onto the existing YAML template loader without changing behavior for
  templates that don't use them; GET /api/v1/templates/catalog/schema.

Migration 029 adds the onboarding table + columns. 60 new tests pass; frontend
builds clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 18:23:47 -04:00

29 lines
834 B
Python

"""REST surface for the centralized container status aggregator.
Mounted at /api/v1/status (registered in app/__init__.py).
"""
from flask import Blueprint, jsonify
from flask_jwt_extended import jwt_required
from app.services import container_status_service as css
container_status_bp = Blueprint('container_status', __name__)
@container_status_bp.route('/app/<int:app_id>', methods=['GET'])
@jwt_required()
def app_status(app_id):
"""Aggregated container status for a single application."""
return jsonify(css.get_app_status(app_id))
@container_status_bp.route('/apps', methods=['GET'])
@jwt_required()
def apps_status():
"""Lightweight aggregated status for every application.
Returns {'statuses': [{app_id, status, total, healthy}, ...]}.
"""
return jsonify({'statuses': css.list_app_statuses()})