UNPKG

@cumulus/api-client

Version:

API client for working with the Cumulus archive API

83 lines 3.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createReconciliationReport = exports.deleteReconciliationReport = exports.getReconciliationReport = void 0; const cumulusApiClient_1 = require("./cumulusApiClient"); /** * GET /reconciliationReports/{name} * * @param {Object} params - params * @param {string} params.prefix - the prefix configured for the stack * @param {string} params.name - report record name * @param {Function} params.callback - async function to invoke the api lambda * that takes a prefix / user payload. Defaults * to cumulusApiClient.invokeApifunction to invoke the * api lambda * @returns {Promise<Object>} - the report fetched by the API */ const getReconciliationReport = async (params) => { const { prefix, name, callback = cumulusApiClient_1.invokeApi, } = params; return await callback({ prefix: prefix, payload: { httpMethod: 'GET', resource: '/{proxy+}', path: `/reconciliationReports/${name}`, }, }); }; exports.getReconciliationReport = getReconciliationReport; /** * Delete a reconciliation report from Cumulus via the API lambda * DELETE /reconciliationReports/${name} * * @param {Object} params - params * @param {string} params.prefix - the prefix configured for the stack * @param {string} params.name - report record name * @param {Function} params.callback - async function to invoke the api lambda * that takes a prefix / user payload. Defaults * to cumulusApiClient.invokeApi function to invoke the * api lambda * @returns {Promise<Object>} - the delete confirmation from the API */ const deleteReconciliationReport = async (params) => { const { prefix, name, callback = cumulusApiClient_1.invokeApi } = params; return await callback({ prefix: prefix, payload: { httpMethod: 'DELETE', resource: '/{proxy+}', path: `/reconciliationReports/${name}`, }, }); }; exports.deleteReconciliationReport = deleteReconciliationReport; /** * Post a request to the reconciliationReports API * POST /reconciliationReports * * @param {Object} params - params * @param {string} params.prefix - the prefix configured for the stack * @param {Object} params.request - request body to post * @param {Function} params.callback - async function to invoke the api lambda * that takes a prefix / user payload. Defaults * to cumulusApiClient.invokeApifunction to invoke the api lambda * @returns {Promise<Object>} - promise that resolves to the output of the API lambda */ async function createReconciliationReport(params) { const { prefix, request, callback = cumulusApiClient_1.invokeApi, } = params; return await callback({ prefix: prefix, payload: { httpMethod: 'POST', resource: '/{proxy+}', headers: { 'Content-Type': 'application/json', }, path: '/reconciliationReports', body: JSON.stringify(request), }, expectedStatusCodes: 202, }); } exports.createReconciliationReport = createReconciliationReport; //# sourceMappingURL=reconciliationReports.js.map