⚠️ Traduction non officielle - Cette documentation est une traduction communautaire non officielle de Docker.

Interface : BackendV0

Méthodes de conteneurs

execInContainer

execInContainer(container, cmd): Promise<ExecResultV0>

Exécute une commande à l'intérieur d'un conteneur.

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

console.log(output);
Warning

Il sera supprimé dans une version future.

Paramètres

Nom Type Description
container string -
cmd string La commande à exécuter.

Retourne

Promise<ExecResultV0>


Méthodes HTTP

get

get(url): Promise<unknown>

Effectue une requête HTTP GET vers un service backend.

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

Il sera supprimé dans une version future. Utilisez get à la place.

Paramètres

Nom Type Description
url string L'URL du service backend.

Retourne

Promise<unknown>


post

post(url, data): Promise<unknown>

Effectue une requête HTTP POST vers un service backend.

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

Il sera supprimé dans une version future. Utilisez post à la place.

Paramètres

Nom Type Description
url string L'URL du service backend.
data any Le corps de la requête.

Retourne

Promise<unknown>


put

put(url, data): Promise<unknown>

Effectue une requête HTTP PUT vers un service backend.

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

Il sera supprimé dans une version future. Utilisez put à la place.

Paramètres

Nom Type Description
url string L'URL du service backend.
data any Le corps de la requête.

Retourne

Promise<unknown>


patch

patch(url, data): Promise<unknown>

Effectue une requête HTTP PATCH vers un service backend.

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

Il sera supprimé dans une version future. Utilisez patch à la place.

Paramètres

Nom Type Description
url string L'URL du service backend.
data any Le corps de la requête.

Retourne

Promise<unknown>


delete

delete(url): Promise<unknown>

Effectue une requête HTTP DELETE vers un service backend.

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

Il sera supprimé dans une version future. Utilisez delete à la place.

Paramètres

Nom Type Description
url string L'URL du service backend.

Retourne

Promise<unknown>


head(url): Promise<unknown>

Effectue une requête HTTP HEAD vers un service backend.

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

Il sera supprimé dans une version future. Utilisez head à la place.

Paramètres

Nom Type Description
url string The URL of the backend service.

Returns

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 request instead.

Parameters

Name Type Description
config RequestConfigV0 The URL of the backend service.

Returns

Promise<unknown>


VM Methods

execInVMExtension

execInVMExtension(cmd): Promise<ExecResultV0>

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 exec instead.

Parameters

Name Type Description
cmd string The command to be executed.

Returns

Promise<ExecResultV0>


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.

Parameters

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.

Returns

void