Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « services « alerts_settings « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1835d6b46aaaf0d53bce5b32e7786d4299b6de5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-disable @gitlab/require-i18n-strings */
import axios from '~/lib/utils/axios_utils';

export default {
  // TODO: All this code save updateTestAlert will be deleted as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/255501
  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',
      },
    });
  },
  updateTestAlert({ endpoint, data, token }) {
    return axios.post(endpoint, data, {
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${token}`,
      },
    });
  },
};