From cf87e60156cf4e814efb2e6e87d7ccaf7f392ded Mon Sep 17 00:00:00 2001 From: rfougier Date: Wed, 2 May 2018 10:43:00 -0400 Subject: [PATCH] feat(cloud-project-stack): add Cloud Project Stack API feature --- src/cloud/project/cloud-project.service.js | 3 ++ .../stack/cloud-project-stack.service.js | 11 +++++ .../stack/cloud-project-stack.v6.service.js | 42 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/cloud/project/stack/cloud-project-stack.service.js create mode 100644 src/cloud/project/stack/cloud-project-stack.v6.service.js diff --git a/src/cloud/project/cloud-project.service.js b/src/cloud/project/cloud-project.service.js index 8422ecc9..7f0422f1 100644 --- a/src/cloud/project/cloud-project.service.js +++ b/src/cloud/project/cloud-project.service.js @@ -51,6 +51,9 @@ angular.module("ovh-api-services").service("OvhApiCloudProject", function ($inje }, Migration: function () { return $injector.get("OvhApiCloudProjectMigration"); + }, + Stack: function () { + return $injector.get("OvhApiCloudProjectStack"); } }; diff --git a/src/cloud/project/stack/cloud-project-stack.service.js b/src/cloud/project/stack/cloud-project-stack.service.js new file mode 100644 index 00000000..5665966f --- /dev/null +++ b/src/cloud/project/stack/cloud-project-stack.service.js @@ -0,0 +1,11 @@ +angular.module("ovh-api-services").service("OvhApiCloudProjectStack", function ($injector) { + + "use strict"; + + return { + v6: function () { + return $injector.get("OvhApiCloudProjectStackV6"); + } + }; + +}); diff --git a/src/cloud/project/stack/cloud-project-stack.v6.service.js b/src/cloud/project/stack/cloud-project-stack.v6.service.js new file mode 100644 index 00000000..6ecee49f --- /dev/null +++ b/src/cloud/project/stack/cloud-project-stack.v6.service.js @@ -0,0 +1,42 @@ +angular.module("ovh-api-services").service("OvhApiCloudProjectStackV6", function ($resource, $cacheFactory) { + "use strict"; + + var queryCache = $cacheFactory("OvhApiCloudProjectStackV6Query"); + var cache = $cacheFactory("OvhApiCloudProjectStackV6"); + + var interceptor = { + response: function (response) { + cache.remove(response.config.url); + queryCache.removeAll(); + return response.data; + } + }; + + var stack = $resource("/cloud/project/:serviceName/stack/:stackId", { + serviceName: "@serviceName", + stackId: "@stackId" + }, { + get: { method: "GET", cache: cache }, + query: { method: "GET", cache: queryCache, isArray: true }, + availability: { + url: "/cloud/project/:serviceName/stack/:stackId/availability", + method: "GET", + interceptor: interceptor + }, + client: { + url: "/cloud/project/:serviceName/stack/:stackId/client", + method: "POST", + interceptor: interceptor + } + }); + + stack.resetCache = function () { + cache.removeAll(); + }; + + stack.resetQueryCache = function () { + queryCache.removeAll(); + }; + + return stack; +});