{
  "swagger": "2.0",
  "info": {
    "title": "APIs for Serverless service",
    "version": "1.0"
  },
  "tags": [
    {
      "name": "ServerlessBillingService"
    }
  ],
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/v1/serverless/cost/predict": {
      "get": {
        "operationId": "PredictCost",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/PredictCostResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "cloud_provider",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "region",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "rcu",
            "in": "query",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "name": "service_plan",
            "description": "Optional. Valid values: essential, premium. Default: essential.",
            "in": "query",
            "required": false,
            "type": "string",
            "default": "essential"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/clusters/{cluster_id}/resource_limit": {
      "get": {
        "operationId": "GetResourceLimitMode",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetResourceLimitModeResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/clusters/{cluster_id}/spend_limits": {
      "get": {
        "operationId": "GetSpendLimit",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetSpendLimitResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      },
      "delete": {
        "operationId": "DeleteSpendLimit",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetSpendLimitResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      },
      "post": {
        "operationId": "SetSpendLimit",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetSpendLimitResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ServerlessBillingService.SetSpendLimitBody"
            }
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      },
      "put": {
        "operationId": "ModifySpendLimit",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetSpendLimitResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ServerlessBillingService.ModifySpendLimitBody"
            }
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/clusters/{cluster_id}/spend_limits/details": {
      "get": {
        "operationId": "GetSpendLimitDetails",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetSpendLimitDetailsResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/clusters/{cluster_id}/spend_limits/predict": {
      "get": {
        "operationId": "PredictClusterSpendLimit",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/PredictSpendLimitResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "spend_limit",
            "description": "spend limit in cents",
            "in": "query",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "name": "region",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "enhanced_encryption_enabled",
            "in": "query",
            "required": false,
            "type": "boolean"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/spend_limits": {
      "get": {
        "operationId": "GetAllSpendLimits",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetAllSpendLimitsResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "type": "string",
            "format": "uint64"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/spend_limits/predict": {
      "get": {
        "operationId": "PredictSpendLimit",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/PredictSpendLimitResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "spend_limit",
            "description": "spend limit in cents",
            "in": "query",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "name": "region",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "enhanced_encryption_enabled",
            "in": "query",
            "required": false,
            "type": "boolean"
          },
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "type": "string",
            "format": "uint64"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    },
    "/api/v1/serverless/pricing/details": {
      "get": {
        "operationId": "GetPricingDetails",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetPricingDetailsResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "region",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "cloud_provider",
            "in": "query",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "ServerlessBillingService"
        ]
      }
    }
  },
  "definitions": {
    "Any": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    },
    "BaseResp": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "title": "such as: request_id, trace_id"
        },
        "err_code": {
          "type": "string",
          "format": "int64"
        },
        "err_msg": {
          "type": "string"
        }
      }
    },
    "ExpensiveSqlEmailResp": {
      "type": "object",
      "properties": {
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      }
    },
    "GetAllSpendLimitsResp": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "format": "int32"
        },
        "free_credit_max_count": {
          "type": "integer",
          "format": "int32"
        },
        "has_free_credit_quota": {
          "type": "boolean"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/GetSpendLimitResp"
          }
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "total",
        "free_credit_max_count",
        "has_free_credit_quota",
        "items",
        "base_resp"
      ]
    },
    "GetPricingDetailsResp": {
      "type": "object",
      "properties": {
        "region": {
          "type": "string"
        },
        "request_units": {
          "type": "string"
        },
        "row_based_storage": {
          "type": "string"
        },
        "column_storage": {
          "type": "string"
        },
        "cloud_provider": {
          "type": "string"
        },
        "request_capacity_units": {
          "type": "string"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "region",
        "request_units",
        "row_based_storage",
        "cloud_provider"
      ]
    },
    "GetResourceLimitModeResp": {
      "type": "object",
      "properties": {
        "cluster_id": {
          "type": "string",
          "format": "uint64"
        },
        "ru_mode": {
          "$ref": "#/definitions/GetResourceLimitModeResp.Mode"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "cluster_id",
        "mode"
      ]
    },
    "GetResourceLimitModeResp.Mode": {
      "type": "string",
      "enum": [
        "STANDARD",
        "THROTTLED"
      ]
    },
    "GetSpendLimitDetailsResp": {
      "type": "object",
      "properties": {
        "cluster_id": {
          "type": "string",
          "format": "uint64"
        },
        "spend_limit": {
          "type": "integer",
          "format": "int64",
          "title": "spend limit in cents"
        },
        "free_credit": {
          "type": "integer",
          "format": "int64",
          "title": "free credit in cents"
        },
        "spent_total": {
          "type": "integer",
          "format": "int64",
          "title": "money spent so far in cents"
        },
        "spent_free": {
          "$ref": "#/definitions/MoneySpents",
          "title": "money spent so far on free credit in cents"
        },
        "spent_paid": {
          "$ref": "#/definitions/MoneySpents",
          "title": "money spent so far on spend limit in cents"
        },
        "usages": {
          "$ref": "#/definitions/ResourceUsages",
          "title": "resource usages"
        },
        "update_at": {
          "type": "string",
          "format": "date-time"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "cluster_id",
        "spend_limit",
        "free_credit",
        "spent_total",
        "spent_free",
        "spent_paid",
        "usages",
        "update_at",
        "base_resp"
      ]
    },
    "GetSpendLimitResp": {
      "type": "object",
      "properties": {
        "cluster_id": {
          "type": "string",
          "format": "uint64"
        },
        "spend_limit": {
          "type": "integer",
          "format": "int64",
          "title": "spend limit in cents"
        },
        "free_credit": {
          "type": "integer",
          "format": "int64",
          "title": "free credit in cents"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "cluster_id",
        "spend_limit",
        "free_credit",
        "base_resp"
      ]
    },
    "MoneySpents": {
      "type": "object",
      "properties": {
        "request_unit": {
          "type": "integer",
          "format": "int64"
        },
        "row_storage": {
          "type": "integer",
          "format": "int64"
        },
        "column_storage": {
          "type": "integer",
          "format": "int64"
        }
      }
    },
    "PredictCostResp": {
      "type": "object",
      "properties": {
        "cloud_provider": {
          "type": "string"
        },
        "region": {
          "type": "string"
        },
        "rcu": {
          "type": "integer",
          "format": "int64"
        },
        "rcu_cost_hourly": {
          "type": "string"
        },
        "rcu_cost_monthly": {
          "type": "string"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "cloud_provider",
        "region"
      ]
    },
    "PredictSpendLimitResp": {
      "type": "object",
      "properties": {
        "spend_limit": {
          "type": "integer",
          "format": "int64",
          "title": "spend limit in cents"
        },
        "free_credit": {
          "type": "integer",
          "format": "int64",
          "title": "free credit in cents"
        },
        "max_request_units": {
          "type": "string",
          "format": "uint64"
        },
        "max_column_storage": {
          "type": "number",
          "format": "double"
        },
        "max_row_storage": {
          "type": "number",
          "format": "double"
        },
        "free_request_units": {
          "type": "string",
          "format": "uint64"
        },
        "free_column_storage": {
          "type": "number",
          "format": "double"
        },
        "free_row_storage": {
          "type": "number",
          "format": "double"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "spend_limit",
        "free_credit",
        "max_request_units",
        "max_column_storage",
        "max_row_storage",
        "free_request_units",
        "free_column_storage",
        "free_row_storage",
        "base_resp"
      ]
    },
    "ResourceUsages": {
      "type": "object",
      "properties": {
        "request_unit": {
          "type": "string",
          "format": "uint64"
        },
        "row_storage": {
          "type": "number",
          "format": "double"
        },
        "column_storage": {
          "type": "number",
          "format": "double"
        }
      }
    },
    "ServerlessBillingService.ModifySpendLimitBody": {
      "type": "object",
      "properties": {
        "spend_limit": {
          "type": "integer",
          "format": "int64",
          "title": "spend limit in cents"
        },
        "region": {
          "type": "string"
        },
        "enhanced_encryption_enabled": {
          "type": "boolean"
        },
        "zone_redundant_enabled": {
          "type": "boolean"
        },
        "validate_only": {
          "type": "boolean"
        }
      },
      "required": [
        "spend_limit",
        "region"
      ]
    },
    "ServerlessBillingService.SetSpendLimitBody": {
      "type": "object",
      "properties": {
        "spend_limit": {
          "type": "integer",
          "format": "int64",
          "title": "spend limit in cents"
        },
        "region": {
          "type": "string"
        },
        "enhanced_encryption_enabled": {
          "type": "boolean"
        },
        "zone_redundant_enabled": {
          "type": "boolean"
        },
        "validate_only": {
          "type": "boolean"
        }
      },
      "required": [
        "spend_limit",
        "region"
      ]
    },
    "Status": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Any"
          }
        }
      }
    }
  },
  "securityDefinitions": {
    "bearer": {
      "type": "apiKey",
      "description": "Authentication token, prefixed by Bearer: 'Bearer token'",
      "name": "Authorization",
      "in": "header"
    }
  }
}
