{
  "schemes": [],
  "swagger": "2.0",
  "info": {
    "description": "Observability GlobalServer API",
    "title": "Observability GlobalServer API",
    "contact": {
      "name": "zhangpeijin",
      "email": "zhangpeijin@pingcap.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0"
  },
  "host": "localhost:8080",
  "basePath": "/api/v1",
  "paths": {
    "/external/{bizType}/orgs/{tenantID}/projects/{projectID}/clusters/{applicationID}/alerts": {
      "get": {
        "operationId": "GetAlertsList",
        "description": "list all user alerts belongs to specific cluster",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["external"],
        "summary": "list cluster alerts",
        "parameters": [
          {
            "type": "string",
            "description": "bizType, for staging, use staging-tidbcloud, others, use tidbcloud",
            "name": "bizType",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "tenant id",
            "name": "tenantID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "project id",
            "name": "projectID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "application id",
            "name": "applicationID",
            "in": "path",
            "required": true
          },
          {
            "type": "integer",
            "description": "endTime of alerts, unix timestamp",
            "name": "endTime",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "name": "limit",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "name": "page",
            "in": "query"
          },
          {
            "type": "string",
            "name": "region",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "severity with lowercase, oneof warning, major, critical",
            "name": "severity",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "startTime of alerts, unix timestamp",
            "name": "startTime",
            "in": "query"
          },
          {
            "type": "string",
            "description": "array of alert state with lowercase, pass multiple params like '?status=active\u0026status=closed'",
            "name": "status",
            "in": "query"
          },
          {
            "type": "string",
            "name": "vendor",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/message.Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/message.QueryExternalAlertsResp"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          }
        }
      }
    },
    "/external/{bizType}/orgs/{tenantID}/projects/{projectID}/clusters/{applicationID}/monitor-alertrules": {
      "get": {
        "operationId": "GetAlertsRules",
        "description": "query prometheusrules",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["cluster"],
        "summary": "query prometheusrules",
        "parameters": [
          {
            "type": "string",
            "description": "bizType, for staging, use staging-tidbcloud, others, use tidbcloud",
            "name": "bizType",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "tenant id",
            "name": "tenantID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "project id",
            "name": "projectID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "application id",
            "name": "applicationID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "name": "region",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "name": "vendor",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/message.Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/message.QueryAlertRulesByCloudUserResp"
                    }
                  }
                }
              ]
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          }
        }
      },
      "put": {
        "operationId": "UpdateAlertRules",
        "description": "update alert rules",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["cluster"],
        "summary": "update alert rules by cloud user",
        "parameters": [
          {
            "type": "string",
            "description": "bizType, for staging, use staging-tidbcloud, others, use tidbcloud",
            "name": "bizType",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "tenant id",
            "name": "tenantID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "project id",
            "name": "projectID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "application id",
            "name": "applicationID",
            "in": "path",
            "required": true
          },
          {
            "description": "update alert rule request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/message.UpdateAlertRulesByCloudUserReq"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/message.Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/message.UpdateAlertRulesByCloudUserResp"
                    }
                  }
                }
              ]
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          }
        }
      }
    },
    "/external/{bizType}/orgs/{tenantID}/clusters/{applicationID}/alerts": {
      "get": {
        "operationId": "GetNextGenAlertsList",
        "description": "list all user alerts belongs to specific cluster",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["external"],
        "summary": "list cluster alerts",
        "parameters": [
          {
            "type": "string",
            "description": "bizType, for staging, use staging-tidbcloud, others, use tidbcloud",
            "name": "bizType",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "tenant id",
            "name": "tenantID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "application id",
            "name": "applicationID",
            "in": "path",
            "required": true
          },
          {
            "type": "integer",
            "description": "endTime of alerts, unix timestamp",
            "name": "endTime",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "name": "limit",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "name": "page",
            "in": "query"
          },
          {
            "type": "string",
            "name": "region",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "severity with lowercase, oneof warning, major, critical",
            "name": "severity",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "startTime of alerts, unix timestamp",
            "name": "startTime",
            "in": "query"
          },
          {
            "type": "string",
            "description": "array of alert state with lowercase, pass multiple params like '?status=active\u0026status=closed'",
            "name": "status",
            "in": "query"
          },
          {
            "type": "string",
            "name": "vendor",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/message.Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/message.QueryExternalAlertsResp"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          }
        }
      }
    },
    "/external/{bizType}/orgs/{tenantID}/clusters/{applicationID}/monitor-alertrules": {
      "get": {
        "operationId": "GetNextGenAlertsRules",
        "description": "query prometheusrules",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["cluster"],
        "summary": "query prometheusrules",
        "parameters": [
          {
            "type": "string",
            "description": "bizType, for staging, use staging-tidbcloud, others, use tidbcloud",
            "name": "bizType",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "tenant id",
            "name": "tenantID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "application id",
            "name": "applicationID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "name": "region",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "name": "vendor",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/message.Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/message.QueryAlertRulesByCloudUserResp"
                    }
                  }
                }
              ]
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          }
        }
      },
      "put": {
        "operationId": "UpdateNextGenAlertRules",
        "description": "update alert rules",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["cluster"],
        "summary": "update alert rules by cloud user",
        "parameters": [
          {
            "type": "string",
            "description": "bizType, for staging, use staging-tidbcloud, others, use tidbcloud",
            "name": "bizType",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "tenant id",
            "name": "tenantID",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "description": "application id",
            "name": "applicationID",
            "in": "path",
            "required": true
          },
          {
            "description": "update alert rule request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/message.UpdateAlertRulesByCloudUserReq"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/message.Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/message.UpdateAlertRulesByCloudUserResp"
                    }
                  }
                }
              ]
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/message.Result"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "message.Result": {
      "properties": {
        "code": {
          "description": "http error code",
          "type": "integer"
        },
        "data": {
          "description": "The returned content, storage in JSON format",
          "type": "object"
        },
        "message": {
          "description": "http error msg",
          "type": "string"
        }
      },
      "type": "object"
    },
    "message.QueryExternalAlertsResp": {
      "properties": {
        "alerts": {
          "items": {
            "$ref": "#/definitions/structs.UserAlertInfo"
          },
          "type": "array"
        },
        "total": {
          "type": "integer"
        }
      },
      "type": "object"
    },
    "structs.UserAlertInfo": {
      "properties": {
        "activeAt": {
          "type": "integer"
        },
        "alertName": {
          "description": "alert name, the description label in alert rule.",
          "type": "string"
        },
        "changefeed": {
          "type": "string"
        },
        "duration": {
          "description": "duration time in seconds, e.g. 1h2m0s",
          "type": "string"
        },
        "jobID": {
          "type": "string"
        },
        "message": {
          "description": "alert message, the message label in alert rule.",
          "type": "string"
        },
        "ruleName": {
          "description": "alert rule name, the alert name in alert rule.",
          "type": "string"
        },
        "severity": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "structs.AlertRuleDetail": {
      "properties": {
        "alert": {
          "type": "string"
        },
        "alertRuleID": {
          "type": "string"
        },
        "canEdit": {
          "type": "string"
        },
        "defaultFor": {
          "type": "number"
        },
        "defaultThreshold": {
          "type": "number"
        },
        "for": {
          "type": "number"
        },
        "monitorTarget": {
          "type": "string"
        },
        "operator": {
          "type": "string"
        },
        "sortID": {
          "type": "integer"
        },
        "status": {
          "type": "string"
        },
        "threshold": {
          "type": "number"
        }
      },
      "type": "object"
    },
    "structs.AlertRuleGroup": {
      "properties": {
        "name": {
          "type": "string"
        },
        "rules": {
          "items": {
            "$ref": "#/definitions/structs.AlertRuleDetail"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "message.QueryAlertRulesByCloudUserResp": {
      "properties": {
        "alertRuleList": {
          "items": {
            "$ref": "#/definitions/structs.AlertRuleGroup"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "message.UpdateAlertRulesByCloudUserReq": {
      "properties": {
        "alertRules": {
          "additionalProperties": {
            "$ref": "#/definitions/structs.AlertRuleBase"
          },
          "type": "object"
        },
        "clusterID": {
          "type": "string"
        },
        "region": {
          "type": "string"
        },
        "vendor": {
          "type": "string"
        }
      },
      "required": ["region", "vendor"],
      "type": "object"
    },
    "structs.AlertRuleBase": {
      "properties": {
        "alertRuleID": {
          "type": "string"
        },
        "for": {
          "type": "number"
        },
        "status": {
          "type": "string"
        },
        "threshold": {
          "type": "number"
        }
      },
      "type": "object"
    },
    "message.UpdateAlertRulesByCloudUserResp": {
      "type": "object"
    }
  }
}
