Properties

new HealthCheck(compute, name[, options])

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

Parameters

Name Type Optional Description

compute

 

 

Compute object this health check belongs to.

name

 

 

Name of the health check.

options

 

Yes

Optional configuration.

Values in options have the following properties:

Name Type Optional Description

https

 

 

Specify if this is an HTTPS health check resource. Default: false

See also

Health Checks Overview

Properties

compute  Compute

The parent Compute instance of this HealthCheck instance.

id  string

Methods

create(options)

Create an HTTP or HTTPS health check.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

healthCheck.create(function(err, healthCheck, operation, apiResponse) {
  // `healthCheck` is a HealthCheck 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.
//-
healthCheck.create().then(function(data) {
  const healthCheck = data[0];
  const operation = data[1];
  const apiResponse = data[2];
});

Parameter

Name Type Optional Description

options

object

 

See Compute#createHealthCheck.

delete([callback])

Delete the health check.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

healthCheck.delete(function(err, operation, apiResponse) {
  // `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.
//-
healthCheck.delete().then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

operation

Operation

 

An operation object that can be used to check the status of the request.

apiResponse

object

 

The full API response.

See also

HttpHealthCheck: delete API Documentation

HttpsHealthCheck: delete API Documentation

exists(callback)

Check if the health check exists.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

healthCheck.exists(function(err, exists) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
healthCheck.exists().then(function(data) {
  const exists = data[0];
});

Parameters

Name Type Optional Description

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

exists

boolean

 

Whether the health check exists or not.

get([options])

Get the health check if it exists.

You may optionally use this to "get or create" an object by providing an object with autoCreate set to true. Any extra configuration that is normally required for the create method must be contained within this object as well.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

healthCheck.get(function(err, healthCheck, apiResponse) {
  // `healthCheck` is a HealthCheck object.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
healthCheck.get().then(function(data) {
  const healthCheck = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

options

options

Yes

Configuration object.

Values in options have the following properties:

Name Type Optional Description

autoCreate

boolean

 

Automatically create the object if it does not exist. Default: false

getMetadata([callback])

Get the health check's metadata.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

healthCheck.getMetadata(function(err, metadata, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
healthCheck.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 callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

metadata

object

 

The health check's metadata.

apiResponse

object

 

The full API response.

See also

HttpHealthChecks: get API Documentation

HttpHealthCheck resource

HttpsHealthChecks: get API Documentation

HttpsHealthCheck resource

setMetadata(metadata[, callback])

Set the health check's metadata.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const healthCheck = gce.healthCheck('health-check-name');

const metadata = {
  description: 'New description'
};

healthCheck.setMetadata(metadata, function(err, operation, apiResponse) {
  // `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.
//-
healthCheck.setMetadata(metadata).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

metadata

object

 

See a HttpHealthCheck resource and HttpsHealthCheck resource.

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

operation

Operation

 

An operation object that can be used to check the status of the request.

apiResponse

object

 

The full API response.

See also

HttpHealthCheck: insert API Documentation

HttpsHealthCheck: insert API Documentation