# Google Cloud Batch V1 Client - Class TaskSpec (1.4.1)

1.4.1 (latest) 1.4.0 1.3.1 1.2.2 1.1.7 1.0.3 0.17.0 0.16.10 0.15.0 0.14.0 0.13.1 0.12.1 0.11.3 0.10.0 0.9.0 0.8.0 0.7.0 0.6.0 0.5.2 0.4.0 0.3.0 0.2.2 Reference documentation and code samples for the Google Cloud Batch V1 Client class TaskSpec.

Spec of a task

Generated from protobuf message `google.cloud.batch.v1.TaskSpec`

## Namespace

Google \\ Cloud \\ Batch \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ runnables` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Runnable>` Required. The sequence of one or more runnables (executable scripts, executable containers, and/or barriers) for each task in this task group to run. Each task runs this list of runnables in order. For a task to succeed, all of its script and container runnables each must meet at least one of the following conditions: + The runnable exited with a zero status. + The runnable didn't finish, but you enabled its `background` subfield. + The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield. |
| `↳ compute_resource` | `https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.ComputeResource` ComputeResource requirements. |
| `↳ max_run_duration` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Duration` Maximum duration the task should run before being automatically retried (if enabled) or automatically failed. Format the value of this field as a time limit in seconds followed by `s`---for example, `3600s` for 1 hour. The field accepts any value between 0 and the maximum listed for the `Duration` field type at <https://protobuf.dev/reference/protobuf/google.protobuf/#duration>; however, the actual maximum run time for a job will be limited to the maximum run time for a job listed at <https://cloud.google.com/batch/quotas#max-job-duration>. |
| `↳ max_retry_count` | `int` Maximum number of retries on failures. The default, 0, which means never retry. The valid value range is \[0, 10\]. |
| `↳ lifecycle_policies` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.LifecyclePolicy>` Lifecycle management schema when any task in a task group is failed. Currently we only support one lifecycle policy. When the lifecycle policy condition is met, the action in the policy will execute. If task execution result does not meet with the defined lifecycle policy, we consider it as the default policy. Default policy means if the exit code is 0, exit task. If task ends with non-zero exit code, retry the task with max_retry_count. |
| `↳ environments` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` Deprecated: please use environment(non-plural) instead. |
| `↳ volumes` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Volume>` Volumes to mount before running Tasks using this TaskSpec. |
| `↳ environment` | `https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Environment` Environment variables to set before running the Task. |

### getRunnables

Required. The sequence of one or more runnables (executable scripts,
executable containers, and/or barriers) for each task in this task group to
run. Each task runs this list of runnables in order. For a task to succeed,
all of its script and container runnables each must meet at least one of
the following conditions:

- The runnable exited with a zero status.

- The runnable didn't finish, but you enabled its `background` subfield.

- The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Runnable>` |   |

### setRunnables

Required. The sequence of one or more runnables (executable scripts,
executable containers, and/or barriers) for each task in this task group to
run. Each task runs this list of runnables in order. For a task to succeed,
all of its script and container runnables each must meet at least one of
the following conditions:

- The runnable exited with a zero status.

- The runnable didn't finish, but you enabled its `background` subfield.

- The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Runnable>` |

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

### getComputeResource

ComputeResource requirements.

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

### hasComputeResource

### clearComputeResource

### setComputeResource

ComputeResource requirements.

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

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

### getMaxRunDuration

Maximum duration the task should run before being automatically retried
(if enabled) or automatically failed. Format the value of this field
as a time limit in seconds followed by `s`---for example, `3600s`
for 1 hour. The field accepts any value between 0 and the maximum listed
for the `Duration` field type at
<https://protobuf.dev/reference/protobuf/google.protobuf/#duration>; however,
the actual maximum run time for a job will be limited to the maximum run
time for a job listed at
<https://cloud.google.com/batch/quotas#max-job-duration>.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Duration|null` |   |

### hasMaxRunDuration

### clearMaxRunDuration

### setMaxRunDuration

Maximum duration the task should run before being automatically retried
(if enabled) or automatically failed. Format the value of this field
as a time limit in seconds followed by `s`---for example, `3600s`
for 1 hour. The field accepts any value between 0 and the maximum listed
for the `Duration` field type at
<https://protobuf.dev/reference/protobuf/google.protobuf/#duration>; however,
the actual maximum run time for a job will be limited to the maximum run
time for a job listed at
<https://cloud.google.com/batch/quotas#max-job-duration>.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Duration` |

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

### getMaxRetryCount

Maximum number of retries on failures.

The default, 0, which means never retry.
The valid value range is \[0, 10\].

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

### setMaxRetryCount

Maximum number of retries on failures.

The default, 0, which means never retry.
The valid value range is \[0, 10\].

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

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

### getLifecyclePolicies

Lifecycle management schema when any task in a task group is failed.

Currently we only support one lifecycle policy.
When the lifecycle policy condition is met,
the action in the policy will execute.
If task execution result does not meet with the defined lifecycle
policy, we consider it as the default policy.
Default policy means if the exit code is 0, exit task.
If task ends with non-zero exit code, retry the task with max_retry_count.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.LifecyclePolicy>` |   |

### setLifecyclePolicies

Lifecycle management schema when any task in a task group is failed.

Currently we only support one lifecycle policy.
When the lifecycle policy condition is met,
the action in the policy will execute.
If task execution result does not meet with the defined lifecycle
policy, we consider it as the default policy.
Default policy means if the exit code is 0, exit task.
If task ends with non-zero exit code, retry the task with max_retry_count.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.LifecyclePolicy>` |

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

### getEnvironments

Deprecated: please use environment(non-plural) instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |   |

### setEnvironments

Deprecated: please use environment(non-plural) instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |

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

### getVolumes

Volumes to mount before running Tasks using this TaskSpec.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Volume>` |   |

### setVolumes

Volumes to mount before running Tasks using this TaskSpec.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-batch/latest/V1.Volume>` |

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

### getEnvironment

Environment variables to set before running the Task.

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

### hasEnvironment

### clearEnvironment

### setEnvironment

Environment variables to set before running the Task.

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

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