Junos Space SDK > Developer Guides > Junos Space Application Developer Guide > Programming with the Junos Space SDK > Developing Junos Space Applications > Creating REST Services

Adding REST Resources and Methods Manually

This topic describes the manual operation for adding REST resources and methods. Junos Space SDK allows you to add resources and methods as new API's.

Adding REST resources manually

If you are RESTifying a java interface directly without using the EJB-REST Wizard, you can add a new REST resource by creating the following two new REST resource files,

  1. REST interface
  2. REST implementation class
The REST interface will be containing a @Path() annotation at the top of interface file. When adding a new resource, ensure that the @Path() annotation at the top of the resource is unique. In case, it is not unique, your resource API will still function correctly. However, the HATEOAS links from the root of the resource, will not point to the new API you created.

Adding REST methods manually

When adding a REST method to an existing REST resource, manually, you have three alternatives:

  1. Add a new REST method directly to an existing resource. In this case, the REST Wizard will overwrite your new REST method, every time you go back to using the EJB-REST Wizard. However, the HATEOAS link from the root-level of the resource will still point to all your method API's for that resource.
  2. Create a new REST resource with the same top-level @Path() as an existing resource (see previous section on adding REST resources manually), and add the new REST method directly into the new REST resource. This approach ensures that the REST Wizard will not overwrite your new REST method. However, the HATEOAS links from the root of the resource will not point to the new API you've just created. The /api/jssdk/hello-space/images API in the HelloSpace application, presents an example of this approach.
  3. Design your new API's in such a way that the new REST method does not share the same root path with the existing resource. This will ensure that the REST method will not overwrite the new resource, and the HATEOAS links will still work. This is the most desirable approach, but may not be easy to implement.