mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
06832697d0
- Add endpoint for deletion of label by ID - Use ID endpoint from frontend JS Fixes #1847
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import endpoints from 'kolide/endpoints';
|
|
import helpers from 'kolide/helpers';
|
|
|
|
export default (client) => {
|
|
return {
|
|
create: ({ description, name, platform, query }) => {
|
|
const { LABELS } = endpoints;
|
|
|
|
return client.authenticatedPost(client._endpoint(LABELS), JSON.stringify({ description, name, platform, query }))
|
|
.then((response) => {
|
|
const { label } = response;
|
|
|
|
return {
|
|
...label,
|
|
slug: helpers.labelSlug(label),
|
|
type: 'custom',
|
|
};
|
|
});
|
|
},
|
|
destroy: (label) => {
|
|
const { LABELS } = endpoints;
|
|
const endpoint = client._endpoint(`${LABELS}/id/${label.id}`);
|
|
|
|
return client.authenticatedDelete(endpoint);
|
|
},
|
|
loadAll: () => {
|
|
const { LABELS } = endpoints;
|
|
|
|
return client.authenticatedGet(client._endpoint(LABELS))
|
|
.then(response => helpers.formatLabelResponse(response));
|
|
},
|
|
update: (label, updateAttrs) => {
|
|
const { LABELS } = endpoints;
|
|
const endpoint = client._endpoint(`${LABELS}/${label.id}`);
|
|
|
|
return client.authenticatedPatch(endpoint, JSON.stringify(updateAttrs))
|
|
.then((response) => {
|
|
const { label: updatedLabel } = response;
|
|
|
|
return {
|
|
...updatedLabel,
|
|
slug: helpers.labelSlug(updatedLabel),
|
|
type: 'custom',
|
|
};
|
|
});
|
|
},
|
|
};
|
|
};
|