...
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.
Creating the project entity
When starting with project creation, the first token to create could be
...
Code Block | ||
---|---|---|
| ||
{ "relatedId": "project1", "key": "key_words", "value": "[\"eggsfoo\", \"hambar\"]" } |
Creating the product entity
We can start creating the product entity by giving it a name.
Code Block | ||
---|---|---|
| ||
{
"relatedId": "product1",
"key": "name",
"value": "apples"
} |
After creating the product, we can create a token to represent the relation between the product and the project.
Code Block | ||
---|---|---|
| ||
{ "relatedId": "product1", "key": "project", "value": "project1" } |
User Account Private Token Store
This Token Store is conceptually different. It may be accessed both with Management API Client permissions, or with signed-in user account permissions. These tokens are private to the user account. Unlike Management API Client private tokens, these tokens may be shared between applications and services. To do that, ACLs must be defined. Se here for more information.
...
Creating the employee entity
The employee is a simple entity with id, name and email address. We will start by creating a token with a name.
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.doe@example.com"
} |
After we have the basic object created, we can create the relation between the employee and the project:
Code Block | ||
---|---|---|
| ||
{
"relatedId": "employee1",
"key": "project",
"value": "[\"project1\"]"
} |
If the employee is part of many projects, then we can append the project IDs to the list.
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.