UNPKG

@cumulus/api-client

Version:

API client for working with the Cumulus archive API

55 lines (50 loc) 1.72 kB
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<Object>} - promise that resolves to the output * of the API lambda */ export const getWorkflow = async (params: { prefix: string, workflowName: string, callback?: InvokeApiFunction }): Promise<ApiGatewayLambdaHttpProxyResponse> => { 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<Object>} - the list of workflows fetched by the API */ export const getWorkflows = async (params: { prefix: string, callback?: InvokeApiFunction }): Promise<ApiGatewayLambdaHttpProxyResponse> => { const { prefix, callback = invokeApi } = params; return await callback({ prefix: prefix, payload: { httpMethod: 'GET', resource: '/{proxy+}', path: '/workflows', }, }); };