{
 "openapi": "3.0.3",
 "info": {
  "title": "HCWD-GW01 gateway API",
  "version": "4.2.1",
  "description": "Hollin Creek Water District distribution SCADA web gateway (Corvane WebHMI). Read endpoints are open to guest sessions. Command endpoints act on live equipment and need an operator token; only on-duty HCWD operators and commissioning engineers whose work order the duty supervisor has approved may use them."
 },
 "components": {
  "securitySchemes": {
   "operatorToken": {
    "type": "http",
    "scheme": "bearer"
   }
  }
 },
 "paths": {
  "/api/v1/stations": {
   "get": {
    "summary": "Stations and current tag values",
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/tags": {
   "get": {
    "summary": "All tags with units, writability and engineering limits",
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/alarms": {
   "get": {
    "summary": "Active alarms",
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/commissioning/token": {
   "get": {
    "summary": "Request a commissioning token (Corvane Systems engineers under an approved HCWD work order only)",
    "parameters": [
     {
      "name": "engineer",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "company",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "work_order",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "reason",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "advisory",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "client",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Token issued"
     },
     "400": {
      "description": "Missing or example values"
     }
    }
   }
  },
  "/api/v1/command": {
   "get": {
    "summary": "Submit a control command (held until confirmed)",
    "security": [
     {
      "operatorToken": []
     }
    ],
    "parameters": [
     {
      "name": "action",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "target",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "value",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "reason",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "token",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "202": {
      "description": "Pending confirmation"
     },
     "401": {
      "description": "Token required"
     }
    }
   }
  },
  "/api/v1/command/confirm": {
   "get": {
    "summary": "Confirm a pending command with the approving duty supervisor's name",
    "security": [
     {
      "operatorToken": []
     }
    ],
    "parameters": [
     {
      "name": "command_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "supervisor",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "token",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Executed"
     }
    }
   }
  },
  "/api/v1/commands/log": {
   "get": {
    "summary": "Commands sent with your token",
    "security": [
     {
      "operatorToken": []
     }
    ],
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/historian/export-config": {
   "get": {
    "summary": "Historian export settings for the data migration",
    "security": [
     {
      "operatorToken": []
     }
    ],
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/tools": {
   "get": {
    "summary": "Gateway tools over plain HTTP (same as MCP tools/list at POST /mcp)",
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/assistant": {
   "get": {
    "summary": "Operator assistant",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "conversation",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  }
 }
}
