@Override public List<Task> listTasks(final Task.Criteria criteria) throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final Map<String, List<String>> filters = new HashMap<>(); if (criteria.taskId() != null) { filters.put("id", Collections.singletonList(criteria.taskId())); } if (criteria.taskName() != null) { filters.put("name", Collections.singletonList(criteria.taskName())); } if (criteria.serviceName() != null) { filters.put("service", Collections.singletonList(criteria.serviceName())); } if (criteria.nodeId() != null) { filters.put("node", Collections.singletonList(criteria.nodeId())); } if (criteria.label() != null) { filters.put("label", Collections.singletonList(criteria.label())); } if (criteria.desiredState() != null) { filters.put("desired-state", Collections.singletonList(criteria.desiredState())); } WebTarget resource = resource().path("tasks"); resource = resource.queryParam("filters", urlEncodeFilters(filters)); return request(GET, TASK_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
List<Task> tasks = docker.listTasks(Task.Criteria.builder().serviceName(service.spec().name()).build());
@Override public List<Task> listTasks(final Task.Criteria criteria) throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final Map<String, List<String>> filters = new HashMap<>(); if (criteria.taskId() != null) { filters.put("id", Collections.singletonList(criteria.taskId())); } if (criteria.taskName() != null) { filters.put("name", Collections.singletonList(criteria.taskName())); } if (criteria.serviceName() != null) { filters.put("service", Collections.singletonList(criteria.serviceName())); } if (criteria.nodeId() != null) { filters.put("node", Collections.singletonList(criteria.nodeId())); } if (criteria.label() != null) { filters.put("label", Collections.singletonList(criteria.label())); } if (criteria.desiredState() != null) { filters.put("desired-state", Collections.singletonList(criteria.desiredState())); } WebTarget resource = resource().path("tasks"); resource = resource.queryParam("filters", urlEncodeFilters(filters)); return request(GET, TASK_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Task.Criteria) { Task.Criteria that = (Task.Criteria) o; return ((this.taskId == null) ? (that.taskId() == null) : this.taskId.equals(that.taskId())) && ((this.taskName == null) ? (that.taskName() == null) : this.taskName.equals(that.taskName())) && ((this.serviceName == null) ? (that.serviceName() == null) : this.serviceName.equals(that.serviceName())) && ((this.nodeId == null) ? (that.nodeId() == null) : this.nodeId.equals(that.nodeId())) && ((this.label == null) ? (that.label() == null) : this.label.equals(that.label())) && ((this.desiredState == null) ? (that.desiredState() == null) : this.desiredState.equals(that.desiredState())); } return false; }
Builder(Task.Criteria source) { this.taskId = source.taskId(); this.taskName = source.taskName(); this.serviceName = source.serviceName(); this.nodeId = source.nodeId(); this.label = source.label(); this.desiredState = source.desiredState(); } @Override
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Task.Criteria) { Task.Criteria that = (Task.Criteria) o; return ((this.taskId == null) ? (that.taskId() == null) : this.taskId.equals(that.taskId())) && ((this.taskName == null) ? (that.taskName() == null) : this.taskName.equals(that.taskName())) && ((this.serviceName == null) ? (that.serviceName() == null) : this.serviceName.equals(that.serviceName())) && ((this.nodeId == null) ? (that.nodeId() == null) : this.nodeId.equals(that.nodeId())) && ((this.label == null) ? (that.label() == null) : this.label.equals(that.label())) && ((this.desiredState == null) ? (that.desiredState() == null) : this.desiredState.equals(that.desiredState())); } return false; }
Builder(Task.Criteria source) { this.taskId = source.taskId(); this.taskName = source.taskName(); this.serviceName = source.serviceName(); this.nodeId = source.nodeId(); this.label = source.label(); this.desiredState = source.desiredState(); } @Override