fleet/ee/bulk-operations-dashboard/api/controllers/get-labels.js
Eric 102f9f3cb1
MSP Dashboard: Add labels to profiles page (#23145)
#22073

Changes:
- Added the ability to use labels to assign configuration profiles on
the profiles page.
2024-12-05 17:39:47 -06:00

45 lines
865 B
JavaScript

module.exports = {
friendlyName: 'Get labels',
description: 'Builds and returns an array of labels on the Fleet instance.',
exits: {
success: {
outputType: [{}],
}
},
fn: async function () {
let labelsOnThisInstance = [];
let labelsResponseData = await sails.helpers.http.get.with({
url: '/api/v1/fleet/labels',
baseUrl: sails.config.custom.fleetBaseUrl,
headers: {
Authorization: `Bearer ${sails.config.custom.fleetApiToken}`
}
})
.timeout(120000)
.retry(['requestFailed', {name: 'TimeoutError'}]);
for(let label of labelsResponseData.labels) {
labelsOnThisInstance.push({
name: label.name,
value: label.id
});
}
labelsOnThisInstance = _.sortBy(labelsOnThisInstance, 'name');
// All done.
return labelsOnThisInstance;
}
};