{
  "openapi": "3.1.0",
  "info": {
    "title": "闲力云整机时长租用 API",
    "version": "0.1.0-preview",
    "description": "未开放的接口草案。仅用于约定配置和用量预估格式，控制台当前在浏览器内预览配置。"
  },
  "servers": [
    {
      "url": "https://api.example.com",
      "description": "占位地址"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/gpu/rentals/estimate": {
      "post": {
        "operationId": "estimateGpuRentalUsage",
        "summary": "预估整机时",
        "description": "按整机台数和使用窗口计算整机时。预估只返回用量，库存、正式报价和计费规则待开放。",
        "x-xianliyun-availability": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RentalEstimateRequest"
              },
              "example": {
                "startAt": "2030-01-01T09:00:00+08:00",
                "endAt": "2030-01-01T12:00:00+08:00",
                "machines": 2,
                "gpuModel": "NVIDIA RTX 5090",
                "gpuCount": 2
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功计算预估用量。整机时等于台数乘以使用时长，以小时为单位。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RentalEstimate"
                },
                "example": {
                  "machines": 2,
                  "durationMinutes": 180,
                  "machineHours": 6
                }
              }
            }
          },
          "400": {
            "description": "请求参数不符合约定，例如结束时间早于或等于开始时间。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RentalError"
                },
                "example": {
                  "error": {
                    "code": "invalid_time_window",
                    "message": "结束时间必须晚于开始时间。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer 凭据缺失或无效。"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "RentalEstimateRequest": {
        "type": "object",
        "required": [
          "startAt",
          "endAt",
          "machines"
        ],
        "properties": {
          "startAt": {
            "type": "string",
            "format": "date-time",
            "description": "开始时间，使用带时区偏移的时间戳或 UTC。"
          },
          "endAt": {
            "type": "string",
            "format": "date-time",
            "description": "结束时间，须晚于开始时间。"
          },
          "machines": {
            "type": "integer",
            "minimum": 1,
            "description": "整机台数。"
          },
          "gpuModel": {
            "type": "string",
            "maxLength": 80,
            "description": "偏好的 GPU 型号。"
          },
          "gpuCount": {
            "type": "integer",
            "minimum": 1,
            "description": "每台 GPU 卡数。"
          },
          "vramGb": {
            "type": "integer",
            "minimum": 1,
            "description": "单卡显存，单位 GB。"
          },
          "memoryGb": {
            "type": "integer",
            "minimum": 1,
            "description": "每台系统内存，单位 GB。"
          },
          "nvmeGb": {
            "type": "integer",
            "minimum": 1,
            "description": "每台本地 NVMe 容量，单位 GB。"
          }
        }
      },
      "RentalEstimate": {
        "type": "object",
        "required": [
          "machines",
          "durationMinutes",
          "machineHours"
        ],
        "properties": {
          "machines": {
            "type": "integer",
            "minimum": 1,
            "description": "整机台数。"
          },
          "durationMinutes": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "使用窗口时长，单位分钟。"
          },
          "machineHours": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "预估用量，单位整机时。"
          }
        }
      },
      "RentalError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}