Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knet Updates. Workflow updates #389

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading