{
  "schemes": [],
  "swagger": "2.0",
  "info": {
    "description": "This is a server of API to inject fault into tidb cluster.",
    "title": "Chaos API",
    "contact": {},
    "version": "1.0"
  },
  "host": "",
  "basePath": "/",
  "paths": {
    "/chaos/api/actions/schema": {
      "get": {
        "description": "List experiment actions",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "List experiment actions",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/api.ActionSchema"
              }
            }
          }
        }
      }
    },
    "/chaos/api/approve/orgs/{oid}/clusters/{cid}/experiments/{eid}": {
      "post": {
        "description": "Approve a draft chaos experiment",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Approve a draft chaos experiment",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "experiment id",
            "name": "eid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/chaos/api/components/orgs/{oid}/clusters/{cid}": {
      "get": {
        "description": "List components",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "List components",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/api.Component"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/chaos/api/draft/orgs/{oid}/clusters/{cid}": {
      "post": {
        "description": "Create draft chaos experiment",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Create draft chaos experiment",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "description": "create draft experiment",
            "name": "experiment",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/api.CreateExperimentRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/api.Experiment"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/chaos/api/orgs/{oid}/clusters/{cid}": {
      "get": {
        "description": "List chaos experiments",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "List chaos experiments",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "minimum": 1,
            "type": "integer",
            "default": 1,
            "description": "the page index",
            "name": "page",
            "in": "query"
          },
          {
            "minimum": 1,
            "type": "integer",
            "default": 10,
            "description": "the page size",
            "name": "size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/api.ExperimentResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/chaos/api/orgs/{oid}/clusters/{cid}/experiments/{eid}": {
      "get": {
        "description": "Get chaos experiment",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Get chaos experiment",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "experiment id",
            "name": "eid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/api.Experiment"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      },
      "delete": {
        "description": "Delete chaos experiment",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Delete chaos experiment",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "experiment id",
            "name": "eid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/chaos/api/start/orgs/{oid}/clusters/{cid}/experiments/{eid}": {
      "post": {
        "description": "Start chaos experiment",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Start chaos experiment",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "experiment id",
            "name": "eid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/api.Experiment"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/chaos/api/summary/orgs/{oid}/clusters/{cid}/experiments/{eid}": {
      "post": {
        "description": "Update experiment info",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Update experiment info",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "experiment id",
            "name": "eid",
            "in": "path",
            "required": true
          },
          {
            "description": "experiment info",
            "name": "Info",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/api.ExperimentInfo"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/fault/api/orgs/{oid}/clusters/{cid}": {
      "get": {
        "description": "Get fault drill backend status",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Get fault drill backend status",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/api.BackendStatus"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      },
      "post": {
        "description": "Enable fault drill",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Enable fault drill",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      },
      "delete": {
        "description": "Disable fault drill",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Disable fault drill",
        "parameters": [
          {
            "type": "string",
            "description": "organization id",
            "name": "oid",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "cluster id",
            "name": "cid",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "schema": {}
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {}
          }
        }
      }
    },
    "/fault/api/ping": {
      "get": {
        "description": "Ping chaos backend",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Chaos"
        ],
        "summary": "Ping chaos backend",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "definitions": {
    "api.Action": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "pod_shutdown"
          ]
        },
        "pod_shutdown": {
          "$ref": "#/definitions/api.PodShutdown"
        }
      }
    },
    "api.ActionSchema": {
      "type": "object",
      "properties": {
        "component": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "kind": {
          "type": "string"
        }
      }
    },
    "api.BackendStatus": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "ready",
            "disabled",
            "installing",
            "uninstalling",
            "install_failed"
          ]
        },
        "updated_at": {
          "type": "integer"
        },
        "updated_by": {
          "$ref": "#/definitions/session.CtxUser"
        }
      }
    },
    "api.Component": {
      "type": "object",
      "properties": {
        "pd": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.PodInfo"
          }
        },
        "tidb": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.PodInfo"
          }
        },
        "tiflash": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.PodInfo"
          }
        },
        "tikv": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.PodInfo"
          }
        }
      }
    },
    "api.CreateExperimentRequest": {
      "type": "object",
      "properties": {
        "action": {
          "$ref": "#/definitions/api.Action"
        },
        "summary": {
          "type": "string"
        }
      }
    },
    "api.Experiment": {
      "type": "object",
      "properties": {
        "action": {
          "$ref": "#/definitions/api.Action"
        },
        "approved_by": {
          "$ref": "#/definitions/session.CtxUser"
        },
        "cluster_id": {
          "type": "integer"
        },
        "completed_at": {
          "type": "integer"
        },
        "created_at": {
          "type": "integer"
        },
        "created_by": {
          "$ref": "#/definitions/session.CtxUser"
        },
        "deleted_at": {
          "type": "integer"
        },
        "draft": {
          "type": "boolean"
        },
        "experiment_id": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "report_link": {
          "type": "string"
        },
        "started_at": {
          "type": "integer"
        },
        "status": {
          "type": "string",
          "enum": [
            "Waiting Approve",
            "Draft",
            "Running",
            "Done",
            "Failed",
            "Deleted"
          ]
        },
        "summary": {
          "type": "string"
        }
      }
    },
    "api.ExperimentInfo": {
      "type": "object",
      "properties": {
        "report_link": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        }
      }
    },
    "api.ExperimentResponse": {
      "type": "object",
      "properties": {
        "experiments": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.Experiment"
          }
        },
        "total": {
          "description": "Total number of experiments",
          "type": "integer"
        }
      }
    },
    "api.PodInfo": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      }
    },
    "api.PodShutdown": {
      "type": "object",
      "properties": {
        "target": {
          "$ref": "#/definitions/api.Target"
        }
      }
    },
    "api.Target": {
      "type": "object",
      "properties": {
        "component": {
          "type": "string",
          "enum": [
            "tidb",
            "tikv",
            "pd"
          ]
        },
        "mode": {
          "type": "string",
          "enum": [
            "random",
            "specified"
          ]
        },
        "name": {
          "type": "string"
        }
      }
    },
    "session.CtxUser": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string"
        },
        "internal": {
          "type": "boolean"
        },
        "org_id": {
          "type": "integer"
        },
        "user_id": {
          "type": "integer"
        },
        "username": {
          "type": "string"
        }
      }
    }
  }
}