Skip to main content

jobs

Creates, updates, deletes, gets or lists a jobs resource.

Overview

Namejobs
TypeResource
Idgoogle.batch.jobs

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput only. Job name. For example: "projects/123456/locations/us-central1/jobs/job01".
allocationPolicyobjectCompute resource allocation for all TaskGroups in the Job. (id: AllocationPolicy)
createTimestring (google-datetime)Output only. When the Job was created.
labelsobjectCustom labels to apply to the job and any Cloud Logging LogEntry that it generates. Use labels to group and describe the resources they are applied to. Batch automatically applies predefined labels and supports multiple labels fields for each job, which each let you apply custom labels to various resources. Label names that start with "goog-" or "google-" are reserved for predefined labels. For more information about labels with Batch, see Organize resources using labels.
logsPolicyobjectLog preservation policy for the Job. (id: LogsPolicy)
notificationsarrayNotification configurations.
prioritystring (int64)Priority of the Job. The valid value range is [0, 100). Default value is 0. Higher value indicates higher priority. A job with higher priority value is more likely to run earlier if all other requirements are satisfied.
statusobjectOutput only. Job status. It is read only for users. (id: JobStatus)
taskGroupsarrayRequired. TaskGroups in the Job. Only one TaskGroup is supported now.
uidstringOutput only. A system generated unique ID for the Job.
updateTimestring (google-datetime)Output only. The last time the Job was updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, jobsIdGet a Job specified by its resource name.
listselectprojectsId, locationsIdfilter, orderBy, pageSize, pageTokenList all Jobs for a project within a region.
createinsertprojectsId, locationsIdjobId, requestIdCreate a Job.
deletedeleteprojectsId, locationsId, jobsIdreason, requestIdDelete a Job.
cancelexecprojectsId, locationsId, jobsIdCancel a Job.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
jobsIdstring
locationsIdstring
projectsIdstring
filterstring
jobIdstring
orderBystring
pageSizeinteger (int32)
pageTokenstring
reasonstring
requestIdstring

SELECT examples

Get a Job specified by its resource name.

SELECT
name,
allocationPolicy,
createTime,
labels,
logsPolicy,
notifications,
priority,
status,
taskGroups,
uid,
updateTime
FROM google.batch.jobs
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND jobsId = '{{ jobsId }}' -- required;

INSERT examples

Create a Job.

INSERT INTO google.batch.jobs (
data__priority,
data__taskGroups,
data__allocationPolicy,
data__labels,
data__logsPolicy,
data__notifications,
projectsId,
locationsId,
jobId,
requestId
)
SELECT
'{{ priority }}',
'{{ taskGroups }}',
'{{ allocationPolicy }}',
'{{ labels }}',
'{{ logsPolicy }}',
'{{ notifications }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ jobId }}',
'{{ requestId }}'
RETURNING
name,
allocationPolicy,
createTime,
labels,
logsPolicy,
notifications,
priority,
status,
taskGroups,
uid,
updateTime
;

DELETE examples

Delete a Job.

DELETE FROM google.batch.jobs
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND jobsId = '{{ jobsId }}' --required
AND reason = '{{ reason }}'
AND requestId = '{{ requestId }}';

Lifecycle Methods

Cancel a Job.

EXEC google.batch.jobs.cancel 
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@jobsId='{{ jobsId }}' --required
@@json=
'{
"requestId": "{{ requestId }}"
}';