Skip to main content
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({ assetID, response });
}
};

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.