779 lines
20 KiB
JSON
779 lines
20 KiB
JSON
{
|
||
"openapi": "3.0.3",
|
||
"info": {
|
||
"title": "License Platform Client API",
|
||
"version": "1.1.0",
|
||
"description": "Client-facing instance APIs. Update checks return signed update-v1 metadata; admin sessions are never client credentials. See protocol.md for canonical signature and trust-root rules."
|
||
},
|
||
"servers": [
|
||
{
|
||
"url": "https://license.yihuiyong.cn",
|
||
"description": "Deployed HTTPS origin"
|
||
}
|
||
],
|
||
"paths": {
|
||
"/api/v1/portal/snapshot": {
|
||
"post": {
|
||
"summary": "实例凭据查询已发布版本与下载权限",
|
||
"parameters": [
|
||
{
|
||
"in": "query",
|
||
"name": "page",
|
||
"schema": {
|
||
"type": "integer",
|
||
"minimum": 1
|
||
}
|
||
},
|
||
{
|
||
"in": "query",
|
||
"name": "page_size",
|
||
"schema": {
|
||
"type": "integer",
|
||
"minimum": 1,
|
||
"maximum": 100
|
||
}
|
||
}
|
||
],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"required": [
|
||
"instance_id",
|
||
"secret"
|
||
],
|
||
"properties": {
|
||
"instance_id": {
|
||
"type": "string",
|
||
"format": "uuid"
|
||
},
|
||
"secret": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "data 含 customer/product/license/instance/lease/releases,meta 为分页;版本项含 id/version/sha256/size_bytes/download_allowed,不是签名升级清单。"
|
||
},
|
||
"403": {
|
||
"description": "实例凭据无效"
|
||
},
|
||
"503": {
|
||
"description": "门户不可用"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/v1/activation/instances/{instance_id}": {
|
||
"post": {
|
||
"operationId": "activateInstance",
|
||
"summary": "Activate pre-provisioned instance",
|
||
"parameters": [
|
||
{
|
||
"$ref": "#/components/parameters/InstanceID"
|
||
},
|
||
{
|
||
"$ref": "#/components/parameters/IdempotencyKey"
|
||
}
|
||
],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"required": [
|
||
"license_key",
|
||
"secret"
|
||
],
|
||
"properties": {
|
||
"license_key": {
|
||
"type": "string"
|
||
},
|
||
"secret": {
|
||
"type": "string",
|
||
"format": "password"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Activation certificate; verify data.certificate before accepting",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"data": {
|
||
"type": "object",
|
||
"properties": {
|
||
"instance_id": {
|
||
"type": "string"
|
||
},
|
||
"status": {
|
||
"type": "string",
|
||
"enum": [
|
||
"activated"
|
||
]
|
||
},
|
||
"certificate": {
|
||
"$ref": "#/components/schemas/Certificate"
|
||
}
|
||
}
|
||
},
|
||
"idempotent_replay": {
|
||
"type": "boolean"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"default": {
|
||
"$ref": "#/components/responses/Error"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/v1/instances/{instance_id}/heartbeat": {
|
||
"post": {
|
||
"operationId": "heartbeat",
|
||
"summary": "Refresh signed runtime lease",
|
||
"parameters": [
|
||
{
|
||
"$ref": "#/components/parameters/InstanceID"
|
||
},
|
||
{
|
||
"$ref": "#/components/parameters/IdempotencyKey"
|
||
}
|
||
],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"required": [
|
||
"secret",
|
||
"client_time"
|
||
],
|
||
"properties": {
|
||
"secret": {
|
||
"type": "string",
|
||
"format": "password"
|
||
},
|
||
"client_time": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Signed lease; HTTP 200 does not imply active state",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"data": {
|
||
"$ref": "#/components/schemas/Lease"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"429": {
|
||
"description": "Rate limited; respect Retry-After",
|
||
"headers": {
|
||
"Retry-After": {
|
||
"schema": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"$ref": "#/components/schemas/Error"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"default": {
|
||
"$ref": "#/components/responses/Error"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/v1/customers/{customer_id}/releases/{id}/download": {
|
||
"post": {
|
||
"operationId": "downloadRelease",
|
||
"summary": "Download entitled release; repeat credentials for Range retries",
|
||
"parameters": [
|
||
{
|
||
"name": "customer_id",
|
||
"in": "path",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "integer",
|
||
"minimum": 1
|
||
}
|
||
},
|
||
{
|
||
"name": "id",
|
||
"in": "path",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "integer",
|
||
"minimum": 1
|
||
}
|
||
},
|
||
{
|
||
"name": "Range",
|
||
"in": "header",
|
||
"schema": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"required": [
|
||
"instance_id",
|
||
"secret"
|
||
],
|
||
"properties": {
|
||
"instance_id": {
|
||
"type": "string"
|
||
},
|
||
"secret": {
|
||
"type": "string",
|
||
"format": "password"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Full file (through configured download gateway)",
|
||
"content": {
|
||
"application/octet-stream": {
|
||
"schema": {
|
||
"type": "string",
|
||
"format": "binary"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"206": {
|
||
"description": "Partial file",
|
||
"headers": {
|
||
"Content-Range": {
|
||
"schema": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"content": {
|
||
"application/octet-stream": {
|
||
"schema": {
|
||
"type": "string",
|
||
"format": "binary"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"416": {
|
||
"description": "Unsatisfiable Range"
|
||
},
|
||
"default": {
|
||
"$ref": "#/components/responses/Error"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/v1/activation/keyring": {
|
||
"get": {
|
||
"operationId": "discoverKeyring",
|
||
"summary": "Discovery only, NOT a trust-root bootstrap",
|
||
"responses": {
|
||
"200": {
|
||
"description": "Configured verification keys",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"data": {
|
||
"type": "object",
|
||
"properties": {
|
||
"current_key_id": {
|
||
"type": "string"
|
||
},
|
||
"keys": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "object",
|
||
"properties": {
|
||
"key_id": {
|
||
"type": "string"
|
||
},
|
||
"public_key_pem": {
|
||
"type": "string"
|
||
},
|
||
"revoked": {
|
||
"type": "boolean"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"default": {
|
||
"$ref": "#/components/responses/Error"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/v1/instances/{instance_id}/updates/check": {
|
||
"post": {
|
||
"operationId": "checkForUpdate",
|
||
"summary": "返回实例绑定的签名 update-v1 策略与发布元数据",
|
||
"parameters": [
|
||
{
|
||
"$ref": "#/components/parameters/InstanceID"
|
||
}
|
||
],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"$ref": "#/components/schemas/UpdateCheckRequest"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Signed envelope; verify raw decoded payload before use",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"$ref": "#/components/schemas/UpdateCheckResponse"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"default": {
|
||
"$ref": "#/components/responses/Error"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"components": {
|
||
"parameters": {
|
||
"InstanceID": {
|
||
"name": "instance_id",
|
||
"in": "path",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "string"
|
||
}
|
||
},
|
||
"IdempotencyKey": {
|
||
"name": "Idempotency-Key",
|
||
"in": "header",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "Same key and unchanged body for retries of one operation; new key for a new operation"
|
||
}
|
||
},
|
||
"responses": {
|
||
"Error": {
|
||
"description": "See error.code and HTTP status; never blindly retry conflicts",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"$ref": "#/components/schemas/Error"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"schemas": {
|
||
"Error": {
|
||
"type": "object",
|
||
"properties": {
|
||
"error": {
|
||
"type": "object",
|
||
"properties": {
|
||
"code": {
|
||
"type": "string"
|
||
},
|
||
"message": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"Certificate": {
|
||
"type": "object",
|
||
"required": [
|
||
"version",
|
||
"payload",
|
||
"signature",
|
||
"canonical_sha256"
|
||
],
|
||
"properties": {
|
||
"version": {
|
||
"type": "string",
|
||
"enum": [
|
||
"license-v2"
|
||
]
|
||
},
|
||
"payload": {
|
||
"$ref": "#/components/schemas/CertificatePayload"
|
||
},
|
||
"signature": {
|
||
"type": "string",
|
||
"description": "ASN.1 DER ECDSA, unpadded standard Base64"
|
||
},
|
||
"canonical_sha256": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"CertificatePayload": {
|
||
"type": "object",
|
||
"additionalProperties": false,
|
||
"required": [
|
||
"version",
|
||
"instance_id",
|
||
"license_id",
|
||
"customer_id",
|
||
"product_id",
|
||
"starts_at",
|
||
"expires_at",
|
||
"key_id"
|
||
],
|
||
"properties": {
|
||
"version": {
|
||
"type": "string",
|
||
"enum": [
|
||
"license-v2"
|
||
]
|
||
},
|
||
"instance_id": {
|
||
"type": "string"
|
||
},
|
||
"license_id": {
|
||
"type": "integer",
|
||
"minimum": 1
|
||
},
|
||
"customer_id": {
|
||
"type": "integer",
|
||
"minimum": 1
|
||
},
|
||
"product_id": {
|
||
"type": "integer",
|
||
"minimum": 1
|
||
},
|
||
"starts_at": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"expires_at": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"key_id": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"Lease": {
|
||
"type": "object",
|
||
"required": [
|
||
"payload",
|
||
"signature",
|
||
"canonical_sha256",
|
||
"algorithm",
|
||
"next_heartbeat_seconds"
|
||
],
|
||
"properties": {
|
||
"payload": {
|
||
"$ref": "#/components/schemas/LeasePayload"
|
||
},
|
||
"signature": {
|
||
"type": "string",
|
||
"description": "ASN.1 DER ECDSA, unpadded standard Base64"
|
||
},
|
||
"canonical_sha256": {
|
||
"type": "string"
|
||
},
|
||
"algorithm": {
|
||
"type": "string",
|
||
"enum": [
|
||
"ECDSA-P256-SHA256"
|
||
]
|
||
},
|
||
"next_heartbeat_seconds": {
|
||
"type": "integer",
|
||
"minimum": 60
|
||
}
|
||
}
|
||
},
|
||
"LeasePayload": {
|
||
"type": "object",
|
||
"additionalProperties": false,
|
||
"required": [
|
||
"version",
|
||
"instance_id",
|
||
"state",
|
||
"server_time",
|
||
"entitlement_expires_at",
|
||
"lease_expires_at",
|
||
"key_id"
|
||
],
|
||
"properties": {
|
||
"version": {
|
||
"type": "string",
|
||
"enum": [
|
||
"lease-v2"
|
||
]
|
||
},
|
||
"instance_id": {
|
||
"type": "string"
|
||
},
|
||
"state": {
|
||
"type": "string",
|
||
"enum": [
|
||
"active",
|
||
"frozen",
|
||
"revoked",
|
||
"expired",
|
||
"not_started",
|
||
"not_activated"
|
||
]
|
||
},
|
||
"server_time": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"entitlement_expires_at": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"lease_expires_at": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"key_id": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"UpdateCheckRequest": {
|
||
"type": "object",
|
||
"required": [
|
||
"secret",
|
||
"current_version",
|
||
"platform",
|
||
"arch",
|
||
"channel"
|
||
],
|
||
"properties": {
|
||
"secret": {
|
||
"type": "string",
|
||
"format": "password"
|
||
},
|
||
"current_version": {
|
||
"type": "string"
|
||
},
|
||
"platform": {
|
||
"type": "string"
|
||
},
|
||
"arch": {
|
||
"type": "string"
|
||
},
|
||
"channel": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"UpdateCheckResponse": {
|
||
"type": "object",
|
||
"required": [
|
||
"data"
|
||
],
|
||
"properties": {
|
||
"data": {
|
||
"$ref": "#/components/schemas/UpdateEnvelope"
|
||
}
|
||
}
|
||
},
|
||
"UpdateEnvelope": {
|
||
"type": "object",
|
||
"required": [
|
||
"payload",
|
||
"signature",
|
||
"key_id"
|
||
],
|
||
"properties": {
|
||
"payload": {
|
||
"type": "string",
|
||
"description": "Standard Base64 of raw UTF-8 JSON update-v1 payload"
|
||
},
|
||
"signature": {
|
||
"type": "string",
|
||
"description": "Unpadded standard Base64 DER ECDSA P-256 SHA-256 over decoded payload"
|
||
},
|
||
"key_id": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"UpdatePayload": {
|
||
"type": "object",
|
||
"additionalProperties": false,
|
||
"required": [
|
||
"version",
|
||
"instance_id",
|
||
"product_id",
|
||
"customer_id",
|
||
"current_version",
|
||
"platform",
|
||
"arch",
|
||
"channel",
|
||
"server_time",
|
||
"expires_at",
|
||
"policy_revision",
|
||
"policy_enabled",
|
||
"recommended_version",
|
||
"minimum_supported_version",
|
||
"enforce_after",
|
||
"mandatory",
|
||
"required_now",
|
||
"update_available",
|
||
"download_allowed",
|
||
"release_id",
|
||
"sha256",
|
||
"size_bytes",
|
||
"message"
|
||
],
|
||
"properties": {
|
||
"version": {
|
||
"type": "string",
|
||
"enum": [
|
||
"update-v1"
|
||
]
|
||
},
|
||
"instance_id": {
|
||
"type": "string"
|
||
},
|
||
"product_id": {
|
||
"type": "integer"
|
||
},
|
||
"customer_id": {
|
||
"type": "integer"
|
||
},
|
||
"current_version": {
|
||
"type": "string"
|
||
},
|
||
"platform": {
|
||
"type": "string"
|
||
},
|
||
"arch": {
|
||
"type": "string"
|
||
},
|
||
"channel": {
|
||
"type": "string"
|
||
},
|
||
"server_time": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"expires_at": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"policy_revision": {
|
||
"type": "integer",
|
||
"format": "int64",
|
||
"minimum": 0
|
||
},
|
||
"policy_enabled": {
|
||
"type": "boolean"
|
||
},
|
||
"recommended_version": {
|
||
"type": "string"
|
||
},
|
||
"minimum_supported_version": {
|
||
"type": "string"
|
||
},
|
||
"enforce_after": {
|
||
"type": "string",
|
||
"format": "date-time"
|
||
},
|
||
"mandatory": {
|
||
"type": "boolean"
|
||
},
|
||
"required_now": {
|
||
"type": "boolean"
|
||
},
|
||
"update_available": {
|
||
"type": "boolean"
|
||
},
|
||
"download_allowed": {
|
||
"type": "boolean"
|
||
},
|
||
"release_id": {
|
||
"type": "integer",
|
||
"minimum": 0
|
||
},
|
||
"sha256": {
|
||
"type": "string"
|
||
},
|
||
"size_bytes": {
|
||
"type": "integer",
|
||
"minimum": 0
|
||
},
|
||
"message": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|