#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package};
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.SecurityContext;
import org.codehaus.enunciate.jaxrs.StatusCodes;
import org.codehaus.enunciate.jaxrs.TypeHint;
/**
* Northbound REST API
*
*
*
* Authentication scheme : HTTP Basic
* Authentication realm : opendaylight
* Transport : HTTP and HTTPS
*
* HTTPS Authentication is disabled by default.
*/
@Path("/")
public class Northbound {
private String username;
@Context
public void setSecurityContext(SecurityContext context) {
if (context != null && context.getUserPrincipal() != null) {
username = context.getUserPrincipal().getName();
}
}
/**
*
* Sample REST API call
*
* @return A response string
*
*
* Example: * * Request URL: * http://localhost:8080/northbound/${artifactId}/api * * Response body in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> * Sample Northbound API * * Response body in JSON: * Sample Northbound API **/ @Path("/api") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(String.class) @StatusCodes() public String getWidget() { String result = "Sample Northbound API - ${artifactId}"; return result; } }