接口:BackendV0

容器方法

execInContainer

execInContainer(container, cmd): Promise<ExecResultV0>

在容器内执行命令。

const output = await window.ddClient.backend.execInContainer(container, cmd);

console.log(output);
警告

它将在未来的版本中删除。

参数

名称类型描述
容器字符串-
命令字符串要执行的命令。

返回

Promise<ExecResultV0>


HTTP 方法

获取 (get)

get(url): Promise<未知>

对后端服务执行 HTTP GET 请求。

window.ddClient.backend
 .get("/some/service")
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 get

参数

名称类型描述
url字符串后端服务的 URL。

返回

Promise<未知>


post

post(url, data): Promise<unknown>

向后端服务执行 HTTP POST 请求。

window.ddClient.backend
 .post("/some/service", { ... })
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 post

参数

名称类型描述
url字符串后端服务的 URL。
data任意请求体。

返回

Promise<未知>


put

put(url, data): Promise<unknown>

向后端服务执行 HTTP PUT 请求。

window.ddClient.backend
 .put("/some/service", { ... })
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 put

参数

名称类型描述
url字符串后端服务的 URL。
data任意请求体。

返回

Promise<未知>


patch

patch(url, data): Promise<unknown>

向后端服务执行 HTTP PATCH 请求。

window.ddClient.backend
 .patch("/some/service", { ... })
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 patch

参数

名称类型描述
url字符串后端服务的 URL。
data任意请求体。

返回

Promise<未知>


删除 (delete)

delete(url): Promise<unknown>

向后端服务执行 HTTP DELETE 请求。

window.ddClient.backend
 .delete("/some/service")
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 delete

参数

名称类型描述
url字符串后端服务的 URL。

返回

Promise<未知>


head(url): Promise<unknown>

向后端服务执行 HTTP HEAD 请求。

window.ddClient.backend
 .head("/some/service")
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 head

参数

名称类型描述
url字符串后端服务的 URL。

返回

Promise<未知>


request

request(config): Promise<unknown>

向后端服务执行 HTTP 请求。

window.ddClient.backend
 .request({ url: "/url", method: "GET", headers: { 'header-key': 'header-value' }, data: { ... }})
 .then((value: any) => console.log(value));
警告

它将在未来的版本中删除。请改用 request

参数

名称类型描述
配置RequestConfigV0后端服务的 URL。

返回

Promise<未知>


虚拟机方法

execInVMExtension

execInVMExtension(cmd): Promise<ExecResultV0>

在后端容器内执行命令。如果您的扩展带有应在后端容器内运行的其他二进制文件,您可以使用 execInVMExtension 函数。

const output = await window.ddClient.backend.execInVMExtension(
  `cliShippedInTheVm xxx`
);

console.log(output);
警告

它将在未来的版本中删除。请改用 exec

参数

名称类型描述
命令字符串要执行的命令。

返回

Promise<ExecResultV0>


spawnInVMExtension

spawnInVMExtension(cmd, args, callback): void

从后端容器中执行的命令返回一个流。

window.ddClient.spawnInVMExtension(
  `cmd`,
  [`arg1`, `arg2`],
  (data: any, err: any) => {
    console.log(data.stdout, data.stderr);
    // Once the command exits we get the status code
    if (data.code) {
      console.log(data.code);
    }
  }
);
警告

它将在未来的版本中删除。

参数

名称类型描述
命令字符串要执行的命令。
args字符串[]要执行的命令参数。
回调(data: any, error: any) => void用于监听命令输出数据和错误的回调函数。

返回

© . This site is unofficial and not affiliated with Kubernetes or Docker Inc.