import { invokeApi } from './cumulusApiClient'; import { ApiGatewayLambdaHttpProxyResponse, InvokeApiFunction } from './types'; /** * Fetch a workflow from the Cumulus API * * @param {Object} params - params * @param {string} params.prefix - the prefix configured for the stack * @param {string} params.workflowName * @param {Function} params.callback - async function to invoke the api lambda * that takes a prefix / user payload. Defaults * to cumulusApiClient.invokeApi * @returns {Promise} - promise that resolves to the output * of the API lambda */ export const getWorkflow = async (params: { prefix: string, workflowName: string, callback?: InvokeApiFunction }): Promise => { const { prefix, workflowName, callback = invokeApi } = params; return await callback({ prefix, payload: { httpMethod: 'GET', resource: '/{proxy+}', path: `/workflows/${workflowName}`, }, }); }; /** * Fetch a list of workflows from the Cumulus API * * @param {Object} params - params * @param {string} params.prefix - the prefix configured for the stack * @returns {Promise} - the list of workflows fetched by the API */ export const getWorkflows = async (params: { prefix: string, query?: { fields?: string[], [key: string]: string | string[] | undefined }, callback?: InvokeApiFunction }): Promise => { const { prefix, query, callback = invokeApi } = params; return await callback({ prefix: prefix, payload: { httpMethod: 'GET', resource: '/{proxy+}', path: '/workflows', queryStringParameters: query, }, }); };