Interface: BackendV0

Interface: BackendV0

Docker Desktop 확장 SDK의 BackendV0 인터페이스예요. 백엔드 서비스에 HTTP 요청을 보내고, 컨테이너나 VM 안에서 명령을 실행하는 레거시(v0) API를 제공해요. v0라서 향후 제거될 예정이에요.

출처: 문서

본문

Interface: BackendV0

컨테이너 메서드

execInContainer

execInContainer(container, cmd): Promise<ExecResultV0ExecResultV0)>

Executes a command inside a container.

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

console.log(output);

Warning

It will be removed in a future version.

파라미터

Name | Type | Description container | string | - cmd | string | The command to be executed.

반환값

Promise<ExecResultV0ExecResultV0)>

HTTP 메서드

get

get(url): Promise<unknown>

Performs an HTTP GET request to a backend service.

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

Warning

It will be removed in a future version. Use getget) instead.

파라미터

Name | Type | Description url | string | The URL of the backend service.

반환값

Promise<unknown>

post

post(url, data): Promise<unknown>

Performs an HTTP POST request to a backend service.

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

Warning

It will be removed in a future version. Use postpost) instead.

파라미터

Name | Type | Description url | string | The URL of the backend service. data | any | The body of the request.

반환값

Promise<unknown>

put

put(url, data): Promise<unknown>

Performs an HTTP PUT request to a backend service.

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

Warning

It will be removed in a future version. Use putput) instead.

파라미터

Name | Type | Description url | string | The URL of the backend service. data | any | The body of the request.

반환값

Promise<unknown>

patch

patch(url, data): Promise<unknown>

Performs an HTTP PATCH request to a backend service.

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

Warning

It will be removed in a future version. Use patchpatch) instead.

파라미터

Name | Type | Description url | string | The URL of the backend service. data | any | The body of the request.

반환값

Promise<unknown>

delete

delete(url): Promise<unknown>

Performs an HTTP DELETE request to a backend service.

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

Warning

It will be removed in a future version. Use deletedelete) instead.

파라미터

Name | Type | Description url | string | The URL of the backend service.

반환값

Promise<unknown>

head(url): Promise<unknown>

Performs an HTTP HEAD request to a backend service.

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

Warning

It will be removed in a future version. Use headhead) instead.

파라미터

Name | Type | Description url | string | The URL of the backend service.

반환값

Promise<unknown>

request

request(config): Promise<unknown>

Performs an HTTP request to a backend service.

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

Warning

It will be removed in a future version. Use requestrequest) instead.

파라미터

Name | Type | Description config | RequestConfigV0RequestConfigV0) | The URL of the backend service.

반환값

Promise<unknown>

VM 메서드

execInVMExtension

execInVMExtension(cmd): Promise<ExecResultV0ExecResultV0)>

Executes a command inside the backend container. If your extensions ships with additional binaries that should be run inside the backend container you can use the execInVMExtension function.

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

console.log(output);

Warning

It will be removed in a future version. Use execexec) instead.

파라미터

Name | Type | Description cmd | string | The command to be executed.

반환값

Promise<ExecResultV0ExecResultV0)>

spawnInVMExtension

spawnInVMExtension(cmd, args, callback): void

Returns a stream from the command executed in the backend container.

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);
    }
  }
);

Warning

It will be removed in a future version.

파라미터

Name | Type | Description cmd | string | The command to be executed. args | string[] | The arguments of the command to execute. callback | (data: any, error: any) => void | The callback function where to listen from the command output data and errors.

반환값

void

더 알아보기