Search in sources :

Example 1 with NetworksListElement

use of io.fabric8.maven.docker.model.NetworksListElement in project docker-maven-plugin by fabric8io.

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(io.fabric8.maven.docker.model.NetworksListElement) Network(io.fabric8.maven.docker.model.Network) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

JsonArray (com.google.gson.JsonArray)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 Network (io.fabric8.maven.docker.model.Network)1 NetworksListElement (io.fabric8.maven.docker.model.NetworksListElement)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1