Search in sources :

Example 6 with LinkParameter

use of org.eclipse.che.api.core.rest.shared.dto.LinkParameter in project che by eclipse.

the class MachineLinksInjector method injectLinks.

public MachineDto injectLinks(MachineDto machine, ServiceContext serviceContext) {
    final List<Link> links = new ArrayList<>();
    injectTerminalLink(machine, serviceContext, links);
    injectExecAgentLink(machine, serviceContext, links);
    // add workspace channel links
    final Link workspaceChannelLink = createLink("GET", serviceContext.getBaseUriBuilder().path("ws").scheme("https".equals(serviceContext.getBaseUriBuilder().build().getScheme()) ? "wss" : "ws").build().toString(), null);
    final LinkParameter channelParameter = newDto(LinkParameter.class).withName("channel").withRequired(true);
    links.add(cloneDto(workspaceChannelLink).withRel(LINK_REL_ENVIRONMENT_OUTPUT_CHANNEL).withParameters(singletonList(cloneDto(channelParameter).withDefaultValue(format(ENVIRONMENT_OUTPUT_CHANNEL_TEMPLATE, machine.getWorkspaceId())))));
    links.add(cloneDto(workspaceChannelLink).withRel(ENVIRONMENT_STATUS_CHANNEL_TEMPLATE).withParameters(singletonList(cloneDto(channelParameter).withDefaultValue(format(ENVIRONMENT_STATUS_CHANNEL_TEMPLATE, machine.getWorkspaceId())))));
    return machine.withLinks(links);
}
Also used : LinkParameter(org.eclipse.che.api.core.rest.shared.dto.LinkParameter) ArrayList(java.util.ArrayList) Link(org.eclipse.che.api.core.rest.shared.dto.Link) LinksHelper.createLink(org.eclipse.che.api.core.util.LinksHelper.createLink)

Aggregations

Link (org.eclipse.che.api.core.rest.shared.dto.Link)6 LinkParameter (org.eclipse.che.api.core.rest.shared.dto.LinkParameter)6 ArrayList (java.util.ArrayList)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 GenerateLink (org.eclipse.che.api.core.rest.annotations.GenerateLink)2 LinksHelper.createLink (org.eclipse.che.api.core.util.LinksHelper.createLink)2 Annotation (java.lang.annotation.Annotation)1 URI (java.net.URI)1 LinkedList (java.util.LinkedList)1 Consumes (javax.ws.rs.Consumes)1 DefaultValue (javax.ws.rs.DefaultValue)1 HttpMethod (javax.ws.rs.HttpMethod)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 QueryParam (javax.ws.rs.QueryParam)1 Description (org.eclipse.che.api.core.rest.annotations.Description)1 Required (org.eclipse.che.api.core.rest.annotations.Required)1 Valid (org.eclipse.che.api.core.rest.annotations.Valid)1 RequestBodyDescriptor (org.eclipse.che.api.core.rest.shared.dto.RequestBodyDescriptor)1 BeforeTest (org.testng.annotations.BeforeTest)1