# Compute V1 Client - Class HealthCheck (2.10.0)

2.10.0 (latest) 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.0.0 1.36.0 1.35.0 1.34.0 1.33.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 1.24.0 1.23.0 1.22.1 1.21.0 1.20.0 1.19.0 1.18.1 1.17.0 1.16.2 1.14.0 1.13.0 1.12.1 1.11.1 1.10.1 1.9.1 1.8.3 1.7.1 1.6.1 1.5.0 Reference documentation and code samples for the Compute V1 Client class HealthCheck.

Represents a health check resource.

Google Compute Engine has two health check resources:

- [Regional](https://docs.cloud.google.com/compute/docs/reference/rest/v1/regionHealthChecks)
- [Global](https://docs.cloud.google.com/compute/docs/reference/rest/v1/healthChecks) These health check resources can be used for load balancing and for autohealing VMs in a managed instance group (MIG). **Load balancing** Health check requirements vary depending on the type of load balancer. For details about the type of health check supported for each load balancer and corresponding backend type, see Health checks overview: Load balancer guide. **Autohealing in MIGs** The health checks that you use for autohealing VMs in a MIG can be either regional or global. For more information, see Set up an application health check and autohealing. For more information, seeHealth checks overview.

Generated from protobuf message `google.cloud.compute.v1.HealthCheck`

## Namespace

Google \\ Cloud \\ Compute \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ check_interval_sec` | `int` How often (in seconds) to send a health check. The default value is 5 seconds. |
| `↳ creation_timestamp` | `string` Output only. \[Output Only\] Creation timestamp in3339 text format. |
| `↳ description` | `string` An optional description of this resource. Provide this property when you create the resource. |
| `↳ grpc_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.GRPCHealthCheck` |
| `↳ grpc_tls_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.GRPCTLSHealthCheck` |
| `↳ healthy_threshold` | `int` A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2. |
| `↳ http2_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTP2HealthCheck` |
| `↳ http_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTPHealthCheck` |
| `↳ https_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTPSHealthCheck` |
| `↳ id` | `int|string` \[Output Only\] The unique identifier for the resource. This identifier is defined by the server. |
| `↳ kind` | `string` Output only. Type of the resource. |
| `↳ log_config` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HealthCheckLogConfig` Configure logging on this health check. |
| `↳ name` | `string` Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply withRFC1035. For example, a name that is 1-63 characters long, matches the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`, and otherwise complies with RFC1035. This regular expression describes a name where the first character is a lowercase letter, and all following characters are a dash, lowercase letter, or digit, except the last character, which isn't a dash. |
| `↳ region` | `string` Output only. \[Output Only\] Region where the health check resides. Not applicable to global health checks. |
| `↳ self_link` | `string` \[Output Only\] Server-defined URL for the resource. |
| `↳ source_regions` | `string[]` The list of cloud regions from which health checks are performed. If any regions are specified, then exactly 3 regions should be specified. The region names must be valid names of Google Cloud regions. This can only be set for global health check. If this list is non-empty, then there are restrictions on what other health check fields are supported and what other resources can use this health check: - SSL, HTTP2, and GRPC protocols are not supported. - The TCP request field is not supported. - The proxyHeader field for HTTP, HTTPS, and TCP is not supported. - The checkIntervalSec field must be at least 30. - The health check cannot be used with BackendService nor with managed instance group auto-healing. |
| `↳ ssl_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.SSLHealthCheck` |
| `↳ tcp_health_check` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.TCPHealthCheck` |
| `↳ timeout_sec` | `int` How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec. |
| `↳ type` | `string` Specifies the type of the healthCheck, either TCP,SSL, HTTP, HTTPS,HTTP2 or GRPC. Exactly one of the protocol-specific health check fields must be specified, which must matchtype field. Check the Type enum for the list of possible values. |
| `↳ unhealthy_threshold` | `int` A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. |

### getCheckIntervalSec

How often (in seconds) to send a health check. The default value is 5
seconds.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasCheckIntervalSec

### clearCheckIntervalSec

### setCheckIntervalSec

How often (in seconds) to send a health check. The default value is 5
seconds.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCreationTimestamp

Output only. \[Output Only\] Creation timestamp in3339
text format.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasCreationTimestamp

### clearCreationTimestamp

### setCreationTimestamp

Output only. \[Output Only\] Creation timestamp in3339
text format.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDescription

An optional description of this resource. Provide this property when you
create the resource.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasDescription

### clearDescription

### setDescription

An optional description of this resource. Provide this property when you
create the resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getGrpcHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.GRPCHealthCheck grpc_health_check = 85529574;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.GRPCHealthCheck|null` |   |

### hasGrpcHealthCheck

### clearGrpcHealthCheck

### setGrpcHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.GRPCHealthCheck grpc_health_check = 85529574;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.GRPCHealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getGrpcTlsHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.GRPCTLSHealthCheck grpc_tls_health_check = 267273258;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.GRPCTLSHealthCheck|null` |   |

### hasGrpcTlsHealthCheck

### clearGrpcTlsHealthCheck

### setGrpcTlsHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.GRPCTLSHealthCheck grpc_tls_health_check = 267273258;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.GRPCTLSHealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getHealthyThreshold

A so-far unhealthy instance will be marked healthy after this
many consecutive successes. The default value is 2.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasHealthyThreshold

### clearHealthyThreshold

### setHealthyThreshold

A so-far unhealthy instance will be marked healthy after this
many consecutive successes. The default value is 2.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getHttp2HealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.HTTP2HealthCheck http2_health_check = 11360986;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTP2HealthCheck|null` |   |

### hasHttp2HealthCheck

### clearHttp2HealthCheck

### setHttp2HealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.HTTP2HealthCheck http2_health_check = 11360986;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTP2HealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getHttpHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.HTTPHealthCheck http_health_check = 412586940;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTPHealthCheck|null` |   |

### hasHttpHealthCheck

### clearHttpHealthCheck

### setHttpHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.HTTPHealthCheck http_health_check = 412586940;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTPHealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getHttpsHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.HTTPSHealthCheck https_health_check = 436046905;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTPSHealthCheck|null` |   |

### hasHttpsHealthCheck

### clearHttpsHealthCheck

### setHttpsHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.HTTPSHealthCheck https_health_check = 436046905;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HTTPSHealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getId

\[Output Only\] The unique identifier for the resource. This identifier is
defined by the server.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int|string` |   |

### hasId

### clearId

### setId

\[Output Only\] The unique identifier for the resource. This identifier is
defined by the server.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int|string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getKind

Output only. Type of the resource.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasKind

### clearKind

### setKind

Output only. Type of the resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getLogConfig

Configure logging on this health check.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HealthCheckLogConfig|null` |   |

### hasLogConfig

### clearLogConfig

### setLogConfig

Configure logging on this health check.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.HealthCheckLogConfig` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getName

Name of the resource. Provided by the client when the resource is created.

The name must be 1-63 characters long, and comply withRFC1035.
For example, a name that is 1-63 characters long, matches the regular
expression `[a-z]([-a-z0-9]*[a-z0-9])?`, and otherwise complies with
RFC1035. This regular expression describes a name where the first
character is a lowercase letter, and all following characters are a dash,
lowercase letter, or digit, except the last character, which isn't a dash.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasName

### clearName

### setName

Name of the resource. Provided by the client when the resource is created.

The name must be 1-63 characters long, and comply withRFC1035.
For example, a name that is 1-63 characters long, matches the regular
expression `[a-z]([-a-z0-9]*[a-z0-9])?`, and otherwise complies with
RFC1035. This regular expression describes a name where the first
character is a lowercase letter, and all following characters are a dash,
lowercase letter, or digit, except the last character, which isn't a dash.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRegion

Output only. \[Output Only\] Region where the health check resides. Not applicable to
global health checks.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasRegion

### clearRegion

### setRegion

Output only. \[Output Only\] Region where the health check resides. Not applicable to
global health checks.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSelfLink

\[Output Only\] Server-defined URL for the resource.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasSelfLink

### clearSelfLink

### setSelfLink

\[Output Only\] Server-defined URL for the resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSourceRegions

The list of cloud regions from which health checks are performed. If any
regions are specified, then exactly 3 regions should be specified. The
region names must be valid names of Google Cloud regions.

This can only be set for global health check.
If this list is non-empty, then there are restrictions
on what other health check fields are supported and what other resources
can use this health check:

- SSL, HTTP2, and GRPC protocols are not supported.
- The TCP request field is not supported.
- The proxyHeader field for HTTP, HTTPS, and TCP is not supported.
- The checkIntervalSec field must be at least 30.
- The health check cannot be used with BackendService nor with managed instance group auto-healing.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<string>` |   |

### setSourceRegions

The list of cloud regions from which health checks are performed. If any
regions are specified, then exactly 3 regions should be specified. The
region names must be valid names of Google Cloud regions.

This can only be set for global health check.
If this list is non-empty, then there are restrictions
on what other health check fields are supported and what other resources
can use this health check:

- SSL, HTTP2, and GRPC protocols are not supported.
- The TCP request field is not supported.
- The proxyHeader field for HTTP, HTTPS, and TCP is not supported.
- The checkIntervalSec field must be at least 30.
- The health check cannot be used with BackendService nor with managed instance group auto-healing.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSslHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.SSLHealthCheck ssl_health_check = 280032440;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.SSLHealthCheck|null` |   |

### hasSslHealthCheck

### clearSslHealthCheck

### setSslHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.SSLHealthCheck ssl_health_check = 280032440;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.SSLHealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTcpHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.TCPHealthCheck tcp_health_check = 469980419;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.TCPHealthCheck|null` |   |

### hasTcpHealthCheck

### clearTcpHealthCheck

### setTcpHealthCheck

Generated from protobuf field `optional .google.cloud.compute.v1.TCPHealthCheck tcp_health_check = 469980419;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.TCPHealthCheck` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTimeoutSec

How long (in seconds) to wait before claiming failure. The default value is
5 seconds. It is invalid for timeoutSec to have greater
value than checkIntervalSec.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasTimeoutSec

### clearTimeoutSec

### setTimeoutSec

How long (in seconds) to wait before claiming failure. The default value is
5 seconds. It is invalid for timeoutSec to have greater
value than checkIntervalSec.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getType

Specifies the type of the healthCheck, either TCP,SSL, HTTP, HTTPS,HTTP2 or GRPC. Exactly one of the
protocol-specific health check fields must be specified, which must matchtype field.

Check the Type enum for the list of possible values.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasType

### clearType

### setType

Specifies the type of the healthCheck, either TCP,SSL, HTTP, HTTPS,HTTP2 or GRPC. Exactly one of the
protocol-specific health check fields must be specified, which must matchtype field.

Check the Type enum for the list of possible values.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getUnhealthyThreshold

A so-far healthy instance will be marked unhealthy after this many
consecutive failures. The default value is 2.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasUnhealthyThreshold

### clearUnhealthyThreshold

### setUnhealthyThreshold

A so-far healthy instance will be marked unhealthy after this many
consecutive failures. The default value is 2.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |