MachineType
Source: machine-type.
A MachineType object allows you to interact with a Google Compute Engine machine type.
new MachineType(zone, name)
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
zone |
|
|
|
|
name |
|
|
Properties
id string
name string
zone Zone
The parent Zone instance of this MachineType instance.
Methods
create(callback)
Check if the machine type exists.
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');
machineType.exists(function(err, exists) {});
//-
// If the callback is omitted, we'll return a Promise.
//-
machineType.exists().then(function(data) {
const exists = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
callback |
function() |
|
The callback function. Values in
|
get()
Get a machine type if it exists.
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');
machineType.get(function(err, machineType, apiResponse) {
// `machineType` is a MachineType object.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
machineType.get().then(function(data) {
const machineType = data[0];
const apiResponse = data[1];
});
getMetadata([callback])
Get the machine type's metadata.
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-b');
const machineType = zone.machineType('g1-small');
machineType.getMetadata(function(err, metadata, apiResponse) {});
//-
// If the callback is omitted, we'll return a Promise.
//-
machineType.getMetadata().then(function(data) {
const metadata = data[0];
const apiResponse = data[1];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
callback |
function() |
Yes |
The callback function. Values in
|