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

Commit

Permalink
feat(deskaas): Add deskaas api
Browse files Browse the repository at this point in the history
  • Loading branch information
cyril.biencourt committed Oct 11, 2017
1 parent 0f19e35 commit 2cf6c35
Show file tree
Hide file tree
Showing 5 changed files with 4,935 additions and 11 deletions.
115 changes: 115 additions & 0 deletions dist/ovh-api-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,121 @@ angular.module("ovh-api-services").service("OvhApiDedicatedCloudUser", ["$inject

}]);

"use strict";

angular.module("ovh-api-services").service("OvhApiDeskaasLexi",
["$resource", "OvhApiDeskaasService", function ($resource, OvhApiDeskaasService) {

var interceptor = {
response: function (response) {
OvhApiDeskaasService.resetCache();
return response.resource;
}
};


// TODO: try to remove the "deskaas" base url to quickly move when product name change
var res = $resource("/deskaas/:serviceName", {
serviceName : "@serviceName" }, {

schema : { method : "GET", url: "/deskaas.json" },
query : { method : "GET", isArray: true, cache: OvhApiDeskaasService.cache },

getServices : { method : "GET", isArray: true, cache: OvhApiDeskaasService.cache },
getDetails : { method : "GET", url: "/deskaas/:serviceName", cache: OvhApiDeskaasService.cache },

changeAlias : { method : "POST", url: "/deskaas/:serviceName/changeAlias", interceptor: interceptor},
changeUsername : { method : "POST", url: "/deskaas/:serviceName/changeUsername", interceptor: interceptor},
changeContact : { method : "POST", url: "/deskaas/:serviceName/changeContact", interceptor: interceptor},

getAuthToken : { method : "GET", url: "/deskaas/:serviceName/getAuthToken", cache: OvhApiDeskaasService.cache },

getPwdPolicy : { method : "GET", url: "/deskaas/:serviceName/passwordPolicy", interceptor: interceptor},

rebootService : { method : "POST", url: "/deskaas/:serviceName/reboot"},
restoreService : { method : "POST", url: "/deskaas/:serviceName/refresh", interceptor: interceptor},

serviceInfos : { method : "GET", url: "/deskaas/:serviceName/serviceInfos", cache: OvhApiDeskaasService.cache},
putServiceInfos : { method : "PUT", url: "/deskaas/:serviceName/serviceInfos", cache: OvhApiDeskaasService.cache},

getAllTasks : { method : "GET", url: "/deskaas/:serviceName/task", isArray: true, interceptor: interceptor},
getTaskBatch : { method : "GET", url: "/deskaas/:serviceName/task/:taskId", isArray: true, interceptor: interceptor, headers: {"X-Ovh-Batch": ","}},
getTask : { method : "GET", url: "/deskaas/:serviceName/task/:taskId", interceptor: interceptor},
getDoneTasks : { method : "GET", url: "/deskaas/:serviceName/task?state=done", isArray: true, interceptor: interceptor},
getCanceledTasks: { method : "GET", url: "/deskaas/:serviceName/task?state=canceled", isArray: true, interceptor: interceptor},

deleteService : { method : "POST", url: "/deskaas/:serviceName/terminate", interceptor: interceptor},
upgradeService : { method : "POST", url: "/deskaas/:serviceName/upgrade", interceptor: interceptor},

getUser : { method : "GET", url: "/deskaas/:serviceName/user", interceptor: interceptor},
resetPassword : { method : "POST", url: "/deskaas/:serviceName/user/changePassword", interceptor: interceptor},

getUserTasks : { method : "GET", url: "/deskaas/:serviceName/user/task/", interceptor: interceptor},
getUserTask : { method : "GET", url: "/deskaas/:serviceName/user/task/:taskId", interceptor: interceptor},

confirmTerminate: { method : "POST", url: "/deskaas/:serviceName/confirmTermination", interceptor: interceptor},

console : { method : "POST", url: "/deskaas/:serviceName/console", interceptor: interceptor},

getProducts : { method : "GET", url: "/order/catalog/formatted/deskaas", interceptor: interceptor}

});

return res;
}]);

"use strict";

angular.module("ovh-api-services")
.service(
"OvhApiDeskaasService",
["$injector", "$cacheFactory", "Poller", function ($injector, $cacheFactory, Poller) {

var cache = $cacheFactory("deskaas");


return {
Lexi : function () {
return $injector.get("OvhApiDeskaasLexi");
},
resetCache: cache.removeAll,
cache: cache,
pollTask: function ($scope, opts) {
// TODO: polling of multiple task should be replace by a batch query to avoid multiple calls
// Maybe precede by a /task to get new tasks

// Poll a task
var url = ["/deskaas/", opts.serviceName, opts.isUserTask ? "/user" : "", "/task/", opts.taskId].join("");

$scope.$on("$destroy", function () {
// Destroy all task from deskaas_task namespace
Poller.kill(function (task) {
if (task.namespace === "deskaas_task") {
return true;
}
return false;
});
});

// Success or failure is handle by the caller
return Poller.poll(url, null, {
namespace : "deskaas_task",
scope : $scope.$id
});
},
stopPollTask: function($scope, taskToStop) {
// Stop polling a specific url to continue polling other tasks
var url = ["/deskaas/", taskToStop.serviceName, taskToStop.isUserTask ? "/user" : "", "/task/", taskToStop.taskId].join("");
Poller.kill(function(task) {
if (task.namespace === "deskaas_task" && task.url === url) {
return true;
}
return false;
});
}
};
}])

angular.module("ovh-api-services").service("OvhApiDomainErika", ["apiv7", function (apiv7) {
"use strict";

Expand Down
21 changes: 10 additions & 11 deletions dist/ovh-api-services.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 2cf6c35

Please sign in to comment.