Skip to main content
Version: v5.0

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.

ParameterRequiredTypeDescription
orchestratorYesObjectDefine an object based on the Orchestrator class properties.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Orchestrator> - A promise with the Orchestrator object

Examples
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.

ParameterRequiredTypeDescription
orchestratorScheduleYesOrchestratorSchedulePass an OrchestratorSchedule object.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<OrchestratorSchedule> - A promise with the OrchestratorSchedule object

Examples
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.

ParameterRequiredTypeDescription
permissionsYesArray<Permission>Pass an array of your Permission objects.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<CreatePermissionsResponse> - Returns a CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions

Examples
// 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.

ParameterRequiredTypeDescription
orchIdYesStringThe Orchestrator's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<String> - ok: 204 response

Examples
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.

ParameterRequiredTypeDescription
orchestratorScheduleIdYesStringThe OrchestratorSchedule's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<String> - ok: 204 response

Examples
const result = await IafDataSource.deleteOrchestratorSchedule(orch.id);

deletePermission#

Deletes a Permission when you pass its id.

ParameterRequiredTypeDescription
idYesStringThe permission's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<String> - ok:204 response

Examples
const result = await IafDatasourceSvc.deletePermission(permission._id, ctx);

executeFetchOrchestrator#

Executes a fetch orchestrator with a REST connector component.

ParameterRequiredTypeDescription
paramsNoObjectPass an object that contains your rest connector component's parameters and values.
ctxNoContextContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Object> - Returns an object with the orchestrator run result

Examples
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.

ParameterRequiredTypeDescription
orchIdYesStringOrch UUID
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Orchestrator> - A promise with the Orchestrator class object

Examples
const orchestrator = await IafDataSource.getOrchestrator(orchId);

getOrchestratorBasedOnUserType#

Filters Orchestrator objects based on userType.

ParameterRequiredTypeDescription
userTypeYesstringEnter the userType.
ctxNoanyContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Array - Returns an array of orchestrators that match your query.

Examples
const orchs = await getOrchestratorBasedOnUserType("my-orch-user-type", ctx);

getOrchestratorComponent#

Gets OrchestratorComponent class objects by id

ParameterRequiredTypeDescription
componentidYesStringOrchComponent UUID
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<OrchComponent> -

Examples
const orchComponent = await IafDataSource.getOrchestratorComponent(componentid, ctx);

getOrchestratorComponents#

Gets an Orchestrator class object's components or the components that match the criteria you pass.

ParameterRequiredTypeDescription
criteriaNoJSONObjectPass an object with your page response options and key-pair queries to filter orchestrator runs by start date, end date, or status.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsNoOptionsFor page response options, pass an Options object with "_offset" or "_pageSize".
Returns

Promise<OrchComponent> - A promise with the Orchestrator object

Examples
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.

ParameterRequiredTypeDescription
runIdYesString
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
criteriaNoJSONObjectPass an object with your page response options and key-pair queries to filter orchestrator runs by start date, end date, or status.
parsingFunctionNoFunctionit uses built-in defaultOrchRunLogParsingFunction as the default one, the client code can also provide its own when things change
Returns

Promise<OrchRunLog> - A promise with an array ofthe OrchRunLog object

Examples
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.

ParameterRequiredTypeDescription
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
criteriaNoJSONObjectPass an object with your page response options and key-pair queries to filter orchestrator runs by start date, end date, or status.
Returns

Promise<OrchRun> - A promise with the OrchRun object

Examples
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.

ParameterRequiredTypeDescription
criteriaNoOrchCriteriaPass an OrchCriteria class object that contains your simple query.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsNoOptionsFor page response options, pass an Options class object with "_offset" or "_pageSize".
Returns

Promise<Page<Orchestrator>> - A promise with a page of Orchestrator objects

Examples
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.

ParameterRequiredTypeDescription
orchScheduleIdYesStringThe orchestrator schedule's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Orchestrator> - A promise with the Orchestrator object

Examples
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.

ParameterRequiredTypeDescription
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<OrchScheduleDTO> -

Examples
const orchSchedules = await IafDataSource.getOrchestratorSchedules(ctx);

getOrchRunStatus#

Gets an orchestrator run's status when you pass its id.

ParameterRequiredTypeDescription
runidYesStringThe OrchRun object's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<OrchRun> - A promise with an OrchRun object

Examples
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.

ParameterRequiredTypeDescription
criteriaYesPermissionCriteriaPass a PermissionCriteria object with your criteria.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Page<Permission>> - A promise with a page of Permission objects that match your criteria

Examples
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.

ParameterRequiredTypeDescription
orchIdYesStringThe Orchestrator's id
paramsYesStringPass an object with the actual parameters you want to pass to the orchestrator as key-value pairs.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<True/False> - Returns a promise with a Boolean true or false

Examples
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.

ParameterRequiredTypeDescription
paramsYesObjectPass an object that contains your rest connector component's parameters and values.
permissionsNoArray<Permission>To give the orchestrator permissions, pass a Permission object.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Orchestrator> - A promise with the Orchestrator object

Examples
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.

ParameterRequiredTypeDescription
orchestratorIdYesStringPass the id of the Orchestrator you want to update
orchestratorYesObjectPass your updated Orchestrator object.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Orchestrator> - A promise with the Orchestrator object

Examples
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.

ParameterRequiredTypeDescription
orchestratorRunIdYesStringThe OrchRun object's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<OrchestratorRunDTO> -

Examples
const updatedOrchRun = await IafDataSource.updateOrchestratorRun(orchestratorRunId, ctx);

updateOrchestratorSchedule#

Updates an OrchestratorSchedule class object.

ParameterRequiredTypeDescription
orchestratorScheduleIdYesStringThe OrchestratorSchedule's id
orchestratorScheduleYesOrchestratorSchedulePass your updated OrchestratorSchedule object.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<OrchestratorRun> - A promise with the updated OrchestratorRun object

Examples
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.

ParameterRequiredTypeDescription
permissionsYesArray<Permission>Pass an array with your updated Permissions objects.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<CreatePermissionsResponse> - Returns a CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions

Examples
const criteria = {  _actions: usergroup._userAttributes.project_workspace._namespaces,};
const namespacePermissions = await IafDatasourceSvc.getPermissions(criteria, ctx);