From 94f2d6d951b059adf2714b2f13d1ffb33e60c37d Mon Sep 17 00:00:00 2001 From: Arthur Edelstein Date: Fri, 22 Jul 2016 22:18:32 -0700 Subject: [PATCH] implement VM.prototype.setMachineType --- lib/compute/vm.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/compute/vm.js b/lib/compute/vm.js index e4dd276817e..416f807acff 100644 --- a/lib/compute/vm.js +++ b/lib/compute/vm.js @@ -422,6 +422,42 @@ VM.prototype.reset = function(callback) { }, callback || util.noop); }; +/** + * Set the metadata for this instance. + * + * @resource [Instances: setMachineType API Documentation]{@link https://cloud.google.com/compute/docs/reference/v1/instances/setMachineType} + * + * @param {string} zone - the compute engine zone + * @param {string} machineType - new machine type. + * @param {function=} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {module:compute/operation} callback.operation - An operation object + * that can be used to check the status of the request. + * @param {object} callback.apiResponse - The full API response. + * + * @example + * vm.setMachineType( + * 'us-central1-f', + * 'n1-standard-1' + * }, function(err, operation, apiResponse) { + * // `operation` is an Operation object that can be used to check the status + * // of the request. + * }); + */ +VM.prototype.setMachineType = function(zone, machineType, callback) { + var self = this; + + callback = callback || util.noop; + + var machineTypeUrl = 'zones/' + zone + '/machineTypes/' + machineType; + + self.request({ + method: 'POST', + uri: '/setMachineType', + json: { 'machineType': machineTypeUrl } + }, callback); +}; + /** * Set the metadata for this instance. *