debian-mirror-gitlab/app/assets/javascripts/alerts_settings/services/index.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-07-28 23:09:34 +05:30
/* eslint-disable @gitlab/require-i18n-strings */
import axios from '~/lib/utils/axios_utils';
export default {
2021-01-29 00:20:46 +05:30
// TODO: All this code save updateTestAlert will be deleted as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/255501
2020-07-28 23:09:34 +05:30
updateGenericKey({ endpoint, params }) {
return axios.put(endpoint, params);
},
updatePrometheusKey({ endpoint }) {
return axios.post(endpoint);
},
updateGenericActive({ endpoint, params }) {
return axios.put(endpoint, params);
},
updatePrometheusActive({ endpoint, params: { token, config, url, redirect } }) {
const data = new FormData();
data.set('_method', 'put');
data.set('authenticity_token', token);
data.set('service[manual_configuration]', config);
data.set('service[api_url]', url);
data.set('redirect_to', redirect);
return axios.post(endpoint, data, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
},
2021-01-29 00:20:46 +05:30
updateTestAlert({ endpoint, data, token }) {
2020-07-28 23:09:34 +05:30
return axios.post(endpoint, data, {
headers: {
'Content-Type': 'application/json',
2021-01-29 00:20:46 +05:30
Authorization: `Bearer ${token}`,
2020-07-28 23:09:34 +05:30
},
});
},
};