列出应用 snapshot
列出应用已存储的 snapshot(GET /v2/apps//snapshots),包括大小、日期、下载 URL 以及恢复所需的 ID。
GET
/
v2
/
apps
/
{app_id}
/
snapshots
列出应用 snapshot
curl --request GET \
--url https://api.squarecloud.app/v2/apps/{app_id}/snapshots \
--header 'Authorization: <authorization>'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/snapshots"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/snapshots', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/snapshots",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/snapshots"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.squarecloud.app/v2/apps/{app_id}/snapshots")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/snapshots")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"status": "success",
"response": [
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab_javascript_manual",
"size": 12900705,
"modified": "2024-06-27T06:23:42.326Z",
"key": "AWSAccessKeyId=access key",
"version_id": "3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": "javascript",
"origin": "manual"
},
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab_javascript_automatic",
"size": 12900705,
"modified": "2024-06-26T07:05:40.000Z",
"key": "AWSAccessKeyId=access key",
"version_id": "Qm8cFZ2vY1tBn4LhXw0e.KpR7sUjD9aGz",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": "javascript",
"origin": "automatic"
},
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab",
"size": 12900705,
"modified": "2024-06-25T05:15:51.533Z",
"key": "AWSAccessKeyId=access key",
"version_id": "yT5wN0cE3hJ.bV8mLq2XoZr6dAiK4sPf",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": null,
"origin": null
}
]
}
需要具有
snapshots:read 权限范围的 API 密钥。
此端点会返回某个应用已存储的所有快照,每项包含大小、最后修改日期,以及用于下载的签名 url。你可以用它构建还原选择界面;也可以在收到 创建快照 返回的 202 SNAPSHOT_PROCESSING 响应后,通过轮询本端点确认快照是否已生成完成,而不是重新向创建端点发起 POST 请求。
结果按所有者/应用维度缓存 30 分钟,因此即使集群已经在后台写入完成,刚生成好的快照也可能需要一小段时间才会出现在这里。拿到快照的 name 和 version_id 后,可将它们作为 snapshotId 和 versionId 传给 恢复快照,将应用回滚到该时间点。
快照需要有效套餐,每日快照配额随应用的 RAM 分配而变化。在工作区共享的应用上,调用者需要具备 admin 角色。
参数
string
必填
应用程序的 ID。你可以在应用程序控制台的 URL 中找到它。
响应
string
指示调用是否成功。成功时为
success,否则为 error。object
响应的内容。
显示 展开对象
显示 展开对象
string
snapshot 的名称:应用程序 ID,可选带有
_<runtime> 和 _<origin> 后缀。恢复时将其原样作为 snapshotId 传入。number
备份的大小,单位为字节。
string
备份最后一次修改的日期。
string
下载 URL 的签名查询字符串。
string
snapshot 的版本。恢复时将其作为
versionId 传入。string
用于下载该 snapshot 的签名 URL,有效期 30 天。
string | null
snapshot 所来自的运行时:应用程序的语言(
javascript、python、rust 等)或数据库引擎(mongo、mysql、postgres、redis)。在此字段出现之前创建的 snapshot 为 null。string | null
snapshot 的创建方式:
manual(通过 API、控制台或 CLI 请求)或 automatic(每日定时 snapshot)。较旧的 snapshot 为 null。{
"status": "success",
"response": [
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab_javascript_manual",
"size": 12900705,
"modified": "2024-06-27T06:23:42.326Z",
"key": "AWSAccessKeyId=access key",
"version_id": "3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": "javascript",
"origin": "manual"
},
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab_javascript_automatic",
"size": 12900705,
"modified": "2024-06-26T07:05:40.000Z",
"key": "AWSAccessKeyId=access key",
"version_id": "Qm8cFZ2vY1tBn4LhXw0e.KpR7sUjD9aGz",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": "javascript",
"origin": "automatic"
},
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab",
"size": 12900705,
"modified": "2024-06-25T05:15:51.533Z",
"key": "AWSAccessKeyId=access key",
"version_id": "yT5wN0cE3hJ.bV8mLq2XoZr6dAiK4sPf",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": null,
"origin": null
}
]
}
通过快照的
url 下载快照。该链接在 30 天内有效。常见错误
| 代码 | HTTP | 说明 |
|---|---|---|
APP_NOT_FOUND | 404 | 在已解析的所有者名下,不存在该 ID 对应的应用。 |
相关内容
- CLI:
squarecloud app snapshot list - SDK:
api.apps.snapshots.list()(JavaScript)、client.apps.snapshots.list()(Python)、c.Apps.Snapshots.List()(Go)
⌘I
列出应用 snapshot
curl --request GET \
--url https://api.squarecloud.app/v2/apps/{app_id}/snapshots \
--header 'Authorization: <authorization>'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/snapshots"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/snapshots', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/snapshots",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/snapshots"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.squarecloud.app/v2/apps/{app_id}/snapshots")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/snapshots")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"status": "success",
"response": [
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab_javascript_manual",
"size": 12900705,
"modified": "2024-06-27T06:23:42.326Z",
"key": "AWSAccessKeyId=access key",
"version_id": "3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": "javascript",
"origin": "manual"
},
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab_javascript_automatic",
"size": 12900705,
"modified": "2024-06-26T07:05:40.000Z",
"key": "AWSAccessKeyId=access key",
"version_id": "Qm8cFZ2vY1tBn4LhXw0e.KpR7sUjD9aGz",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": "javascript",
"origin": "automatic"
},
{
"name": "1d2cdc0d6ebd435c91315c6329d12eab",
"size": 12900705,
"modified": "2024-06-25T05:15:51.533Z",
"key": "AWSAccessKeyId=access key",
"version_id": "yT5wN0cE3hJ.bV8mLq2XoZr6dAiK4sPf",
"url": "https://snapshots.squarecloud.app/applications/<account_id>/<name>.zip?<signed-query-string>",
"runtime": null,
"origin": null
}
]
}

