Documentation
¶
Overview ¶
Package bulk provides Bulk API 2.0 operations.
Index ¶
- type ColumnDelimiter
- type ContentType
- type CreateJobRequest
- type FailedRecord
- type HTTPClient
- type JobInfo
- type JobListResult
- type LineEnding
- type Operation
- type QueryJobInfo
- type QueryJobRequest
- type Service
- func (s *Service) AbortJob(ctx context.Context, jobID string) (*JobInfo, error)
- func (s *Service) AbortQueryJob(ctx context.Context, jobID string) (*QueryJobInfo, error)
- func (s *Service) CloseJob(ctx context.Context, jobID string) (*JobInfo, error)
- func (s *Service) CreateJob(ctx context.Context, req CreateJobRequest) (*JobInfo, error)
- func (s *Service) CreateQueryJob(ctx context.Context, req QueryJobRequest) (*QueryJobInfo, error)
- func (s *Service) DeleteJob(ctx context.Context, jobID string) error
- func (s *Service) DeleteQueryJob(ctx context.Context, jobID string) error
- func (s *Service) GetFailedRecords(ctx context.Context, jobID string) ([]FailedRecord, error)
- func (s *Service) GetJob(ctx context.Context, jobID string) (*JobInfo, error)
- func (s *Service) GetQueryJob(ctx context.Context, jobID string) (*QueryJobInfo, error)
- func (s *Service) GetQueryResults(ctx context.Context, jobID string, maxRecords int, locator string) ([]map[string]interface{}, string, error)
- func (s *Service) GetSuccessfulRecords(ctx context.Context, jobID string) ([]SuccessRecord, error)
- func (s *Service) GetUnprocessedRecords(ctx context.Context, jobID string) ([]map[string]interface{}, error)
- func (s *Service) ListJobs(ctx context.Context, concurrencyMode string, isPkChunkingEnabled bool) (*JobListResult, error)
- func (s *Service) UploadCSV(ctx context.Context, jobID string, records []map[string]interface{}, ...) error
- func (s *Service) UploadData(ctx context.Context, jobID string, data io.Reader) error
- func (s *Service) WaitForCompletion(ctx context.Context, jobID string, pollInterval time.Duration) (*JobInfo, error)
- type State
- type SuccessRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnDelimiter ¶
type ColumnDelimiter string
ColumnDelimiter represents CSV column delimiters.
const ( DelimiterComma ColumnDelimiter = "COMMA" DelimiterTab ColumnDelimiter = "TAB" DelimiterSemicolon ColumnDelimiter = "SEMICOLON" DelimiterPipe ColumnDelimiter = "PIPE" DelimiterBackquote ColumnDelimiter = "BACKQUOTE" DelimiterCaret ColumnDelimiter = "CARET" )
type ContentType ¶
type ContentType string
ContentType represents data content types.
const ( ContentTypeCSV ContentType = "CSV" ContentTypeJSON ContentType = "JSON" )
type CreateJobRequest ¶
type CreateJobRequest struct {
Object string `json:"object"`
Operation Operation `json:"operation"`
ExternalIdFieldName string `json:"externalIdFieldName,omitempty"`
ContentType ContentType `json:"contentType,omitempty"`
LineEnding LineEnding `json:"lineEnding,omitempty"`
ColumnDelimiter ColumnDelimiter `json:"columnDelimiter,omitempty"`
}
CreateJobRequest contains job creation parameters.
type FailedRecord ¶
type FailedRecord struct {
ID string `json:"sf__Id"`
Error string `json:"sf__Error"`
Data map[string]interface{} `json:"-"`
}
FailedRecord represents a failed record.
type HTTPClient ¶
type HTTPClient interface {
Get(ctx context.Context, path string) ([]byte, error)
Post(ctx context.Context, path string, body interface{}) ([]byte, error)
Patch(ctx context.Context, path string, body interface{}) ([]byte, error)
Put(ctx context.Context, path string, body interface{}) ([]byte, error)
Delete(ctx context.Context, path string) ([]byte, error)
}
HTTPClient interface for dependency injection.
type JobInfo ¶
type JobInfo struct {
ID string `json:"id"`
Object string `json:"object"`
Operation Operation `json:"operation"`
State State `json:"state"`
ContentType ContentType `json:"contentType"`
ColumnDelimiter string `json:"columnDelimiter"`
LineEnding LineEnding `json:"lineEnding"`
ExternalIdFieldName string `json:"externalIdFieldName,omitempty"`
CreatedById string `json:"createdById"`
CreatedDate string `json:"createdDate"`
SystemModstamp string `json:"systemModstamp"`
ConcurrencyMode string `json:"concurrencyMode"`
ContentURL string `json:"contentUrl,omitempty"`
NumberRecordsProcessed int `json:"numberRecordsProcessed"`
NumberRecordsFailed int `json:"numberRecordsFailed"`
Retries int `json:"retries"`
TotalProcessingTime int `json:"totalProcessingTime"`
ApiActiveProcessingTime int `json:"apiActiveProcessingTime"`
ApexProcessingTime int `json:"apexProcessingTime"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
JobInfo contains bulk job information.
func (*JobInfo) IsComplete ¶
IsComplete returns true if the job has finished.
type JobListResult ¶
type JobListResult struct {
Done bool `json:"done"`
Records []JobInfo `json:"records"`
NextRecordsURL string `json:"nextRecordsUrl,omitempty"`
}
JobListResult contains a list of jobs.
type LineEnding ¶
type LineEnding string
LineEnding represents line ending types.
const ( LineEndingLF LineEnding = "LF" LineEndingCRLF LineEnding = "CRLF" )
type QueryJobInfo ¶
type QueryJobInfo struct {
ID string `json:"id"`
Operation Operation `json:"operation"`
Object string `json:"object"`
State State `json:"state"`
ContentType ContentType `json:"contentType"`
CreatedById string `json:"createdById"`
CreatedDate string `json:"createdDate"`
SystemModstamp string `json:"systemModstamp"`
NumberRecordsProcessed int `json:"numberRecordsProcessed"`
}
QueryJobInfo contains query job information.
type QueryJobRequest ¶
type QueryJobRequest struct {
Query string `json:"query"`
Operation Operation `json:"operation,omitempty"`
ContentType ContentType `json:"contentType,omitempty"`
}
QueryJobRequest contains query job creation parameters.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides Bulk API 2.0 operations.
func NewService ¶
func NewService(client HTTPClient, apiVersion string) *Service
NewService creates a new Bulk service.
func (*Service) AbortQueryJob ¶
AbortQueryJob aborts a query job.
func (*Service) CreateQueryJob ¶
func (s *Service) CreateQueryJob(ctx context.Context, req QueryJobRequest) (*QueryJobInfo, error)
CreateQueryJob creates a bulk query job.
func (*Service) DeleteQueryJob ¶
DeleteQueryJob deletes a query job.
func (*Service) GetFailedRecords ¶
GetFailedRecords retrieves failed records.
func (*Service) GetQueryJob ¶
GetQueryJob retrieves query job information.
func (*Service) GetQueryResults ¶
func (s *Service) GetQueryResults(ctx context.Context, jobID string, maxRecords int, locator string) ([]map[string]interface{}, string, error)
GetQueryResults retrieves query job results.
func (*Service) GetSuccessfulRecords ¶
GetSuccessfulRecords retrieves successfully processed records.
func (*Service) GetUnprocessedRecords ¶
func (s *Service) GetUnprocessedRecords(ctx context.Context, jobID string) ([]map[string]interface{}, error)
GetUnprocessedRecords retrieves unprocessed records.
func (*Service) ListJobs ¶
func (s *Service) ListJobs(ctx context.Context, concurrencyMode string, isPkChunkingEnabled bool) (*JobListResult, error)
ListJobs lists all ingest jobs.
func (*Service) UploadCSV ¶
func (s *Service) UploadCSV(ctx context.Context, jobID string, records []map[string]interface{}, columns []string) error
UploadCSV uploads CSV data to an ingest job.
func (*Service) UploadData ¶
UploadData uploads data to an ingest job.
type SuccessRecord ¶
type SuccessRecord struct {
ID string `json:"sf__Id"`
Created bool `json:"sf__Created"`
Data map[string]interface{} `json:"-"`
}
SuccessRecord represents a successful record.