Documentation
¶
Overview ¶
Package genericinterface provides the GenericInterface service for web service execution. This is the core execution engine for both inbound (Provider) and outbound (Requester) operations.
Index ¶
- type AutocompleteResult
- type FieldConfig
- type RESTTransport
- func (t *RESTTransport) Execute(ctx context.Context, config models.TransportHTTPConfig, request *Request) (*Response, error)
- func (t *RESTTransport) ExecuteRaw(ctx context.Context, method, url string, headers map[string]string, ...) (*Response, error)
- func (t *RESTTransport) TestConnection(ctx context.Context, config models.TransportHTTPConfig) error
- func (t *RESTTransport) Type() string
- type Request
- type Response
- type SOAPBody
- type SOAPEnvelope
- type SOAPFault
- type SOAPHeader
- type SOAPTransport
- func (t *SOAPTransport) BuildSOAPRequest(config models.TransportHTTPConfig, request *Request) ([]byte, error)
- func (t *SOAPTransport) Execute(ctx context.Context, config models.TransportHTTPConfig, request *Request) (*Response, error)
- func (t *SOAPTransport) TestConnection(ctx context.Context, config models.TransportHTTPConfig) error
- func (t *SOAPTransport) Type() string
- type Service
- func (s *Service) CreateWebservice(ctx context.Context, ws *models.WebserviceConfig, userID int) (int, error)
- func (s *Service) DeleteWebservice(ctx context.Context, id int) error
- func (s *Service) GetHistory(ctx context.Context, configID int) ([]*models.WebserviceConfigHistory, error)
- func (s *Service) GetTransport(transportType string) (Transport, error)
- func (s *Service) GetWebservice(ctx context.Context, name string) (*models.WebserviceConfig, error)
- func (s *Service) GetWebserviceByID(ctx context.Context, id int) (*models.WebserviceConfig, error)
- func (s *Service) GetWebservicesForField(ctx context.Context) ([]*models.WebserviceConfig, error)
- func (s *Service) Invoke(ctx context.Context, webserviceName, invokerName string, ...) (*Response, error)
- func (s *Service) InvokeWithController(ctx context.Context, webserviceName, invokerName string, controller string, ...) (*Response, error)
- func (s *Service) ListValidWebservices(ctx context.Context) ([]*models.WebserviceConfig, error)
- func (s *Service) ListWebservices(ctx context.Context) ([]*models.WebserviceConfig, error)
- func (s *Service) RegisterTransport(t Transport)
- func (s *Service) RestoreFromHistory(ctx context.Context, historyID int64, userID int) error
- func (s *Service) SetDebug(debug bool)
- func (s *Service) UpdateWebservice(ctx context.Context, ws *models.WebserviceConfig, userID int) error
- func (s *Service) WebserviceExists(ctx context.Context, name string) (bool, error)
- func (s *Service) WebserviceExistsExcluding(ctx context.Context, name string, excludeID int) (bool, error)
- type Transport
- type WebserviceFieldService
- func (s *WebserviceFieldService) ClearCache(webservice string)
- func (s *WebserviceFieldService) GetDisplayValue(ctx context.Context, config FieldConfig, storedValue string) (string, error)
- func (s *WebserviceFieldService) GetMultipleDisplayValues(ctx context.Context, config FieldConfig, storedValues []string) (map[string]string, error)
- func (s *WebserviceFieldService) Search(ctx context.Context, config FieldConfig, searchTerm string) ([]AutocompleteResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutocompleteResult ¶
type AutocompleteResult struct {
StoredValue string `json:"StoredValue"` // The stored value (e.g., ID) - OTRS compatible
DisplayValue string `json:"DisplayValue"` // The displayed text - OTRS compatible
Data map[string]interface{} `json:"Data,omitempty"` // Additional data for autofill
// Legacy aliases for frontend compatibility (same values, different keys)
Value string `json:"value,omitempty"` // Alias for StoredValue
Label string `json:"label,omitempty"` // Alias for DisplayValue
}
AutocompleteResult represents a single autocomplete suggestion. JSON field names match OTRS's expected format for compatibility.
type FieldConfig ¶
type FieldConfig struct {
Webservice string
InvokerSearch string
InvokerGet string
StoredValue string
DisplayedValues []string
DisplayedValuesSeparator string
SearchKeys []string
AutocompleteMinLength int
Limit int
CacheTTL int
}
FieldConfig holds the configuration needed to query a webservice field.
func ParseFieldConfigFromMap ¶
func ParseFieldConfigFromMap(configMap map[string]interface{}) FieldConfig
ParseFieldConfigFromMap parses a DynamicFieldConfig-like map into FieldConfig.
type RESTTransport ¶
type RESTTransport struct {
// contains filtered or unexported fields
}
RESTTransport implements the Transport interface for HTTP REST APIs.
func NewRESTTransport ¶
func NewRESTTransport() *RESTTransport
NewRESTTransport creates a new REST transport.
func (*RESTTransport) Execute ¶
func (t *RESTTransport) Execute(ctx context.Context, config models.TransportHTTPConfig, request *Request) (*Response, error)
Execute performs an HTTP request to the remote REST API.
func (*RESTTransport) ExecuteRaw ¶
func (t *RESTTransport) ExecuteRaw(ctx context.Context, method, url string, headers map[string]string, body []byte) (*Response, error)
ExecuteRaw performs a raw HTTP request with minimal processing. Useful for testing and debugging.
func (*RESTTransport) TestConnection ¶
func (t *RESTTransport) TestConnection(ctx context.Context, config models.TransportHTTPConfig) error
TestConnection tests connectivity to the remote host.
type Request ¶
type Request struct {
// Operation is the invoker/operation name.
Operation string
// Data contains the request payload.
Data map[string]interface{}
// Method is the HTTP method (GET, POST, PUT, DELETE).
Method string
// Path is the endpoint path (can contain placeholders like :id).
Path string
}
Request represents an outbound request to a remote system.
type Response ¶
type Response struct {
// Success indicates if the request succeeded.
Success bool
// Data contains the response payload.
Data map[string]interface{}
// RawData contains the raw response body.
RawData []byte
// StatusCode is the HTTP status code.
StatusCode int
// Error contains any error message.
Error string
// Headers contains response headers.
Headers map[string]string
}
Response represents a response from a remote system.
type SOAPEnvelope ¶
type SOAPEnvelope struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Header *SOAPHeader `xml:"Header,omitempty"`
Body SOAPBody `xml:"Body"`
}
SOAPEnvelope represents the SOAP envelope structure.
type SOAPFault ¶
type SOAPFault struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
FaultCode string `xml:"faultcode"`
FaultString string `xml:"faultstring"`
Detail string `xml:"detail,omitempty"`
}
SOAPFault represents a SOAP fault response.
type SOAPHeader ¶
type SOAPHeader struct {
Content []byte `xml:",innerxml"`
}
SOAPHeader represents the SOAP header.
type SOAPTransport ¶
type SOAPTransport struct {
// contains filtered or unexported fields
}
SOAPTransport implements the Transport interface for SOAP web services.
func NewSOAPTransport ¶
func NewSOAPTransport() *SOAPTransport
NewSOAPTransport creates a new SOAP transport.
func (*SOAPTransport) BuildSOAPRequest ¶
func (t *SOAPTransport) BuildSOAPRequest(config models.TransportHTTPConfig, request *Request) ([]byte, error)
BuildSOAPRequest creates a complete SOAP request envelope for debugging/testing.
func (*SOAPTransport) Execute ¶
func (t *SOAPTransport) Execute(ctx context.Context, config models.TransportHTTPConfig, request *Request) (*Response, error)
Execute performs a SOAP request to the remote service.
func (*SOAPTransport) TestConnection ¶
func (t *SOAPTransport) TestConnection(ctx context.Context, config models.TransportHTTPConfig) error
TestConnection tests connectivity to the SOAP endpoint.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the main GenericInterface execution service.
func NewService ¶
NewService creates a new GenericInterface service.
func (*Service) CreateWebservice ¶
func (s *Service) CreateWebservice(ctx context.Context, ws *models.WebserviceConfig, userID int) (int, error)
CreateWebservice creates a new webservice configuration.
func (*Service) DeleteWebservice ¶
DeleteWebservice deletes a webservice configuration.
func (*Service) GetHistory ¶
func (s *Service) GetHistory(ctx context.Context, configID int) ([]*models.WebserviceConfigHistory, error)
GetHistory returns the configuration history for a webservice.
func (*Service) GetTransport ¶
GetTransport returns a transport by type.
func (*Service) GetWebservice ¶
GetWebservice returns a webservice configuration by name.
func (*Service) GetWebserviceByID ¶
GetWebserviceByID returns a webservice configuration by ID.
func (*Service) GetWebservicesForField ¶
GetWebservicesForField returns webservices suitable for dynamic field configuration.
func (*Service) Invoke ¶
func (s *Service) Invoke(ctx context.Context, webserviceName, invokerName string, data map[string]interface{}) (*Response, error)
Invoke executes an invoker on a webservice. This is the main method for making outbound requests.
func (*Service) InvokeWithController ¶
func (s *Service) InvokeWithController(ctx context.Context, webserviceName, invokerName string, controller string, method string, data map[string]interface{}) (*Response, error)
InvokeWithController executes an invoker with specific controller/path settings. Used for REST APIs where the path may vary based on parameters.
func (*Service) ListValidWebservices ¶
ListValidWebservices returns only valid (active) webservices.
func (*Service) ListWebservices ¶
ListWebservices returns all webservice configurations.
func (*Service) RegisterTransport ¶
RegisterTransport registers a transport implementation.
func (*Service) RestoreFromHistory ¶
RestoreFromHistory restores a webservice configuration from a history entry.
func (*Service) UpdateWebservice ¶
func (s *Service) UpdateWebservice(ctx context.Context, ws *models.WebserviceConfig, userID int) error
UpdateWebservice updates an existing webservice configuration.
func (*Service) WebserviceExists ¶
WebserviceExists checks if a webservice with the given name exists.
type Transport ¶
type Transport interface {
// Execute performs an HTTP request using the transport configuration.
Execute(ctx context.Context, config models.TransportHTTPConfig, request *Request) (*Response, error)
// Type returns the transport type (e.g., "HTTP::REST", "HTTP::SOAP").
Type() string
}
Transport defines the interface for HTTP transports (REST, SOAP).
type WebserviceFieldService ¶
type WebserviceFieldService struct {
// contains filtered or unexported fields
}
WebserviceFieldService handles autocomplete and display value retrieval for WebserviceDropdown and WebserviceMultiselect dynamic fields.
func NewWebserviceFieldService ¶
func NewWebserviceFieldService(db *sql.DB) *WebserviceFieldService
NewWebserviceFieldService creates a new webservice field service.
func NewWebserviceFieldServiceWithGI ¶
func NewWebserviceFieldServiceWithGI(giService *Service) *WebserviceFieldService
NewWebserviceFieldServiceWithGI creates a service using an existing GI service.
func (*WebserviceFieldService) ClearCache ¶
func (s *WebserviceFieldService) ClearCache(webservice string)
ClearCache clears the cache for a specific webservice or all caches.
func (*WebserviceFieldService) GetDisplayValue ¶
func (s *WebserviceFieldService) GetDisplayValue(ctx context.Context, config FieldConfig, storedValue string) (string, error)
GetDisplayValue retrieves the display value for a stored value. This is used to show the human-readable label when loading existing data.
func (*WebserviceFieldService) GetMultipleDisplayValues ¶
func (s *WebserviceFieldService) GetMultipleDisplayValues(ctx context.Context, config FieldConfig, storedValues []string) (map[string]string, error)
GetMultipleDisplayValues retrieves display values for multiple stored values. Used for WebserviceMultiselect fields.
func (*WebserviceFieldService) Search ¶
func (s *WebserviceFieldService) Search(ctx context.Context, config FieldConfig, searchTerm string) ([]AutocompleteResult, error)
Search performs a search/autocomplete query against the configured webservice.