class SwarmScanner {

	protected ObjectNode flattenTask(JsonNode n) {

		ObjectNode out = new ObjectMapper().createObjectNode();
		out.put("swarmClusterId", getSwarmClusterId().get());
		out.put("taskId", n.path("ID").asText());
		out.put("versionIndex", n.path("Version").path("Index").asText());
		out.put("createdAt", n.path("CreatedAt").asText());
		out.put("updatedAt", n.path("UpdatedAt").asText());
		n.path("Labels").fields().forEachRemaining(it -> {
			out.put(formatLabelKey(it.getKey()), it.getValue().asText());
		});
		n.path("Spec").path("ContainerSepc");
		out.put("serviceId", n.path("ServiceID").asText());

		out.put("swarmNodeId", n.path("NodeID").asText());
		out.put("state", n.path("Status").path("State").asText());
		out.put("message", n.path("Status").path("Message").asText());
		out.put("containerId", n.path("Status").path("ContainerStatus").path("ContainerID").asText());
		out.put("desiredState", n.path("DesiredState").asText());

		n.path("Status").path("PortStatus").path("Ports").forEach(it -> {

			String mode = it.path("PublishMode").asText();
			String protocol = it.path("Protocol").asText();
			if (mode.equals("host") && protocol.equals("tcp")) {

				int targetPort = it.path("TargetPort").asInt();
				int publishedPort = it.path("PublishedPort").asInt();
				String key = String.format("hostTcpPortMap_%d", targetPort);
				out.put(key, publishedPort);
			}

		});
		;

		return out;
	}

	  SwarmScanner(DockerScanner ds);

}