fleet/ee/bulk-operations-dashboard/api/controllers/software/delete-software.js
Eric 0da7afb332
Bulk operations dashboard: Add software page (#22584)
Related to #21928

Changes:
- Added a /software page, a page where users can manage
(upload/edit/download/delete) software installers on their Fleet
instance across multiple teams at once.
- ~~Removed the `deploy-bulk-operations-dashboard-on-heroku` GitHub
action (This dashboard will be hosted in Render in the future)~~
Reverted this change to unblock merging this PR, I will remove this file
in a separate PR.
2024-10-15 10:17:05 -05:00

46 lines
1.2 KiB
JavaScript

module.exports = {
friendlyName: 'Delete software',
description: 'Deletes deployed software for all teams on a Fleet instance, or undeployed software in the app\'s database',
inputs: {
software: {
type: {},
description: 'The software that will be deleted.',
required: true,
}
},
exits: {
},
fn: async function ({software}) {
// If the provided software does not have a teams array and has an ID, it is an undeployed software that will be deleted.
if(software.id && !software.teams){
await sails.rm(sails.config.uploads.prefixForFileDeletion+software.uploadFd);
await UndeployedSoftware.destroy({id: software.id});
} else {// Otherwise, this is a deployed software, and we'll use information from the teams array to remove the software.
for(let team of software.teams){
await sails.helpers.http.sendHttpRequest.with({
method: 'DELETE',
baseUrl: sails.config.custom.fleetBaseUrl,
url: `/api/v1/fleet/software/titles/${software.fleetApid}/available_for_install?team_id=${team.fleetApid}`,
headers: {
Authorization: `Bearer ${sails.config.custom.fleetApiToken}`,
}
});
}
}
// All done.
return;
}
};