Little ZabbixAPIService refactor.
This commit is contained in:
@@ -32,7 +32,7 @@ function (angular, _) {
|
|||||||
p.request = function(method, params) {
|
p.request = function(method, params) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (this.auth) {
|
if (this.auth) {
|
||||||
return ZabbixAPIService._request(this.url, method, params, this.requestOptions, this.auth)
|
return ZabbixAPIService.request(this.url, method, params, this.requestOptions, this.auth)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@@ -43,7 +43,7 @@ function (angular, _) {
|
|||||||
return ZabbixAPIService.login(self.url, self.username, self.password, self.requestOptions)
|
return ZabbixAPIService.login(self.url, self.username, self.password, self.requestOptions)
|
||||||
.then(function(auth) {
|
.then(function(auth) {
|
||||||
self.auth = auth;
|
self.auth = auth;
|
||||||
return ZabbixAPIService._request(self.url, method, params, self.requestOptions, self.auth);
|
return ZabbixAPIService.request(self.url, method, params, self.requestOptions, self.auth);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -53,7 +53,7 @@ function (angular, _) {
|
|||||||
return ZabbixAPIService.login(this.url, this.username, this.password, this.requestOptions)
|
return ZabbixAPIService.login(this.url, this.username, this.password, this.requestOptions)
|
||||||
.then(function(auth) {
|
.then(function(auth) {
|
||||||
self.auth = auth;
|
self.auth = auth;
|
||||||
return ZabbixAPIService._request(self.url, method, params, self.requestOptions, self.auth);
|
return ZabbixAPIService.request(self.url, method, params, self.requestOptions, self.auth);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function (angular) {
|
|||||||
* Request data from Zabbix API
|
* Request data from Zabbix API
|
||||||
* @return {object} response.result
|
* @return {object} response.result
|
||||||
*/
|
*/
|
||||||
this._request = function(api_url, method, params, options, auth) {
|
this.request = function(api_url, method, params, options, auth) {
|
||||||
var requestData = {
|
var requestData = {
|
||||||
jsonrpc: '2.0',
|
jsonrpc: '2.0',
|
||||||
method: method,
|
method: method,
|
||||||
@@ -70,7 +70,7 @@ function (angular) {
|
|||||||
user: username,
|
user: username,
|
||||||
password: password
|
password: password
|
||||||
};
|
};
|
||||||
return this._request(api_url, 'user.login', params, options, null);
|
return this.request(api_url, 'user.login', params, options, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +78,7 @@ function (angular) {
|
|||||||
* Matches the version of Zabbix starting from Zabbix 2.0.4
|
* Matches the version of Zabbix starting from Zabbix 2.0.4
|
||||||
*/
|
*/
|
||||||
this.getVersion = function(api_url, options) {
|
this.getVersion = function(api_url, options) {
|
||||||
return this._request(api_url, 'apiinfo.version', [], options);
|
return this.request(api_url, 'apiinfo.version', [], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user