From 74083e443f6208fa8d093b489abd6f10002baaa9 Mon Sep 17 00:00:00 2001 From: Vincent Giersch Date: Wed, 22 Oct 2014 13:11:24 +0200 Subject: [PATCH] Kimsufi and SoYouStart APIs support Signed-off-by: Vincent Giersch --- CHANGELOG.md | 4 ++ README.md | 47 +++++++++++++++ lib/endpoints.js | 60 +++++++++++++++++++ lib/ovh.js | 30 ++-------- package.json | 2 +- .../integration/04_REST_multiple_backends.js | 55 +++++++++++++++++ 6 files changed, 173 insertions(+), 25 deletions(-) create mode 100644 lib/endpoints.js create mode 100644 tests/integration/04_REST_multiple_backends.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e8134a..84c486f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 92402d4..fa2c703 100644 --- a/README.md +++ b/README.md @@ -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)**. @@ -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')({ @@ -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 @@ -170,6 +182,7 @@ 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 @@ -177,12 +190,46 @@ available in the *gh-pages* branch. - **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 diff --git a/lib/endpoints.js b/lib/endpoints.js new file mode 100644 index 0000000..2df9d75 --- /dev/null +++ b/lib/endpoints.js @@ -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' + }, +}; diff --git a/lib/ovh.js b/lib/ovh.js index 6d8ce32..7536f26 100644 --- a/lib/ovh.js +++ b/lib/ovh.js @@ -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"; @@ -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]; } } } @@ -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 || {}); }; diff --git a/package.json b/package.json index 01716ea..0bd4f7f 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/tests/integration/04_REST_multiple_backends.js b/tests/integration/04_REST_multiple_backends.js new file mode 100644 index 0000000..3a3e567 --- /dev/null +++ b/tests/integration/04_REST_multiple_backends.js @@ -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(); + } + ); + } +};