Compute
Source: index.
Properties
Methods
- createFirewall(name, config, callback)
- createHealthCheck(name[, options][, callback])
- createImage(name, disk[, options], callback)
- createNetwork(name, config[, callback])
- createRule(name, config, callback)
- createService(name, config[, callback])
- execAfterOperation_()
- firewall(name)
- getAddresses([options], callback)
- getAutoscalers([options], callback)
- getDisks([options], callback)
- getDisksStream([options])
- getFirewalls([options], callback)
- getFirewallsStream([query])
- getHealthChecks([options], callback)
- getHealthChecksStream([options])
- getImages([options], callback)
- getImagesStream([query])
- getInstanceGroups([options], callback)
- getInstanceGroupsStream([options])
- getMachineTypes([options], callback)
- getMachineTypesStream([options])
- getNetworks([options], callback)
- getNetworksStream([options])
- getOperations([options], callback)
- getOperationsStream([options])
- getRegions([options], callback)
- getRegionsStream([options])
- getRules([options], callback)
- getRulesStream([options])
- getServices([options], callback)
- getServicesStream([options])
- getSnapshots([options], callback)
- getSnapshotsStream([options])
- getSubnetworks([options], callback)
- getSubnetworksStream([options])
- getVMs([options], callback)
- getVMsStream([options])
- getZones([options], callback)
- getZonesStream([options])
- healthCheck(name[, options])
- image(name)
- network(name)
- operation(name)
- project()
- region(name)
- rule(name)
- service(name)
- snapshot(name)
- zone(name)
new Compute([options])
Examples
Create a client that uses Application Default Credentials (ADC)
const Compute = require('@google-cloud/compute');
const compute = new Compute();
Create a client with explicit credentials
const Compute = require('@google-cloud/compute');
const compute = new Compute({
projectId: 'your-project-id',
keyFilename: '/path/to/keyfile.json'
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
|
Yes |
Configuration options. |
- See also
Properties
Firewall constructor
Firewall class.
- See also
- Firewall
HealthCheck constructor
HealthCheck class.
- See also
- HealthCheck
Image constructor
Image class.
- See also
- Image
Network constructor
Network class.
- See also
- Network
Operation constructor
Operation class.
- See also
- Operation
Project constructor
Project class.
- See also
- Project
Region constructor
Region class.
- See also
- Region
Rule constructor
Rule class.
- See also
- Rule
Service constructor
Service class.
- See also
- Service
Snapshot constructor
Snapshot class.
- See also
- Snapshot
Zone constructor
Zone class.
- See also
- Zone
getAddressesStream
Get a list of Address objects as a readable object stream.
Example
gce.getAddressesStream()
.on('error', console.error)
.on('data', function(address) {
// `address` is an `Address` object.
})
.on('end', function() {
// All addresses retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getAddressesStream()
.on('data', function(address) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getAddresses for a complete list of options. |
- Returns
stream
getAutoscalersStream
Get a list of Autoscaler objects as a readable object stream.
Example
gce.getAutoscalersStream()
.on('error', console.error)
.on('data', function(autoscaler) {
// `autoscaler` is an `Autoscaler` object.
})
.on('end', function() {
// All addresses retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getAutoscalersStream()
.on('data', function(address) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
query |
object |
Yes |
Configuration object. See Compute#getAutoscalers for a complete list of options. |
- Returns
stream
Methods
createFirewall(name, config, callback)
Create a firewall.
Example
var config = {
protocols: {
tcp: [3000],
udp: [] // An empty array means all ports are allowed.
},
ranges: ['0.0.0.0/0']
};
function callback(err, firewall, operation, apiResponse) {
// `firewall` is a Firewall object.
// `operation` is an Operation object that can be used to check the status
// of the request.
}
gce.createFirewall('new-firewall-name', config, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.createFirewall('new-firewall-name', config).then(function(data) {
var firewall = data[0];
var operation = data[1];
var apiResponse = data[2];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
Name of the firewall. |
||||||||||||||||||||
|
config |
object |
|
See a Firewall resource. Values in
|
||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
- See also
- Throws
Errorif a name is not provided.
Errorif a config object is not provided.
createHealthCheck(name[, options][, callback])
Create an HTTP or HTTPS health check.
Example
function callback(err, healthCheck, operation, apiResponse) {
// `healthCheck` is a HealthCheck object.
// `operation` is an Operation object that can be used to check the status
// of network creation.
}
gce.createHealthCheck('new-health-check-name', callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.createHealthCheck('new-health-check-name').then(function(data) {
var healthCheck = data[0];
var operation = data[1];
var apiResponse = data[2];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
Name of the HTTP or HTTPS health check to create. |
||||||||||||||||||||
|
options |
object |
Yes |
See a HttpHealthCheck resource and HttpsHealthCheck resource. Values in
|
||||||||||||||||||||
|
callback |
function() |
Yes |
The callback function. Values in
|
- See also
createImage(name, disk[, options], callback)
Create an image from a disk.
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const disk = zone.disk('disk1');
compute.createImage('new-image', disk, function(err, operation, apiResponse) {
// `operation` is an Operation object that can be used to check the status
// of network creation.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
compute.createImage('new-image', disk).then(function(data) {
var operation = data[0];
var apiResponse = data[1];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
The name of the target image. |
||||||||||||||||
|
disk |
|
The source disk to create the image from. |
|||||||||||||||||
|
options |
object |
Yes |
See the Images: insert API documentation. |
||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
- See also
createNetwork(name, config[, callback])
Create a network.
Example
var config = {
range: '10.240.0.0/16'
};
function callback(err, network, operation, apiResponse) {
// `network` is a Network object.
// `operation` is an Operation object that can be used to check the status
// of network creation.
}
gce.createNetwork('new-network', config, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.createNetwork('new-network', config).then(function(data) {
var network = data[0];
var operation = data[1];
var apiResponse = data[2];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
Name of the network. |
||||||||||||||||||||
|
config |
object |
|
See a Network resource. Values in
|
||||||||||||||||||||
|
callback |
function() |
Yes |
The callback function. Values in
|
createRule(name, config, callback)
Create a global forwarding rule.
Example
var name = 'new-rule-name';
var config = {
target: 'global/targetHttpProxies/my-proxy',
range: '8080-8089'
};
gce.createRule(name, config, function (err, rule, operation, apiResponse) {
// `rule` is a Rule object.
// `operation` is an Operation object that can be used to check the status
// of the request.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.createRule(name, config).then(function(data) {
var rule = data[0];
var operation = data[1];
var apiResponse = data[2];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
Name of the rule. |
||||||||||||||||||||
|
config |
object |
|
See a GlobalForwardingRule resource. Values in
|
||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
createService(name, config[, callback])
Create a backend service.
Example
var config = {
backends: [
{
group: 'URL of an Instance Group resource'
}
],
healthChecks: [
'URL of an HTTP/HTTPS health check resource'
]
};
function callback(err, service, operation, apiResponse) {
// `service` is a Service object.
// `operation` is an Operation object that can be used to check the status
// of network creation.
}
gce.createService('new-service', config, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.createService('new-service', config).then(function(data) {
var service = data[0];
var operation = data[1];
var apiResponse = data[2];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
Name of the backend service. |
||||||||||||||||||||
|
config |
object |
|
See a BackendService resource. |
||||||||||||||||||||
|
callback |
function() |
Yes |
The callback function. Values in
|
execAfterOperation_() → (function(), error, or object)
Register a single callback that will wait for an operation to finish before being executed.
- Returns
function()callback - The callback function.
nullable errorcallback.err - An error returned from the operation.
objectcallback.apiResponse - The operation's final API response.
firewall(name) → Firewall
Get a reference to a Google Compute Engine firewall.
See Network#firewall to get a Firewall object for a specific network.
Example
var firewall = gce.firewall('firewall-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the firewall. |
- See also
- Returns
getAddresses([options], callback)
Get a list of addresses. For a detailed description of method's options see API reference.
Example
gce.getAddresses(function(err, addresses) {
// addresses is an array of `Address` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, addresses, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getAddresses(nextQuery, callback);
}
}
gce.getAddresses({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getAddresses().then(function(data) {
var addresses = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Address search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getAutoscalers([options], callback)
Get a list of autoscalers. For a detailed description of this method's options, see the API reference.
Example
gce.getAutoscalers(function(err, autoscalers) {
// autoscalers is an array of `Autoscaler` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, autoscalers, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getAutoscalers(nextQuery, callback);
}
}
gce.getAutoscalers({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getAutoscalers().then(function(data) {
var autoscalers = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Address search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
- See also
getDisks([options], callback)
Get a list of disks.
Example
gce.getDisks(function(err, disks) {
// `disks` is an array of `Disk` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, disks, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getDisks(nextQuery, callback);
}
}
gce.getDisks({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getDisks().then(function(data) {
var disks = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Disk search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getDisksStream([options]) → stream
Get a list of Disk objects as a readable object stream.
Example
gce.getDisksStream()
.on('error', console.error)
.on('data', function(disk) {
// `disk` is a `Disk` object.
})
.on('end', function() {
// All disks retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getDisksStream()
.on('data', function(disk) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getDisks for a complete list of options. |
- Returns
stream
getFirewalls([options], callback)
Get a list of firewalls.
Example
gce.getFirewalls(function(err, firewalls) {
// `firewalls` is an array of `Firewall` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, firewalls, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getFirewalls(nextQuery, callback);
}
}
gce.getFirewalls({
autoPaginate: false
}, callback);
gce.getFirewalls().then(function(data) {
var firewalls = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Firewall search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getFirewallsStream([query]) → stream
Get a list of Firewall objects as a readable object stream.
Example
gce.getFirewallsStream()
.on('error', console.error)
.on('data', function(firewall) {
// `firewall` is a `Firewall` object.
})
.on('end', function() {
// All firewalls retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getFirewallsStream()
.on('data', function(firewall) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
query |
object |
Yes |
Configuration object. See Compute#getFirewalls for a complete list of options. |
- Returns
stream
getHealthChecks([options], callback)
Get a list of health checks.
Example
gce.getHealthChecks(function(err, healthChecks) {
// `healthChecks` is an array of `HealthCheck` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, healthChecks, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getHealthChecks(nextQuery, callback);
}
}
gce.getHealthChecks({
autoPaginate: false
}, callback);
gce.getHealthChecks().then(function(data) {
var healthChecks = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Health check search options. Values in
|
||||||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
- See also
getHealthChecksStream([options]) → stream
Get a list of HealthCheck objects as a readable object stream.
Example
gce.getHealthChecksStream()
.on('error', console.error)
.on('data', function(healthCheck) {
// `healthCheck` is a `HealthCheck` object.
})
.on('end', function() {
// All health checks retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getHealthChecksStream()
.on('data', function(healthCheck) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getHealthChecks for a complete list of options. |
- Returns
stream
getImages([options], callback)
Get a list of images.
Example
gce.getImages(function(err, images) {
// `images` is an array of `Image` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, images, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getImages(nextQuery, callback);
}
}
gce.getImages({
autoPaginate: false
}, callback);
gce.getImages().then(function(data) {
var images = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Image search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getImagesStream([query]) → stream
Get a list of Image objects as a readable object stream.
Example
gce.getImagesStream()
.on('error', console.error)
.on('data', function(image) {
// `image` is an `Image` object.
})
.on('end', function() {
// All images retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getImagesStream()
.on('data', function(image) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
query |
object |
Yes |
Configuration object. See Compute#getImages for a complete list of options. |
- Returns
stream
getInstanceGroups([options], callback)
Get a list of instance groups.
Example
gce.getInstanceGroups(function(err, instanceGroups) {
// `instanceGroups` is an array of `InstanceGroup` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, instanceGroups, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getInstanceGroups(nextQuery, callback);
}
}
gce.getInstanceGroups({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getInstanceGroups().then(function(data) {
var instanceGroups = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Instance group search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getInstanceGroupsStream([options]) → stream
Get a list of InstanceGroup objects as a readable object stream.
Example
gce.getInstanceGroupsStream()
.on('error', console.error)
.on('data', function(instanceGroup) {
// `instanceGroup` is an `InstanceGroup` object.
})
.on('end', function() {
// All instance groups retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getInstanceGroupsStream()
.on('data', function(instanceGroup) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getInstanceGroups for a complete list of options. |
- Returns
stream
getMachineTypes([options], callback)
Get a list of machine types in this project.
Example
gce.getMachineTypes(function(err, machineTypes) {
// `machineTypes` is an array of `MachineType` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, machineTypes, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getMachineTypes(nextQuery, callback);
}
}
gce.getMachineTypes({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getMachineTypes().then(function(data) {
var machineTypes = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Machine type search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getMachineTypesStream([options]) → stream
Get a list of MachineType objects in this project as a readable object stream.
Example
gce.getMachineTypesStream()
.on('error', console.error)
.on('data', function(machineType) {
// `machineType` is a `MachineType` object.
})
.on('end', function() {
// All machine types retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getMachineTypesStream()
.on('data', function(machineType) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getMachineTypes for a complete list of options. |
- Returns
stream
getNetworks([options], callback)
Get a list of networks.
Example
gce.getNetworks(function(err, networks) {
// `networks` is an array of `Network` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, networks, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getNetworks(nextQuery, callback);
}
}
gce.getNetworks({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getNetworks().then(function(data) {
var networks = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Network search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getNetworksStream([options]) → stream
Get a list of Network objects as a readable object stream.
Example
gce.getNetworksStream()
.on('error', console.error)
.on('data', function(network) {
// `network` is a `Network` object.
})
.on('end', function() {
// All networks retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getNetworksStream()
.on('data', function(network) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getNetworks for a complete list of options. |
- Returns
stream
getOperations([options], callback)
Get a list of global operations.
Example
gce.getOperations(function(err, operations) {
// `operations` is an array of `Operation` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, operations, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getOperations(nextQuery, callback);
}
}
gce.getOperations({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getOperations().then(function(data) {
var operations = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Operation search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getOperationsStream([options]) → stream
Get a list of global Operation objects as a readable object stream.
Example
gce.getOperationsStream()
.on('error', console.error)
.on('data', function(operation) {
// `operation` is a `Operation` object.
})
.on('end', function() {
// All operations retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getOperationsStream()
.on('data', function(operation) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getOperations for a complete list of options. |
- Returns
stream
getRegions([options], callback)
Return the regions available to your project.
Example
gce.getRegions(function(err, regions) {
// `regions` is an array of `Region` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, regions, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getRegions(nextQuery, callback);
}
}
gce.getRegions({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getRegions().then(function(data) {
var regions = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Instance search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getRegionsStream([options]) → stream
Return the Region objects available to your project as a readable object stream.
Example
gce.getRegionsStream()
.on('error', console.error)
.on('data', function(region) {
// `region` is a `Region` object.
})
.on('end', function() {
// All regions retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getRegionsStream()
.on('data', function(region) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getRegions for a complete list of options. |
- Returns
stream
getRules([options], callback)
Get a list of forwarding rules.
Example
gce.getRules(function(err, rules) {
// `rules` is an array of `Rule` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, rules, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getRules(nextQuery, callback);
}
}
gce.getRules({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getRules().then(function(data) {
var rules = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Rules search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getRulesStream([options]) → stream
Get a list of Rule objects as a readable object stream.
Example
gce.getRulesStream()
.on('error', console.error)
.on('data', function(rule) {
// `rule` is a `Rule` object.
})
.on('end', function() {
// All rules retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getRulesStream()
.on('data', function(rule) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getRules for a complete list of options. |
- Returns
stream
getServices([options], callback)
Get a list of backend services.
Example
gce.getServices(function(err, services) {
// `services` is an array of `Service` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, services, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getServices(nextQuery, callback);
}
}
gce.getServices({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getServices().then(function(data) {
var services = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
BackendService search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getServicesStream([options]) → stream
Get a list of Service objects as a readable object stream.
Example
gce.getServicesStream()
.on('error', console.error)
.on('data', function(service) {
// `service` is a `Service` object.
})
.on('end', function() {
// All services retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getServicesStream()
.on('data', function(service) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getServices for a complete list of options. |
- Returns
stream
getSnapshots([options], callback)
Get a list of snapshots.
Example
gce.getSnapshots(function(err, snapshots) {
// `snapshots` is an array of `Snapshot` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, snapshots, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getSnapshots(nextQuery, callback);
}
}
gce.getSnapshots({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getSnapshots().then(function(data) {
var snapshots = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Snapshot search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getSnapshotsStream([options]) → stream
Get a list of Snapshot objects as a readable object stream.
Example
gce.getSnapshotsStream()
.on('error', console.error)
.on('data', function(snapshot) {
// `snapshot` is a `Snapshot` object.
})
.on('end', function() {
// All snapshots retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getSnapshotsStream()
.on('data', function(snapshot) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getSnapshots for a complete list of options. |
- Returns
stream
getSubnetworks([options], callback)
Get a list of subnetworks in this project.
Example
gce.getSubnetworks(function(err, subnetworks) {
// `subnetworks` is an array of `Subnetworks` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, subnetworks, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getSubnetworks(nextQuery, callback);
}
}
gce.getSubnetworks({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getSubnetworks().then(function(data) {
var subnetworks = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Subnetwork search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getSubnetworksStream([options]) → stream
Get a list of Subnetwork objects in this project as a readable object stream.
Example
gce.getSubnetworksStream()
.on('error', console.error)
.on('data', function(subnetwork) {
// `subnetwork` is a `Subnetwork` object.
})
.on('end', function() {
// All subnetworks retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getSubnetworksStream()
.on('data', function(subnetwork) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getSubnetworks for a complete list of options. |
- Returns
stream
getVMs([options], callback)
Get a list of virtual machine instances.
Example
gce.getVMs(function(err, vms) {
// `vms` is an array of `VM` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, vms, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getVMs(nextQuery, callback);
}
}
gce.getVMs({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getVMs().then(function(data) {
var vms = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Instance search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getVMsStream([options]) → stream
Get a list of VM instances as a readable object stream.
Example
gce.getVMsStream()
.on('error', console.error)
.on('data', function(vm) {
// `vm` is a `VM` object.
})
.on('end', function() {
// All vms retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getVMsStream()
.on('data', function(vm) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getVMs for a complete list of options. |
- Returns
stream
getZones([options], callback)
Return the zones available to your project.
Example
gce.getZones(function(err, zones) {
// `zones` is an array of `Zone` objects.
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, zones, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
gce.getZones(nextQuery, callback);
}
}
gce.getZones({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
gce.getZones().then(function(data) {
var zones = data[0];
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Instance search options. Values in
|
||||||||||||||||||||||||
|
callback |
function() |
|
The callback function. Values in
|
getZonesStream([options]) → stream
Return the Zone objects available to your project as a readable object stream.
Example
gce.getZonesStream()
.on('error', console.error)
.on('data', function(zone) {
// `zone` is a `Zone` object.
})
.on('end', function() {
// All zones retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
gce.getZonesStream()
.on('data', function(zone) {
this.end();
});
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
options |
object |
Yes |
Configuration object. See Compute#getZones for a complete list of options. |
- Returns
stream
healthCheck(name[, options]) → HealthCheck
Get a reference to a Google Compute Engine health check.
Example
var healthCheck = gce.healthCheck('http-health-check-name');
//-
// Access an HTTPS health check.
//-
var httpsHealthCheck = gce.healthCheck('https-health-check-name', {
https: true
});
Parameters
| Name | Type | Optional | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
name |
string |
|
Name of the health check. |
||||||||
|
options |
object |
Yes |
Configuration object. Values in
|
- See also
- Returns
image(name) → Image
Get a reference to a Google Compute Engine image.
Example
var image = gce.image('image-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the image. |
- See also
- Returns
network(name) → Network
Get a reference to a Google Compute Engine network.
Example
var network = gce.network('network-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the network. |
- See also
- Returns
operation(name) → Operation
Get a reference to a global Google Compute Engine operation.
Example
var operation = gce.operation('operation-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the existing operation. |
- See also
- Returns
project() → Project
Get a reference to your Google Compute Engine project.
Example
var project = gce.project();
- See also
- Returns
region(name) → Region
Get a reference to a Google Compute Engine region.
Example
var region = gce.region('region-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the region. |
- See also
- Returns
rule(name) → Rule
Get a reference to a Google Compute Engine forwading rule.
Example
var rule = gce.rule('rule-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the rule. |
- Returns
service(name) → Service
Get a reference to a Google Compute Engine backend service.
Example
var service = gce.service('service-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the existing service. |
- See also
- Returns
snapshot(name) → Snapshot
Get a reference to a Google Compute Engine snapshot.
Example
var snapshot = gce.snapshot('snapshot-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the existing snapshot. |
- See also
- Returns
zone(name) → Zone
Get a reference to a Google Compute Engine zone.
Example
var zone = gce.zone('zone-name');
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
name |
string |
|
Name of the zone. |
- See also
- Returns