Profile Revision Management
Profile Revision Management
镜像配置管理 API 用于创建,查看,测试以及应用镜像配置。
授权
使用 Basic Authorization 来进行鉴权 (推荐服务器端程序使用). 步骤如下:
在 UOS 网站上获取当前需要使用的 UOS APP 的 AppId 和 AppServiceSecret
注:此处 AppId 和 AppServiceSecret,可在 UOS 网站上获取


在请求任意 API 的 Request Header 中增加 Header:
- Authorization: Basic base64(appId:appServiceSecret)
示例代码
C## C# 使用示例 - Basic 授权方式 using System; using System.Collections.Generic; using System.Net.Http; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; class Program { private static string GetBasicAuthorization(string appId, string appServiceSecret) { string credentials = $"{appId}:{appServiceSecret}"; byte[] credentialsBytes = Encoding.UTF8.GetBytes(credentials); string encodedCredentials = Convert.ToBase64String(credentialsBytes); return $"Basic {encodedCredentials}"; } public static async Task Main(string[] args) { using (HttpClient client = new HttpClient()) { // 使用项目的 APP_ID, APP_SERVICE_SECRET 获取 headers client.DefaultRequestHeaders.Add("Authorization", GetBasicAuthorization(APP_ID, APP_SERVICE_SECRET)); // 以get方法为例,替换 url 为你需要请求的 url HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); // 其他处理…… } } }Python# Python 使用示例 - Basic 授权方式 import base64 import requests def get_basic_authorization(app_id, app_service_secret): """ 获取basic auth的Header """ credentials = f'{app_id}:{app_service_secret}' encoded_credentials = base64.b64encode(credentials.encode("utf-8")).decode("utf-8") return {'Authorization': f'Basic {encoded_credentials}'} # 使用 APP_ID, APP_SERVICE_SECRET 获取Basic Token Header headers = get_basic_authorization(APP_ID, APP_SERVICE_SECRET) # 以get方法为例,替换 url 为你需要请求的 url response = requests.get(url, headers=headers)JavaScript// JavaScript 使用示例 - Basic 授权方式 const axios = require('axios'); function getBasicAuthorization(appId, appServiceSecret) { /** 获取 basic auth 的 Header */ const credentials = `${appId}:${appServiceSecret}`; const encodedCredentials = btoa(credentials); return { 'Authorization': `Basic ${encodedCredentials}` }; } // 使用 APP_ID, APP_SERVICE_SECRET 获取Basic Token Header const headers = getBasicAuthorization(APP_ID, APP_SERVICE_SECRET); // 以get方法为例,替换 url 为你需要请求的 url const response = await axios.get(url, { headers });Go// Go 使用示例 - Basic 授权方式 import ( "bytes" "encoding/base64" "encoding/json" "fmt" "io" "net/http" ) func GetBasicAuthorization(appID, appServiceSecret string) string { credentials := appID + ":" + appServiceSecret encodedCredentials := base64.StdEncoding.EncodeToString([]byte(credentials)) return "Basic " + encodedCredentials } func main() { // 以get方法为例,替换 url 为你需要请求的 url req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } // 使用 APP_ID, APP_SERVICE_SECRET 获取Basic Token Header req.Header.Set("Authorization", GetBasicAuthorization(APP_ID, APP_SERVICE_SECRET)) client := &http.Client{} response, err := client.Do(req) if err != nil { return nil, err } defer resp.Body.Close() // ……其他处理 }
API 列表
创建镜像配置
镜像配置创建完成的同时会默认启动一个服务器测试。可通过下一步 「查询镜像配置状态API」 来查询服务器测试状态。
基本信息
| URL | Method | Content-Type |
|---|---|---|
https://multiverse.scaling.unity.cn/v1/game/profiles/{profileId}/ci/profile-revision | POST | application/json |
Parameter
| 参数名 | 描述 |
|---|---|
| profileId | 待分配服务所属的profileId |
注:此处 profileId 可在 UOS 网站上获取

Request Body
{
"ProfileRevisionInfo": {
"gameServerPorts": [
{
"port": 9998,
"protocol": "UDP",
"name": "rest"
}
],
"environmentVariables": {
"foo": "bar"
},
"cpuLimit": "0.1",
"gameStartDuration": "10s",
"gameServerEntryPoint": [
"BossRoom.x86_64"
],
"fileConfigs": [
{
"mountPath": "/etc/config",
"filename": "test.json",
"content": "string"
}
],
"timeZone": "UTC"
},
"gameImageInfo": {
"objectUrl": "string",
"imageTagPrefix": "build-a",
"gamePackageCompressedFormat": "zip",
"executableFileList": [
"string"
]
}
}Body参数
| 参数名 | 描述 | 类型 | 必填 |
|---|---|---|---|
| gamServerPorts | 服务端程序的listen端口 包含 port: 端口号,protocol: 端口协议,name: 自定义端口名称 | Array | 是 |
| environmentVariables | 环境变量 用于舰队模式给所有buffer设置统一的环境变量,按需模式可忽略此选项 | map<string, string> | 否 |
| cpuLimit | CPU限制,支持两位小数 | String | 是 |
| gameStartDuration | 游戏启动超时时长 (支持格式例如 1m30s) | String | 是 |
| gameServerEntryPoint | 游戏入口程序 | Array | 是 |
| fileConfigs | 文件挂载列表, 当前只允许挂载一个文件,文件大小限制为50kb mountPath : 挂载路径(绝对路径,如/foo/bar) filename: 挂载文件名(如config.json,程序中可以访问/foo/bar/config.json文件) content: 挂载文件内容 | Array | 是 |
| timeZone | 服务器时区, 可选项有Asia/Shanghai和UTC. 默认UTC | String | 否 |
| objectUrl | 你的游戏服务器包的地址,可供我们下载拿到package | String | 是 |
| imageTagPrefix | 镜像标签,默认Tag为当时的日期 | String | 否 |
| gamePackageCompressedFormat | 压缩格式,当前仅支持zip | String | 是 |
| executableFileList | 可执行文件列表 | Array | 否 |
注:相关描述说明即获取方式
- name: 自定义端口名称
- CPU限制,支持两位小数
对应的内存限制将按照 "1核CPU/1.5GB内存" 的单位换算,如填写0.1核CPU, 对应的内存是153MB - 游戏入口程序
- 挂载文件
- 可执行文件列表
如你的游戏是入口程序去执行其他可执行文件,需要给其他可执行文件权限,可将该可执行文件填到此处
输出示例
{
"profileRevisionId": "string",
"imageId": "string",
"testId": "string"
}查询镜像配置状态
需要主动轮询此 API, 直到 status 为 success, 才可调用「应用镜像配置API」来发布镜像版本(一般轮询时长在2到5分钟之间)。
基本信息
| URL | Method |
|---|---|
https://multiverse.scaling.unity.cn/v1/game/profiles/ci/profile-revision/{profileRevisionId}/status | GET |
Parameter
| 参数名 | 描述 |
|---|---|
| profileRevisionId | 镜像配置的profileRevisionId,在上一步 「创建镜像配置状态API」 的返回中获取 |
输出示例
{
"status": "string",
"imageId": "string",
"testId": "string",
"msg": "string",
"reason": "string"
}Status(镜像配置状态)
| 状态 | 描述 |
|---|---|
| buildingImage | 正在将你的游戏服务器包build为docker镜像 |
| testing | 正在测试你的镜像配置 |
| success | 成功创建新的镜像配置 只有在此状态下, 才可调用 「应用镜像配置API」 来应用该镜像配置 |
| imageBuildingFailure | 构建镜像失败 可以通过返回的 imageId 调用下方 「获取镜像创建的日志API」 查看镜像创建日志 |
| testFailure | 测试镜像配置失败 可以通过返回的 testId 调用下方 「查看测试server的运行日志API」 查看测试server日志 |
| imageBuildingError | 镜像构建错误 请稍后重试或者联系我们 |
获取镜像创建的日志
若在 「查询镜像配置状态API」 中查询到的镜像配置状态为 imageBuildingFailure ,则可调用该API来查询日志。
基本信息
| URL | Method |
|---|---|
https://multiverse.scaling.unity.cn/v1/game/images/{imageId}/logs | GET |
Parameter
| 参数名 | 描述 |
|---|---|
| imageId | 镜像的 imageId,在 「查询镜像配置状态API」 的返回中获取 |
输出示例
{
"logs": "string"
}查看测试server的运行日志
若在 「查询镜像配置状态API」 中查询到的镜像配置状态为 testFailure ,则可调用该API来查询日志。
基本信息
| URL | Method |
|---|---|
https://multiverse.scaling.unity.cn/v1/game/profile-revisions/test-server/{testId}/logs | GET |
Parameter
| 参数名 | 描述 |
|---|---|
| testId | 镜像的 testId,在 「查询镜像配置状态API」 的返回中获取 |
输出示例
{
"testId": "string",
"tailLines": 0,
"log": "string",
"reason": "string"
}应用镜像配置
若在 「查询镜像配置状态API」 中查询到的镜像配置状态为 success ,则可调用该API来应用该镜像配置。
基本信息
| URL | Method |
|---|---|
https://multiverse.scaling.unity.cn/v1/game/profile-revisions/{profileRevisionId}/release | PUT |
Parameter
| 参数名 | 描述 |
|---|---|
| profileRevisionId | 镜像配置的profileRevisionId,在 「查询镜像配置状态API」 的返回中获取 |
输出示例
{
"profileRevision": {
"revisionId": "string",
"profileId": "string",
"gameImageId": "string",
"revisionStatus": "string",
"releaseVersion": 0,
"gameServerPorts": [
{
"port": 9998,
"protocol": "UDP",
"name": "rest"
}
],
"environmentVariables": {
"foo": "bar"
},
"createdAt": "2023-05-29T06:40:07.755Z",
"createdByUser": "string",
"modifiedAt": "2023-05-29T06:40:07.755Z",
"modifiedByUser": "string",
"releasedAt": "2023-05-29T06:40:07.755Z",
"releasedByUser": "string",
"resourceAge": 0,
"gameServerEntryPoint": [
"BossRoom.x86_64"
],
"cpuLimit": "0.1",
"cpuRequest": "0.1",
"memoryLimit": "128Mi",
"memoryRequest": "128Mi",
"gameStartDuration": "10s",
"gameImageTag": "string",
"testResult": "string",
"gameImageUrl": "string",
"imageCreatedAt": "2023-05-29T06:40:07.755Z",
"fileConfigs": [
{
"mountPath": "/etc/config",
"filename": "test.json",
"content": "string"
}
]
}
}