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

Overview of Tagging

A tag is a non-hierarchical keyword or term assigned to a piece of information (such as a user object or device object). This meta data helps describe an object and allows you to find the object by browsing or searching for it. Tags are selected by the object creators depending on the system. A tag can be:

Tagging Implementation on Objects

If a private tag 'myusers' is applied on two users (super and test) and filtering is done on the users' collection as given below:

/api/space/user-management/users?filter=(TAG eq 'myusers:private')

Output of the above request will be:

<users uri="/api/space/user-management/users"> 
 <user uri="/api/space/user-management/user/518">
  <method href="/api/space/user-management/email-user/518" desc="email this user"/>
 <user uri="/api/space/user-management/user/519">
  <method href="/api/space/user-management/email-user/519" desc="email this user"/>

To learn more about using a TAG keyword in a filter string, see Tag Management.

You can enable tagging of an object by adding a ManagedObject annotation to its entity object. For example:

import javax.persistence.*;
import net.juniper.jmp.metadata.OptimisticEntity;
import net.juniper.jmp.metadata.ManagedObject;

@Table(name = "USER", uniqueConstraints=@UniqueConstraint(columnNames={"name"}))
public class UserEntity extends OptimisticEntity 
  //Entity code

The platform will read this annotation while deploying the application and store it in the database. Any further request to tag any user object with URI '/api/space/user-management/users/{id}' will be understood by the platform.

Note: The URI attribute in the @ManagedObject annotation should be a URI to get a object from the primary collection. An object accessible in the secondary collection cannot be tagged.

For example, if a role object has to be tagged, the URI value should be /api/space/user-management/roles/{id}. If the URI specified is /api/space/user-management/users/{id}/roles/{id}, tagging will not work on this URI.