...
Additionally, tokens can be used to hold complex arbitrary data structures as embedded JSON objects. The JSON objects have to be escaped when persisting.
Example: Mapping an entity relation to tokens
Mapping an entity relation to tokens may not be obvious at first. This section will walk through a simple example of mapping an entity relation model to tokens. The TIS Management API token endpoint is documented in the TIS instance's /apidoc
. See Management API for more detailed instructions on how to get the most current documentation for the Management API.
Consider the entity relations diagram above. There are projects, which has one or more products. The projects also have n employees assigned. Additionally, an employee can be assigned to m
projects. The project has an id, a human readable name and a list of key words. A product has an id and a name. An employee has an id, name and an email address.
...
Code Block | ||
---|---|---|
| ||
{
"relatedId": "employee1",
"key": "name",
"value": "John Doe"
} |
After that we may create a token with an email address.
Code Block | ||
---|---|---|
| ||
{ "relatedId": "employee1", "key": "email", "value": "john@examplejohn.doe@example.com" } |
After we have the basic object created, we can create the relation between the employee and the project:
...
The above steps can be repeated after all project employee info has been saved.
Querying objects
When we want to read the created objects, we will have to query them from the token endpoint.
Listing all tokens
Listing all tokens with filter support will be implemented soon.
Listing tokens based on relatedId and key
Tokens can be listed using the related id. This allows getting all properties for a single entity. For example, we could use the relatedId "employee1" to retrieve the name and email for the employee. Additionally, if we only want to fetch the name of the employee, we can get a single token by relatedId and key. Getting single tokens is extremely useful in situations where the size of the token is more than a few kilobytes.