# REST Resource: namespaces.tasks

- [Resource: Task](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#Task)
  - [JSON representation](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#Task.SCHEMA_REPRESENTATION)
- [TaskStatus](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskStatus)
  - [JSON representation](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskStatus.SCHEMA_REPRESENTATION)
- [TaskAttemptResult](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskAttemptResult)
  - [JSON representation](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskAttemptResult.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#METHODS_SUMMARY)

## Resource: Task

Task represents a single run of a container to completion.

| JSON representation |
|---|
| ``` { "apiVersion": string, "kind": string, "metadata": { object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/ObjectMeta`) }, "spec": { object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/TaskSpec`) }, "status": { object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskStatus`) } } ``` |

| Fields ||
|---|---|
| `apiVersion` | `string` Optional. APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. |
| `kind` | `string` Optional. Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. |
| `metadata` | ``object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/ObjectMeta`)`` Optional. Standard object's metadata. |
| `spec` | ``object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/TaskSpec`)`` Optional. Specification of the desired behavior of a task. |
| `status` | ``object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskStatus`)`` Output only. Current status of a task. |

## TaskStatus

TaskStatus represents the status of a task.

| JSON representation |
|---|
| ``` { "observedGeneration": integer, "conditions": [ { object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/Condition`) } ], "index": integer, "startTime": string, "completionTime": string, "retried": integer, "lastAttemptResult": { object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskAttemptResult`) }, "logUri": string } ``` |

| Fields ||
|---|---|
| `observedGeneration` | `integer` Optional. The 'generation' of the task that was last processed by the controller. |
| `conditions[]` | ``object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/Condition`)`` Optional. Conditions communicate information about ongoing/complete reconciliation processes that bring the "spec" inline with the observed state of the world. Task-specific conditions include: - `Started`: `True` when the task has started to execute. - `Completed`: `True` when the task has succeeded. `False` when the task has failed. |
| `index` | `integer` Required. Index of the task, unique per execution, and beginning at 0. |
| `startTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Optional. Represents time when the task started to run. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `completionTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Optional. Represents time when the task was completed. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `retried` | `integer` Optional. The number of times this task was retried. Instances are retried when they fail up to the maxRetries limit. |
| `lastAttemptResult` | ``object (`https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks#TaskAttemptResult`)`` Optional. Result of the last attempt of this task. |
| `logUri` | `string` Optional. URI where logs for this task can be found in Cloud Console. |

## TaskAttemptResult

Result of a task attempt.

| JSON representation |
|---|
| ``` { "status": { object (`https://docs.cloud.google.com/run/docs/reference/rest/Shared.Types/Status`) }, "exitCode": integer, "termSignal": integer } ``` |

| Fields ||
|---|---|
| `status` | ``object (`https://docs.cloud.google.com/run/docs/reference/rest/Shared.Types/Status`)`` Optional. The status of this attempt. If the status code is OK, then the attempt succeeded. |
| `exitCode` | `integer` Optional. The exit code of this attempt. This may be unset if the container was unable to exit cleanly with a code due to some other failure. See status field for possible failure details. At most one of exitCode or termSignal will be set. |
| `termSignal` | `integer` Optional. Termination signal of the container. This is set to non-zero if the container is terminated by the system. At most one of exitCode or termSignal will be set. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks/get` | Get information about a task. |
| ### `https://docs.cloud.google.com/run/docs/reference/rest/v1/namespaces.tasks/list` | List tasks. |