Search in sources :

Example 1 with ServiceNotFoundException

use of com.spotify.docker.client.exceptions.ServiceNotFoundException in project docker-client by spotify.

the class DefaultDockerClient method updateService.

@Override
public void updateService(final String serviceId, final Long version, final ServiceSpec spec, final RegistryAuth config) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.24");
    try {
        WebTarget resource = resource().path("services").path(serviceId).path("update");
        resource = resource.queryParam("version", version);
        request(POST, String.class, resource, resource.request(APPLICATION_JSON_TYPE).header("X-Registry-Auth", authHeader(config)), Entity.json(spec));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                throw new ServiceNotFoundException(serviceId);
            default:
                throw e;
        }
    }
}
Also used : DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) ServiceNotFoundException(com.spotify.docker.client.exceptions.ServiceNotFoundException) WebTarget(javax.ws.rs.client.WebTarget)

Example 2 with ServiceNotFoundException

use of com.spotify.docker.client.exceptions.ServiceNotFoundException in project docker-client by spotify.

the class DefaultDockerClient method removeService.

@Override
public void removeService(final String serviceId) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.24");
    try {
        final WebTarget resource = resource().path("services").path(serviceId);
        request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                throw new ServiceNotFoundException(serviceId);
            default:
                throw e;
        }
    }
}
Also used : DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) ServiceNotFoundException(com.spotify.docker.client.exceptions.ServiceNotFoundException) WebTarget(javax.ws.rs.client.WebTarget)

Aggregations

DockerRequestException (com.spotify.docker.client.exceptions.DockerRequestException)2 ServiceNotFoundException (com.spotify.docker.client.exceptions.ServiceNotFoundException)2 WebTarget (javax.ws.rs.client.WebTarget)2