Simple http provider for OVH API.
$ bower install ovh-angular-http --save
$ npm install ovh-angular-http --save
$ git clone https://github.com/ovh-ux/ovh-angular-http.git
$ cd ovh-angular-http
$ npm install
$ bower install
.config(["OvhHttpProvider", "constants", function (OvhHttpProvider, constants) {
"use strict";
OvhHttpProvider.rootPath = constants.swsRootPath; // URL prefix
OvhHttpProvider.clearCacheVerb = ["POST", "PUT", "DELETE"]; // Auto delete get cache (for this url) if method is in table
OvhHttpProvider.returnSuccessKey = 'data'; // By default, requeste return response.data
OvhHttpProvider.returnErrorKey = 'data'; // By default, requeste return error.data
}])
// http request
OvhHttp.["get", "put", "post", "delete"](URL, options); (promise)
// get API schema (option only rootPath)
OvhHttp.schema(URL, options); (promise)
// get specifically enum of API schema (option only rootPath)
OvhHttp.models(URL, enumName, options); (promise)
// return window.encodeURIComponent(param);
OvhHttp.encode(param);
options = {
method: // get post put or delete
url: // url of sws or proxypass
urlParams: // params of url (replace {*})
data: // data of body for POST and PUT
params: // params in URL
cache: // cache key (String)
clearCache: // (String, String[], boolean) clear cache of this url (boolean) or specifique cache (String or String[])
clearAllCache: // (String, String[], boolean) clear all cache of this cache (boolean) or specifique cache (String or String[])
encodeParams: // Encode params
encodeUrlParams: // Encode url params
// Override provider conf
returnSuccessKey: // (String or empty string) return specific key (first level) (empty for return all)
returnErrorKey: // (String or empty string) return specific key (first level) (empty for return all)
rootPath: // prefix url (provider conf)
clearCacheVerb: // table of [PUT POST DELETE]. remove automatically cache of url if method is in table(provider conf)
}
this.getSelected = function (forceRefresh) {
return OvhHttp.get("hosting/web/{serviceName}", {
urlParams: {
serviceName: $routeParams.productId
},
clearCache: forceRefresh,
cache: "hostingCache"
});
};
this.flushCdn = function () {
return OvhHttp.post("proxypass/hosting/web/{serviceName}/request", {
urlParams: {
serviceName: $routeParams.productId
},
data: {
action: "FLUSH_CACHE"
}
clearAllCache: "hostingCache" // or ["hostingCache"]
});
};
You've developed a new cool feature? Fixed an annoying bug? We'd be happy to hear from you!
Have a look in CONTRIBUTING.md
- Contribute: https://github.com/ovh-ux/ovh-angular-http/blob/master/CONTRIBUTING.md
- Report bugs: https://github.com/ovh-ux/ovh-angular-http/issues
- Get latest version: https://github.com/ovh-ux/ovh-angular-http
See https://github.com/ovh-ux/ovh-angular-http/blob/master/LICENSE