force

package
v0.0.0-...-c071db9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package force - Salesforce BULK API is used to upload larger data sets, it supports CSV, XML and JSON as input format. It consists of jobs which contain one ore more data batches.

Batches limits are not taken care of by the package, users are responsible to check the MaxBatch constants against there batch contents

Package force provides bindings to the force.com REST API

See http://www.salesforce.com/us/developer/docs/api_rest/

Index

Constants

View Source
const (
	// MaxBatchSizeInRecords is the maimum a batch can hold
	MaxBatchSizeInRecords = 1000

	// SaveBatchSizeInRecords a bit smaller than MaxBatchSizeMiB,
	// to be on the save side
	SaveBatchSizeInRecords = 5000

	// MaxBatchSizeMiB is the maimum a batch can hold
	MaxBatchSizeMiB = 1024 * 1024 * 10

	// SaveBatchSizeMiB a bit smaller than MaxBatchSizeMiB,
	// to be on the save side
	SaveBatchSizeMiB = 1024 * 1024 * 8

	// MaxBatchCharsPerBatch a batch can contain a maximum of
	// 10,000,000 characters for all the data in a batch.
	MaxBatchCharsPerBatch = 10000000

	// MaxBatchCharsPerRecord a record can contain a maximum
	// of 400,000 characters for all its fields.
	MaxBatchCharsPerRecord = 400000

	// MaxBatchCharsPerField a field can contain a maximum of
	// 32,000 characters.
	MaxBatchCharsPerField = 32000

	// MaxBatchFields a record can contain a maximum of
	// 5,000 fields.
	MaxBatchFields = 5000
)
View Source
const (
	// BaseQueryString represents a base query.
	BaseQueryString = "SELECT %v FROM %v"
)
View Source
const MaxBatchv2SizeMiB = 1024 * 1024 * 100

MaxBatchv2SizeMiB is the maximum a batch can hold

View Source
const SaveBatchv2SizeMiB = 1024 * 1024 * 80

SaveBatchv2SizeMiB a bit smaller than MaxBatchSizeMiB, to be on the save side

Variables

This section is empty.

Functions

func BuildQuery

func BuildQuery(fields, table string, constraints []string) string

BuildQuery builds a SOQL query.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

An API represents a SalesForce API client.

func Create

func Create(version, clientID, clientSecret, userName, password, securityToken,
	environment string, requiredObj []string) (*API, error)

Create initialises a new SalesForce API client.

func CreateWithAccessToken

func CreateWithAccessToken(version, clientID, accessToken, instanceURL string) (*API, error)

CreateWithAccessToken initialises a new SalesForce API client with an access token.

func CreateWithRefreshToken

func CreateWithRefreshToken(version, clientID, accessToken, instanceURL string) (*API, error)

CreateWithRefreshToken initialises a new SalesForce API client with a refresh token.

func (*API) CloseJobByID

func (forceAPI *API) CloseJobByID(ID string) error

CloseJobByID closes a job by ID.

func (*API) CreateBulkJob

func (forceAPI *API) CreateBulkJob(
	sObjectname string,
	sObjectExtID string,
	contentType ContentType,
	operation Operation,
	mode ConcurrencyMode,
) (BulkJober, error)

CreateBulkJob creates an Bulk API 2.0 Job. sObjectExtID used for upsert and should be empty if not needed.

func (*API) CreateBulkv2Job

func (forceAPI *API) CreateBulkv2Job(sObjectname string, operation Operation) (*BulkV2Job, error)

CreateBulkv2Job creates an Bulk API 2.0 Job.

func (*API) CreateJob

func (forceAPI *API) CreateJob(bulkAPIVersion string, req *SJobRequest) (*SJob, error)

CreateJob requests a new bulk job.

func (*API) Delete

func (forceAPI *API) Delete(path string, params url.Values, headers http.Header) error

Delete issues a DELETE to the specified path with the given payload

func (*API) DeleteSObject

func (forceAPI *API) DeleteSObject(id string, in SObject) (err error)

DeleteSObject deletes an SObject.

func (*API) DeleteSObjectByExternalID

func (forceAPI *API) DeleteSObjectByExternalID(id string, in SObject) (err error)

DeleteSObjectByExternalID deletes an SObject by external ID.

func (*API) DescribeSObject

func (forceAPI *API) DescribeSObject(in SObject) (resp *SObjectDescription, err error)

DescribeSObject describes an SObject.

func (*API) DescribeSObjectStr

func (forceAPI *API) DescribeSObjectStr(object string) (resp *SObjectDescription, err error)

DescribeSObjectStr describes an SObject.

func (*API) DescribeSObjects

func (forceAPI *API) DescribeSObjects() (map[string]*SObjectMetaData, error)

DescribeSObjects describes a list of SObjects.

func (*API) FileUpload

func (forceAPI *API) FileUpload(j *SJob, params map[string]string, paramName string, file *os.File) (*SBatch, error)

FileUpload creates a new file upload http request with optional extra params

func (*API) Get

func (forceAPI *API) Get(path string, params url.Values, headers http.Header, out interface{}) error

Get issues a GET to the specified path with the given params and put the umarshalled (json) result in the third parameter

func (*API) GetAccessToken

func (forceAPI *API) GetAccessToken() string

GetAccessToken returns the access token.

func (*API) GetAllBulkv2Jobs

func (forceAPI *API) GetAllBulkv2Jobs() (resp []*BulkV2Job, err error)

GetAllBulkv2Jobs retrieves all jobs in the org

func (*API) GetAvailableRecordTypes

func (forceAPI *API) GetAvailableRecordTypes(object string) ([]SObjectRecord, error)

GetAvailableRecordTypes ...

func (*API) GetInstanceURL

func (forceAPI *API) GetInstanceURL() string

GetInstanceURL returns the instance URL.

func (*API) GetLimits

func (forceAPI *API) GetLimits() (limits *Limits, err error)

GetLimits returns a specific API limit.

func (*API) GetOpenSJobs

func (forceAPI *API) GetOpenSJobs() map[string]SJob

GetOpenSJobs return a map containing the list of open SJobs.

func (*API) GetSJob

func (forceAPI *API) GetSJob(id string) (SJob, error)

GetSJob return an open SJob.

func (*API) GetSObject

func (forceAPI *API) GetSObject(id string, fields []string, out SObject) (err error)

GetSObject returns an SObject.

func (*API) GetSObjectByExternalID

func (forceAPI *API) GetSObjectByExternalID(id string, fields []string, out SObject) (err error)

GetSObjectByExternalID returns an SObject by external ID.

func (*API) GetSObjectList

func (forceAPI *API) GetSObjectList(object string) ([]SObjectRecord, error)

GetSObjectList returns a list of SObjects with the ID and name.

func (*API) InsertSObject

func (forceAPI *API) InsertSObject(in SObject) (resp *SObjectResponse, err error)

InsertSObject creates an SObject.

func (*API) IsCompletedByID

func (forceAPI *API) IsCompletedByID(ID string) (bool, error)

IsCompletedByID given a job ID, returns whether a job is completed (i.e. no in-progress or queued records).

func (*API) Patch

func (forceAPI *API) Patch(path string, params url.Values, headers http.Header, payload, out interface{}) error

Patch issues a PATCH to the specified path with the given params and payload and put the unmarshalled (json) result in the third parameter

func (*API) Post

func (forceAPI *API) Post(path string, params url.Values, headers http.Header, payload, out interface{}) error

Post issues a POST to the specified path with the given params and payload and put the unmarshalled (json) result in the third parameter

func (*API) Put

func (forceAPI *API) Put(path string, params url.Values, headers http.Header, payload, out interface{}) error

Put issues a PUT to the specified path with the given params and payload and put the unmarshalled (json) result in the third parameter

func (*API) Query

func (forceAPI *API) Query(query string, headers http.Header, out interface{}) (err error)

Query executes a SOQL query that returns all the results in a single response, or if needed, returns part of the results and an identifier used to retrieve the remaining results.

func (*API) QueryAll

func (forceAPI *API) QueryAll(query string, out interface{}) (err error)

QueryAll executes a SOQL query that includes information about records that have been deleted because of a merge or delete. Use QueryAll rather than Query, because the Query resource will automatically filter out items that have been deleted.

func (*API) QueryNext

func (forceAPI *API) QueryNext(uri string, out interface{}) (err error)

QueryNext returns the next row in a query.

func (*API) RefreshToken

func (forceAPI *API) RefreshToken() error

RefreshToken refreshes an access token.

func (*API) TraceOff

func (forceAPI *API) TraceOff()

TraceOff turns off tracing. It is idempotent.

func (*API) TraceOn

func (forceAPI *API) TraceOn(prefix string, logger APILogger)

TraceOn turns on logging for this API. After this is called, all requests, responses, and raw response bodies will be sent to the logger. If prefix is a non-empty string, it will be written to the front of all logged strings, which can aid in filtering log lines.

Use TraceOn if you want to spy on the API requests and responses.

Note that the base log.Logger type satisfies APILogger, but adapters can easily be written for other logging packages (e.g., the golang-sanctioned glog framework).

func (*API) UpdateSObject

func (forceAPI *API) UpdateSObject(id string, in SObject) (err error)

UpdateSObject updates an SObject.

func (*API) UpsertSObjectByExternalID

func (forceAPI *API) UpsertSObjectByExternalID(id string, in SObject) (resp *SObjectResponse, err error)

UpsertSObjectByExternalID performs an upsert using an external ID.

func (*API) UpsertSObjectStringByExternalID

func (forceAPI *API) UpsertSObjectStringByExternalID(object, extenalID, id, data string) (resp *SObjectResponse, err error)

UpsertSObjectStringByExternalID performs an upsert using an external ID and the JSON string representation of an SObject.

func (*API) UpsertSObjectStringByID

func (forceAPI *API) UpsertSObjectStringByID(object, ID, data string) (resp *SObjectResponse, err error)

UpsertSObjectStringByID performs an upsert using an ID and the JSON string representation of an SObject.

type APIError

type APIError struct {
	Fields           []string `json:"fields,omitempty" force:"fields,omitempty"`
	Message          string   `json:"message,omitempty" force:"message,omitempty"`
	ErrorCode        string   `json:"errorCode,omitempty" force:"errorCode,omitempty"`
	ErrorName        string   `json:"error,omitempty" force:"error,omitempty"`
	ErrorDescription string   `json:"error_description,omitempty" force:"error_description,omitempty"`
	// batch error fields
	// NOTE:
	// Bulk API uses the same status codes and exception codes as SOAP API.
	ExceptionCode    string `json:"exceptionCode,omitempty" force:"exceptionCode,omitempty"`
	ExceptionMessage string `json:"exceptionMessage,omitempty" force:"exceptionMessage,omitempty"`
}

APIError reprensents a SalesForce API error.

func (APIError) Error

func (e APIError) Error() string

Error returns the string representation for an APIError.

func (APIError) String

func (e APIError) String() string

String formats the fields in an APIError.

func (APIError) Validate

func (e APIError) Validate() bool

Validate validates an APIError.

type APIErrors

type APIErrors []*APIError

APIErrors is a list of API errors used to handle salesforce API responses.

func (APIErrors) Error

func (e APIErrors) Error() string

Error returns the string representation for an APIErrors.

func (APIErrors) String

func (e APIErrors) String() string

String formats the fields in an APIErrors.

func (APIErrors) Validate

func (e APIErrors) Validate() bool

Validate validates an APIErrors.

type APILogger

type APILogger interface {
	Printf(format string, v ...interface{})
}

APILogger describes an API logger.

type BaseRequest

type BaseRequest interface {
	GetID() string
}

BaseRequest is the interface for job and batch requests.

type BaseResponse

type BaseResponse interface {
	GetID() string
	GetState() string
}

BaseResponse is the interface for job and batch responses.

type Batch

type Batch struct {
	API        *API
	APIVersion float32 `json:"apiVersion,omitempty"` // The API version of the job set in the URI when the job was created.

	ID    string     `json:"id,omitempty"`    // The ID of the batch.
	JobID string     `json:"jobId,omitempty"` // The unique, 18–character ID for the job associated with this batch.
	State BatchState `json:"state,omitempty"` // The current state of processing for the batch.

	// StateMessage Contains details about the state.
	// For example, if the state value is Failed, this field contains the reasons for failure.
	// If there are multiple failures, the message may be truncated. If so, fix the known errors
	// and re-submit the batch. Even if the batch failed, some records could have been completed successfully.
	StateMessage            string `json:"stateMessage,omitempty"`
	CreatedDate             string `json:"createdDate,omitempty"`             // The date and time in the UTC time zone when the batch was created.
	SystemModstamp          string `json:"systemModstamp,omitempty"`          // The date and time in the UTC time zone that processing ended. This is only valid when the state is Completed.
	NumberRecordsProcessed  int    `json:"numberRecordsProcessed,omitempty"`  // The number of records processed in this batch at the time the request was sent.
	NumberRecordsFailed     int    `json:"numberRecordsFailed,omitempty"`     // The number of records that were not processed successfully in this batch.
	TotalProcessingTime     int64  `json:"totalProcessingTime,omitempty"`     // The number of milliseconds taken to process the batch. This excludes the time the batch waited in the queue to be processed.
	ApiActiveProcessingTime int64  `json:"apiActiveProcessingTime,omitempty"` // The number of milliseconds taken to actively process the batch, and includes apexProcessingTime.
	ApexProcessingTime      int64  `json:"apexProcessingTime,omitempty"`      // The number of milliseconds taken to process triggers and other processes related to the batch data.
}

Batch holds the batch structure as represented by the API.

func (*Batch) GetNumberRecordsFailed

func (b *Batch) GetNumberRecordsFailed() int

GetNumberRecordsFailed return number of failed records

func (*Batch) GetState

func (b *Batch) GetState() BatchState

GetState returns batch status

func (*Batch) Info

func (b *Batch) Info() (err error)

Info gets information about an existing batch.

func (*Batch) Request

func (b *Batch) Request() ([]BatchRequest, error)

Request gets the request of a batch.

func (*Batch) Result

func (b *Batch) Result() ([]BatchResult, error)

Result gets results of a batch that has completed processing.

type BatchError

type BatchError struct {
	Fields     []string `json:"fields"`
	Message    string   `json:"message"`
	StatusCode string   `json:"statusCode"`
}

BatchError as represented within the API.

type BatchRequest

type BatchRequest map[string]interface{}

BatchRequest is a json represantion of the request.

type BatchResult

type BatchResult struct {
	Success bool          `json:"success"`
	Created bool          `json:"created"`
	Id      string        `json:"id"`
	Errors  []*BatchError `json:"errors"`
}

BatchResult as represented within the API.

type BatchState

type BatchState string

BatchState as represented by the API.

const (

	// BatchStateQueued Processing of the batch has not started yet.
	// If the job associated with this batch is aborted, the batch isn’t
	// processed and its state is set to
	BatchStateQueued BatchState = `Queued`

	// BatchStateInProgress the batch is being processed.
	// If the job associated with the batch is aborted, the batch is still
	// processed to completion. You must close the job associated
	// with the batch so that the batch can finish processing.
	BatchStateInProgress BatchState = `InProgress`

	// BatchStateCompleted the batch has been processed completely,
	// and the result resource is available. The result resource indicates if
	// some records have failed. A batch can be completed even if some or all
	// the records have failed. If a subset of records failed, the successful
	// records aren’t rolled back.
	BatchStateCompleted BatchState = `Completed`

	// BatchStateFailed the batch failed to process the full request due to an
	// unexpected error, such as the request is compressed with an unsupported
	// format, or an internal server error. The stateMessage element could
	// contain more details about any failures. Even if the batch failed, some
	// records could have been completed successfully. The numberRecordsProcessed
	// field tells you how many records were processed. The numberRecordsFailed
	// field contains the number of records that were not processed successfully.
	BatchStateFailed BatchState = `Failed`

	// BatchStateNotProcessed The batch won’t be processed. This state is assigned
	// when a job is aborted while the batch is queued. For bulk queries, if the job
	// has PK chunking enabled, this state is assigned to the original batch that
	// contains the query when the subsequent batches are created. After the original
	// batch is changed to this state, you can monitor the subsequent batches and
	// retrieve each batch’s results when it’s completed. Then you can safely close the job.
	BatchStateNotProcessed BatchState = `NotProcessed`
)

type Batcher

type Batcher interface {
	// Info gets information about an existing batch.
	Info() (err error)

	// Request gets the request of a batch.
	Request() ([]BatchRequest, error)

	// Result gets results of a batch that has completed processing.
	Result() ([]BatchResult, error)

	// GetState returns batch status
	GetState() BatchState

	// GetNumberRecordsFailed return number of failed records
	GetNumberRecordsFailed() int
}

Batcher interface for Batch api

type BulkJob

type BulkJob struct {
	API        *API
	APIVersion float32 `json:"apiVersion,omitempty"` // The API version of the job set in the URI when the job was created.

	ID             string    `json:"id,omitempty"`             // Unique ID for this job.
	Operation      Operation `json:"operation,omitempty"`      // The processing operation for the job. Values include: insert delete update upsert hardDelete query queryAll.
	Object         string    `json:"object,omitempty"`         // The object type for the data being processed.
	CreatedById    string    `json:"createdById,omitempty"`    // The ID of the user who created the job.
	CreatedDate    string    `json:"createdDate,omitempty"`    // The date and time in the UTC time zone when the job was created.
	SystemModstamp string    `json:"systemModstamp,omitempty"` // Date and time in the UTC time zone when the job finished.

	State               JobState        `json:"state,omitempty"`               // The current state of processing for the job.
	ExternalIdFieldName string          `json:"externalIdFieldName,omitempty"` // The name of the external ID field for an upsert.
	ConcurrencyMode     ConcurrencyMode `json:"concurrencyMode,omitempty"`     // The concurrency mode for the job.
	ContentType         ContentType     `json:"contentType,omitempty"`         // The format of the data being processed.

	NumberBatchesQueued     int `json:"numberBatchesQueued,omitempty"`     // The number of batches queued for this job.
	NumberBatchesInProgress int `json:"numberBatchesInProgress,omitempty"` // The number of batches that are in progress for this job.
	NumberBatchesCompleted  int `json:"numberBatchesCompleted,omitempty"`  // The number of batches that have been completed for this job.
	NumberBatchesFailed     int `json:"numberBatchesFailed,omitempty"`     // The number of batches that have failed for this job.
	NumberBatchesTotal      int `json:"numberBatchesTotal,omitempty"`      // The number of total batches currently in the job. This value increases as more batches are added to the job.

	NumberRecordsProcessed int `json:"numberRecordsProcessed,omitempty"` // The number of records already processed. This number increases as more batches are processed.
	NumberRetries          int `json:"numberRetries,omitempty"`          // The number of times that Salesforce attempted to save the results of an operation. The repeated attempts are due to a problem, such as a lock contention.
	NumberRecordsFailed    int `json:"numberRecordsFailed,omitempty"`    // The number of records that were not processed successfully in this job.

	ApiActiveProcessingTime int64 `json:"apiActiveProcessingTime,omitempty"` // The number of milliseconds taken to actively process the job.
	ApexProcessingTime      int64 `json:"apexProcessingTime,omitempty"`      // The number of milliseconds taken to process triggers and other processes related to the job data.
	TotalProcessingTime     int64 `json:"totalProcessingTime,omitempty"`     // The number of milliseconds taken to process the job. This is the sum of the total processing times for all batches in the job.

}

BulkJob s represented by the API.

func (*BulkJob) Abort

func (b *BulkJob) Abort() (err error)

Abort the job.

func (*BulkJob) AddBatch

func (b *BulkJob) AddBatch(batch []byte) (Batcher, error)

AddBatch adds a new batch to a job by sending a POST request to the following URI. The request body contains a list of records for processing.

func (*BulkJob) Close

func (b *BulkJob) Close() (err error)

Close the job, starts executing the batches.

func (*BulkJob) GetBatchesInfo

func (b *BulkJob) GetBatchesInfo() (batchInfo *BulkJobBatches, err error)

GetBatchesInfo gets information about all batches in a job.

func (*BulkJob) Info

func (b *BulkJob) Info() (err error)

Info of the current job.

type BulkJobBatches

type BulkJobBatches struct {
	BatchInfo []*Batch `json:"batchInf,omitempty"`
}

BulkJobBatches as represented by the API.

type BulkJobReq

type BulkJobReq struct {
	ContentType         ContentType `force:"contentType,omitempty"`         // The content type for the job. The only valid value (and the default) is CSV.
	ExternalIdFieldName string      `force:"externalIdFieldName,omitempty"` // The external ID field in the object being updated. Only needed for upsert operations. Field values must also exist in CSV job data.
	Object              string      `force:"object"`                        // The object type for the data being processed. Use only a single object type per job.
	Operation           Operation   `force:"operation"`                     // The processing operation for the job. Valid values are: insert delete update upsert
}

BulkJobReq is used to create a new job

type BulkJober

type BulkJober interface {
	// AddBatch adds a new batch to a job by sending a POST request to the following URI.
	// The request body contains a list of records for processing.
	AddBatch(batch []byte) (Batcher, error)

	// Close the job, starts executing the batches.
	Close() (err error)

	// Abort the job.
	Abort() (err error)

	// Info of the current job.
	Info() (err error)

	// GetBatchesInfo gets information about all batches in a job.
	GetBatchesInfo() (batchInfo *BulkJobBatches, err error)
}

BulkJober interface for BulkJob api

type BulkV2Job

type BulkV2Job struct {
	API        *API
	ApiVersion float32 `force:"apiVersion,omitempty"` // The API version that the job was created in.

	ID             string    `force:"id,omitempty"`             // Unique ID for this job.
	Operation      Operation `force:"operation,omitempty"`      // The processing operation for the job. Values include: insert delete update upsert
	Object         string    `force:"object,omitempty"`         // The object type for the data being processed.
	CreatedById    string    `force:"createdById,omitempty"`    // The ID of the user who created the job.
	CreatedDate    string    `force:"createdDate,omitempty"`    // The date and time in the UTC time zone when the job was created.
	SystemModstamp string    `force:"systemModstamp,omitempty"` // Date and time in the UTC time zone when the job finished.

	State               JobState        `force:"state,omitempty"`               // The current state of processing for the job.
	ExternalIdFieldName string          `force:"externalIdFieldName,omitempty"` // The name of the external ID field for an upsert.
	ConcurrencyMode     ConcurrencyMode `force:"concurrencyMode,omitempty"`     // The concurrency mode for the job.
	ContentType         string          `force:"contentType,omitempty"`         // The format of the data being processed. In Bulk API v2.0 only CSV is supported.
	ContentUrl          string          `force:"contentUrl,omitempty"`          // The URL to use for Upload Job Data requests for this job. Only valid if the job is in Open state.

	ColumnDelimiter ColumnDelimiter `force:"columnDelimiter,omitempty"` // The column delimiter used for CSV job data.
	LineEnding      LineEnding      `force:"lineEnding,omitempty"`      // The line ending used for CSV job data. Values include: LF—linefeed character CRLF—carriage return character followed by a linefeed character

	NumberRecordsFailed    int `force:"numberRecordsFailed,omitempty"`    // The number of records that were not processed successfully in this job.
	NumberRecordsProcessed int `force:"numberRecordsProcessed,omitempty"` // The number of records already processed.

	JobType                 JobType `force:"jobType,omitempty"`                  // The job’s type. Values include: BigObjectIngest—BigObjects job Classic—Bulk API 1.0 job V2Ingest—Bulk API 2.0 job
	ApiActiveProcessingTime int64   `force:"apiActiveProcessingTime,omitempty"`  // The number of milliseconds taken to actively process the job and includes apexProcessingTime
	ApexProcessingTime      int64   `force:"apexProcessingTime,omitempty"`       // The number of milliseconds taken to process triggers and other processes related to the job data.
	TotalProcessingTime     int64   `force:"totaforcelProcessingTime,omitempty"` // The number of milliseconds taken to process the job.
	Retries                 int     `force:"retries,omitempty"`                  // The number `json:" of times that Salesforce attempted to save the results of an operation.

}

BulkV2Job as represented by the API.

func (*BulkV2Job) Abort

func (b *BulkV2Job) Abort() (err error)

Abort the job.

func (*BulkV2Job) AddBatch

func (b *BulkV2Job) AddBatch(batch []byte) (err error)

AddBatch uploads a data batch of up to 150MB.

A request can provide CSV data that does not in total exceed 150 MB of base64 encoded content. When job data is uploaded, it is converted to base64. This conversion can increase the data size by approximately 50%. To account for the base64 conversion increase, upload data that does not exceed 100 MB.

func (*BulkV2Job) Close

func (b *BulkV2Job) Close() (err error)

Close the job, starts executing the batches.

func (*BulkV2Job) Delete

func (b *BulkV2Job) Delete() (err error)

Delete the job.

func (*BulkV2Job) FailedResults

func (b *BulkV2Job) FailedResults() (resp []byte, err error)

FailedResults of job execution.

Returns a CSV with all failed records. CSV fields are as provided in the original job data. Except two additional fields: "sf__Id" and "sf__Created"

func (*BulkV2Job) Info

func (b *BulkV2Job) Info() (err error)

Info of the current job.

func (*BulkV2Job) SuccessfulResults

func (b *BulkV2Job) SuccessfulResults() (resp []byte, err error)

SuccessfulResults of job execution.

Returns a CSV with all successful records. CSV fields are as provided in the original job data. Except two additional fields: "sf__Id" and "sf__Created"

func (*BulkV2Job) UnprocessedRecords

func (b *BulkV2Job) UnprocessedRecords() (resp []byte, err error)

UnprocessedRecords of job execution.

A job that is interrupted or otherwise fails to complete can result in rows that aren’t processed. Unprocessed rows are not the same as failed rows. Failed rows are processed but encounter an error during processing.

Returns a CSV with all failed records. CSV fields are as provided in the original job data.

type BulkV2JobList

type BulkV2JobList struct {
	Done           bool        `json:"done"`
	NextRecordsUrl string      `json:"nextRecordsUrl"`
	Records        []BulkV2Job `json:"records"`
}

BulkV2JobList us used to unmarshal a list of BulkV2Jobs.

type Bulkv2JobReq

type Bulkv2JobReq struct {
	ColumnDelimiter     string      `force:"columnDelimiter,omitempty"`     // The column delimiter used for CSV job data. The default value is COMMA.
	ContentType         ContentType `force:"contentType,omitempty"`         // The content type for the job. The only valid value (and the default) is CSV.
	ExternalIdFieldName string      `force:"externalIdFieldName,omitempty"` // The external ID field in the object being updated. Only needed for upsert operations. Field values must also exist in CSV job data.
	LineEnding          LineEnding  `force:"lineEnding,omitempty"`          // The line ending used for CSV job data, marking the end of a data row. The default is LF. Valid values are:
	Object              string      `force:"object"`                        // The object type for the data being processed. Use only a single object type per job.
	Operation           Operation   `force:"operation"`                     // The processing operation for the job. Valid values are: insert delete update upsert
}

Bulkv2JobReq is used to create a new Bulk API 2.0 Job.

type ChildRelationship

type ChildRelationship struct {
	Field               string `json:"field"`
	ChildSObject        string `json:"childSObject"`
	DeprecatedAndHidden bool   `json:"deprecatedAndHidden"`
	CascadeDelete       bool   `json:"cascadeDelete"`
	RestrictedDelete    bool   `json:"restrictedDelete"`
	RelationshipName    string `json:"relationshipName"`
}

ChildRelationship represents a child relationship for two SObjects.

type ColumnDelimiter

type ColumnDelimiter string

ColumnDelimiter mode for ContentTypeCSV

const (

	// ColumnDelimiterBackquote `
	ColumnDelimiterBackquote ColumnDelimiter = `BACKQUOTE`

	// ColumnDelimiterCaret ^
	ColumnDelimiterCaret ColumnDelimiter = `CARET`

	// ColumnDelimiterComma ,
	ColumnDelimiterComma ColumnDelimiter = `COMMA`

	// ColumnDelimiterPipe |
	ColumnDelimiterPipe ColumnDelimiter = `PIPE`

	// ColumnDelimiterSemicolon :
	ColumnDelimiterSemicolon ColumnDelimiter = `SEMICOLON`

	// ColumnDelimiterTab tab
	ColumnDelimiterTab ColumnDelimiter = `TAB`
)

type ConcurrencyMode

type ConcurrencyMode string

ConcurrencyMode mode

const (

	// ConcurrencyModeParallel runs in parallel
	ConcurrencyModeParallel ConcurrencyMode = `Parallel`

	// ConcurrencyModeSerial runs in serial
	ConcurrencyModeSerial ConcurrencyMode = `Serial`
)

type ContentType

type ContentType string

ContentType within the Batch

const (

	// ContentTypeCSV data in CSV format (default and only supported content type for Bulk V2 type jobs)
	ContentTypeCSV ContentType = `CSV`

	// ContentTypeJSON data in JSON format
	ContentTypeJSON ContentType = `JSON`

	// ContentTypeXML data in XML format (default option for Bulk V1 type jobs)
	ContentTypeXML ContentType = `XML`

	// ContentTypeZIPXML data in CSV format in a zip file containing binary attachments
	ContentTypeZIPXML ContentType = `ZIP_XML`

	// ContentTypeZIPJSON data in JSON format in a zip file containing binary attachments
	ContentTypeZIPJSON ContentType = `ZIP_JSON`

	// ContentTypeZIPCSV data in XML format in a zip file containing binary attachments
	ContentTypeZIPCSV ContentType = `ZIP_CSV`
)

type JobState

type JobState string

JobState used to control and monitor jobs

const (

	// JobStateOpen job is open to add batches
	JobStateOpen JobState = `Open`

	// JobStateClosed job is open to add batches
	JobStateClosed JobState = `Closed`

	// JobStateUploadComplete job is queued or running
	JobStateUploadComplete JobState = `UploadComplete`

	// JobStateAborted job was aborted
	JobStateAborted JobState = `Aborted`

	// JobStateJobComplete job is completed
	JobStateJobComplete JobState = `JobComplete`

	// JobStateFailed job has failed
	JobStateFailed JobState = `Failed`
)

type JobType

type JobType string

JobType description

const (

	// JobTypeBigObjectIngest ...
	JobTypeBigObjectIngest JobType = `BigObjectIngest`

	// JobTypeClassic ...
	JobTypeClassic JobType = `Classic`

	// JobTypeV2Ingest ...
	JobTypeV2Ingest JobType = `V2Ingest`
)

type Limit

type Limit struct {
	Remaining float64
	Max       float64
}

Limit describes an API limit.

type Limits

type Limits map[string]Limit

Limits is map containing limits.

type LineEnding

type LineEnding string

LineEnding mode

const (

	// LineEndingLF LF
	LineEndingLF LineEnding = `LF`

	// LineEndingCRLF CRLF
	LineEndingCRLF LineEnding = `CRLF`
)

type Operation

type Operation string

Operation on the individual records

const (

	// OperationInsert inserts a new record
	OperationInsert Operation = `insert`

	// OperationDelete deletes a record
	OperationDelete Operation = `delete`

	// OperationUpdate updates a recored
	OperationUpdate Operation = `update`

	// OperationUpsert upserts a record
	OperationUpsert Operation = `upsert`

	// OperationHardDelete (Bulk V1 type jobs only)
	OperationHardDelete Operation = `hardDelete` // (Bulk V1 type jobs only)

	// OperationQuery (Bulk V1 type jobs only)
	OperationQuery Operation = `query` // (Bulk V1 type jobs only)

	// OperationQyeryAll (Bulk V1 type jobs only)
	OperationQyeryAll Operation = `queryall` //(Bulk V1 type jobs only)

)

type PicklistValue

type PicklistValue struct {
	Value       string `json:"value"`
	DefaulValue bool   `json:"defaultValue"`
	ValidFor    string `json:"validFor"`
	Active      bool   `json:"active"`
	Label       string `json:"label"`
}

PicklistValue represents a picklist value type.

type RecordTypeInfo

type RecordTypeInfo struct {
	Name                     string            `json:"name"`
	Available                bool              `json:"available"`
	RecordTypeID             string            `json:"recordTypeID"`
	URLs                     map[string]string `json:"urls"`
	DefaultRecordTypeMapping bool              `json:"defaultRecordTypeMapping"`
}

RecordTypeInfo represents a record value type.

type RefreshTokenResponse

type RefreshTokenResponse struct {
	ID          string `json:"id"`
	IssuedAt    string `json:"issued_at"`
	Signature   string `json:"signature"`
	AccessToken string `json:"access_token"`
}

RefreshTokenResponse represents a refresh token.

type SBatch

type SBatch struct {
	ApexProcessingTime      int    `json:"apexProcessingTime"`
	APIActiveProcessingTime int    `json:"apiActiveProcessingTime"`
	CreatedDate             string `json:"createdDate"`
	ID                      string `json:"id"`
	JobID                   string `json:"jobId"`
	NumberRecordsFailed     int    `json:"numberRecordsFailed"`
	NumberRecordsProcessed  int    `json:"numberRecordsProcessed"`
	State                   string `json:"state"`
	SystemModstamp          string `json:"systemModstamp"`
	TotalProcessingTime     int    `json:"totalProcessingTime"`
}

SBatch represents a batch of records.

type SBatchInfo

type SBatchInfo struct {
	BatchInfo []SBatch `json:"batchInfo"`
}

SBatchInfo is container for the a list of batch status.

type SBatchResponse

type SBatchResponse struct {
	ID      string    `json:"id"`
	Errors  APIErrors `json:"errors"`
	Success bool      `json:"success"`
	Created bool      `json:"created"`
}

SBatchResponse contains the batch results.

type SJob

type SJob struct {
	BaseResponse
	ApexProcessingTime      int     `json:"apexProcessingTime"`
	APIVersion              float64 `json:"apiVersion"`
	APIActiveProcessingTime int     `json:"apiActiveProcessingTime"`
	AssignmentRuleID        string  `json:"assignmentRuleId"`
	BaseURI                 string

	ConcurrencyMode     string `json:"concurrencyMode"`
	ContentType         string `json:"contentType"`
	CreatedByID         string `json:"createdById"`
	CreatedDate         string `json:"createdDate"`
	ExternalIDFieldName string `json:"externalIdFieldName"`
	FastPathEnabled     bool   `json:"fastPathEnabled"`

	ID                      string `json:"id"`
	NumberBatchesCompleted  int    `json:"numberBatchesCompleted"`
	NumberBatchesFailed     int    `json:"numberBatchesFailed"`
	NumberBatchesInProgress int    `json:"numberBatchesInProgress"`
	NumberBatchesQueued     int    `json:"numberBatchesQueued"`
	NumberBatchesTotal      int    `json:"numberBatchesTotal"`
	NumberRecordsFailed     int    `json:"numberRecordsFailed"`
	NumberRecordsProcessed  int    `json:"numberRecordsProcessed"`
	NumberRetries           int    `json:"numberRetries"`
	Object                  string `json:"object"`
	Operation               string `json:"operation"`
	State                   string `json:"state"`
	SystemModstamp          string `json:"systemModstamp"`
	TotalProcessingTime     int    `json:"totalProcessingTime"`
	// contains filtered or unexported fields
}

SJob represents a response for a given job request.

func (*SJob) Abort

func (j *SJob) Abort() error

Abort aborts a job.

func (*SJob) AddBatch

func (j *SJob) AddBatch(payload interface{}) (*SBatch, error)

AddBatch adds a batch to job.

func (*SJob) BatchState

func (j *SJob) BatchState(id string) ([]SBatchResponse, error)

BatchState returns an array containing the state of each record in the batch.

func (*SJob) Close

func (j *SJob) Close() error

Close closes the job.

func (*SJob) GetBatchRecordIDs

func (j *SJob) GetBatchRecordIDs(ID string, all bool) ([]string, error)

GetBatchRecordIDs returns a list of records in a batch. If 'all' is false only the successful records are returned. Otherwise all records are returned.

func (*SJob) GetBatches

func (j *SJob) GetBatches() (*SBatchInfo, error)

GetBatches returns an array containing the list of batches in a job.

func (*SJob) GetState

func (j *SJob) GetState() (string, error)

GetState returns the state of a job.

func (*SJob) IsCompleted

func (j *SJob) IsCompleted() (bool, error)

IsCompleted returns whether a job is completed (i.e. no in-progress or queued records).

func (*SJob) IsOpen

func (j *SJob) IsOpen() bool

IsOpen checks whether the job is open.

func (*SJob) Refresh

func (j *SJob) Refresh() error

Refresh updates the info of a job.

type SJobRequest

type SJobRequest struct {
	Operation           string `force:"operation"`
	Object              string `force:"object"`
	ContentType         string `force:"contentType"`
	ExternalIDFieldName string `force:"externalIdFieldName"`
	// contains filtered or unexported fields
}

SJobRequest represents an job request.

type SObject

type SObject interface {
	APIName() string
	ExternalIDAPIName() string
}

SObject is an interface that all standard and custom objects must implement. Needed for uri generation.

type SObjectAPIResponse

type SObjectAPIResponse struct {
	Encoding     string             `json:"encoding"`
	MaxBatchSize int64              `json:"maxBatchSize"`
	SObjects     []*SObjectMetaData `json:"sobjects"`
}

SObjectAPIResponse represents an API response.

type SObjectDescription

type SObjectDescription struct {
	Name                string               `json:"name"`
	Fields              []*SObjectField      `json:"fields"`
	KeyPrefix           string               `json:"keyPrefix"`
	Layoutable          bool                 `json:"layoutable"`
	Activateable        bool                 `json:"activateable"`
	LabelPlural         string               `json:"labelPlural"`
	Custom              bool                 `json:"custom"`
	CompactLayoutable   bool                 `json:"compactLayoutable"`
	Label               string               `json:"label"`
	Searchable          bool                 `json:"searchable"`
	URLs                map[string]string    `json:"urls"`
	Queryable           bool                 `json:"queryable"`
	Deletable           bool                 `json:"deletable"`
	Updateable          bool                 `json:"updateable"`
	Createable          bool                 `json:"createable"`
	CustomSetting       bool                 `json:"customSetting"`
	Undeletable         bool                 `json:"undeletable"`
	Mergeable           bool                 `json:"mergeable"`
	Replicateable       bool                 `json:"replicateable"`
	Triggerable         bool                 `json:"triggerable"`
	FeedEnabled         bool                 `json:"feedEnabled"`
	Retrievable         bool                 `json:"retrieveable"`
	SearchLayoutable    bool                 `json:"searchLayoutable"`
	LookupLayoutable    bool                 `json:"lookupLayoutable"`
	Listviewable        bool                 `json:"listviewable"`
	DeprecatedAndHidden bool                 `json:"deprecatedAndHidden"`
	RecordTypeInfos     []*RecordTypeInfo    `json:"recordTypeInfos"`
	ChildRelationsips   []*ChildRelationship `json:"childRelationships"`

	AllFields string `json:"-"` // Not from force.com API. Used to generate SELECT * queries.
}

SObjectDescription represents an SObject description.

type SObjectField

type SObjectField struct {
	Length                   float64          `json:"length"`
	Name                     string           `json:"name"`
	Type                     string           `json:"type"`
	RestrictedPicklist       bool             `json:"restrictedPicklist"`
	NameField                bool             `json:"nameField"`
	ByteLength               float64          `json:"byteLength"`
	Precision                float64          `json:"precision"`
	Filterable               bool             `json:"filterable"`
	Sortable                 bool             `json:"sortable"`
	Unique                   bool             `json:"unique"`
	CaseSensitive            bool             `json:"caseSensitive"`
	Calculated               bool             `json:"calculated"`
	Scale                    float64          `json:"scale"`
	Label                    string           `json:"label"`
	NamePointing             bool             `json:"namePointing"`
	Custom                   bool             `json:"custom"`
	HTMLFormatted            bool             `json:"htmlFormatted"`
	DependentPicklist        bool             `json:"dependentPicklist"`
	Permissionable           bool             `json:"permissionable"`
	ReferenceTo              []string         `json:"referenceTo"`
	RelationshipOrder        float64          `json:"relationshipOrder"`
	SoapType                 string           `json:"soapType"`
	CalculatedValueFormula   string           `json:"calculatedValueFormula"`
	DefaultValueFormula      string           `json:"defaultValueFormula"`
	DefaultedOnCreate        bool             `json:"defaultedOnCreate"`
	Digits                   float64          `json:"digits"`
	Groupable                bool             `json:"groupable"`
	Nillable                 bool             `json:"nillable"`
	InlineHelpText           string           `json:"inlineHelpText"`
	WriteRequiresMasterRead  bool             `json:"writeRequiresMasterRead"`
	PicklistValues           []*PicklistValue `json:"picklistValues"`
	Updateable               bool             `json:"updateable"`
	Createable               bool             `json:"createable"`
	DeprecatedAndHidden      bool             `json:"deprecatedAndHidden"`
	DisplayLocationInDecimal bool             `json:"displayLocationInDecimal"`
	CascadeDelete            bool             `json:"cascasdeDelete"`
	RestrictedDelete         bool             `json:"restrictedDelete"`
	ControllerName           string           `json:"controllerName"`
	ExternalID               bool             `json:"externalID"`
	IDLookup                 bool             `json:"idLookup"`
	AutoNumber               bool             `json:"autoNumber"`
	RelationshipName         string           `json:"relationshipName"`
}

SObjectField represents a field in an SObject.

type SObjectList

type SObjectList struct {
	Done    bool            `json:"done"`
	Records []SObjectRecord `json:"records"`
}

SObjectList represents a list of SObjects with ID and name.

type SObjectMetaData

type SObjectMetaData struct {
	Name                string            `json:"name"`
	Label               string            `json:"label"`
	KeyPrefix           string            `json:"keyPrefix"`
	LabelPlural         string            `json:"labelPlural"`
	Custom              bool              `json:"custom"`
	Layoutable          bool              `json:"layoutable"`
	Activateable        bool              `json:"activateable"`
	URLs                map[string]string `json:"urls"`
	Searchable          bool              `json:"searchable"`
	Updateable          bool              `json:"updateable"`
	Createable          bool              `json:"createable"`
	DeprecatedAndHidden bool              `json:"deprecatedAndHidden"`
	CustomSetting       bool              `json:"customSetting"`
	Deletable           bool              `json:"deletable"`
	FeedEnabled         bool              `json:"feedEnabled"`
	Mergeable           bool              `json:"mergeable"`
	Queryable           bool              `json:"queryable"`
	Replicateable       bool              `json:"replicateable"`
	Retrieveable        bool              `json:"retrieveable"`
	Undeletable         bool              `json:"undeletable"`
	Triggerable         bool              `json:"triggerable"`
}

SObjectMetaData represents a list of metadata for an SObject.

type SObjectRecord

type SObjectRecord struct {
	Name string
	ID   string `json:"Id"`
}

SObjectRecord represents a single SObject with ID and name.

type SObjectResponse

type SObjectResponse struct {
	ID      string    `force:"id,omitempty"`
	Errors  APIErrors `force:"error,omitempty"` //TODO: Not sure if APIErrors is the right object
	Success bool      `force:"success,omitempty"`
}

SObjectResponse represents a response received from force.com API after insert of an SObject.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL