Search in sources :

Example 1 with Network

use of org.eclipse.jkube.kit.build.api.model.Network in project jkube by eclipse.

the class DockerAccessWithHcClient method listNetworks.

@Override
public List<Network> listNetworks() throws DockerAccessException {
    String url = urlBuilder.listNetworks();
    try {
        String response = delegate.get(url, HTTP_OK);
        JsonArray array = JsonFactory.newJsonArray(response);
        List<Network> networks = new ArrayList<>(array.size());
        for (int i = 0; i < array.size(); i++) {
            networks.add(new NetworksListElement(array.get(i).getAsJsonObject()));
        }
        return networks;
    } catch (IOException e) {
        throw new DockerAccessException(e.getMessage());
    }
}
Also used : JsonArray(com.google.gson.JsonArray) NetworksListElement(org.eclipse.jkube.kit.build.api.model.NetworksListElement) Network(org.eclipse.jkube.kit.build.api.model.Network) DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

JsonArray (com.google.gson.JsonArray)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Network (org.eclipse.jkube.kit.build.api.model.Network)1 NetworksListElement (org.eclipse.jkube.kit.build.api.model.NetworksListElement)1 DockerAccessException (org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException)1