forked from wangqifan/calc
218 lines
5.5 KiB
YAML
218 lines
5.5 KiB
YAML
openapi: 3.0.0
|
|
info:
|
|
title: 云计算价格计算器 API
|
|
description: 支持多云平台价格计算的服务。
|
|
version: "1.0.0"
|
|
servers:
|
|
- url: /api
|
|
description: Main API server
|
|
|
|
paths:
|
|
/regions:
|
|
get:
|
|
summary: 获取区域列表
|
|
description: 获取指定平台的可用区域列表。
|
|
parameters:
|
|
- name: platform
|
|
in: query
|
|
description: '云平台。支持的值: "aws", "azure", "aliyun"。'
|
|
required: false
|
|
schema:
|
|
type: string
|
|
default: "aws"
|
|
enum: ["aws", "azure", "aliyun"]
|
|
responses:
|
|
'200':
|
|
description: 成功响应
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
code:
|
|
type: string
|
|
example: "us-east-1"
|
|
name:
|
|
type: string
|
|
example: "US East (N. Virginia)"
|
|
'400':
|
|
description: 如果平台不受支持。
|
|
|
|
/instance-types:
|
|
get:
|
|
summary: 获取实例类型
|
|
description: 获取指定平台的可用实例类型。
|
|
parameters:
|
|
- name: platform
|
|
in: query
|
|
description: 云平台。
|
|
required: false
|
|
schema:
|
|
type: string
|
|
default: "aws"
|
|
responses:
|
|
'200':
|
|
description: 成功响应,包含实例类型及其信息的字典。
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
'400':
|
|
description: 如果平台不受支持。
|
|
|
|
/search-instances:
|
|
post:
|
|
summary: 搜索实例
|
|
description: 搜索符合指定条件的实例类型。
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/InstanceSearchRequest'
|
|
responses:
|
|
'200':
|
|
description: 匹配的实例列表,按月度总价排序。
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
'400':
|
|
description: 如果缺少必需的参数。
|
|
'500':
|
|
description: 内部服务器错误。
|
|
|
|
/search-instances-v2:
|
|
post:
|
|
summary: 搜索实例 V2
|
|
description: 使用 MySQL 数据库搜索符合条件的 AWS 实例。
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/InstanceSearchRequestV2'
|
|
responses:
|
|
'200':
|
|
description: 匹配的实例列表。
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
'500':
|
|
description: 内部服务器错误。
|
|
|
|
/compare-prices:
|
|
post:
|
|
summary: 比较价格
|
|
description: 比较多种实例配置的价格。
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/PriceComparison'
|
|
responses:
|
|
'200':
|
|
description: 包含配置及其计算价格的列表。
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
'500':
|
|
description: 内部服务器错误。
|
|
|
|
components:
|
|
schemas:
|
|
InstanceSearchRequest:
|
|
type: object
|
|
properties:
|
|
cpu_cores:
|
|
type: integer
|
|
description: CPU 核心数
|
|
memory_gb:
|
|
type: number
|
|
format: float
|
|
description: 内存 (GB)
|
|
disk_gb:
|
|
type: integer
|
|
description: 磁盘大小 (GB)
|
|
region:
|
|
type: string
|
|
description: 区域
|
|
operating_system:
|
|
type: string
|
|
description: 操作系统
|
|
default: "Linux"
|
|
platform:
|
|
type: string
|
|
description: 云平台
|
|
default: "aws"
|
|
|
|
InstanceSearchRequestV2:
|
|
type: object
|
|
properties:
|
|
cpu_cores:
|
|
type: integer
|
|
description: CPU 核心数
|
|
memory_gb:
|
|
type: number
|
|
format: float
|
|
description: 内存 (GB)
|
|
disk_gb:
|
|
type: integer
|
|
description: 磁盘大小 (GB)
|
|
region:
|
|
type: string
|
|
description: 区域
|
|
operating_system:
|
|
type: string
|
|
description: 操作系统
|
|
default: "Linux"
|
|
|
|
PriceComparison:
|
|
type: object
|
|
properties:
|
|
configurations:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/PriceRequest'
|
|
description: 价格请求配置列表
|
|
|
|
PriceRequest:
|
|
type: object
|
|
required:
|
|
- instance_type
|
|
- region
|
|
- operating_system
|
|
- purchase_option
|
|
properties:
|
|
instance_type:
|
|
type: string
|
|
description: 实例类型
|
|
region:
|
|
type: string
|
|
description: 区域
|
|
operating_system:
|
|
type: string
|
|
description: 操作系统
|
|
purchase_option:
|
|
type: string
|
|
description: 购买选项
|
|
duration:
|
|
type: integer
|
|
description: 持续时间
|
|
default: 1
|
|
disk_gb:
|
|
type: integer
|
|
description: 磁盘大小 (GB)
|
|
default: 0
|