grab-api-sentinel-mocks/main.js

20 lines
966 B
JavaScript

import { normalized_config } from "./normalize-config.js";
import { get_run_details, create_plan_export } from "./tfc-api-functions.mjs";
import { runidNotProvided, runIdPrefixCheckFail } from "./validate-user-input.mjs";
const my_config = await normalized_config;
if(runidNotProvided(my_config.run_id) || runIdPrefixCheckFail(my_config.run_id)){
throw new Error("A valid RunID must be provided. Please check that the supplied runID is valid");
}
// TODO: Add error handling for `data: { errors: [ { status: '404', title: 'not found' } ] }`
const run_details = await get_run_details(my_config.base_url, process.argv.slice(2), my_config.token);
const plan_id = run_details.data.data.relationships.plan.data.id;
console.log(`The plan ID is ${plan_id}`);
const export_response = await create_plan_export(my_config.base_url, plan_id, my_config.token);
const plan_export_id = export_response.data.data.id;
console.log(`The plan export ID is ${plan_export_id}`);