Skip to content

Commit

Permalink
Knet Updates. Workflow updates
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko committed Oct 2, 2024
1 parent 02a3663 commit 9999245
Show file tree
Hide file tree
Showing 2 changed files with 853 additions and 181 deletions.
118 changes: 118 additions & 0 deletions src/api/workflows/workflows.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@ export default class Workflows {
}
}

/**
* Adds a workflow action. Actions determine what the workflow will do when it is triggered.
*
* @memberof Workflows
* @param {string} id Workflow Id.
* @param {Object} body Workflows request body.
* @return {Promise<Object>} A promise to the Workflows response.
*/
async addAction(id, body) {
try {
const response = await post(
this.config.httpClient,
`${this.config.host}/workflows/${id}/actions/`,
this.config,
this.config.sk,
body
);
return await response.json;
} catch (err) {
const error = await determineError(err);
throw error;
}
}

/**
* Update a workflow action.
*
Expand All @@ -150,6 +174,53 @@ export default class Workflows {
}
}

/**
* Removes a workflow action. Actions determine what the workflow will do when it is triggered.
*
* @memberof Workflows
* @param {string} workflowId Workflow id.
* @param {string} workflowActionId Workflow action Id.
* @return {Promise<Object>} A promise to the Workflows response.
*/
async removeAction(workflowId, workflowActionId) {
try {
const response = await _delete(
this.config.httpClient,
`${this.config.host}/workflows/${workflowId}/actions/${workflowActionId}`,
this.config,
this.config.sk
);
return await response.json;
} catch (err) {
const error = await determineError(err);
throw error;
}
}

/**
* Adds a workflow condition. Conditions determine when the workflow will trigger.
*
* @memberof Workflows
* @param {string} id Workflow Id.
* @param {Object} body Workflows request body.
* @return {Promise<Object>} A promise to the Workflows response.
*/
async addCondition(id, body) {
try {
const response = await post(
this.config.httpClient,
`${this.config.host}/workflows/${id}/conditions/`,
this.config,
this.config.sk,
body
);
return await response.json;
} catch (err) {
const error = await determineError(err);
throw error;
}
}

/**
* Update a workflow condition.
*
Expand All @@ -175,6 +246,53 @@ export default class Workflows {
}
}

/**
* Removes a workflow condition. Conditions determine when the workflow will trigger.
*
* @memberof Workflows
* @param {string} workflowId Workflow id.
* @param {string} workflowConditionId Workflow condition Id.
* @return {Promise<Object>} A promise to the Workflows response.
*/
async removeCondition(workflowId, workflowConditionId) {
try {
const response = await _delete(
this.config.httpClient,
`${this.config.host}/workflows/${workflowId}/conditions/${workflowConditionId}`,
this.config,
this.config.sk
);
return await response.json;
} catch (err) {
const error = await determineError(err);
throw error;
}
}

/**
* Validate a workflow in our Sandbox environment.
*
* @memberof Workflows
* @param {string} id Workflow id.
* @param {Object} body Event types for which the workflow will execute.
* @return {Promise<Object>} A promise to the Workflows response.
*/
async test(id, body) {
try {
const response = await post(
this.config.httpClient,
`${this.config.host}/workflows/${id}/test`,
this.config,
this.config.sk,
body
);
return await response.json;
} catch (err) {
const error = await determineError(err);
throw error;
}
}

/**
* Get a list of sources and their events for building new workflows
*
Expand Down
Loading

0 comments on commit 9999245

Please sign in to comment.