Skip to main content

Destructive example: the source lists only page 1 (up to 500 pipelines). Review the selected IDs before calling bulkDelete(). This does not delete every pipeline when there are additional pages. Save the authentication helper as get_auth_token.js and use Node.js 18+ with ES modules enabled. The response block below is the source's illustrative placeholder, not the function's return shape.

Node.js 18+
import { getToken } from "./get_auth_token.js";

const bulkDelete = async () => {
const apiToken = await getToken();
const pipelinesIds = await getListOfAllPipelinesIds(apiToken);
console.log(pipelinesIds);
const deleteResponseCollection = [];
for (const pipelineId of pipelinesIds) {
const response = await deletePipeline(apiToken, pipelineId);
deleteResponseCollection.push({ pipelineId, response });
}
return deleteResponseCollection;
};

const getListOfAllPipelinesIds = async (token) => {
const url = "https://maestro.dadosfera.ai/pipelinesV2?size=500&page=1";

return fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `${token}`,
},
})
.then((response) => {
if (response.ok) return response.json();
else throw response.statusText;
})
.then((data) => {
const pipelinesIds = [];
data.pipelines.forEach((pipeline) => {
pipelinesIds.push(pipeline.id);
});
return pipelinesIds;
});
};

const deletePipeline = (token, pipelineId) => {
const url = `https://maestro.dadosfera.ai/pipelinesV2/${pipelineId}`;

return fetch(url, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `${token}`,
},
})
.then((response) => {
if (response.ok) return response.json();
else throw response.statusText;
});
};
{"success":true}

Get API auth token

For any API request it is necessary to have the authentication token; this recipe demonstrates how to get it.

Get the list of pipeline IDs

Get the list of pipeline IDs you want to delete using a function that can be customized according to your needs.

Delete pipelines

Using the list of IDs execute a loop to delete calling the pipelines delete route.

Observation about the requests

Note that the functions that make the requests have a configuration and request pattern.