Search in sources :

Example 1 with Allocation

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();
    }
}
Also used : Allocation(org.eclipse.winery.repository.targetallocation.Allocation) ArrayList(java.util.ArrayList) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) URI(java.net.URI) InvalidParameterException(java.security.InvalidParameterException) IOException(java.io.IOException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) POST(javax.ws.rs.POST)

Aggregations

IOException (java.io.IOException)1 URI (java.net.URI)1 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)1 Allocation (org.eclipse.winery.repository.targetallocation.Allocation)1