Comparing version 0.3.2 to 0.4.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.version = exports.linkType = exports.genericType = exports.connectorType = undefined; | ||
exports.version = undefined; | ||
@@ -15,6 +15,16 @@ var _regenerator = require('babel-runtime/regenerator'); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** | ||
* Created by Chyroc on 17/1/10. | ||
*/ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _constant = require('./constant'); | ||
Object.keys(_constant).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _constant[key]; | ||
} | ||
}); | ||
}); | ||
var _utils = require('./utils'); | ||
@@ -44,6 +54,2 @@ | ||
var _keymirror = require('keymirror'); | ||
var _keymirror2 = _interopRequireDefault(_keymirror); | ||
var _querystring = require('querystring'); | ||
@@ -53,43 +59,16 @@ | ||
var _sendRequest = require('./sendRequest'); | ||
var _setJobOptions = require('./setJobOptions'); | ||
var _setLinkOptions = require('./setLinkOptions'); | ||
var _setJobOptions = require('./setJobOptions'); | ||
var _sendRequest = require('./sendRequest'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var connectorType = exports.connectorType = (0, _keymirror2.default)({ | ||
generic: null, | ||
hdfs: null | ||
}); | ||
var genericType = exports.genericType = (0, _keymirror2.default)({ | ||
mysql: null | ||
}); | ||
var linkType = exports.linkType = (0, _keymirror2.default)({ | ||
mysql: null, | ||
hdfs: null | ||
}); | ||
var sqoopAction = (0, _keymirror2.default)({ | ||
start: null, | ||
stop: null, | ||
status: null, | ||
all: null, | ||
jname: null, | ||
cname: null, | ||
enable: null, | ||
disable: null | ||
}); | ||
var version = exports.version = 'v1'; | ||
@@ -103,2 +82,6 @@ var versionUri = 'version'; | ||
/** | ||
* Hasoop client, get your own instance by creating an instance. | ||
*/ | ||
var Hasoop = function () { | ||
@@ -114,2 +97,12 @@ function Hasoop(config) { | ||
/** | ||
* use some param to create a sqoop rest api url. | ||
* | ||
* @param basicPath | ||
* @param queryObject | ||
* @param otherPath | ||
* @returns {*} | ||
*/ | ||
_createClass(Hasoop, [{ | ||
@@ -141,5 +134,65 @@ key: 'formatUrl', | ||
} | ||
}, { | ||
key: 'launchRequest', | ||
value: function () { | ||
var _ref3 = _asyncToGenerator(_regenerator2.default.mark(function _callee(methodName) { | ||
for (var _len2 = arguments.length, params = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
params[_key2 - 1] = arguments[_key2]; | ||
} | ||
// version | ||
var res, errorMessage; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (Object.keys(_constant.hasoopMethod).includes(methodName)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
throw Error('hasoop method ' + methodName + ' is not supported'); | ||
case 2: | ||
_context.next = 4; | ||
return this[methodName].apply(this, params); | ||
case 4: | ||
res = _context.sent; | ||
if (!(res.headers.get('sqoop-error-code') === '1000' && res.headers.get('sqoop-error-message') === 'OK')) { | ||
_context.next = 11; | ||
break; | ||
} | ||
_context.next = 8; | ||
return res.json(); | ||
case 8: | ||
return _context.abrupt('return', _context.sent); | ||
case 11: | ||
errorMessage = res.headers.get('sqoop-internal-error-message'); | ||
throw new Error('Hasoop error of ' + errorMessage); | ||
case 13: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function launchRequest(_x) { | ||
return _ref3.apply(this, arguments); | ||
} | ||
return launchRequest; | ||
}() | ||
/** | ||
* get sqoop server version. | ||
* | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -152,3 +205,7 @@ key: 'getVersion', | ||
// driver | ||
/** | ||
* get infos of all drivers. | ||
* | ||
* @returns {*} | ||
*/ | ||
@@ -158,7 +215,11 @@ }, { | ||
value: function getDriver() { | ||
var url = this.formatUrl([driverUri], sqoopAction.all); | ||
var url = this.formatUrl([driverUri], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
// connector | ||
/** | ||
* get infos of all connectors. | ||
* | ||
* @returns {*} | ||
*/ | ||
@@ -168,5 +229,13 @@ }, { | ||
value: function getConnectorAll() { | ||
var url = this.formatUrl([connectorUri], sqoopAction.all); | ||
var url = this.formatUrl([connectorUri], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
/** | ||
* get info of connector by connector name. | ||
* | ||
* @param connectorName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -179,3 +248,7 @@ key: 'getConnectorByConnectorName', | ||
// link | ||
/** | ||
* get infos of all links. | ||
* | ||
* @returns {*} | ||
*/ | ||
@@ -185,11 +258,27 @@ }, { | ||
value: function getLinkAll() { | ||
var url = this.formatUrl([linkUri], sqoopAction.all); | ||
var url = this.formatUrl([linkUri], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
/** | ||
* get info of link by connector name. | ||
* | ||
* @param connectorName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'getLinkByConnectorName', | ||
value: function getLinkByConnectorName(connectorName) { | ||
var url = this.formatUrl([linkUri, _defineProperty({}, sqoopAction.cname, connectorName)], sqoopAction.all); | ||
var url = this.formatUrl([linkUri, _defineProperty({}, _constant.sqoopAction.cname, connectorName)], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
/** | ||
* get info of link by link name. | ||
* | ||
* @param linkName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -201,2 +290,10 @@ key: 'getLinkByLinkName', | ||
} | ||
/** | ||
* create link. | ||
* | ||
* @param config | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -207,4 +304,13 @@ key: 'createLink', | ||
var url = this.formatUrl([linkUri]); | ||
return (0, _sendRequest.senPostRequest)(url, JSON.stringify(body)); | ||
return (0, _sendRequest.sendPostRequest)(url, JSON.stringify(body)); | ||
} | ||
/** | ||
* update link config. | ||
* | ||
* @param oldLinkName | ||
* @param config | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -215,16 +321,40 @@ key: 'updateLinkConfig', | ||
var url = this.formatUrl([linkUri], oldLinkName); | ||
return (0, _sendRequest.senPutRequest)(url, JSON.stringify(body)); | ||
return (0, _sendRequest.sendPutRequest)(url, JSON.stringify(body)); | ||
} | ||
/** | ||
* change link to enable by link name. | ||
* | ||
* @param linkName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'updateLinkEnable', | ||
value: function updateLinkEnable(linkName) { | ||
var url = this.formatUrl([linkUri], linkName, sqoopAction.enable); | ||
return (0, _sendRequest.senPutRequest)(url); | ||
var url = this.formatUrl([linkUri], linkName, _constant.sqoopAction.enable); | ||
return (0, _sendRequest.sendPutRequest)(url); | ||
} | ||
/** | ||
* change link to disable by link name. | ||
* | ||
* @param linkName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'updateLinkDisable', | ||
value: function updateLinkDisable(linkName) { | ||
var url = this.formatUrl([linkUri], linkName, sqoopAction.disable); | ||
return (0, _sendRequest.senPutRequest)(url); | ||
var url = this.formatUrl([linkUri], linkName, _constant.sqoopAction.disable); | ||
return (0, _sendRequest.sendPutRequest)(url); | ||
} | ||
/** | ||
* delete link by link name. | ||
* | ||
* @param linkName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -234,39 +364,46 @@ key: 'deleteLink', | ||
var url = this.formatUrl([linkUri], linkName); | ||
return (0, _sendRequest.senDeleteRequest)(url); | ||
return (0, _sendRequest.sendDeleteRequest)(url); | ||
} | ||
/** | ||
* delete all links on sqoop server. | ||
* | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'deleteLinkAll', | ||
value: function () { | ||
var _ref4 = _asyncToGenerator(_regenerator2.default.mark(function _callee() { | ||
var _ref5 = _asyncToGenerator(_regenerator2.default.mark(function _callee2() { | ||
var _this = this; | ||
var data, deleteList; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_context.next = 2; | ||
return this.getLinkAll(); | ||
_context2.next = 2; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkAll); | ||
case 2: | ||
data = _context.sent; | ||
data = _context2.sent; | ||
deleteList = data.links.map(function (link) { | ||
return _this.deleteLink(link.name); | ||
}); | ||
_context.next = 6; | ||
_context2.next = 6; | ||
return Promise.all(deleteList); | ||
case 6: | ||
return _context.abrupt('return', _context.sent); | ||
return _context2.abrupt('return', _context2.sent); | ||
case 7: | ||
case 'end': | ||
return _context.stop(); | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
}, _callee2, this); | ||
})); | ||
function deleteLinkAll() { | ||
return _ref4.apply(this, arguments); | ||
return _ref5.apply(this, arguments); | ||
} | ||
@@ -277,3 +414,7 @@ | ||
// job | ||
/** | ||
* get infos of all jobs. | ||
* | ||
* @returns {*} | ||
*/ | ||
@@ -283,5 +424,13 @@ }, { | ||
value: function getJobAll() { | ||
var url = this.formatUrl([jobUri], sqoopAction.all); | ||
var url = this.formatUrl([jobUri], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
/** | ||
* get info of job by job name. | ||
* | ||
* @param JobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -293,41 +442,57 @@ key: 'getJobByJobName', | ||
} | ||
/** | ||
* get info of job by connector name. | ||
* | ||
* @param connectorName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'getJobByConnectorName', | ||
value: function getJobByConnectorName(connectorName) { | ||
var url = this.formatUrl([jobUri, _defineProperty({}, sqoopAction.cname, connectorName)], sqoopAction.all); | ||
var url = this.formatUrl([jobUri, _defineProperty({}, _constant.sqoopAction.cname, connectorName)], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
/** | ||
* create job. | ||
* | ||
* @param config | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'createJob', | ||
value: function () { | ||
var _ref6 = _asyncToGenerator(_regenerator2.default.mark(function _callee2(config) { | ||
var _ref7 = _asyncToGenerator(_regenerator2.default.mark(function _callee3(config) { | ||
var fromLinkInfo, toLinkInfo, body, url; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
return _regenerator2.default.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return this.getLinkByLinkName(config['fromLinkName']); | ||
_context3.next = 2; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['fromLinkName']); | ||
case 2: | ||
fromLinkInfo = _context2.sent; | ||
_context2.next = 5; | ||
return this.getLinkByLinkName(config['toLinkName']); | ||
fromLinkInfo = _context3.sent; | ||
_context3.next = 5; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['toLinkName']); | ||
case 5: | ||
toLinkInfo = _context2.sent; | ||
toLinkInfo = _context3.sent; | ||
body = (0, _setJobOptions.setCreateJobRequestBody)(config.jobName, config.jobConfig, fromLinkInfo, toLinkInfo); | ||
url = this.formatUrl([jobUri]); | ||
return _context2.abrupt('return', (0, _sendRequest.senPostRequest)(url, JSON.stringify(body))); | ||
return _context3.abrupt('return', (0, _sendRequest.sendPostRequest)(url, JSON.stringify(body))); | ||
case 9: | ||
case 'end': | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
}, _callee3, this); | ||
})); | ||
function createJob(_x) { | ||
return _ref6.apply(this, arguments); | ||
function createJob(_x2) { | ||
return _ref7.apply(this, arguments); | ||
} | ||
@@ -337,42 +502,51 @@ | ||
}() | ||
/** | ||
* update job config. | ||
* | ||
* @param oldJobName | ||
* @param config | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'updateJobConfig', | ||
value: function () { | ||
var _ref7 = _asyncToGenerator(_regenerator2.default.mark(function _callee3(oldJobName, config) { | ||
var _ref8 = _asyncToGenerator(_regenerator2.default.mark(function _callee4(oldJobName, config) { | ||
var oldJobConfig, fromLinkInfo, toLinkInfo, body, url; | ||
return _regenerator2.default.wrap(function _callee3$(_context3) { | ||
return _regenerator2.default.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context3.t0 = _utils.splitJobConfig; | ||
_context3.next = 3; | ||
return this.getJobByJobName(oldJobName); | ||
_context4.t0 = _utils.splitJobConfig; | ||
_context4.next = 3; | ||
return this.launchRequest(_constant.hasoopMethod.getJobByJobName, oldJobName); | ||
case 3: | ||
_context3.t1 = _context3.sent; | ||
oldJobConfig = (0, _context3.t0)(_context3.t1); | ||
_context3.next = 7; | ||
return this.getLinkByLinkName(config['fromLinkName']); | ||
_context4.t1 = _context4.sent; | ||
oldJobConfig = (0, _context4.t0)(_context4.t1); | ||
_context4.next = 7; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['fromLinkName']); | ||
case 7: | ||
fromLinkInfo = _context3.sent; | ||
_context3.next = 10; | ||
return this.getLinkByLinkName(config['toLinkName']); | ||
fromLinkInfo = _context4.sent; | ||
_context4.next = 10; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['toLinkName']); | ||
case 10: | ||
toLinkInfo = _context3.sent; | ||
toLinkInfo = _context4.sent; | ||
body = (0, _setJobOptions.setUpdateJobRequestBody)(config.jobName, config.jobConfig, fromLinkInfo, toLinkInfo, oldJobConfig.topId); | ||
url = this.formatUrl([jobUri], oldJobName); | ||
return _context3.abrupt('return', (0, _sendRequest.senPutRequest)(url, JSON.stringify(body))); | ||
return _context4.abrupt('return', (0, _sendRequest.sendPutRequest)(url, JSON.stringify(body))); | ||
case 14: | ||
case 'end': | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
}, _callee4, this); | ||
})); | ||
function updateJobConfig(_x2, _x3) { | ||
return _ref7.apply(this, arguments); | ||
function updateJobConfig(_x3, _x4) { | ||
return _ref8.apply(this, arguments); | ||
} | ||
@@ -382,14 +556,38 @@ | ||
}() | ||
/** | ||
* change job to enable by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'updateJobEnable', | ||
value: function updateJobEnable(jobName) { | ||
var url = this.formatUrl([jobUri], jobName, sqoopAction.enable); | ||
return (0, _sendRequest.senPutRequest)(url); | ||
var url = this.formatUrl([jobUri], jobName, _constant.sqoopAction.enable); | ||
return (0, _sendRequest.sendPutRequest)(url); | ||
} | ||
/** | ||
* change job to disable by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'updateJobDisable', | ||
value: function updateJobDisable(jobName) { | ||
var url = this.formatUrl([jobUri], jobName, sqoopAction.disable); | ||
return (0, _sendRequest.senPutRequest)(url); | ||
var url = this.formatUrl([jobUri], jobName, _constant.sqoopAction.disable); | ||
return (0, _sendRequest.sendPutRequest)(url); | ||
} | ||
/** | ||
* delete job by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
@@ -399,39 +597,46 @@ key: 'deleteJob', | ||
var url = this.formatUrl([jobUri], jobName); | ||
return (0, _sendRequest.senDeleteRequest)(url); | ||
return (0, _sendRequest.sendDeleteRequest)(url); | ||
} | ||
/** | ||
* delete all jobs on sqoop server. | ||
* | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'deleteJobAll', | ||
value: function () { | ||
var _ref8 = _asyncToGenerator(_regenerator2.default.mark(function _callee4() { | ||
var _ref9 = _asyncToGenerator(_regenerator2.default.mark(function _callee5() { | ||
var _this2 = this; | ||
var data, deleteList; | ||
return _regenerator2.default.wrap(function _callee4$(_context4) { | ||
return _regenerator2.default.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context4.next = 2; | ||
return this.getJobAll(); | ||
_context5.next = 2; | ||
return this.launchRequest(_constant.hasoopMethod.getJobAll); | ||
case 2: | ||
data = _context4.sent; | ||
data = _context5.sent; | ||
deleteList = data.jobs.map(function (job) { | ||
return _this2.deleteJob(job.name); | ||
}); | ||
_context4.next = 6; | ||
_context5.next = 6; | ||
return Promise.all(deleteList); | ||
case 6: | ||
return _context4.abrupt('return', _context4.sent); | ||
return _context5.abrupt('return', _context5.sent); | ||
case 7: | ||
case 'end': | ||
return _context4.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
}, _callee5, this); | ||
})); | ||
function deleteJobAll() { | ||
return _ref8.apply(this, arguments); | ||
return _ref9.apply(this, arguments); | ||
} | ||
@@ -441,22 +646,50 @@ | ||
}() | ||
/** | ||
* start job by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'startJob', | ||
value: function startJob(jobName) { | ||
var url = this.formatUrl([jobUri], jobName, sqoopAction.start); | ||
return (0, _sendRequest.senPutRequest)(url); | ||
var url = this.formatUrl([jobUri], jobName, _constant.sqoopAction.start); | ||
return (0, _sendRequest.sendPutRequest)(url); | ||
} | ||
/** | ||
* stop job by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'stopJob', | ||
value: function stopJob(jobName) { | ||
var url = this.formatUrl([jobUri], jobName, sqoopAction.stop); | ||
return (0, _sendRequest.senPutRequest)(url); | ||
var url = this.formatUrl([jobUri], jobName, _constant.sqoopAction.stop); | ||
return (0, _sendRequest.sendPutRequest)(url); | ||
} | ||
/** | ||
* get status of job by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'jobStatus', | ||
value: function jobStatus(jobName) { | ||
var url = this.formatUrl([jobUri], jobName, sqoopAction.status); | ||
var url = this.formatUrl([jobUri], jobName, _constant.sqoopAction.status); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
// submission | ||
/** | ||
* get infos of all submissions. | ||
* | ||
* @returns {*} | ||
*/ | ||
@@ -466,9 +699,17 @@ }, { | ||
value: function getSubmissionAll() { | ||
var url = this.formatUrl([submissionsUri], sqoopAction.all); | ||
var url = this.formatUrl([submissionsUri], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
} | ||
/** | ||
* get info of submission by job name. | ||
* | ||
* @param jobName | ||
* @returns {*} | ||
*/ | ||
}, { | ||
key: 'getSubmissionByJobName', | ||
value: function getSubmissionByJobName(jobName) { | ||
var url = this.formatUrl([submissionsUri, _defineProperty({}, sqoopAction.jname, jobName)], sqoopAction.all); | ||
var url = this.formatUrl([submissionsUri, _defineProperty({}, _constant.sqoopAction.jname, jobName)], _constant.sqoopAction.all); | ||
return (0, _sendRequest.sendGetRequest)(url); | ||
@@ -475,0 +716,0 @@ } |
@@ -7,5 +7,5 @@ 'use strict'; | ||
exports.sendGetRequest = sendGetRequest; | ||
exports.senPostRequest = senPostRequest; | ||
exports.senPutRequest = senPutRequest; | ||
exports.senDeleteRequest = senDeleteRequest; | ||
exports.sendPostRequest = sendPostRequest; | ||
exports.sendPutRequest = sendPutRequest; | ||
exports.sendDeleteRequest = sendDeleteRequest; | ||
@@ -18,14 +18,20 @@ var _isomorphicFetch = require('isomorphic-fetch'); | ||
/** | ||
* @ignore | ||
*/ | ||
function sendRequest(method, url) { | ||
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
return (0, _isomorphicFetch2.default)(url, { method: method, body: body }).then(function (res) { | ||
return res.json(); | ||
}).catch(function (err) { | ||
console.log(err); | ||
return (0, _isomorphicFetch2.default)(url, { method: method, body: body }).catch(function (err) { | ||
return console.log(err); | ||
}); | ||
} /** | ||
* Created by Chyroc on 17/1/10. | ||
*/ | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
/** | ||
* Created by Chyroc on 17/1/10. | ||
*/ | ||
function sendGetRequest(url) { | ||
@@ -37,3 +43,6 @@ var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
function senPostRequest(url) { | ||
/** | ||
* @ignore | ||
*/ | ||
function sendPostRequest(url) { | ||
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -44,3 +53,6 @@ | ||
function senPutRequest(url) { | ||
/** | ||
* @ignore | ||
*/ | ||
function sendPutRequest(url) { | ||
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -51,3 +63,6 @@ | ||
function senDeleteRequest(url) { | ||
/** | ||
* @ignore | ||
*/ | ||
function sendDeleteRequest(url) { | ||
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -54,0 +69,0 @@ |
@@ -11,2 +11,5 @@ 'use strict'; | ||
/** | ||
* @ignore | ||
*/ | ||
function setMysqlJobConfig(linkConfig, jobConfig) { | ||
@@ -110,9 +113,12 @@ return { | ||
}; | ||
} /** | ||
* Created by Chyroc on 17/1/15. | ||
*/ | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
/** | ||
* Created by Chyroc on 17/1/15. | ||
*/ | ||
// import { connectorType } from './index' | ||
function setHdfsJobConfig(linkConfig, jobConfig) { | ||
@@ -195,2 +201,5 @@ return { | ||
/** | ||
* @ignore | ||
*/ | ||
function setJobConfig(jobConfig) { | ||
@@ -239,2 +248,5 @@ return { | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateJobRequestBody(jobName, jobConfig, fromLinkInfo, toLinkInfo) { | ||
@@ -264,4 +276,8 @@ var jobId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
function setUpdateJobRequestBody(jobName, jobConfig, fromLinkInfo, toLinkInfo, jobId) { | ||
return setCreateJobRequestBody(jobName, jobConfig, fromLinkInfo, toLinkInfo, jobId); | ||
} |
@@ -22,2 +22,5 @@ 'use strict'; | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateLinkRequestMainBody(linkName, connectorName) { | ||
@@ -35,2 +38,6 @@ return { | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateLinkRequestMysqlBody(jdbcDriver, connectionString, fetchSize, identifierEnclose, linkConfig) { | ||
@@ -125,2 +132,5 @@ return { | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateLinkRequestHdfsBody(linkConfig) { | ||
@@ -174,2 +184,5 @@ var body = { | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateMysqlLinkRequestBody(linkConfig) { | ||
@@ -187,2 +200,5 @@ var fetchSize = linkConfig.fetchSize || 1000; | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateHdfsLinkRequestBody(linkConfig) { | ||
@@ -199,2 +215,5 @@ var connectorName = 'hdfs-connector'; | ||
/** | ||
* @ignore | ||
*/ | ||
function setCreateLinkRequestBody(linkConfig) { | ||
@@ -210,4 +229,7 @@ if (linkConfig.linkType === _index.linkType.mysql) { | ||
/** | ||
* @ignore | ||
*/ | ||
function setUpdateLinkRequestBody(linkConfig) { | ||
return setCreateLinkRequestBody(linkConfig); | ||
} |
@@ -12,2 +12,3 @@ 'use strict'; | ||
exports.expectSqoopHeaders = expectSqoopHeaders; | ||
exports.splitLinkConfig = splitLinkConfig; | ||
@@ -20,4 +21,14 @@ exports.splitJobConfig = splitJobConfig; | ||
var _chai = require('chai'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function expectSqoopHeaders(res) { | ||
(0, _chai.expect)(res.headers.get('sqoop-error-code')).to.equal('1000'); | ||
(0, _chai.expect)(res.headers.get('sqoop-error-message')).to.equal('OK'); | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
function splitTopConfig(config) { | ||
@@ -27,2 +38,5 @@ return _lodash2.default.omitBy(config, _lodash2.default.isObject); | ||
/** | ||
* @ignore | ||
*/ | ||
function splitInputsConfig(configs) { | ||
@@ -39,2 +53,8 @@ var inputConfig = {}; | ||
/** | ||
* split link config. | ||
* | ||
* @param linkInfo | ||
* @returns {{}} | ||
*/ | ||
function splitLinkConfig(linkInfo) { | ||
@@ -50,2 +70,8 @@ var topConfig = splitTopConfig(_lodash2.default.get(linkInfo, 'links[0]')); | ||
/** | ||
* split job config. | ||
* | ||
* @param jobInfo | ||
* @returns {{}} | ||
*/ | ||
function splitJobConfig(jobInfo) { | ||
@@ -52,0 +78,0 @@ var topConfig = splitTopConfig(_lodash2.default.get(jobInfo, 'jobs[0]')); |
{ | ||
"name": "hasoop", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"main": "dist/index.js", | ||
@@ -29,4 +29,6 @@ "license": "MIT", | ||
"build": "babel -d dist src", | ||
"postbuild": "npm run esdoc", | ||
"esdoc": "esdoc", | ||
"lint": "standard --verbose | snazzy", | ||
"test": "npm run pre-test-mysql && SQOOPHOST=$(docker exec -i test-sqoop hostname) mocha", | ||
"test": "npm run pre-test-mysql && SQOOP_HOST=$(docker exec -i test-sqoop hostname) mocha", | ||
"precommit": "npm run lint", | ||
@@ -52,2 +54,3 @@ "prepush": "npm run lint", | ||
"coveralls": "^2.11.16", | ||
"esdoc": "^0.5.2", | ||
"faker": "^3.1.0", | ||
@@ -54,0 +57,0 @@ "husky": "^0.13.1", |
@@ -6,3 +6,4 @@ # Hasoop | ||
[![Coverage Status](https://coveralls.io/repos/github/Madadata/hasoop/badge.svg?branch=master)](https://coveralls.io/github/Madadata/hasoop?branch=master) | ||
[![ESDoc](https://doc.esdoc.org/github.com/Madadata/hasoop/badge.svg)](https://doc.esdoc.org/github.com/Madadata/hasoop/) | ||
Node.js client for Sqoop 2 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46793
9
1256
9
16