Skip to main content
import { getToken } from "./get_auth_token.js";

const getPipelinesLastRunStatus = async () => {
const apiToken = await getToken();
const pipelines = await getListOfAllPipelinesIdsAndNames(apiToken);
const pipelinesStatus = [];
for (const pipeline of pipelines) {
const response = await getPipelineStatus(apiToken, pipeline.id);
pipelinesStatus.push({ pipeline_id: pipeline.id, pipeline_name: pipeline.name, last_status: response });
}
return pipelinesStatus;
};

const getListOfAllPipelinesIdsAndNames = (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 pipelinesInfos = [];
data.pipelines.forEach((pipeline) => {
pipelinesInfos.push({ id: pipeline.id, name: pipeline.name });
});
return pipelinesInfos;
});
};

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

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) => data.status[0]);
};
{"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.

Grab required information from pipelines

To get this information, it is necessary to configure the return of the route that makes the pipeline catalog available.

Get the execution history of each pipeline

Using the information from the pipeline information list, fetch the run history.

Configure the response

A little configuration is needed to return the last execution, it is necessary to get the first element of the list.