summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/clusters/services/clusters_service.js
blob: 0ac8e68187d72d76a7784ef0f1c4c2e6c5f6fe85 (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
import axios from 'axios';
import setAxiosCsrfToken from '../../lib/utils/axios_utils';

export default class ClusterService {
  constructor(options = {}) {
    setAxiosCsrfToken();

    this.options = options;
    this.appInstallEndpointMap = {
      helm: this.options.installHelmEndpoint,
      ingress: this.options.installIngressEndpoint,
      runner: this.options.installRunnerEndpoint,
    };
  }

  fetchData() {
    return axios.get(this.options.endpoint);
  }

  installApplication(appId) {
    const endpoint = this.appInstallEndpointMap[appId];
    return axios.post(endpoint);
  }
}