Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
712:collector_data_rest_api [2025/09/15 20:46] – [Methods] Iseler, Marc712: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?direct }}+{{ :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.
Line 14: Line 14:
   * **License Usage** data collector: {{ :712:apicollector_licenseusage.zip |download-link}}   * **License Usage** data collector: {{ :712:apicollector_licenseusage.zip |download-link}}
   * **All Roles** data collector: {{ :712:apicollector_allroles.zip |download-link}}   * **All Roles** data collector: {{ :712:apicollector_allroles.zip |download-link}}
-  * **All Roles with associated Activities** data collector: download-link+  * **All Roles with associated Activities** data collector: {{ :712:apicollector_allroleswithactivities.zip |download-link}}
  
 ==== Installation and Deployment ==== ==== Installation and Deployment ====
   * Configure server for API token generation (see [[712:api-tokens]])   * Configure server for API token generation (see [[712:api-tokens]])
   * 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 39: 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:
  
-<code>+<code bash>
 curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/licenseUsage" curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/licenseUsage"
 </code> </code>
Line 45: Line 46:
 The result may look like the following example: The result may look like the following example:
  
-<code>+<code javascript>
 { {
     "workspaceId": "1",     "workspaceId": "1",
Line 94: Line 95:
 With the following command you then can query for the list of all Roles of //all Workspaces//: With the following command you then can query for the list of all Roles of //all Workspaces//:
  
-<code>+<code bash>
 curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/allRoles" curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/allRoles"
 </code> </code>
Line 100: Line 101:
 To query the list of roles for a specific workspace add the workspace ID as additional parameter: To query the list of roles for a specific workspace add the workspace ID as additional parameter:
  
-<code>+<code bash>
 curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/allRoles/65" curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/allRoles/65"
 </code> </code>
Line 106: Line 107:
 The result may look like the following example: The result may look like the following example:
  
-<code>+<code javascript>
 { {
         "workspaceId": "65",         "workspaceId": "65",
Line 125: Line 126:
 ==== All Roles with associated Activities ==== ==== All Roles with associated Activities ====
  
-This data collector provides a list of all roles contained in the valid version of a workspace. Every role entry shows the associated Activities grouped by the RASIC-association type. +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 the data collection script, extract the .js-file and create an Admin Job with the following properties to update the list of roles every Friday night:+To deploy this, download the data collection script, extract the .js-file and modify the following line adjusted to your workspace hierarchy. The script will process recursively all workspaces below this given workspace: 
 + 
 +<code javascript> 
 +const projectPath = "Company|Samples|Programs and Projects"; 
 +</code> 
 + 
 +Then create an Admin Job with the following properties to update the list of roles every Friday night:
  
 <code> <code>
Line 137: Line 144:
 With the following command you then can query for the list of all Roles with Activities for Workspace with ID 65: With the following command you then can query for the list of all Roles with Activities for Workspace with ID 65:
  
-<code>+<code bash>
 curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/allRolesWithActivities/65" curl -H "Authorization: Bearer <accessToken>" "<stages-URL>/stages/api/1/collectordata/allRolesWithActivities/65"
 </code> </code>
Line 143: Line 150:
 The result may look like the following example: The result may look like the following example:
  
-<code>+<code javascript>
 ... ...
 "allRoles": [ "allRoles": [
Line 163: Line 170:
         },...         },...
 </code> </code>
- 
- 
-==== Data Population via Administrative Jobs ==== 
- 
-The data is populated in the REST API endpoint through the execution of [[:712:admin_jobs|Administrative Jobs]] scripts. Each Admin job is designed to handle a specific use case, exporting relevant data and storing it at the endpoint for retrieval. 
- 
-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. 
  
  
Line 191: Line 191:
 GET /stages/api/1/collectordata/{key} GET /stages/api/1/collectordata/{key}
 </code> </code>
 +
 +==== Creating customized REST endpoints ====
 +
 +The data is populated in the REST API endpoint through the execution of [[:712:admin_jobs|Administrative Jobs]] scripts. Each Admin job is designed to handle a specific use case, exporting relevant data and storing it at the endpoint for retrieval.
 +
 +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.
 +
 +For customizing data collector scripts on your own you can find the comprehensive Stages internal API documentation on the Administration Start page > section "Further information".
 +
 ==== Example ==== ==== Example ====
  
Line 208: Line 217:
 === Reading the data (single value) === === Reading the data (single value) ===
  
-<code ->+<code>
 GET /stages/api/1/collectordata/demoKey/1 GET /stages/api/1/collectordata/demoKey/1
 </code> </code>
Line 222: Line 231:
 === Reading the data (multiple records) === === Reading the data (multiple records) ===
  
-<code ->+<code>
 GET /stages/api/1/collectordata/demoKey?wsFilter=1&wsFilter=2 GET /stages/api/1/collectordata/demoKey?wsFilter=1&wsFilter=2
 </code> </code>