use of org.eclipse.winery.repository.targetallocation.Allocation in project winery by eclipse.
the class TopologyTemplateResource method allocate.
@Path("allocate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@POST
public Response allocate(@Context UriInfo uriInfo, AllocationRequest allocationRequest) {
try {
Allocation allocation = new Allocation(allocationRequest);
List<ServiceTemplateId> allocatedIds = allocation.allocate((ServiceTemplateId) this.parent.getId());
List<URI> urls = new ArrayList<>();
for (ServiceTemplateId id : allocatedIds) {
urls.add(uriInfo.getBaseUri().resolve(RestUtils.getAbsoluteURL(id)));
}
return Response.ok(urls, MediaType.APPLICATION_JSON).build();
} catch (Exception e) {
LOGGER.debug("Error allocating", e);
return Response.serverError().entity(e.getMessage()).build();
}
}
Aggregations