summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/deploy_keys/service/index.js
blob: fe6dbaa949809f011dfedf1b909de476e8525ea3 (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
import Vue from 'vue';
import VueResource from 'vue-resource';

Vue.use(VueResource);

export default class DeployKeysService {
  constructor(endpoint) {
    this.endpoint = endpoint;

    this.resource = Vue.resource(`${this.endpoint}{/id}`, {}, {
      enable: {
        method: 'PUT',
        url: `${this.endpoint}{/id}/enable`,
      },
      disable: {
        method: 'PUT',
        url: `${this.endpoint}{/id}/disable`,
      },
    });
  }

  getKeys() {
    return this.resource.get()
      .then(response => response.json());
  }

  enableKey(id) {
    return this.resource.enable({ id }, {});
  }

  disableKey(id) {
    return this.resource.disable({ id }, {});
  }
}