V Cloud SDK API 指南

概述

This endpoint provides api for uploading service template, receiving user payment event webhook, handling order refund and managing user serivces.


上传服务模版

GET /api/v1/service/template/add

平台节点会读取请求body中的yaml服务模版并在平台注册服务信息. 服务模版解释 请参考

VSYS 付款网络钩子

POST /api/v1/listener/vsys

该API通过接收从 VSYS 节点发出的transaction信息来更新付款信息。

Order 退款 API

获取订单信息

GET /api/v1/order/id/:id 

返回信息请参考 订单变量

资源服务调用退款

当用户申请的资源在资源节点上不足时,资源节点会调用该API进行退款。

POST /api/v1/order/serviceRefund/:id

id 为订单ID.

请求 Body

{
	"stopService": true
}

请求Body为json字典,可用key解释请看以下表

名称 类型 说明
stopService bool 退款时是否执行停止资源lua脚本

用户调用退款

POST /api/v1/order/userRefund/:id

id 为订单ID.

User Service API

查询 User Service

GET /api/v1/userService?

查询变量

名称 类型 说明
id string 订单ID
address string 与该地址相关的user services,只能查询用户本人的
serviceID string 与该服务ID相关的user services
service string 与服务名称相关的
statuses string[] 在这些请求状态内的user services
startFrom number 查询的起始时间
endAt number 查询的截止时间
current number 当前页面数
pageSize number 页面数据大小

返回

{
    "list": [
        {
            "createdAt": 1623143606,
            "updatedAt": 1623143606,
            "duration": 100,
            "endAt": 0,
            "serviceID": "53bc15ca-e6f8-42ef-a814-8c5f14d22b79",
            "service": "Container Service",
            "address": "AU2TxxxxxxxxxxxxxxxxxxxxxxxGp5sj",
            "userServiceID": "9c547686-aaac-4c0d-9036-df4abba7d097",
            "serviceOptions": {
                "portSpecification": "User Specified Service Port",
                "resourceUnit": "1-Unit-Resource"
            },
            "status": "ServiceRunning",
            "magic": "VzvCRsqQ4vF8twxKcpRmt8gfHpQSjJRFRhY1ijnMdVQzuufKNtar6oV7vqom1bWtAYoYNWY1orypwfV7kAUVvyeEmdV7",
            "serviceActiveTS": 1623143606,
            "serviceRunningTS": 1623143606,
            "serviceAbortTS": 0,
            "serviceDoneTS": 0
        }
    ],
    "pagination": {
        "total": 1,
        "current": 1,
        "pageSize": 10
    }
}

list中user service的变量

名称 类型 说明
createdAt number user service创建时间
updatedAt number user service最后更新时间
duration number 服务时长(小时)
endAt number 服务结束时间
serviceID string 该user service所属服务ID
service string 服务名称
address string 用户地址
userServiceID string 与订单ID相同
serviceOptions string 用户选择的服务选项
status string user service状态
magic string 服务secret token,由用户公钥加密
serviceActiveTS number user service 启用时间
serviceRunningTS number user service 开始使用时间
serviceAbortTS number user service 中止时间
serviceDoneTS number user service 完成时间

获取 User Service

GET /api/v1/userService/:id

id 为订单ID.

请求结果请参考 [user service 变量解释](#list中user service的变量)

开始User Service计时

POST /api/v1/userService/start/:orderId

该API是给资源节点通知SDK节点开始计时

关闭到时 User Service

POST /api/v1/userService/stop

该API由节点自动运行

上次更新: 2021/6/17 上午7:15:15