use of io.fabric8.maven.docker.access.NetworkCreateConfig in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClient method createNetwork.
@Override
public String createNetwork(NetworkCreateConfig networkConfig) throws DockerAccessException {
String createJson = networkConfig.toJson();
log.debug("Network create config: " + createJson);
try {
String url = urlBuilder.createNetwork();
log.verbose(Logger.LogVerboseCategory.API, API_LOG_FORMAT_POST_WITH_REQUEST, url, createJson);
String response = delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
log.debug(response);
JsonObject json = JsonFactory.newJsonObject(response);
if (json.has("Warnings")) {
logWarnings(json);
}
// only need first 12 to id a container
return json.get("Id").getAsString().substring(0, 12);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to create network for [%s]", networkConfig.getName());
}
}
Aggregations