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

feat: add cloud users roles services #172

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/cloud/project/cloud-project.v6.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ angular.module("ovh-api-services").service("OvhApiCloudProjectV6", function ($ca
url: "/cloud/project/:serviceName/vrack",
method: "GET"
},
role: {
url: "/cloud/project/:serviceName/role",
method: "GET"
},
createVrack: {
url: "/cloud/project/:serviceName/vrack",
method: "POST",
Expand Down
3 changes: 3 additions & 0 deletions src/cloud/project/user/cloud-project-user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ angular.module("ovh-api-services").service("OvhApiCloudProjectUser", function ($
},
Aapi: function () {
return $injector.get("OvhApiCloudProjectUserAapi");
},
Role: function () {
return $injector.get("OvhApiCloudProjectUserRole");
}
};

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

"use strict";

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

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
angular.module("ovh-api-services").service("OvhApiCloudProjectUserRoleV6", function ($resource, $cacheFactory) {
"use strict";

var queryCache = $cacheFactory("OvhApiCloudProjectUserRoleV6Query");
var cache = $cacheFactory("OvhApiCloudProjectUserRoleV6");

var interceptor = {
response: function (response) {
cache.remove(response.config.url);
queryCache.removeAll();
return response.data;
}
};

var roles = $resource("/cloud/project/:serviceName/user/:userId/role/:roleId", {
serviceName: "@serviceName",
userId: "@userId",
roleId: "@roleId"
}, {
query: { method: "GET", cache: queryCache, isArray: true },
save: { method: "POST", interceptor: interceptor },
get: { method: "GET", cache: cache },
"delete": { method: "DELETE", interceptor: interceptor }
});

roles.resetCache = function () {
cache.removeAll();
};

roles.resetQueryCache = function () {
queryCache.removeAll();
};

return roles;

});