Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
712:collector_data_rest_api [2025/09/15 08:43] – [Ready to use REST API Data collectors] Iseler, Marc | 712:collector_data_rest_api [2025/09/24 14:50] (current) – Filpes, Claudia | ||
---|---|---|---|
Line 5: | Line 5: | ||
To use a REST API endpoint a Stages User needs to install a respective Data collector first. By default there are no REST endpoints available. A data collector is technically realized via an Admin Job. Every Admin Job is populating exactly one REST endpoint. | To use a REST API endpoint a Stages User needs to install a respective Data collector first. By default there are no REST endpoints available. A data collector is technically realized via an Admin Job. Every Admin Job is populating exactly one REST endpoint. | ||
- | {{:712:datacollectorprocess.png?400|}} | + | {{ :712:data_collector_process.png?direct |
The framework allows to retrieve data for one or more workspaces in one call. Every call always requires an API token which is equipped with sufficient permissions to access the data provided by a REST API endpoint. | The framework allows to retrieve data for one or more workspaces in one call. Every call always requires an API token which is equipped with sufficient permissions to access the data provided by a REST API endpoint. | ||
+ | |||
==== Ready to use REST API Data collectors ==== | ==== Ready to use REST API Data collectors ==== | ||
Line 13: | Line 14: | ||
* **License Usage** data collector: {{ : | * **License Usage** data collector: {{ : | ||
* **All Roles** data collector: {{ : | * **All Roles** data collector: {{ : | ||
- | * **All Roles with associated Activities** data collector: download-link | + | * **All Roles with associated Activities** data collector: |
==== Installation and Deployment ==== | ==== Installation and Deployment ==== | ||
* Configure server for API token generation (see [[712: | * Configure server for API token generation (see [[712: | ||
* As a user with MODEL-license create an API token in User Settings > Security and Privacy | * As a user with MODEL-license create an API token in User Settings > Security and Privacy | ||
+ | * when the API token is used a user-session for this user is created and a user-license is used | ||
* The user needs to be equipped at least with the permission | * The user needs to be equipped at least with the permission | ||
* Domain: Collector Data | * Domain: Collector Data | ||
Line 38: | Line 40: | ||
With the following command you then can query for the current license usage: | With the following command you then can query for the current license usage: | ||
- | < | + | < |
curl -H " | curl -H " | ||
</ | </ | ||
Line 44: | Line 46: | ||
The result may look like the following example: | The result may look like the following example: | ||
- | < | + | < |
{ | { | ||
" | " | ||
Line 79: | Line 81: | ||
</ | </ | ||
- | ==== Data Population via Administrative Jobs ==== | + | ==== All Roles ==== |
- | The data is populated | + | This data collector provides a list of all roles contained |
+ | To deploy this download | ||
- | {{:712:datacollectorprocess.png?400|}} | + | < |
+ | Name: Data Collector - allRoles | ||
+ | Cron Expression: 0 0 23 ? * FRI | ||
+ | </ | ||
- | These Admin job scripts are fully customizable, and additional scripts can be developed to support new use cases. Please contact one of our consultants to customize scripts for your specific needs. | + | Make sure the API token user owns the permissions: |
+ | With the following command you then can query for the list of all Roles of //all Workspaces//: | ||
+ | <code bash> | ||
+ | curl -H " | ||
+ | </ | ||
- | ==== Methods ==== | + | To query the list of roles for a specific workspace add the workspace ID as additional parameter: |
- | * Classes and methods for writing data are described in the JavaScript API documentation (link inside Stages on Administration Page > Further Information) | + | <code bash> |
+ | curl -H " | ||
+ | </code> | ||
- | '' | + | The result may look like the following example: |
- | Returns the single JSON value that was stored for the given key and workspace | + | <code javascript> |
+ | { | ||
+ | " | ||
+ | "value": { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | '' | + | ==== All Roles with associated Activities ==== |
- | Returns the list of scoped key-value pairs for the given key and the workspaces with the given IDs. When the list of workspace IDs is empty, all matching key-value pairs will be returned. A scoped key-value pair is a JSON object with the following | + | This data collector provides a list of all roles contained in the valid version of a workspace (ignores Reference models). Every role entry shows the associated Activities grouped by the RASIC-association type. |
+ | To deploy this, download | ||
- | | + | <code javascript> |
- | * '' | + | const projectPath = " |
+ | </ | ||
+ | |||
+ | Then create an Admin Job with the following properties to update the list of roles every Friday night: | ||
+ | |||
+ | < | ||
+ | Name: Data Collector - allRolesWithActivities | ||
+ | Cron Expression: 0 0 23 ? * FRI | ||
+ | </ | ||
+ | |||
+ | Make sure the API token user owns the permissions: | ||
+ | |||
+ | With the following command you then can query for the list of all Roles with Activities for Workspace with ID 65: | ||
+ | |||
+ | <code bash> | ||
+ | curl -H " | ||
+ | </ | ||
+ | |||
+ | The result may look like the following example: | ||
+ | |||
+ | <code javascript> | ||
+ | ... | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | },... | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Data Retrieval via http GET ==== | ||
+ | |||
+ | Query a single JSON value that was stored for the given key and workspace ID: | ||
+ | |||
+ | < | ||
+ | GET / | ||
+ | </ | ||
+ | |||
+ | Query JSON-data-structures for multiple workspaces at once which returns the list of scoped key-value pairs for the given key and the workspaces with the given IDs | ||
+ | |||
+ | < | ||
+ | GET / | ||
+ | </ | ||
+ | |||
+ | Querying a data-collector without specifying one or multiple workspaces returns all available JSON data structures | ||
+ | |||
+ | < | ||
+ | GET / | ||
+ | </ | ||
+ | |||
+ | ==== Creating customized REST endpoints ==== | ||
+ | |||
+ | The data is populated in the REST API endpoint through the execution of [[: | ||
+ | |||
+ | These Admin job scripts are fully customizable, | ||
+ | For customizing data collector scripts on your own you can find the comprehensive Stages internal API documentation on the Administration Start page > section " | ||
==== Example ==== | ==== Example ==== | ||
Line 122: | Line 217: | ||
=== Reading the data (single value) === | === Reading the data (single value) === | ||
- | < | + | < |
GET / | GET / | ||
</ | </ | ||
Line 136: | Line 231: | ||
=== Reading the data (multiple records) === | === Reading the data (multiple records) === | ||
- | < | + | < |
GET / | GET / | ||
</ | </ |