Skip to content

Commit

Permalink
Kimsufi and SoYouStart APIs support
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
  • Loading branch information
gierschv committed Oct 26, 2014
1 parent 64a40b6 commit 74083e4
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.1

* Add Kimsufi and SoYouStart APIs

## 1.1
* Now official Node.js wrapper
* Rewrite part of the tests, README & documentation
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ websites:
* [OVH Europe](https://eu.api.ovh.com/createApp/)
* [OVH North-America](https://ca.api.ovh.com/createApp/)
* [RunAbove](https://api.runabove.com/createApp/)
* [SoYouStart Europe](https://eu.api.soyoustart.com/createApp/)
* [SoYouStart North-America](https://ca.api.soyoustart.com/createApp/)
* [Kimsufi Europe](https://eu.api.kimsufi.com/createApp/)
* [Kimsufi North-America](https://ca.api.kimsufi.com/createApp/)

Once created, you will obtain an **application key (AK)** and an **application
secret (AS)**.
Expand All @@ -63,6 +67,10 @@ Depending the API you want to use, you need to specify the below API endpoint:
* OVH Europe: ```ovh-eu``` (default)
* OVH North-America: ```ovh-ca```
* RunAbove: ```runabove-ca```
* SoYouStart Europe: ```sys-eu```
* SoYouStart North-America: ```sys-ca```
* Kimsufi Europe: ```ks-eu```
* Kimsufi North-America: ```ks-ca```

```js
var ovh = require('ovh')({
Expand Down Expand Up @@ -116,6 +124,10 @@ You can browse the API schemas using the web consoles of the APIs:
* [OVH Europe](https://eu.api.ovh.com/console/)
* [OVH North-America](https://ca.api.ovh.com/console/)
* [RunAbove](https://api.runabove.com/console/)
* [SoYouStart Europe](https://eu.api.soyoustart.com/console/)
* [SoYouStart North-America](https://ca.api.soyoustart.com/console/)
* [Kimsufi Europe](https://eu.api.kimsufi.com/console/)
* [Kimsufi North-America](https://ca.api.kimsufi.com/console/)
## Full documentation and examples
Expand Down Expand Up @@ -170,19 +182,54 @@ available in the *gh-pages* branch.
- **Community support**: api-subscribe@ml.ovh.net
- **Console**: https://eu.api.ovh.com/console
- **Create application credentials**: https://eu.api.ovh.com/createApp/
- **Create script credentials** (all keys at once): https://eu.api.ovh.com/createToken/
### OVH North America
- **Documentation**: https://ca.api.ovh.com/
- **Community support**: api-subscribe@ml.ovh.net
- **Console**: https://ca.api.ovh.com/console
- **Create application credentials**: https://ca.api.ovh.com/createApp/
- **Create script credentials** (all keys at once): https://ca.api.ovh.com/createToken/
### Runabove
- **Console**: https://api.runabove.com/console/
- **Create application credentials**: https://api.runabove.com/createApp/
### SoYouStart Europe
- **Documentation**: https://eu.api.soyoustart.com/
- **Community support**: api-subscribe@ml.ovh.net
- **Console**: https://eu.api.soyoustart.com/console/
- **Create application credentials**: https://eu.api.soyoustart.com/createApp/
- **Create script credentials** (all keys at once): https://eu.api.soyoustart.com/createToken/
### SoYouStart North America
- **Documentation**: https://ca.api.soyoustart.com/
- **Community support**: api-subscribe@ml.ovh.net
- **Console**: https://ca.api.soyoustart.com/console/
- **Create application credentials**: https://ca.api.soyoustart.com/createApp/
- **Create script credentials** (all keys at once): https://ca.api.soyoustart.com/createToken/
#### Kimsufi Europe
- **Documentation**: https://eu.api.kimsufi.com/
- **Community support**: api-subscribe@ml.ovh.net
- **Console**: https://eu.api.kimsufi.com/console/
- **Create application credentials**: https://eu.api.kimsufi.com/createApp/
- **Create script credentials** (all keys at once): https://eu.api.kimsufi.com/createToken/
#### Kimsufi North America
- **Documentation**: https://ca.api.kimsufi.com/
- **Community support**: api-subscribe@ml.ovh.net
- **Console**: https://ca.api.kimsufi.com/console/
- **Create application credentials**: https://ca.api.kimsufi.com/createApp/
- **Create script credentials** (all keys at once): https://ca.api.kimsufi.com/createToken/
### Related links
- **Contribute**: https://github.com/ovh/node-ovh
Expand Down
60 changes: 60 additions & 0 deletions lib/endpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2014 OVH SAS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Except as contained in this notice, the name of OVH and or its trademarks
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from OVH.
*/

/**
* Preconfigured API endpoints
*
* ovh-eu: OVH Europe
* ovh-ca: OVH North America
* runabove-ca: RunAbove
* sys-eu: SoYouStart Europe
* sys-ca: SoYouStart North America
* ks-eu: Kimsufi Europe
* ks-ca: Kimsufi North America
*/
module.exports = {
'ovh-eu': {
'host': 'eu.api.ovh.com'
},
'ovh-ca': {
'host': 'ca.api.ovh.com'
},
'runabove-ca': {
'host': 'api.runabove.com'
},
'sys-eu': {
'host': 'eu.api.soyoustart.com'
},
'sys-ca': {
'host': 'ca.api.soyoustart.com'
},
'ks-eu': {
'host': 'eu.api.kimsufi.com'
},
'ks-ca': {
'host': 'ca.api.kimsufi.com'
},
};
30 changes: 6 additions & 24 deletions lib/ovh.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var https = require('https'),
url = require('url'),
crypto = require('crypto'),
async = require('async'),
handlerMaker = require('./handler-maker');
handlerMaker = require('./handler-maker'),
endpoints = require('./endpoints');

(function () {
"use strict";
Expand All @@ -45,13 +46,13 @@ var https = require('https'),

// Preconfigured API endpoints
if (this.endpoint) {
if (typeof(this.endpoints[this.endpoint]) === 'undefined') {
if (typeof(endpoints[this.endpoint]) === 'undefined') {
throw new Error('[OVH] Unknown API ' + this.endpoint);
}

for (var key in this.endpoints[this.endpoint]) {
if (this.endpoints[this.endpoint].hasOwnProperty(key)) {
params[key] = this.endpoints[this.endpoint][key];
for (var key in endpoints[this.endpoint]) {
if (endpoints[this.endpoint].hasOwnProperty(key)) {
params[key] = endpoints[this.endpoint][key];
}
}
}
Expand Down Expand Up @@ -653,25 +654,6 @@ var https = require('https'),
return '$1$' + crypto.createHash('sha1').update(s.join('+')).digest('hex');
};

/**
* Preconfigured API endpoints
*
* ovh-eu: OVH Europe
* ovh-ca: OVH North America
* runabove-ca: RunAbove
*/
Ovh.prototype.endpoints = {
'ovh-eu': {
'host': 'eu.api.ovh.com'
},
'ovh-ca': {
'host': 'ca.api.ovh.com'
},
'runabove-ca': {
'host': 'api.runabove.com'
}
};

module.exports = function (params) {
return new Ovh(params || {});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ovh",
"version": "1.1.0",
"version": "1.1.1",
"description": "Official Node.js wrapper for the OVH APIs",
"homepage": "http://ovh.github.io/node-ovh",
"author": "Vincent Giersch <vincent.giersch@ovh.net>",
Expand Down
55 changes: 55 additions & 0 deletions tests/integration/04_REST_multiple_backends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2014 OVH SAS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Except as contained in this notice, the name of OVH and or its trademarks
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from OVH.
*/

var assert = require('assert'),
async = require('async'),
ovh = require('../..'),
endpoints = require('../../lib/endpoints');

exports.REST_call = {
'Preconfigured API endpoints: backends time': function (done) {
"use strict";

async.mapLimit(
Object.keys(endpoints), Object.keys(endpoints).length,
function (endpoint, callback) {
endpoint = ovh({ appKey: 'X', appSecret: 'X', endpoint: endpoint });
endpoint.request('GET', '/auth/time', callback);
},
function (err, times) {
if (err) {
return done(err);
}

for (var i = 0; i < times.length; i++) {
assert(times[i] > Date.now() / 1000 - 3600);
}

done();
}
);
}
};

0 comments on commit 74083e4

Please sign in to comment.