@Test public void listHosts() { assertThat(resource.list(null, NO_SELECTOR_ARG), equalTo(hosts)); }
@GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public List<String> list(@QueryParam("namePattern") final String namePattern, @QueryParam("selector") final List<String> hostSelectors) { List<String> hosts = namePattern == null ? model.listHosts() : model.listHosts(namePattern); if (!hostSelectors.isEmpty()) { final List<HostSelector> selectors = hostSelectors.stream() .map(selectorStr -> { final HostSelector parsed = HostSelector.parse(selectorStr); if (parsed == null) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Invalid host selector: " + selectorStr) .build() ); } return parsed; }) .collect(Collectors.toList()); final Map<String, Map<String, String>> hostsAndLabels = getLabels(hosts); final HostMatcher matcher = new HostMatcher(hostsAndLabels); hosts = matcher.getMatchingHosts(selectors); } return hosts; }
HostsResource { @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public List<String> list(@QueryParam("namePattern") final String namePattern, @QueryParam("selector") final List<String> hostSelectors) { List<String> hosts = namePattern == null ? model.listHosts() : model.listHosts(namePattern); if (!hostSelectors.isEmpty()) { final List<HostSelector> selectors = hostSelectors.stream() .map(selectorStr -> { final HostSelector parsed = HostSelector.parse(selectorStr); if (parsed == null) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Invalid host selector: " + selectorStr) .build() ); } return parsed; }) .collect(Collectors.toList()); final Map<String, Map<String, String>> hostsAndLabels = getLabels(hosts); final HostMatcher matcher = new HostMatcher(hostsAndLabels); hosts = matcher.getMatchingHosts(selectors); } return hosts; } }
HostsResource { @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public List<String> list(@QueryParam("namePattern") final String namePattern, @QueryParam("selector") final List<String> hostSelectors) { List<String> hosts = namePattern == null ? model.listHosts() : model.listHosts(namePattern); if (!hostSelectors.isEmpty()) { final List<HostSelector> selectors = hostSelectors.stream() .map(selectorStr -> { final HostSelector parsed = HostSelector.parse(selectorStr); if (parsed == null) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Invalid host selector: " + selectorStr) .build() ); } return parsed; }) .collect(Collectors.toList()); final Map<String, Map<String, String>> hostsAndLabels = getLabels(hosts); final HostMatcher matcher = new HostMatcher(hostsAndLabels); hosts = matcher.getMatchingHosts(selectors); } return hosts; } HostsResource(final MasterModel model); }
HostsResource { @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public List<String> list(@QueryParam("namePattern") final String namePattern, @QueryParam("selector") final List<String> hostSelectors) { List<String> hosts = namePattern == null ? model.listHosts() : model.listHosts(namePattern); if (!hostSelectors.isEmpty()) { final List<HostSelector> selectors = hostSelectors.stream() .map(selectorStr -> { final HostSelector parsed = HostSelector.parse(selectorStr); if (parsed == null) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Invalid host selector: " + selectorStr) .build() ); } return parsed; }) .collect(Collectors.toList()); final Map<String, Map<String, String>> hostsAndLabels = getLabels(hosts); final HostMatcher matcher = new HostMatcher(hostsAndLabels); hosts = matcher.getMatchingHosts(selectors); } return hosts; } HostsResource(final MasterModel model); @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered List<String> list(@QueryParam("namePattern") final String namePattern,
                           @QueryParam("selector") final List<String> hostSelectors); @PUT @Path("{host}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response.Status put(@PathParam("host") final String host,
                             @QueryParam("id") @DefaultValue("") final String id); @DELETE @Path("{id}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered HostDeregisterResponse delete(@PathParam("id") final String host); @GET @Path("{id}/status") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Optional<HostStatus> hostStatus(
      @PathParam("id") final String host,
      @QueryParam("status") @DefaultValue("") final String statusFilter); @POST @Path("/statuses") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Map<String, HostStatus> hostStatuses(
      final List<String> hosts,
      @QueryParam("status") @DefaultValue("") final String statusFilter); @PUT @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered JobDeployResponse jobPut(
      @PathParam("host") final String host,
      @PathParam("job") final JobId jobId,
      @Valid final Deployment deployment,
      @RequestUser final String username,
      @QueryParam("token") @DefaultValue(EMPTY_TOKEN) final String token); @DELETE @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered JobUndeployResponse jobDelete(@PathParam("host") final String host,
                                       @PathParam("job") final JobId jobId,
                                       @QueryParam("token") @DefaultValue("") final String token); @PATCH @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered SetGoalResponse jobPatch(@PathParam("host") final String host,
                                  @PathParam("job") final JobId jobId,
                                  @Valid final Deployment deployment,
                                  @QueryParam("token") @DefaultValue("") final String token); @GET @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Optional<Deployment> jobGet(@PathParam("host") final String host,
                                     @PathParam("job") final JobId jobId); }
HostsResource { @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public List<String> list(@QueryParam("namePattern") final String namePattern, @QueryParam("selector") final List<String> hostSelectors) { List<String> hosts = namePattern == null ? model.listHosts() : model.listHosts(namePattern); if (!hostSelectors.isEmpty()) { final List<HostSelector> selectors = hostSelectors.stream() .map(selectorStr -> { final HostSelector parsed = HostSelector.parse(selectorStr); if (parsed == null) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Invalid host selector: " + selectorStr) .build() ); } return parsed; }) .collect(Collectors.toList()); final Map<String, Map<String, String>> hostsAndLabels = getLabels(hosts); final HostMatcher matcher = new HostMatcher(hostsAndLabels); hosts = matcher.getMatchingHosts(selectors); } return hosts; } HostsResource(final MasterModel model); @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered List<String> list(@QueryParam("namePattern") final String namePattern,
                           @QueryParam("selector") final List<String> hostSelectors); @PUT @Path("{host}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response.Status put(@PathParam("host") final String host,
                             @QueryParam("id") @DefaultValue("") final String id); @DELETE @Path("{id}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered HostDeregisterResponse delete(@PathParam("id") final String host); @GET @Path("{id}/status") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Optional<HostStatus> hostStatus(
      @PathParam("id") final String host,
      @QueryParam("status") @DefaultValue("") final String statusFilter); @POST @Path("/statuses") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Map<String, HostStatus> hostStatuses(
      final List<String> hosts,
      @QueryParam("status") @DefaultValue("") final String statusFilter); @PUT @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered JobDeployResponse jobPut(
      @PathParam("host") final String host,
      @PathParam("job") final JobId jobId,
      @Valid final Deployment deployment,
      @RequestUser final String username,
      @QueryParam("token") @DefaultValue(EMPTY_TOKEN) final String token); @DELETE @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered JobUndeployResponse jobDelete(@PathParam("host") final String host,
                                       @PathParam("job") final JobId jobId,
                                       @QueryParam("token") @DefaultValue("") final String token); @PATCH @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered SetGoalResponse jobPatch(@PathParam("host") final String host,
                                  @PathParam("job") final JobId jobId,
                                  @Valid final Deployment deployment,
                                  @QueryParam("token") @DefaultValue("") final String token); @GET @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Optional<Deployment> jobGet(@PathParam("host") final String host,
                                     @PathParam("job") final JobId jobId);  }