BulkJob Reference
Salesforce Bulk Job Module.
This module provides classes for managing Salesforce Bulk API 2.0 jobs, including query jobs and DML operation jobs. These classes act as wrappers around a bulk client instance to simplify job-specific operations.
SfBulkJobQuery
Bases: _SfBulkJobBase
Manage a Salesforce Bulk API query job.
This class simplifies waiting for job status and retrieving results for a specific query job.
ATTRIBUTE | DESCRIPTION |
---|---|
_sf_bulk |
The Bulk API client instance used for API communication.
TYPE:
|
id |
The unique ID for the Bulk API job.
TYPE:
|
info |
A dictionary holding the latest metadata and status for the job, which is updated after waiting.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
sf_bulk
|
The Bulk API client instance.
TYPE:
|
job_info
|
The initial job information from the API.
TYPE:
|
get_info
Fetch the latest job information from Salesforce.
Updates self.info
with the latest status.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The latest job information dictionary. |
wait
Wait the job status until it reaches a terminal state.
The terminal states are 'JobComplete', 'Aborted', or 'Failed'.
Updates self.info
with the final job status.
PARAMETER | DESCRIPTION |
---|---|
interval
|
The waiting interval in seconds. If None, the client's default is used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The final job information dictionary. |
get_results
Get the job results in the specified format.
PARAMETER | DESCRIPTION |
---|---|
format_type
|
The desired output format.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The query results. |
SfBulkJob
Bases: _SfBulkJobBase
Manage a Salesforce Bulk API DML job (e.g., insert, update, delete).
Supports uploading CSV data, marking the upload as complete, waiting its status, and retrieving successful or failed records.
ATTRIBUTE | DESCRIPTION |
---|---|
_sf_bulk |
The Bulk API client instance used for API communication.
TYPE:
|
id |
The unique ID for the Bulk API job.
TYPE:
|
info |
A dictionary holding the latest metadata and status for the job, which is updated after waiting.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
sf_bulk
|
The Bulk API client instance.
TYPE:
|
job_info
|
The initial job information from the API.
TYPE:
|
upload_data
Upload CSV data to the job.
PARAMETER | DESCRIPTION |
---|---|
csv_data
|
A string containing the data in CSV format.
TYPE:
|
complete_upload
Mark the job's data upload as complete.
This signals to Salesforce that all data has been uploaded and the job is ready for processing (transitions to 'UploadComplete' state).
get_info
Fetch the latest job information from Salesforce.
Updates self.info
with the latest status.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The latest job information dictionary. |
wait
Wait the job status until it reaches a terminal state.
The terminal states are 'JobComplete', 'Aborted', or 'Failed'.
Updates self.info
with the final job status.
PARAMETER | DESCRIPTION |
---|---|
interval
|
The waiting interval in seconds. If None, the client's default is used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The final job information dictionary. |
is_successful
Check if the job completed successfully.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the job state is 'JobComplete', False otherwise. |
has_failed_records
Check if the job has any failed records.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the number of failed records is greater than 0. |
is_failed
Check if the entire job failed.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the job state is 'Failed', False otherwise. |
is_aborted
Check if the job was aborted.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the job state is 'Aborted', False otherwise. |
get_successful_results
Get the successfully processed records.
PARAMETER | DESCRIPTION |
---|---|
format_type
|
The desired output format.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The successful records in the specified format. |
get_failed_results
Get the records that failed to process.
The results include error messages from Salesforce.
PARAMETER | DESCRIPTION |
---|---|
format_type
|
The desired output format.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The failed records in the specified format. |
get_unprocessed_records
Get records that were not processed.
This typically occurs if the job is aborted or a batch fails before these records could be processed.
PARAMETER | DESCRIPTION |
---|---|
format_type
|
The desired output format.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The unprocessed records in the specified format. |