api.SelfUser() | me, err := c.Account.Me(ctx),然后使用 me.User | 返回 Account |
api.GetApplications() | c.Account.Me(ctx),然后使用 me.Applications([]AppSummary) | |
api.GetDatabases() | c.Account.Me(ctx),然后使用 me.Databases([]DatabaseSummary) | |
api.UserSnapshots(scope) | c.Account.Snapshots(ctx, scope) | |
api.ServiceStatus() | c.Service.Status(ctx) | 新的模型,参见类型 |
api.PostApplications(r) → *ApplicationUploaded | c.Apps.Create(ctx, r) → AppCreated(值类型) | v2 会将 zip 缓冲到内存中,并将该部分命名为 upload.zip;v3 以流的方式传输,并以 *os.File 的名称(其基本名称)命名该部分,否则为 app.zip。Subdomain 已移除:请读取 Domain,即完整主机(my-app.squareweb.app),非 Web 应用为 "" |
api.GetApplication(id) | c.Apps.Get(ctx, id) | |
api.DeleteApplication(id) | c.Apps.Delete(ctx, id) | |
api.PostApplicationSignal(id, squarecloud.ApplicationSignalStart/Stop/Restart) | c.Apps.Start(ctx, id) / c.Apps.Stop(ctx, id) / c.Apps.Restart(ctx, id) | |
api.PostApplicationCommit(id, r, rest.WithQueryParam("path", p)) | c.Apps.Commit(ctx, id, r, p, filename) | v2 总是将该部分命名为 commit.zip;v3 使用 filename,否则使用 *os.File 自身的名称,因此单个非 zip 文件现在会以其自身名称放置,而不会被当作 zip 处理而失败 |
api.GetApplicationStatus(id) | c.Apps.Status(ctx, id) | |
api.GetApplicationStatusRaw(id) | c.Apps.StatusRaw(ctx, id) | |
api.GetApplicationListStatus() | c.Apps.StatusAll(ctx, "") | 返回 []StatusListItem |
api.GetApplicationLogs(id) → ApplicationLogs | c.Apps.Logs(ctx, id) → string | |
api.GetApplicationMetrics(id) | c.Apps.Metrics(ctx, id) | 数据点按 API 发送的顺序排列,最新的在前 |
api.ApplicationRealtime(id, rest.WithContext(ctx)) | c.Apps.Realtime(ctx, id) | 返回 *Realtime;参见行为变更 |
api.GetApplicationDomains() | c.Apps.Domains(ctx) | |
api.GetLoadBalancers() | c.Apps.LoadBalancers(ctx) | |
api.GetApplicationEnvs(id) | c.Apps.Envs.Get(ctx, id) | |
api.SetApplicationEnvs(id, envs) | c.Apps.Envs.Set(ctx, id, envs) | |
api.ReplaceApplicationEnvs(id, envs) | c.Apps.Envs.Replace(ctx, id, envs) | |
api.DeleteApplicationEnvs(id, keys) → error | c.Apps.Envs.Delete(ctx, id, keys...) → (EnvVars, error)(剩余的变量) | |
api.GetApplicationFiles(id, path) → []FileInfo | c.Apps.Files.List(ctx, id, path) → []FileEntry | 不存在的目录现在返回 404 FILE_NOT_FOUND(以前是空列表);受保护的路径返回 403 BLOCKED_PATH |
api.ReadApplicationFile(id, path) → FileContent | c.Apps.Files.Read(ctx, id, path) → []byte | 以 base64 请求并解码;超过 10 MB 的文件返回 413 FILE_TOO_LARGE |
api.PutApplicationFile(id, path, b) → (FileWritten, error) | c.Apps.Files.Write(ctx, id, path, b) → error。去掉所有 written 检查:成功即为 nil 错误 | 内容始终以 base64 编码发送,因此二进制文件是安全的;空内容会写入一个空文件 |
api.MoveApplicationFile(id, from, to) | c.Apps.Files.Move(ctx, id, path, to) | |
api.DeleteApplicationFile(id, path) | c.Apps.Files.Delete(ctx, id, path) | 现在可以正常工作(在 v2 中总是返回 400) |
api.GetApplicationSnapshots(id) | c.Apps.Snapshots.List(ctx, id) | 每个 Snapshot 现在都携带来自 API 的 VersionID 和 URL(已签名的下载链接) |
api.CreateApplicationSnapshot(id) | c.Apps.Snapshots.Create(ctx, id) | 在使用 .URL 之前检查 .Pending(202) |
api.RestoreApplicationSnapshot(id, snapID, verID) | c.Apps.Snapshots.Restore(ctx, id, snap.Name, snap.VersionID) | VersionID 是 API 发送的字段:不再需要从 Key 中解析任何内容。错误请参见 Snapshots |
api.GetApplicationDeployments(id) | c.Apps.Deploys.List(ctx, id) | |
api.GetApplicationCurrentDeployment(id) | c.Apps.Deploys.Current(ctx, id) | |
api.PostApplicationDeployWebhook(id, token) → GithubWebhook | c.Apps.Deploys.SetWebhook(ctx, id, token) → string | |
api.LinkApplicationGithubApp(id, repo, branch) → GithubAppLink | c.Apps.Deploys.LinkGithubApp(ctx, id, repo, branch) → LinkedRepository | 现在可以使用 API 密钥(作用域 apps:deploy);repository 包装已移除;未连接 GitHub 的账户返回 403 GITHUB_NOT_CONNECTED |
api.UnlinkApplicationGithubApp(id) | c.Apps.Deploys.UnlinkGithubApp(ctx, id) | 没有关联时返回 400 GIT_NOT_CONFIGURED |
api.GetApplicationDNS(id) | c.Apps.Network.DNS(ctx, id) | |
api.SetApplicationCustomDomain(id, d) | c.Apps.Network.SetDomain(ctx, id, d) | |
api.GetApplicationAnalytics(id, s, e, opts...) | c.Apps.Network.Analytics(ctx, id, s, e, squarecloud.AnalyticsFilters{...}) | 返回 *NetworkAnalytics,没有流量的窗口为 nil |
api.GetApplicationNetworkErrors(id, s, e, opts...) | c.Apps.Network.Errors(ctx, id, s, e, include4xx) | 返回 *NetworkErrors,为空时为 nil |
api.GetApplicationNetworkLogs(id, s, e) | c.Apps.Network.Logs(ctx, id, s, e) | |
api.GetApplicationNetworkPerformance(id, s, e) | c.Apps.Network.Performance(ctx, id, s, e) | 返回 *NetworkPerformance,为空时为 nil |
api.PurgeApplicationCache(id) | c.Apps.Network.PurgeCache(ctx, id) | |
api.CreateDatabase(opts) | c.Databases.Create(ctx, squarecloud.DatabaseCreate{...}) | |
api.GetDatabase(id) | c.Databases.Get(ctx, id) | |
api.UpdateDatabase(id, opts) | c.Databases.Update(ctx, id, squarecloud.DatabaseUpdate{...}) | |
api.DeleteDatabase(id) | c.Databases.Delete(ctx, id) | |
api.StartDatabase(id) / api.StopDatabase(id) | c.Databases.Start(ctx, id) / c.Databases.Stop(ctx, id) | |
api.GetDatabaseStatus(id) / api.GetDatabaseStatusRaw(id) | c.Databases.Status(ctx, id) / c.Databases.StatusRaw(ctx, id) | |
api.GetDatabaseListStatus() | c.Databases.StatusAll(ctx) | 返回 []StatusListItem |
api.GetDatabaseMetrics(id) | c.Databases.Metrics(ctx, id) | |
api.GetDatabaseCertificate(id) → DatabaseCertificate | c.Databases.Certificate(ctx, id) → string(base64 PEM) | |
api.ResetDatabaseCredentials(id, t) → DatabasePasswordReset | c.Databases.ResetCredentials(ctx, id, t) → string | 新密码;重置证书时为 "" |
api.GetDatabaseSnapshots / CreateDatabaseSnapshot / RestoreDatabaseSnapshot | c.Databases.Snapshots.List / Create / Restore | 与应用相同:使用 snap.Name 和 snap.VersionID 恢复 |
api.GetWorkspaces() | c.Workspaces.List(ctx) | |
api.GetWorkspace(id) | c.Workspaces.Get(ctx, id) | |
api.CreateWorkspace(name) | c.Workspaces.Create(ctx, name) | |
api.DeleteWorkspace(id) | c.Workspaces.Delete(ctx, id) | |
api.LeaveWorkspace(id) | c.Workspaces.Leave(ctx, id) | |
api.AddWorkspaceMember(ws, code, group) | c.Workspaces.Members.Add(ctx, ws, code, group) | |
api.UpdateWorkspaceMember(ws, member, group) | c.Workspaces.Members.Update(ctx, ws, member, group) | |
api.RemoveWorkspaceMember(ws, member) | c.Workspaces.Members.Remove(ctx, ws, member) | |
api.GetWorkspaceInviteCode() → WorkspaceInviteCode | c.Workspaces.Members.InviteCode(ctx) → string | |
api.AddWorkspaceApplication(ws, app) / RemoveWorkspaceApplication | c.Workspaces.Apps.Add(ctx, ws, app) / Remove | |
自行下载 snapshot URL(http.Get) | c.DownloadSnapshot(ctx, url, w) | 以流的方式写入任意 io.Writer;从不发送密钥 |
rest.IsRateLimit(err) | errors.As(err, &apiErr) && apiErr.Status == 429 | 已移除 |
rest.ErrorCode(err) | errors.As(err, &apiErr),然后使用 apiErr.Code | 已移除 |
client.Request(...)、client.Stream(...)(rest.Client) | 上面的类型化方法 | 已移除:每个操作都有对应的方法 |
rest.NewApplications(client)、rest.NewDatabases(client)、rest.NewWorkspaces(client) | squarecloud.New(key),然后使用 c.Apps、c.Databases、c.Workspaces 字段 | 已移除 |
rest.Applications、rest.Databases、rest.Workspaces(接口) | squarecloud.AppsAPI、DatabasesAPI、WorkspacesAPI(这些字段的类型) | 已移除;如需 mock,请声明你自己的接口 |
rest.Config、rest.DefaultConfig()、(*rest.Config).Apply(opts) | squarecloud.New(key, opts...),配合 WithHTTPClient、WithBaseURL、WithUserAgent | 已移除(请使用 Option;没有 logger) |
(*rest.RequestConfig).Apply(opts) | 传入 ctx 和类型化参数 | 已移除 |
(*rest.RealtimeStream).Next() / Close() | (*squarecloud.Realtime).Next() / Close() | 在 REALTIME_DISCONNECTED 之后,Next 返回 io.EOF |
| (无) | c.AI.Chat(ctx, squarecloud.ChatRequest{...}) | 新增 |