@@ -424,17 +424,46 @@ VM.prototype.reset = function(callback) {
424424 * @param {string } machineType - Full or partial machine type. See a list of
425425 * predefined machine types
426426 * [here](https://cloud.google.com/compute/docs/machine-types#predefined_machine_types).
427+ * @param {object= } options - Configuration object.
428+ * @param {boolean } options.start - Start the VM after successfully updating the
429+ * machine type. Default: `false`.
427430 * @param {function } callback - The callback function.
428431 * @param {?error } callback.err - An error returned while making this request.
429432 * @param {object } callback.apiResponse - The full API response.
430433 *
431434 * @example
432- * vm.resize('n1-standard-1', function(err, apiResponse) {});
435+ * vm.resize('n1-standard-1', function(err, apiResponse) {
436+ * if (!err) {
437+ * // The VM is running and its machine type was changed successfully.
438+ * }
439+ * });
440+ *
441+ * //-
442+ * // By default, calling `resize` will start your server after updating its
443+ * // machine type. If you want to leave it stopped, set `options.start` to
444+ * // `false`.
445+ * //-
446+ * var options = {
447+ * start: false
448+ * };
449+ *
450+ * vm.resize('ns-standard-1', options, function(err, apiResponse) {
451+ * if (!err) {
452+ * // The VM is stopped and its machine type was changed successfully.
453+ * }
454+ * });
433455 */
434- VM . prototype . resize = function ( machineType , callback ) {
456+ VM . prototype . resize = function ( machineType , options , callback ) {
435457 var self = this ;
436458 var compute = this . zone . parent ;
437459
460+ if ( is . fn ( options ) ) {
461+ callback = options ;
462+ options = { } ;
463+ }
464+
465+ options = options || { } ;
466+
438467 var isPartialMachineType = machineType . indexOf ( '/' ) === - 1 ;
439468
440469 if ( isPartialMachineType ) {
@@ -469,8 +498,12 @@ VM.prototype.resize = function(machineType, callback) {
469498 return ;
470499 }
471500
472- // The machine type was changed successfully. Start the VM.
473- self . start ( compute . execAfterOperation_ ( callback ) ) ;
501+ // The machine type was changed successfully.
502+ if ( options . start === false ) {
503+ callback ( null , apiResponse ) ;
504+ } else {
505+ self . start ( compute . execAfterOperation_ ( callback ) ) ;
506+ }
474507 } ) ) ;
475508} ;
476509
0 commit comments