Documentation
¶
Index ¶
- func ExtractMultipleRecords(results map[string]*RequestResult) ([]map[string]interface{}, error)
- func ExtractRecordData(result *RequestResult) (map[string]interface{}, error)
- type BatchBuilder
- func (bb *BatchBuilder) AddCustomRequest(req RestRequest) *BatchBuilder
- func (bb *BatchBuilder) Create(id, tableName string, data map[string]interface{}) *BatchBuilder
- func (bb *BatchBuilder) Delete(id, tableName, sysID string) *BatchBuilder
- func (bb *BatchBuilder) Execute() (*BatchResult, error)
- func (bb *BatchBuilder) ExecuteWithContext(ctx context.Context) (*BatchResult, error)
- func (bb *BatchBuilder) Get(id, url string) *BatchBuilder
- func (bb *BatchBuilder) Replace(id, tableName, sysID string, data map[string]interface{}) *BatchBuilder
- func (bb *BatchBuilder) Update(id, tableName, sysID string, data map[string]interface{}) *BatchBuilder
- func (bb *BatchBuilder) WithEnforceOrder(enforce bool) *BatchBuilder
- func (bb *BatchBuilder) WithRequestID(id string) *BatchBuilder
- type BatchClient
- func (bc *BatchClient) CreateMultiple(tableName string, records []map[string]interface{}) (*BatchResult, error)
- func (bc *BatchClient) CreateMultipleWithContext(ctx context.Context, tableName string, records []map[string]interface{}) (*BatchResult, error)
- func (bc *BatchClient) DeleteMultiple(tableName string, sysIDs []string) (*BatchResult, error)
- func (bc *BatchClient) DeleteMultipleWithContext(ctx context.Context, tableName string, sysIDs []string) (*BatchResult, error)
- func (bc *BatchClient) ExecuteMixed(operations MixedOperations) (*BatchResult, error)
- func (bc *BatchClient) ExecuteMixedWithContext(ctx context.Context, operations MixedOperations) (*BatchResult, error)
- func (bc *BatchClient) GetMultiple(tableName string, sysIDs []string) (*BatchResult, error)
- func (bc *BatchClient) GetMultipleWithContext(ctx context.Context, tableName string, sysIDs []string) (*BatchResult, error)
- func (bc *BatchClient) NewBatch() *BatchBuilder
- func (bc *BatchClient) UpdateMultiple(tableName string, updates map[string]map[string]interface{}) (*BatchResult, error)
- func (bc *BatchClient) UpdateMultipleWithContext(ctx context.Context, tableName string, ...) (*BatchResult, error)
- type BatchRequest
- type BatchResponse
- type BatchResult
- func (br *BatchResult) GetAllErrors() map[string]*RequestError
- func (br *BatchResult) GetAllSuccessful() map[string]*RequestResult
- func (br *BatchResult) GetError(id string) (*RequestError, bool)
- func (br *BatchResult) GetResult(id string) (*RequestResult, bool)
- func (br *BatchResult) HasErrors() bool
- func (br *BatchResult) IsSuccess(id string) bool
- type CreateOperation
- type DeleteOperation
- type GetOperation
- type HTTPMethod
- type Header
- type MixedOperations
- type RequestError
- type RequestResult
- type RestRequest
- type ServicedRequest
- type UnservicedRequest
- type UpdateOperation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractMultipleRecords ¶
func ExtractMultipleRecords(results map[string]*RequestResult) ([]map[string]interface{}, error)
Helper method to extract multiple records from batch result
func ExtractRecordData ¶
func ExtractRecordData(result *RequestResult) (map[string]interface{}, error)
Helper method to extract record data from batch result
Types ¶
type BatchBuilder ¶
type BatchBuilder struct {
// contains filtered or unexported fields
}
BatchBuilder provides a fluent interface for building batch requests
func (*BatchBuilder) AddCustomRequest ¶
func (bb *BatchBuilder) AddCustomRequest(req RestRequest) *BatchBuilder
AddCustomRequest adds a custom request to the batch
func (*BatchBuilder) Create ¶
func (bb *BatchBuilder) Create(id, tableName string, data map[string]interface{}) *BatchBuilder
Create adds a POST request to the batch
func (*BatchBuilder) Delete ¶
func (bb *BatchBuilder) Delete(id, tableName, sysID string) *BatchBuilder
Delete adds a DELETE request to the batch
func (*BatchBuilder) Execute ¶
func (bb *BatchBuilder) Execute() (*BatchResult, error)
Execute executes the batch request
func (*BatchBuilder) ExecuteWithContext ¶
func (bb *BatchBuilder) ExecuteWithContext(ctx context.Context) (*BatchResult, error)
ExecuteWithContext executes the batch request with context support
func (*BatchBuilder) Get ¶
func (bb *BatchBuilder) Get(id, url string) *BatchBuilder
Get adds a GET request to the batch
func (*BatchBuilder) Replace ¶
func (bb *BatchBuilder) Replace(id, tableName, sysID string, data map[string]interface{}) *BatchBuilder
Replace adds a PUT request to the batch
func (*BatchBuilder) Update ¶
func (bb *BatchBuilder) Update(id, tableName, sysID string, data map[string]interface{}) *BatchBuilder
Update adds a PATCH request to the batch
func (*BatchBuilder) WithEnforceOrder ¶
func (bb *BatchBuilder) WithEnforceOrder(enforce bool) *BatchBuilder
WithEnforceOrder enables sequential execution of requests
func (*BatchBuilder) WithRequestID ¶
func (bb *BatchBuilder) WithRequestID(id string) *BatchBuilder
WithRequestID sets a custom batch request ID
type BatchClient ¶
type BatchClient struct {
// contains filtered or unexported fields
}
BatchClient handles ServiceNow Batch API operations
func NewBatchClient ¶
func NewBatchClient(client *core.Client) *BatchClient
NewBatchClient creates a new batch client
func (*BatchClient) CreateMultiple ¶
func (bc *BatchClient) CreateMultiple(tableName string, records []map[string]interface{}) (*BatchResult, error)
CreateMultiple creates multiple records in a single batch
func (*BatchClient) CreateMultipleWithContext ¶
func (bc *BatchClient) CreateMultipleWithContext(ctx context.Context, tableName string, records []map[string]interface{}) (*BatchResult, error)
CreateMultipleWithContext creates multiple records with context support
func (*BatchClient) DeleteMultiple ¶
func (bc *BatchClient) DeleteMultiple(tableName string, sysIDs []string) (*BatchResult, error)
DeleteMultiple deletes multiple records in a single batch
func (*BatchClient) DeleteMultipleWithContext ¶
func (bc *BatchClient) DeleteMultipleWithContext(ctx context.Context, tableName string, sysIDs []string) (*BatchResult, error)
DeleteMultipleWithContext deletes multiple records with context support
func (*BatchClient) ExecuteMixed ¶
func (bc *BatchClient) ExecuteMixed(operations MixedOperations) (*BatchResult, error)
ExecuteMixed executes mixed operations in a single batch
func (*BatchClient) ExecuteMixedWithContext ¶
func (bc *BatchClient) ExecuteMixedWithContext(ctx context.Context, operations MixedOperations) (*BatchResult, error)
ExecuteMixedWithContext executes mixed operations with context support
func (*BatchClient) GetMultiple ¶
func (bc *BatchClient) GetMultiple(tableName string, sysIDs []string) (*BatchResult, error)
GetMultiple retrieves multiple records in a single batch
func (*BatchClient) GetMultipleWithContext ¶
func (bc *BatchClient) GetMultipleWithContext(ctx context.Context, tableName string, sysIDs []string) (*BatchResult, error)
GetMultipleWithContext retrieves multiple records with context support
func (*BatchClient) NewBatch ¶
func (bc *BatchClient) NewBatch() *BatchBuilder
NewBatch creates a new batch builder
func (*BatchClient) UpdateMultiple ¶
func (bc *BatchClient) UpdateMultiple(tableName string, updates map[string]map[string]interface{}) (*BatchResult, error)
UpdateMultiple updates multiple records in a single batch
func (*BatchClient) UpdateMultipleWithContext ¶
func (bc *BatchClient) UpdateMultipleWithContext(ctx context.Context, tableName string, updates map[string]map[string]interface{}) (*BatchResult, error)
UpdateMultipleWithContext updates multiple records with context support
type BatchRequest ¶
type BatchRequest struct {
BatchRequestID string `json:"batch_request_id"`
EnforceOrder bool `json:"enforce_order,omitempty"`
RestRequests []RestRequest `json:"rest_requests"`
}
BatchRequest represents the entire batch request payload
type BatchResponse ¶
type BatchResponse struct {
BatchRequestID string `json:"batch_request_id"`
ServicedRequests []ServicedRequest `json:"serviced_requests"`
UnservicedRequests []UnservicedRequest `json:"unserviced_requests"`
}
BatchResponse represents the response from a batch request
type BatchResult ¶
type BatchResult struct {
BatchRequestID string
TotalRequests int
SuccessfulRequests int
FailedRequests int
Results map[string]*RequestResult
Errors map[string]*RequestError
}
BatchResult provides a convenient interface for accessing batch results
func (*BatchResult) GetAllErrors ¶
func (br *BatchResult) GetAllErrors() map[string]*RequestError
GetAllErrors returns all errors
func (*BatchResult) GetAllSuccessful ¶
func (br *BatchResult) GetAllSuccessful() map[string]*RequestResult
GetAllSuccessful returns all successful results
func (*BatchResult) GetError ¶
func (br *BatchResult) GetError(id string) (*RequestError, bool)
GetError returns the error for a specific request ID
func (*BatchResult) GetResult ¶
func (br *BatchResult) GetResult(id string) (*RequestResult, bool)
GetResult returns the result for a specific request ID
func (*BatchResult) HasErrors ¶
func (br *BatchResult) HasErrors() bool
HasErrors returns true if any requests failed
func (*BatchResult) IsSuccess ¶
func (br *BatchResult) IsSuccess(id string) bool
IsSuccess returns true if the request was successful
type CreateOperation ¶
CreateOperation represents a create operation
type DeleteOperation ¶
DeleteOperation represents a delete operation
type GetOperation ¶
GetOperation represents a get operation
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod represents supported HTTP methods for batch requests
const ( MethodGET HTTPMethod = "GET" MethodPOST HTTPMethod = "POST" MethodPATCH HTTPMethod = "PATCH" MethodPUT HTTPMethod = "PUT" MethodDELETE HTTPMethod = "DELETE" )
type MixedOperations ¶
type MixedOperations struct {
Creates []CreateOperation
Updates []UpdateOperation
Deletes []DeleteOperation
Gets []GetOperation
}
MixedOperations allows combining different operations in a single batch
type RequestError ¶
RequestError represents a failed request
type RequestResult ¶
type RequestResult struct {
ID string
StatusCode int
StatusText string
Data map[string]interface{} // Decoded JSON response
ExecutionTime time.Duration
}
RequestResult represents a successful request result
type RestRequest ¶
type RestRequest struct {
ID string `json:"id"`
URL string `json:"url"`
Method HTTPMethod `json:"method"`
Headers []Header `json:"headers,omitempty"`
Body string `json:"body,omitempty"` // Base64 encoded
ExcludeResponseHeaders bool `json:"exclude_response_headers,omitempty"`
}
RestRequest represents an individual request within a batch
type ServicedRequest ¶
type ServicedRequest struct {
ID string `json:"id"`
StatusCode int `json:"status_code"`
StatusText string `json:"status_text"`
Body string `json:"body"` // Base64 encoded
ExecutionTime int `json:"execution_time"`
}
ServicedRequest represents a successfully processed request