@Override public List<Service> listServices(final Service.Criteria criteria) throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final Map<String, List<String>> filters = new HashMap<>(); if (criteria.serviceId() != null) { filters.put("id", Collections.singletonList(criteria.serviceId())); } if (criteria.serviceName() != null) { filters.put("name", Collections.singletonList(criteria.serviceName())); } final List<String> labels = new ArrayList<>(); for (Entry<String, String> input: criteria.labels().entrySet()) { if ("".equals(input.getValue())) { labels.add(input.getKey()); } else { labels.add(String.format("%s=%s", input.getKey(), input.getValue())); } } if (!labels.isEmpty()) { filters.put("label", labels); } WebTarget resource = resource().path("services"); resource = resource.queryParam("filters", urlEncodeFilters(filters)); return request(GET, SERVICE_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<Service> listServices(final Service.Criteria criteria) throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final Map<String, List<String>> filters = new HashMap<>(); if (criteria.serviceId() != null) { filters.put("id", Collections.singletonList(criteria.serviceId())); } if (criteria.serviceName() != null) { filters.put("name", Collections.singletonList(criteria.serviceName())); } final List<String> labels = new ArrayList<>(); for (Entry<String, String> input: criteria.labels().entrySet()) { if ("".equals(input.getValue())) { labels.add(input.getKey()); } else { labels.add(String.format("%s=%s", input.getKey(), input.getValue())); } } if (!labels.isEmpty()) { filters.put("label", labels); } WebTarget resource = resource().path("services"); resource = resource.queryParam("filters", urlEncodeFilters(filters)); return request(GET, SERVICE_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
public static Criteria.Builder find() { return Service.Criteria.builder(); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Service.Criteria) { Service.Criteria that = (Service.Criteria) o; return ((this.serviceId == null) ? (that.serviceId() == null) : this.serviceId.equals(that.serviceId())) && ((this.serviceName == null) ? (that.serviceName() == null) : this.serviceName.equals(that.serviceName())) && ((this.labels == null) ? (that.labels() == null) : this.labels.equals(that.labels())); } return false; }
Builder(Service.Criteria source) { this.serviceId = source.serviceId(); this.serviceName = source.serviceName(); this.labels = source.labels(); } @Override
public static Criteria.Builder find() { return Service.Criteria.builder(); }
Builder(Service.Criteria source) { this.serviceId = source.serviceId(); this.serviceName = source.serviceName(); this.labels = source.labels(); } @Override
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Service.Criteria) { Service.Criteria that = (Service.Criteria) o; return ((this.serviceId == null) ? (that.serviceId() == null) : this.serviceId.equals(that.serviceId())) && ((this.serviceName == null) ? (that.serviceName() == null) : this.serviceName.equals(that.serviceName())) && ((this.labels == null) ? (that.labels() == null) : this.labels.equals(that.labels())); } return false; }