Search in sources :

Example 1 with NetworkNotFoundException

use of org.eclipse.che.plugin.docker.client.exception.NetworkNotFoundException in project che by eclipse.

the class DockerConnector method removeNetwork.

/**
     * Removes network matching provided params
     *
     * @throws NetworkNotFoundException
     *         if network is not found
     * @throws IOException
     *         when a problem occurs with docker api calls
     */
public void removeNetwork(RemoveNetworkParams params) throws IOException {
    try (DockerConnection connection = connectionFactory.openConnection(dockerDaemonUri).method("DELETE").path(apiVersionPathPrefix + "/networks/" + params.getNetworkId())) {
        final DockerResponse response = connection.request();
        int status = response.getStatus();
        if (status == 404) {
            throw new NetworkNotFoundException(readAndCloseQuietly(response.getInputStream()));
        }
        if (status / 100 != 2) {
            throw getDockerException(response);
        }
    }
}
Also used : DockerConnection(org.eclipse.che.plugin.docker.client.connection.DockerConnection) DockerResponse(org.eclipse.che.plugin.docker.client.connection.DockerResponse) NetworkNotFoundException(org.eclipse.che.plugin.docker.client.exception.NetworkNotFoundException)

Aggregations

DockerConnection (org.eclipse.che.plugin.docker.client.connection.DockerConnection)1 DockerResponse (org.eclipse.che.plugin.docker.client.connection.DockerResponse)1 NetworkNotFoundException (org.eclipse.che.plugin.docker.client.exception.NetworkNotFoundException)1