public static Function<AgentStatus, AgentStatusRepresentation> fromAgentStatus(List<AgentStatus> agentStatuses, Repository repository) { return fromAgentStatus(new AgentStatusRepresentationFactory(agentStatuses, repository)); }
@GET @Path("/agent") @Produces(MediaType.APPLICATION_JSON) public Response getAllAgents(@Context UriInfo uriInfo) { List<SlotStatus> allSlotStatus = coordinator.getAllSlotStatus(); Predicate<AgentStatus> agentPredicate = AgentFilterBuilder.build(uriInfo, transform(coordinator.getAgents(), idGetter()), transform(allSlotStatus, SlotStatus.uuidGetter()), false, repository); List<AgentStatus> agents = coordinator.getAgents(agentPredicate); return Response.ok(transform(agents, fromAgentStatus(coordinator.getAgents(), repository))) .header(AIRSHIP_AGENTS_VERSION_HEADER, createAgentsVersion(agents)) .build(); }
@POST @Path("/agent") @Produces(MediaType.APPLICATION_JSON) public Response provisionAgent( AgentProvisioningRepresentation provisioning, @Context UriInfo uriInfo) throws Exception { List<AgentStatus> agents = coordinator.provisionAgents( provisioning.getAgentConfig(), provisioning.getAgentCount(), provisioning.getInstanceType(), provisioning.getAvailabilityZone(), provisioning.getAmi(), provisioning.getKeyPair(), provisioning.getSecurityGroup(), provisioning.getProvisioningScriptsArtifact()); return Response.ok(transform(agents, fromAgentStatus(coordinator.getAgents(), repository))).build(); }
@Override public CommanderResponse<List<AgentStatusRepresentation>> showAgents(AgentFilter agentFilter) { Predicate<AgentStatus> agentPredicate = agentFilter.toAgentPredicate( transform(coordinator.getAgents(), idGetter()), transform(coordinator.getAllSlotStatus(), SlotStatus.uuidGetter()), true, repository); List<AgentStatus> agentStatuses = coordinator.getAgents(agentPredicate); // update just in case something changed updateServiceInventory(); return createCommanderResponse(createAgentsVersion(agentStatuses), transform(agentStatuses, fromAgentStatus(coordinator.getAgents(), repository))); }
@Override public CommanderResponse<List<AgentStatusRepresentation>> showAgents(AgentFilter agentFilter) { Predicate<AgentStatus> agentPredicate = agentFilter.toAgentPredicate( transform(coordinator.getAgents(), idGetter()), transform(coordinator.getAllSlotStatus(), SlotStatus.uuidGetter()), true, repository); List<AgentStatus> agentStatuses = coordinator.getAgents(agentPredicate); // update just in case something changed updateServiceInventory(); return createCommanderResponse(createAgentsVersion(agentStatuses), transform(agentStatuses, fromAgentStatus(coordinator.getAgents(), repository))); }