updateServer with options

This commit is contained in:
abalabahaha
2016-04-15 19:30:01 -07:00
parent 3ed5f4fb90
commit 5f1e1b989b
2 changed files with 18 additions and 4 deletions

View File

@@ -497,7 +497,7 @@ var InternalClient = (function () {
//def updateServer
InternalClient.prototype.updateServer = function updateServer(server, name, region) {
InternalClient.prototype.updateServer = function updateServer(server, options) {
var _this9 = this;
var server = this.resolver.resolveServer(server);
@@ -505,7 +505,14 @@ var InternalClient = (function () {
return Promise.reject(new Error("server did not resolve"));
}
return this.apiRequest("patch", _Constants.Endpoints.SERVER(server.id), true, { name: name || server.name, region: region || server.region }).then(function (res) {
if (!options.name) {
options.name = server.name;
}
if (!options.region) {
options.region = server.region;
}
return this.apiRequest("patch", _Constants.Endpoints.SERVER(server.id), true, options).then(function (res) {
// wait until the name and region are updated
return waitFor(function () {
return _this9.servers.get("name", res.name) ? _this9.servers.get("name", res.name).region === res.region ? _this9.servers.get("id", res.id) : false : false;

View File

@@ -407,13 +407,20 @@ export default class InternalClient {
}
//def updateServer
updateServer(server, name, region) {
updateServer(server, options) {
var server = this.resolver.resolveServer(server);
if (!server) {
return Promise.reject(new Error("server did not resolve"));
}
return this.apiRequest("patch", Endpoints.SERVER(server.id), true, { name: name || server.name, region: region || server.region })
if (!options.name) {
options.name = server.name;
}
if (!options.region) {
options.region = server.region;
}
return this.apiRequest("patch", Endpoints.SERVER(server.id), true, options)
.then(res => {
// wait until the name and region are updated
return waitFor(() =>