IafDataSource
Use the IafDataSources API to manage orchestrators and their components, schedules, runs, and permissions on the platform.
createOrchestrator#
Creates an orchestrator when you pass an Orchestrator class object you define.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchestrator | Yes | Object | Define an object based on the Orchestrator class properties. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Orchestrator> - A promise with the Orchestrator object
let activemqOrchReqPayload = { _name: "ActiveMQ Publish Message", _description: "ActiveMQ Publish Message", _namespaces: _namespaces, _userType: "activemq_publish", _instant: true, _params: { tasks: [ { name: "default_script_target", _sequenceno: 1, TelemetryCollectionId: telCollections._id, sensorId: "e3e052f9-0156-11d5-9301-0000863f27ad-00000131", _actualparams: { userType: "orchestrator", _scriptName: "IotSensorData", }, }, { name: "activemq_target", _sequenceno: 2, _actualparams: { activemq: {}, topic: "VirtualTopic/" + _namespaces, }, }, ], },}; const activemqOrchRes = await IafDataSource.createOrchestrator( activemqOrchReqPayload, ctx);createOrchestratorSchedule#
Creates an orchestrator schedule.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchestratorSchedule | Yes | OrchestratorSchedule | Pass an OrchestratorSchedule object. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<OrchestratorSchedule> - A promise with the OrchestratorSchedule object
const req = { _orchid: orch.id, runinterval: "* * 300" };
const schedule = await IafDataSource.createOrchestratorSchedule(req, ctx);createPermissions#
Creates permissions for an orchestrator resource in the datasource service. If the permission doesn't exist, the method creates it. To identify if a permission exists, the method checks the the following fields: _resourceDesc, _namespace, _user.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<Permission> | Pass an array of your Permission objects. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<CreatePermissionsResponse> - Returns a CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions
// Permissions with mandatory fieldslet permissions = [{ _actions: [ IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete], _namespace: project.namespaces[0], _resourceDesc:{ _irn: IafPermission.OrchestratorIrnInit }, _user:{ _id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup id, specify respective _type _type: IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id }}];
let result = await IafDatasourceSvc.createPermissions(permissions, ctx);deleteOrchestrator#
Deletes an Orchestrator class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchId | Yes | String | The Orchestrator's id |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<String> - ok: 204 response
let allDatasources = await IafDataSource.getOrchestrators();let IotDataSource = allDatasources._list.find( (item) => item._userType === "activemq_publish");
if (IotDataSource) { // Delete active mq orchestrator let res = await IafDataSource.deleteOrchestrator( IotDataSource.id );}deleteOrchestratorSchedule#
Deletes an OrchestratorSchedule class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchestratorScheduleId | Yes | String | The OrchestratorSchedule's id |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<String> - ok: 204 response
const result = await IafDataSource.deleteOrchestratorSchedule(orch.id);deletePermission#
Deletes a Permission when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The permission's id |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<String> - ok:204 response
const result = await IafDatasourceSvc.deletePermission(permission._id, ctx);executeFetchOrchestrator#
Executes a fetch orchestrator with a REST connector component.
| Parameter | Required | Type | Description |
|---|---|---|---|
| params | No | Object | Pass an object that contains your rest connector component's parameters and values. |
| ctx | No | Context | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Object> - Returns an object with the orchestrator run result
let params = { _url: "<url>", _auth: { _type: "NoAuth" }, to: "json"}
let response = IafDataSource.executeFetchOrchestrator(params, ctx);
// Sample responseresponse = { rest_conn_result: {}}getOrchestrator#
Gets an Orchestrator class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchId | Yes | String | Orch UUID |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Orchestrator> - A promise with the Orchestrator class object
const orchestrator = await IafDataSource.getOrchestrator(orchId);getOrchestratorBasedOnUserType#
Filters Orchestrator objects based on userType.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userType | Yes | string | Enter the userType. |
| ctx | No | any | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Array - Returns an array of orchestrators that match your query.
const orchs = await getOrchestratorBasedOnUserType("my-orch-user-type", ctx);getOrchestratorComponent#
Gets OrchestratorComponent class objects by id
| Parameter | Required | Type | Description |
|---|---|---|---|
| componentid | Yes | String | OrchComponent UUID |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
const orchComponent = await IafDataSource.getOrchestratorComponent(componentid, ctx);getOrchestratorComponents#
Gets an Orchestrator class object's components or the components that match the criteria you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | JSONObject | Pass an object with your page response options and key-pair queries to filter orchestrator runs by start date, end date, or status. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
| options | No | Options | For page response options, pass an Options object with "_offset" or "_pageSize". |
Promise<OrchComponent> - A promise with the Orchestrator object
const orchComponent = await IafDataSource.getOrchestratorComponent(ctx);
//returns{ "id": "string", "_name": "string", "_description": "string", "_versionnumber": "number", "_formalparams": "any", "kinds": "OrchCompKinds"}getOrchestratorRunLogs#
Gets the logs of an orchestrator run.
| Parameter | Required | Type | Description |
|---|---|---|---|
| runId | Yes | String | |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
| criteria | No | JSONObject | Pass an object with your page response options and key-pair queries to filter orchestrator runs by start date, end date, or status. |
| parsingFunction | No | Function | it uses built-in defaultOrchRunLogParsingFunction as the default one, the client code can also provide its own when things change |
Promise<OrchRunLog> - A promise with an array ofthe OrchRunLog object
const criteria = { _pageSize: 10, _offset: 0, _status: COMPLETED, startDate: 1675839681115, endDate: 1675839758115 };
const orchRunLogs = await IafDataSource.getOrchestratorRunLogs(runId, ctx, criteria);getOrchestratorRuns#
Gets orchestrator runs that match criteria you pass as OrchRun class objects.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
| criteria | No | JSONObject | Pass an object with your page response options and key-pair queries to filter orchestrator runs by start date, end date, or status. |
Promise<OrchRun> - A promise with the OrchRun object
const criteria = { _pageSize: 10, _offset: 0, _status: COMPLETED, startDate: 1675839681115, endDate: 1675839758115 };
const orchRuns = await IafDataSource.getOrchestratorRuns(ctx, criteria);getOrchestrators#
Gets all Orchestrator class objects or those that match criteria you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | OrchCriteria | Pass an OrchCriteria class object that contains your simple query. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
| options | No | Options | For page response options, pass an Options class object with "_offset" or "_pageSize". |
Promise<Page<Orchestrator>> - A promise with a page of Orchestrator objects
const allOrchs = await IafDataSource.getOrchestrators();
//returns{ "id": "string", "_name": "string", "_description": "string", "_namespaces": "any", "_usertype": "string", "_createdby": "string", "_createdat": "number", "_updatedby": "string", "_updatedat": "number", "_isrunning": "boolean", "_class": "number", "orchsteps": "OrchStep[]", "_orchschedule": "OrchSchedule",}getOrchestratorSchedule#
Gets an Orchestrator's schedule when you pass the schedule's id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchScheduleId | Yes | String | The orchestrator schedule's id |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Orchestrator> - A promise with the Orchestrator object
const orchSchedule = await IafDataSource.getOrchestratorSchedule(orchScheduleId);
//returns{ "id": "string", "_name": "string", "_description": "string", "_namespaces": "any", "_usertype": "string", "_createdby": "string", "_createdat": "number", "_updatedby": "string", "_updatedat": "number", "_isrunning": "boolean", "_class": "number", "orchsteps": "OrchStep[]", "_orchschedule": "OrchSchedule"}getOrchestratorSchedules#
Gets orchestrator schedules.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
const orchSchedules = await IafDataSource.getOrchestratorSchedules(ctx);getOrchRunStatus#
Gets an orchestrator run's status when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| runid | Yes | String | The OrchRun object's id |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<OrchRun> - A promise with an OrchRun object
const orchRun = await IafDataSource.getOrchRunStatus(RunId, ctx);
//returns{ "id": "string", "_orchid": "string", "_name": "string", "_description": "string", "_namespaces": "any", "_usertype": "string", "_createdby": "string", "_createdat": "number", "_updatedat": "number", "_status": "string", "_context": "string", "orch_schedule_id": "string", "_duration": "number", "_instanceid": "string", "orchrunsteps": "OrchRunStep[]", "_result?"": 'any"}getPermissions#
Gets Permission objects for an Orchestrator resource in the Datasource Service. If the permission doesn't exist, the method creates it. To identify if a permission exists, the method checks the the following fields: _resourceDesc, _namespace, _user.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | PermissionCriteria | Pass a PermissionCriteria object with your criteria. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Page<Permission>> - A promise with a page of Permission objects that match your criteria
const criteria = { _namespace: usergroup._userAttributes.project_workspace._namespaces,};
const namespacePermissions = await IafDatasourceSvc.getPermissions(criteria, ctx);runOrchestrator#
Posts an orchestrator run as an OrchRun class object when you pass an Orchestrator object's id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchId | Yes | String | The Orchestrator's id |
| params | Yes | String | Pass an object with the actual parameters you want to pass to the orchestrator as key-value pairs. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<True/False> - Returns a promise with a Boolean true or false
let runRequest = { orchestratorId: orch.id, _actualparams: { userType: "orchestrator", _scriptName: "MyScriptName", },};
const orchRun = await PlatformApi.IafDataSource.runOrchestrator( orch.id, runRequest, ctx);setupFetchOrchestrator#
Sets up a fetch orchestrator with a REST connector component.
| Parameter | Required | Type | Description |
|---|---|---|---|
| params | Yes | Object | Pass an object that contains your rest connector component's parameters and values. |
| permissions | No | Array<Permission> | To give the orchestrator permissions, pass a Permission object. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Orchestrator> - A promise with the Orchestrator object
let params = { _url: "<url>", _auth: { _type: "NoAuth" }, to: "json"};
let permissions = [ { _namespace: "kingspan_L65OJDGN", _actions: ["READ", "RUN"], _user: { _id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup id, specify respective _type _type: IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id } }];
const orch = IafDataSource.setupFetchOrchestrator(params, ctx);
//returns{ "id": "string", "_name": "string", "_description": "string", "_namespaces": "any", "_usertype": "string", "_createdby": "string", "_createdat": "number", "_updatedby": "string", "_updatedat": "number", "_isrunning": "boolean", "_class": "number", "orchsteps": "OrchStep[]", "_orchschedule": "OrchSchedule"}updateOrchestrator#
Updates an orchestrator to the Orchestrator class object you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchestratorId | Yes | String | Pass the id of the Orchestrator you want to update |
| orchestrator | Yes | Object | Pass your updated Orchestrator object. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Orchestrator> - A promise with the Orchestrator object
let orch = await IafDataSource.getOrchestrator(orchId);
orch._name = "update name";
const updatedOrch = await IafDataSources.updateOrchestrator(orch.id, orch);updateOrchestratorRun#
Updates an orchestrator run when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchestratorRunId | Yes | String | The OrchRun object's id |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
const updatedOrchRun = await IafDataSource.updateOrchestratorRun(orchestratorRunId, ctx);updateOrchestratorSchedule#
Updates an OrchestratorSchedule class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| orchestratorScheduleId | Yes | String | The OrchestratorSchedule's id |
| orchestratorSchedule | Yes | OrchestratorSchedule | Pass your updated OrchestratorSchedule object. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<OrchestratorRun> - A promise with the updated OrchestratorRun object
const orchSchedule = await IafDataSource.getOrchestratorSchedule(orchScheduleId);orchSchedule.runinterval = "* * 100";
const updatedOrchSchedule = await IafDataSource.updateOrchestratorSchedule(orchSchedule.id, orchSchedule, ctx);updatePermissions#
Updates permissions for an Orchestrator resource in the Datasources Service.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<Permission> | Pass an array with your updated Permissions objects. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<CreatePermissionsResponse> - Returns a CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions
const criteria = { _actions: usergroup._userAttributes.project_workspace._namespaces,};
const namespacePermissions = await IafDatasourceSvc.getPermissions(criteria, ctx);