summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/deploy_keys/service/index.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-04-28 17:06:19 +0100
committerPhil Hughes <me@iamphill.com>2017-04-28 17:06:19 +0100
commite11a702afceee7f5edeb8c93a4192fa05209b091 (patch)
treeecb9cea80803638c9b8878b091793beb3ed88720 /app/assets/javascripts/deploy_keys/service/index.js
parent79e2a524e22e5474c5b33deb81ac6cc51512d2e5 (diff)
downloadgitlab-ce-e11a702afceee7f5edeb8c93a4192fa05209b091.tar.gz
Re-wrote to match our docs - still not 100% sure but closer than it was
Diffstat (limited to 'app/assets/javascripts/deploy_keys/service/index.js')
-rw-r--r--app/assets/javascripts/deploy_keys/service/index.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/assets/javascripts/deploy_keys/service/index.js b/app/assets/javascripts/deploy_keys/service/index.js
new file mode 100644
index 00000000000..fe6dbaa9498
--- /dev/null
+++ b/app/assets/javascripts/deploy_keys/service/index.js
@@ -0,0 +1,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 }, {});
+ }
+}