@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response install(
AssignmentRepresentation assignmentRepresentation,
@DefaultValue("1") @QueryParam("limit") int limit,
@Context UriInfo uriInfo,
@HeaderParam(GALAXY_AGENTS_VERSION_HEADER) String expectedAgentsVersion)
{
Preconditions.checkNotNull(assignmentRepresentation, "assignmentRepresentation must not be null");
Preconditions.checkArgument(limit > 0, "limit must be at least 1");
Assignment assignment = assignmentRepresentation.toAssignment();
Predicate<AgentStatus> agentFilter = AgentFilterBuilder.build(uriInfo,
transform(coordinator.getAgents(), idGetter()),
transform(coordinator.getAllSlotStatus(), uuidGetter()),
false,
repository);
List<AgentStatus> agents = coordinator.getAgents(agentFilter);
checkAgentsVersion(expectedAgentsVersion, agents);
List<SlotStatus> slots = coordinator.install(agentFilter, limit, assignment);
return Response.ok(transform(slots, fromSlotStatus(coordinator.getAllSlotStatus(), repository)))
.header(GALAXY_SLOTS_VERSION_HEADER, createSlotsVersion(slots))
.build();
}