Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
feat(cloud-project-stack): add Cloud Project Stack API feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rfougier committed May 29, 2018
1 parent dbb24dd commit cf87e60
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cloud/project/cloud-project.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
};

Expand Down
11 changes: 11 additions & 0 deletions src/cloud/project/stack/cloud-project-stack.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
angular.module("ovh-api-services").service("OvhApiCloudProjectStack", function ($injector) {

"use strict";

return {
v6: function () {
return $injector.get("OvhApiCloudProjectStackV6");
}
};

});
42 changes: 42 additions & 0 deletions src/cloud/project/stack/cloud-project-stack.v6.service.js
Original file line number Diff line number Diff line change
@@ -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;
});

0 comments on commit cf87e60

Please sign in to comment.