├── History.md ├── lib ├── dtv.js ├── folder-sharing.js ├── video-controller.js ├── video-station.js ├── surveillance-station.js ├── api.js ├── audio-station.js ├── download-station.js ├── file-station.js ├── synology.js └── dsm.js ├── .travis.yml ├── .npmignore ├── .gitignore ├── .jshintrc ├── test └── test.js ├── package.json ├── LICENSE └── README.md /History.md: -------------------------------------------------------------------------------- 1 | 2 | 0.0.0 / 2013-07-10 3 | ================== 4 | * first revision 5 | -------------------------------------------------------------------------------- /lib/dtv.js: -------------------------------------------------------------------------------- 1 | module.exports = function(syno) { 2 | return { 3 | }; 4 | }; 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.8 4 | - 0.10 5 | - 0.11 6 | -------------------------------------------------------------------------------- /lib/folder-sharing.js: -------------------------------------------------------------------------------- 1 | module.exports = function(syno) { 2 | return { 3 | }; 4 | }; 5 | -------------------------------------------------------------------------------- /lib/video-controller.js: -------------------------------------------------------------------------------- 1 | module.exports = function(syno) { 2 | return { 3 | }; 4 | }; 5 | -------------------------------------------------------------------------------- /lib/video-station.js: -------------------------------------------------------------------------------- 1 | module.exports = function(syno) { 2 | return { 3 | }; 4 | }; 5 | -------------------------------------------------------------------------------- /lib/surveillance-station.js: -------------------------------------------------------------------------------- 1 | module.exports = function(syno) { 2 | return { 3 | }; 4 | }; 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | sftp-config.json 4 | *.sublime-project 5 | *.sublime-workspace -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | node_modules 14 | 15 | npm-debug.log 16 | sftp-config.json -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node" : true, 3 | "esnext" : true, 4 | "bitwise" : true, 5 | "curly" : true, 6 | "eqeqeq" : true, 7 | "immed" : true, 8 | "indent" : 2, 9 | "latedef" : true, 10 | "newcap" : true, 11 | "noarg" : true, 12 | "quotmark" : "single", 13 | "regexp" : true, 14 | "undef" : true, 15 | "unused" : true, 16 | "strict" : true, 17 | "trailing" : true, 18 | "smarttabs": true, 19 | "maxlen" : 120 20 | } 21 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | var Synology = require('..'); 2 | 3 | var syno = new Synology({ 4 | host : 'localhost', 5 | user : 'mylogin', 6 | password: 'mypassword' 7 | }); 8 | 9 | syno.query('/webapi/query.cgi', { 10 | api : 'SYNO.API.Info', 11 | version: 1, 12 | method : 'query', 13 | query : 'ALL' 14 | }, function(err, data) { 15 | console.log(arguments); 16 | }); 17 | 18 | syno.query('/webapi/DownloadStation/info.cgi', { 19 | api : 'SYNO.DownloadStation.Info', 20 | version: 1, 21 | method : 'getinfo' 22 | }, function(err, data) { 23 | console.log(arguments); 24 | }); 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "synology", 3 | "version": "0.0.0", 4 | "description": "A simple wrapper for the Synology NAS API", 5 | "keywords": [ 6 | "api", 7 | "audiostation", 8 | "downloadstation", 9 | "dsm", 10 | "dtv", 11 | "filestation", 12 | "nas", 13 | "surveillancestation", 14 | "synology", 15 | "videostation" 16 | ], 17 | "main": "./lib/synology.js", 18 | "dependencies": { 19 | "request": "2.27.x", 20 | "form-data": "0.1.x" 21 | }, 22 | "engines": { 23 | "node": ">=0.8.0" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "git://github.com/yannickcr/node-synology.git" 28 | }, 29 | "author": "Yannick Croissant (https://github.com/yannickcr)", 30 | "licenses": [ 31 | { 32 | "type": "MIT", 33 | "url": "https://raw.github.com/yannickcr/node-synology/master/LICENSE" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 by Yannick Croissant 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node Synology 2 | 3 | [![NPM version](https://badge.fury.io/js/synology.png)](https://npmjs.org/package/synology) [![Dependency Status](https://gemnasium.com/yannickcr/node-synology.png)](https://gemnasium.com/yannickcr/node-synology) 4 | 5 | A simple wrapper for the Synology NAS API. 6 | 7 | # Installation 8 | 9 | $ npm install synology 10 | 11 | # Usage 12 | 13 | ```javascript 14 | var Synology = require('synology'); 15 | 16 | var syno = new Synology({ 17 | host : 'localhost', 18 | user : 'mylogin', 19 | password: 'mypassword' 20 | }); 21 | 22 | syno.fileStation.upload({ 23 | file: fs.createReadStream(path.join(__dirname, 'foo.txt')), 24 | dest_folder_path: '/home' 25 | }, function(err, data) { 26 | if (err) throw err; 27 | console.log(data); 28 | }); 29 | ``` 30 | 31 | API documentation can be found on the [Wiki](https://github.com/yannickcr/node-synology/wiki) 32 | 33 | It's a pretty big (non-documented) API and I need to reverse every methods and guess the parameters, document it then do a usable wrapper. 34 | Not very difficult for the majority of the methods but really time consuming. Help is welcome ;) 35 | 36 | For now you can still use directly the Synology.query method to do a raw query but it is not very user friendly. 37 | 38 | # TODO 39 | * Documentation (In progress) 40 | * Helpers (In progress) 41 | * Tests 42 | 43 | # License 44 | 45 | Node Synology is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). 46 | -------------------------------------------------------------------------------- /lib/api.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var util = require('util'); 4 | 5 | function auth() { 6 | /*jshint validthis:true */ 7 | var 8 | userParams = 9 | typeof arguments[0] === 'object' ? arguments[0] : 10 | {}, 11 | callback = 12 | typeof arguments[1] === 'function' ? arguments[1] : 13 | typeof arguments[0] === 'function' ? arguments[0] : 14 | null 15 | ; 16 | var params = { 17 | api : 'SYNO.API.Auth', 18 | method : 'login', 19 | version: 3, 20 | account: this.options.user, 21 | passwd : this.options.password, 22 | session: 'NodeSynologyAPI' + Math.round(Math.random() * 1e9), 23 | format : 'sid'/*, 24 | enable_syno_token: 'yes'*/ 25 | }; 26 | util._extend(params, userParams); 27 | 28 | var query = this.query({ 29 | path: '/webapi/auth.cgi', 30 | params: params 31 | }, callback || null); 32 | 33 | return query; 34 | } 35 | 36 | function info() { 37 | /*jshint validthis:true */ 38 | var 39 | userParams = 40 | typeof arguments[0] === 'object' ? arguments[0] : 41 | {}, 42 | callback = 43 | typeof arguments[1] === 'function' ? arguments[1] : 44 | typeof arguments[0] === 'function' ? arguments[0] : 45 | null 46 | ; 47 | var params = { 48 | api : 'SYNO.API.Info', 49 | version: 1, 50 | method : 'query', 51 | query : 'ALL' 52 | }; 53 | util._extend(params, userParams); 54 | 55 | var query = this.query({ 56 | path: '/webapi/query.cgi', 57 | params: params 58 | }, callback || null); 59 | 60 | return query; 61 | } 62 | 63 | module.exports = function(syno) { 64 | return { 65 | auth: auth.bind(syno), 66 | info: info.bind(syno) 67 | }; 68 | }; 69 | -------------------------------------------------------------------------------- /lib/audio-station.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var util = require('util'); 4 | 5 | function info() { 6 | /*jshint validthis:true */ 7 | var 8 | userParams = 9 | typeof arguments[0] === 'object' ? arguments[0] : 10 | {}, 11 | callback = 12 | typeof arguments[1] === 'function' ? arguments[1] : 13 | typeof arguments[0] === 'function' ? arguments[0] : 14 | null 15 | ; 16 | var params = { 17 | api : 'SYNO.AudioStation.Info', 18 | version: 2, 19 | method : 'getInfo' 20 | }; 21 | util._extend(params, userParams); 22 | 23 | var query = this.query({ 24 | path: '/webapi/AudioStation/info.cgi', 25 | params: params 26 | }, callback || null); 27 | 28 | return query; 29 | } 30 | 31 | function folder() { 32 | /*jshint validthis:true */ 33 | var 34 | userParams = 35 | typeof arguments[0] === 'object' ? arguments[0] : 36 | {}, 37 | callback = 38 | typeof arguments[1] === 'function' ? arguments[1] : 39 | typeof arguments[0] === 'function' ? arguments[0] : 40 | null 41 | ; 42 | var params = { 43 | api : 'SYNO.AudioStation.Folder', 44 | version: 1, 45 | method : 'list', 46 | id : '' 47 | }; 48 | util._extend(params, userParams); 49 | 50 | var query = this.query({ 51 | path: '/webapi/AudioStation/folder.cgi', 52 | params: params 53 | }, callback || null); 54 | 55 | return query; 56 | } 57 | 58 | function album() { 59 | /*jshint validthis:true */ 60 | var 61 | userParams = 62 | typeof arguments[0] === 'object' ? arguments[0] : 63 | {}, 64 | callback = 65 | typeof arguments[1] === 'function' ? arguments[1] : 66 | typeof arguments[0] === 'function' ? arguments[0] : 67 | null 68 | ; 69 | var params = { 70 | api : 'SYNO.AudioStation.Album', 71 | version: 1, 72 | method : 'list' 73 | }; 74 | util._extend(params, userParams); 75 | 76 | var query = this.query({ 77 | path: '/webapi/AudioStation/album.cgi', 78 | params: params 79 | }, callback || null); 80 | 81 | return query; 82 | } 83 | 84 | module.exports = function(syno) { 85 | return { 86 | album: album.bind(syno), 87 | info : info.bind(syno), 88 | folder: folder.bind(syno) 89 | }; 90 | }; 91 | -------------------------------------------------------------------------------- /lib/download-station.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var util = require('util'); 4 | 5 | function info() { 6 | /*jshint validthis:true */ 7 | var 8 | userParams = 9 | typeof arguments[0] === 'object' ? arguments[0] : 10 | {}, 11 | callback = 12 | typeof arguments[1] === 'function' ? arguments[1] : 13 | typeof arguments[0] === 'function' ? arguments[0] : 14 | null 15 | ; 16 | var params = { 17 | api : 'SYNO.DownloadStation.Info', 18 | version: 1, 19 | method : 'getinfo' 20 | }; 21 | util._extend(params, userParams); 22 | 23 | var query = this.query({ 24 | path: '/webapi/DownloadStation/info.cgi', 25 | params: params 26 | }, callback || null); 27 | 28 | return query; 29 | } 30 | 31 | function getConfig() { 32 | /*jshint validthis:true */ 33 | var 34 | userParams = 35 | typeof arguments[0] === 'object' ? arguments[0] : 36 | {}, 37 | callback = 38 | typeof arguments[1] === 'function' ? arguments[1] : 39 | typeof arguments[0] === 'function' ? arguments[0] : 40 | null 41 | ; 42 | var params = { 43 | api : 'SYNO.DownloadStation.Info', 44 | version: 1, 45 | method : 'getconfig' 46 | }; 47 | util._extend(params, userParams); 48 | 49 | var query = this.query({ 50 | path: '/webapi/DownloadStation/info.cgi', 51 | params: params 52 | }, callback || null); 53 | 54 | return query; 55 | } 56 | 57 | function setConfig() { 58 | /*jshint validthis:true */ 59 | var 60 | userParams = 61 | typeof arguments[0] === 'object' ? arguments[0] : 62 | {}, 63 | callback = 64 | typeof arguments[1] === 'function' ? arguments[1] : 65 | typeof arguments[0] === 'function' ? arguments[0] : 66 | null 67 | ; 68 | var params = { 69 | api : 'SYNO.DownloadStation.Info', 70 | version: 1, 71 | method : 'setserverconfig' 72 | }; 73 | util._extend(params, userParams); 74 | 75 | var query = this.query({ 76 | path: '/webapi/DownloadStation/info.cgi', 77 | params: params 78 | }, callback || null); 79 | 80 | return query; 81 | } 82 | 83 | module.exports = function(syno) { 84 | return { 85 | info : info.bind(syno), 86 | getConfig: getConfig.bind(syno), 87 | setConfig: setConfig.bind(syno) 88 | }; 89 | }; 90 | -------------------------------------------------------------------------------- /lib/file-station.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var 4 | util = require('util'), 5 | FormData = require('form-data') 6 | ; 7 | 8 | function list() { 9 | /*jshint validthis:true */ 10 | var 11 | userParams = 12 | typeof arguments[0] === 'object' ? arguments[0] : 13 | {}, 14 | callback = 15 | typeof arguments[1] === 'function' ? arguments[1] : 16 | typeof arguments[0] === 'function' ? arguments[0] : 17 | null 18 | ; 19 | var params = { 20 | api : 'SYNO.FileStation.List', 21 | method : userParams.folder_path === '/' ? 'list_share' : 'list', 22 | node : userParams.folder_path === '/' ? 'fm_root' : null, 23 | version : 1, 24 | action : 'list', 25 | filetype : 'all', 26 | folder_path : '/home', 27 | limit : 1000, 28 | offset : 0, 29 | sort_by : 'name', 30 | sort_direction: 'ASC' 31 | }; 32 | util._extend(params, userParams); 33 | 34 | var query = this.query({ 35 | path: '/webapi/FileStation/file_share.cgi', 36 | params: params 37 | }, callback || null); 38 | 39 | return query; 40 | } 41 | 42 | function upload() { 43 | /*jshint validthis:true */ 44 | var 45 | userParams = 46 | typeof arguments[0] === 'object' ? arguments[0] : 47 | {}, 48 | callback = 49 | typeof arguments[1] === 'function' ? arguments[1] : 50 | typeof arguments[0] === 'function' ? arguments[0] : 51 | null, 52 | form = new FormData(), 53 | syno = this, 54 | data = [], 55 | dataLength = 0, 56 | query 57 | ; 58 | var params = { 59 | api : 'SYNO.FileStation.Upload', 60 | method : 'upload', 61 | version : '1', 62 | overwrite : 'false', 63 | create_parents : 'true', 64 | dest_folder_path: '/home' 65 | }; 66 | 67 | util._extend(params, userParams); 68 | 69 | for (var label in params) { 70 | form.append(label, params[label]); 71 | } 72 | 73 | form.on('data', function(chunk) { 74 | chunk = new Buffer(chunk); 75 | dataLength += chunk.length; 76 | data.push(chunk); 77 | }); 78 | 79 | form.on('end', function() { 80 | query = syno.query({ 81 | path : '/webapi/FileStation/api_upload.cgi', 82 | method : 'POST', 83 | params : params, 84 | headers: { 85 | 'Content-Type': 'multipart/form-data; boundary=' + form.getBoundary(), 86 | 'Cookie' : 'id=' + syno.options.sid 87 | }, 88 | body : Buffer.concat(data, dataLength + 2) // Magic number ! 89 | }, callback || null); 90 | }); 91 | 92 | form.submit('http' + (syno.options.secure ? 's' : '') + '://' + syno.options.host + ':' + syno.options.port + '/webapi/FileStation/api_upload.cgi'); 93 | 94 | return query; 95 | } 96 | 97 | function share() { 98 | /*jshint validthis:true */ 99 | var 100 | userParams = 101 | typeof arguments[0] === 'object' ? arguments[0] : 102 | {}, 103 | callback = 104 | typeof arguments[1] === 'function' ? arguments[1] : 105 | typeof arguments[0] === 'function' ? arguments[0] : 106 | null 107 | ; 108 | var params = { 109 | path : null, 110 | api : 'SYNO.FileStation.Sharing', 111 | method : 'create', 112 | version: 1 113 | }; 114 | util._extend(params, userParams); 115 | 116 | var query = this.query({ 117 | path: '/webapi/FileStation/file_sharing.cgi', 118 | params: params 119 | }, callback || null); 120 | 121 | return query; 122 | } 123 | 124 | function unshare() { 125 | /*jshint validthis:true */ 126 | var 127 | userParams = 128 | typeof arguments[0] === 'object' ? arguments[0] : 129 | {}, 130 | callback = 131 | typeof arguments[1] === 'function' ? arguments[1] : 132 | typeof arguments[0] === 'function' ? arguments[0] : 133 | null 134 | ; 135 | var params = { 136 | id : null, 137 | api : 'SYNO.FileStation.Sharing', 138 | method : 'delete', 139 | version: 1 140 | }; 141 | util._extend(params, userParams); 142 | 143 | var query = this.query({ 144 | path: '/webapi/FileStation/file_sharing.cgi', 145 | params: params, 146 | method: 'POST' 147 | }, callback || null); 148 | 149 | return query; 150 | } 151 | 152 | module.exports = function(syno) { 153 | return { 154 | list : list.bind(syno), 155 | upload : upload.bind(syno), 156 | share : share.bind(syno), 157 | unshare: unshare.bind(syno) 158 | }; 159 | }; 160 | -------------------------------------------------------------------------------- /lib/synology.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var 4 | events = require('events'), 5 | request = require('request'), 6 | util = require('util') 7 | ; 8 | 9 | var Synology = function(options) { 10 | events.EventEmitter.call(this); 11 | 12 | var syno = this; 13 | 14 | // Default options 15 | syno.options = { 16 | host : 'localhost', 17 | port : 5000, 18 | secure : false, 19 | user : 'admin', 20 | password: 'admin' 21 | }; 22 | 23 | syno.errors = { 24 | 100: 'Unknown error', 25 | 101: 'Invalid parameter', 26 | 102: 'The requested API does not exist', 27 | 103: 'The requested method does not exist', 28 | 104: 'The requested version does not support the functionality', 29 | 105: 'The logged in session does not have permission', 30 | 106: 'Session timeout', 31 | 107: 'Session interrupted by duplicate login' 32 | }; 33 | 34 | // Override the default options by the user's one 35 | util._extend(syno.options, options); 36 | 37 | /** 38 | * Raw query to the API 39 | * @param {string} path The API path to query 40 | * @param {string} method The method to use for the query (optional, default to GET). Possible values: GET, POST, PUT, DELETE 41 | * @param {object} params Request parameters 42 | * @param {function} callback Function to execute at the end of the request. Passed the response of the request and the response code (optional, default to null) 43 | * @return {Synology} Synology object 44 | */ 45 | syno.query = function(userOptions, callback) { 46 | var 47 | options = { 48 | path : '/', 49 | method : 'GET', 50 | params : {}, 51 | headers: null 52 | }, 53 | timerStart, time 54 | ; 55 | util._extend(options, userOptions); 56 | 57 | if (!syno.options.sid && options.params.api !== 'SYNO.API.Auth') { 58 | syno.api.auth({ 59 | account: syno.options.user, 60 | passwd: syno.options.password 61 | }, function(err, data) { 62 | if (err) { 63 | syno.emit('error', err); 64 | return callback && callback(err, data); 65 | } 66 | 67 | syno.options.sid = data.data.sid; 68 | 69 | syno.query(options, callback); 70 | }); 71 | return; 72 | } else { 73 | options.params._sid = syno.options.sid; 74 | } 75 | 76 | var 77 | // Ask the API for data 78 | _apiCall = function() { 79 | syno.emit('request', options); 80 | 81 | timerStart = process.hrtime(); 82 | 83 | return request({ 84 | url : 'http' + (syno.options.secure ? 's' : '') + '://' + syno.options.host + ':' + syno.options.port + '/' + options.path, 85 | qs : options.params, 86 | body : options.body, 87 | method : options.method, 88 | headers: options.headers, 89 | timeout: 30 * 1e3 90 | }, callback ? _apiCallback : null); 91 | }, 92 | 93 | _apiCallback = function (err, res, data) { 94 | if (err) { 95 | syno.emit('error', err); 96 | return callback && callback(err, data); 97 | } 98 | 99 | // Parse the JSON response 100 | try { 101 | data = JSON.parse(data); 102 | } catch(e) { 103 | syno.emit('error', err); 104 | return callback && callback(err, data); 105 | } 106 | 107 | if (!data.success && data.error) { 108 | var error = new Error(syno.errors[data.error.code] || syno.errors[100]); 109 | syno.emit('error', error); 110 | return callback && callback(error, data); 111 | } 112 | 113 | time = process.hrtime(timerStart); 114 | syno.emit('complete', options, { 115 | code: res.statusCode, 116 | data: data, 117 | time: Math.round(time[0] * 1e3 + time[1] / 1e6) // Because returning a int is too mainstream 118 | }); 119 | 120 | return callback && callback(null, data); 121 | } 122 | ; 123 | 124 | // Call the API 125 | return _apiCall(); 126 | }; 127 | 128 | syno.api = require(__dirname + '/api')(syno); 129 | syno.audioStation = require(__dirname + '/audio-station')(syno); 130 | syno.downloadStation = require(__dirname + '/download-station')(syno); 131 | syno.dsm = require(__dirname + '/dsm')(syno); 132 | syno.dtv = require(__dirname + '/dtv')(syno); 133 | syno.fileStation = require(__dirname + '/file-station')(syno); 134 | syno.folderSharing = require(__dirname + '/folder-sharing'); 135 | syno.surveillanceStation = require(__dirname + '/surveillance-station')(syno); 136 | syno.videoController = require(__dirname + '/video-controller')(syno); 137 | syno.videoStation = require(__dirname + '/video-station')(syno); 138 | 139 | return syno; 140 | }; 141 | util.inherits(Synology, events.EventEmitter); 142 | 143 | module.exports = Synology; 144 | -------------------------------------------------------------------------------- /lib/dsm.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var util = require('util'); 4 | 5 | function info() { 6 | /*jshint validthis:true */ 7 | var 8 | userParams = 9 | typeof arguments[0] === 'object' ? arguments[0] : 10 | {}, 11 | callback = 12 | typeof arguments[1] === 'function' ? arguments[1] : 13 | typeof arguments[0] === 'function' ? arguments[0] : 14 | null 15 | ; 16 | var params = { 17 | api : 'SYNO.DSM.Info', 18 | version: 1, 19 | method : 'getinfo' 20 | }; 21 | util._extend(params, userParams); 22 | 23 | var query = this.query({ 24 | path: '/webapi/dsm/info.cgi', 25 | params: params 26 | }, callback || null); 27 | 28 | return query; 29 | } 30 | 31 | function application() { 32 | /*jshint validthis:true */ 33 | var 34 | userParams = 35 | typeof arguments[0] === 'object' ? arguments[0] : 36 | {}, 37 | callback = 38 | typeof arguments[1] === 'function' ? arguments[1] : 39 | typeof arguments[0] === 'function' ? arguments[0] : 40 | null 41 | ; 42 | var params = { 43 | api : 'SYNO.DSM.Application', 44 | version: 1 45 | }; 46 | util._extend(params, userParams); 47 | 48 | var query = this.query({ 49 | path: '/webapi/dsm/app.cgi', 50 | params: params 51 | }, callback || null); 52 | 53 | return query; 54 | } 55 | 56 | function autoBlock() { 57 | /*jshint validthis:true */ 58 | var 59 | userParams = 60 | typeof arguments[0] === 'object' ? arguments[0] : 61 | {}, 62 | callback = 63 | typeof arguments[1] === 'function' ? arguments[1] : 64 | typeof arguments[0] === 'function' ? arguments[0] : 65 | null 66 | ; 67 | var params = { 68 | api : 'SYNO.DSM.AutoBlock', 69 | version: 1 70 | }; 71 | util._extend(params, userParams); 72 | 73 | var query = this.query({ 74 | path: '/webapi/dsm/autoblock.cgi', 75 | params: params 76 | }, callback || null); 77 | 78 | return query; 79 | } 80 | 81 | function connection() { 82 | /*jshint validthis:true */ 83 | var 84 | userParams = 85 | typeof arguments[0] === 'object' ? arguments[0] : 86 | {}, 87 | callback = 88 | typeof arguments[1] === 'function' ? arguments[1] : 89 | typeof arguments[0] === 'function' ? arguments[0] : 90 | null 91 | ; 92 | var params = { 93 | api : 'SYNO.DSM.Connection', 94 | version: 1, 95 | method : 'list' 96 | }; 97 | util._extend(params, userParams); 98 | 99 | var query = this.query({ 100 | path: '/webapi/dsm/connection.cgi', 101 | params: params 102 | }, callback || null); 103 | 104 | return query; 105 | } 106 | 107 | function encryptShare() { 108 | /*jshint validthis:true */ 109 | var 110 | userParams = 111 | typeof arguments[0] === 'object' ? arguments[0] : 112 | {}, 113 | callback = 114 | typeof arguments[1] === 'function' ? arguments[1] : 115 | typeof arguments[0] === 'function' ? arguments[0] : 116 | null 117 | ; 118 | var params = { 119 | api : 'SYNO.DSM.EncryptShare', 120 | version: 1 121 | }; 122 | util._extend(params, userParams); 123 | 124 | var query = this.query({ 125 | path: '/webapi/dsm/encrypt_share.cgi', 126 | params: params 127 | }, callback || null); 128 | 129 | return query; 130 | } 131 | 132 | function findMe() { 133 | /*jshint validthis:true */ 134 | var 135 | userParams = 136 | typeof arguments[0] === 'object' ? arguments[0] : 137 | {}, 138 | callback = 139 | typeof arguments[1] === 'function' ? arguments[1] : 140 | typeof arguments[0] === 'function' ? arguments[0] : 141 | null 142 | ; 143 | var params = { 144 | api : 'SYNO.DSM.FindMe', 145 | version: 1 146 | }; 147 | util._extend(params, userParams); 148 | 149 | var query = this.query({ 150 | path: '/webapi/dsm/findme.cgi', 151 | params: params 152 | }, callback || null); 153 | 154 | return query; 155 | } 156 | 157 | function group() { 158 | /*jshint validthis:true */ 159 | var 160 | userParams = 161 | typeof arguments[0] === 'object' ? arguments[0] : 162 | {}, 163 | callback = 164 | typeof arguments[1] === 'function' ? arguments[1] : 165 | typeof arguments[0] === 'function' ? arguments[0] : 166 | null 167 | ; 168 | var params = { 169 | api : 'SYNO.DSM.Group', 170 | version: 1 171 | }; 172 | util._extend(params, userParams); 173 | 174 | var query = this.query({ 175 | path: '/webapi/dsm/group.cgi', 176 | params: params 177 | }, callback || null); 178 | 179 | return query; 180 | } 181 | 182 | function logViewer() { 183 | /*jshint validthis:true */ 184 | var 185 | userParams = 186 | typeof arguments[0] === 'object' ? arguments[0] : 187 | {}, 188 | callback = 189 | typeof arguments[1] === 'function' ? arguments[1] : 190 | typeof arguments[0] === 'function' ? arguments[0] : 191 | null 192 | ; 193 | var params = { 194 | //api : 'SYNO.DSM.LogViewer', 195 | //version: 1, 196 | start : 0, 197 | limit : 1000, 198 | sort : 'time', 199 | dir : 'DESC', 200 | logtype : 'syslog', 201 | datefrom : 0, 202 | dateto : 0, 203 | keyword : '', 204 | loglevel : '' 205 | }; 206 | util._extend(params, userParams); 207 | 208 | var query = this.query({ 209 | //path: '/webapi/dsm/logviewer.cgi', 210 | path: '/webman/modules/LogViewer/LogViewer.cgi', 211 | params: params 212 | }, callback || null); 213 | 214 | return query; 215 | } 216 | 217 | function network() { 218 | /*jshint validthis:true */ 219 | var 220 | userParams = 221 | typeof arguments[0] === 'object' ? arguments[0] : 222 | {}, 223 | callback = 224 | typeof arguments[1] === 'function' ? arguments[1] : 225 | typeof arguments[0] === 'function' ? arguments[0] : 226 | null 227 | ; 228 | var params = { 229 | api : 'SYNO.DSM.Network', 230 | version: 1 231 | }; 232 | util._extend(params, userParams); 233 | 234 | var query = this.query({ 235 | path: '/webapi/dsm/network.cgi', 236 | params: params 237 | }, callback || null); 238 | 239 | return query; 240 | } 241 | 242 | function pkg() { 243 | /*jshint validthis:true */ 244 | var 245 | userParams = 246 | typeof arguments[0] === 'object' ? arguments[0] : 247 | {}, 248 | callback = 249 | typeof arguments[1] === 'function' ? arguments[1] : 250 | typeof arguments[0] === 'function' ? arguments[0] : 251 | null 252 | ; 253 | var params = { 254 | api : 'SYNO.DSM.Package', 255 | version: 1 256 | }; 257 | util._extend(params, userParams); 258 | 259 | var query = this.query({ 260 | path: '/webapi/dsm/package.cgi', 261 | params: params 262 | }, callback || null); 263 | 264 | return query; 265 | } 266 | /* 267 | api:SYNO.DSM.Package 268 | service:phpMyAdmin 269 | method:setpackage 270 | version:1 271 | disabled:phpMyAdmin 272 | waitingTime:3000*/ 273 | 274 | function pushNotification() { 275 | /*jshint validthis:true */ 276 | var 277 | userParams = 278 | typeof arguments[0] === 'object' ? arguments[0] : 279 | {}, 280 | callback = 281 | typeof arguments[1] === 'function' ? arguments[1] : 282 | typeof arguments[0] === 'function' ? arguments[0] : 283 | null 284 | ; 285 | var params = { 286 | api : 'SYNO.DSM.PushNotification', 287 | version: 1 288 | }; 289 | util._extend(params, userParams); 290 | 291 | var query = this.query({ 292 | path: '/webapi/dsm/notification.cgi', 293 | params: params 294 | }, callback || null); 295 | 296 | return query; 297 | } 298 | 299 | function service() { 300 | /*jshint validthis:true */ 301 | var 302 | userParams = 303 | typeof arguments[0] === 'object' ? arguments[0] : 304 | {}, 305 | callback = 306 | typeof arguments[1] === 'function' ? arguments[1] : 307 | typeof arguments[0] === 'function' ? arguments[0] : 308 | null 309 | ; 310 | var params = { 311 | api : 'SYNO.DSM.Service', 312 | method : 'list', 313 | version: 1 314 | }; 315 | util._extend(params, userParams); 316 | 317 | var query = this.query({ 318 | path: '/webapi/dsm/service.cgi', 319 | params: params 320 | }, callback || null); 321 | 322 | return query; 323 | } 324 | 325 | function share() { 326 | /*jshint validthis:true */ 327 | var 328 | userParams = 329 | typeof arguments[0] === 'object' ? arguments[0] : 330 | {}, 331 | callback = 332 | typeof arguments[1] === 'function' ? arguments[1] : 333 | typeof arguments[0] === 'function' ? arguments[0] : 334 | null 335 | ; 336 | var params = { 337 | api : 'SYNO.DSM.Share', 338 | version: 1 339 | }; 340 | util._extend(params, userParams); 341 | 342 | var query = this.query({ 343 | path: '/webapi/dsm/share.cgi', 344 | params: params 345 | }, callback || null); 346 | 347 | return query; 348 | } 349 | 350 | function system() { 351 | /*jshint validthis:true */ 352 | var 353 | userParams = 354 | typeof arguments[0] === 'object' ? arguments[0] : 355 | {}, 356 | callback = 357 | typeof arguments[1] === 'function' ? arguments[1] : 358 | typeof arguments[0] === 'function' ? arguments[0] : 359 | null 360 | ; 361 | var params = { 362 | api : 'SYNO.DSM.System', 363 | version: 1 364 | }; 365 | util._extend(params, userParams); 366 | 367 | var query = this.query({ 368 | path: '/webapi/dsm/system.cgi', 369 | params: params 370 | }, callback || null); 371 | 372 | return query; 373 | } 374 | 375 | function systemLoading() { 376 | /*jshint validthis:true */ 377 | var 378 | userParams = 379 | typeof arguments[0] === 'object' ? arguments[0] : 380 | {}, 381 | callback = 382 | typeof arguments[1] === 'function' ? arguments[1] : 383 | typeof arguments[0] === 'function' ? arguments[0] : 384 | null 385 | ; 386 | var params = { 387 | api : 'SYNO.DSM.SystemLoading', 388 | version: 1 389 | }; 390 | util._extend(params, userParams); 391 | 392 | var query = this.query({ 393 | path: '/webapi/dsm/system_loading.cgi', 394 | params: params 395 | }, callback || null); 396 | 397 | return query; 398 | } 399 | 400 | function user() { 401 | /*jshint validthis:true */ 402 | var 403 | userParams = 404 | typeof arguments[0] === 'object' ? arguments[0] : 405 | {}, 406 | callback = 407 | typeof arguments[1] === 'function' ? arguments[1] : 408 | typeof arguments[0] === 'function' ? arguments[0] : 409 | null 410 | ; 411 | var params = { 412 | api : 'SYNO.DSM.User', 413 | version: 1 414 | }; 415 | util._extend(params, userParams); 416 | 417 | var query = this.query({ 418 | path: '/webapi/dsm/user.cgi', 419 | params: params 420 | }, callback || null); 421 | 422 | return query; 423 | } 424 | 425 | function volume() { 426 | /*jshint validthis:true */ 427 | var 428 | userParams = 429 | typeof arguments[0] === 'object' ? arguments[0] : 430 | {}, 431 | callback = 432 | typeof arguments[1] === 'function' ? arguments[1] : 433 | typeof arguments[0] === 'function' ? arguments[0] : 434 | null 435 | ; 436 | var params = { 437 | api : 'SYNO.DSM.Volume', 438 | version: 1 439 | }; 440 | util._extend(params, userParams); 441 | 442 | var query = this.query({ 443 | path: '/webapi/dsm/volume.cgi', 444 | params: params 445 | }, callback || null); 446 | 447 | return query; 448 | } 449 | 450 | function iSCSI() { 451 | /*jshint validthis:true */ 452 | var 453 | userParams = 454 | typeof arguments[0] === 'object' ? arguments[0] : 455 | {}, 456 | callback = 457 | typeof arguments[1] === 'function' ? arguments[1] : 458 | typeof arguments[0] === 'function' ? arguments[0] : 459 | null 460 | ; 461 | var params = { 462 | api : 'SYNO.DSM.iSCSI', 463 | version: 1 464 | }; 465 | util._extend(params, userParams); 466 | 467 | var query = this.query({ 468 | path: '/webapi/dsm/iscsi.cgi', 469 | params: params 470 | }, callback || null); 471 | 472 | return query; 473 | } 474 | 475 | module.exports = function(syno) { 476 | return { 477 | info : info.bind(syno), 478 | application : application.bind(syno), 479 | autoBlock : autoBlock.bind(syno), 480 | connection : connection.bind(syno), 481 | encryptShare : encryptShare.bind(syno), 482 | findMe : findMe.bind(syno), 483 | group : group.bind(syno), 484 | logViewer : logViewer.bind(syno), 485 | network : network.bind(syno), 486 | package : pkg.bind(syno), 487 | pushNotification: pushNotification.bind(syno), 488 | service : service.bind(syno), 489 | share : share.bind(syno), 490 | system : system.bind(syno), 491 | systemLoading : systemLoading.bind(syno), 492 | user : user.bind(syno), 493 | volume : volume.bind(syno), 494 | iSCSI : iSCSI.bind(syno) 495 | }; 496 | }; 497 | --------------------------------------------------------------------------------