openapi: 3.0.0
info:
  title: Superset Tools API
  version: 1.0.0
  description: API for managing Superset automation tools and plugins.

paths:
  /plugins:
    get:
      summary: List available plugins
      operationId: list_plugins
      responses:
        '200':
          description: List of plugins
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Plugin'

  /tasks:
    post:
      summary: Start a new task
      operationId: create_task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - plugin_id
                - params
              properties:
                plugin_id:
                  type: string
                params:
                  type: object
      responses:
        '201':
          description: Task created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'

    get:
      summary: List recent tasks
      operationId: list_tasks
      responses:
        '200':
          description: List of tasks
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Task'

  /tasks/{task_id}:
    get:
      summary: Get task details
      operationId: get_task
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Task details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'

  /tasks/{task_id}/logs:
    get:
      summary: Stream task logs (WebSocket upgrade)
      operationId: stream_logs
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '101':
          description: Switching Protocols to WebSocket

components:
  schemas:
    Plugin:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        version:
          type: string
        schema:
          type: object
          description: JSON Schema for input parameters
        enabled:
          type: boolean

    Task:
      type: object
      properties:
        id:
          type: string
          format: uuid
        plugin_id:
          type: string
        status:
          type: string
          enum: [PENDING, RUNNING, SUCCESS, FAILED]
        started_at:
          type: string
          format: date-time
        finished_at:
          type: string
          format: date-time
        user_id:
          type: string
