Documentation
¶
Index ¶
- type ContextKey
- type DiscoverQueryRequest
- type DiscoverQueryResponse
- type ErrorResponse
- type HealthResponse
- type LoadMappingsRequest
- type LoadMappingsResponse
- type MapQueryRequest
- type MapQueryResponse
- type Server
- type ServerConfig
- type ValidateQueryRequest
- type ValidateQueryResponse
- type ValidationError
- type ValidationErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey type for context keys
const (
RequestIDKey ContextKey = "request-id"
)
type DiscoverQueryRequest ¶
type DiscoverQueryRequest struct {
Query string `json:"query" validate:"required" example:"search sourcetype=access_combined | stats count by src_ip"` // SPL query to analyze
}
DiscoverQueryRequest represents a request to discover query information @Description Request to discover information about an SPL query
type DiscoverQueryResponse ¶
type DiscoverQueryResponse struct {
Query string `json:"query" example:"search sourcetype=access_combined | stats count by src_ip" extensions:"x-order=1"` // Original query
QueryInfo *mapper.QueryInfo `json:"query_info" extensions:"x-order=2"` // Discovered query information
Success bool `json:"success" example:"true" extensions:"x-order=3"` // Whether the discovery was successful
}
DiscoverQueryResponse represents the response from query discovery @Description Response from discovering SPL query information
type ErrorResponse ¶
type ErrorResponse struct {
Error bool `json:"error" example:"true" extensions:"x-order=1"` // Always true for error responses
Message string `json:"message" example:"Invalid request" extensions:"x-order=2"` // Human-readable error message
Code int `json:"code" example:"400" extensions:"x-order=3"` // HTTP status code
}
ErrorResponse represents an error response @Description Standard error response
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status" example:"healthy" extensions:"x-order=1"` // Service health status
Version string `json:"version" example:"1.0.0" extensions:"x-order=2"` // Service version
Service string `json:"service" example:"spl-toolkit-api" extensions:"x-order=3"` // Service name
}
HealthResponse represents the health check response @Description Health check response
type LoadMappingsRequest ¶
type LoadMappingsRequest struct {
Mappings []mapper.FieldMapping `json:"mappings,omitempty" extensions:"x-order=1"` // Simple field mappings
Config *mapper.MappingConfig `json:"config,omitempty" extensions:"x-order=2"` // Complete mapping configuration with rules
}
LoadMappingsRequest represents a request to load field mappings @Description Request to load field mappings into the server
type LoadMappingsResponse ¶
type LoadMappingsResponse struct {
Success bool `json:"success" example:"true" extensions:"x-order=1"` // Whether the mappings were loaded successfully
MappingsCount int `json:"mappings_count" example:"5" extensions:"x-order=2"` // Number of field mappings loaded
RulesCount int `json:"rules_count,omitempty" example:"2" extensions:"x-order=3"` // Number of conditional rules loaded
}
LoadMappingsResponse represents the response from loading mappings @Description Response from loading field mappings
type MapQueryRequest ¶
type MapQueryRequest struct {
Query string `json:"query" validate:"required" example:"search src_ip=192.168.1.1" extensions:"x-order=1"` // SPL query to map
Context map[string]interface{} `json:"context,omitempty" extensions:"x-order=2"` // Optional context for mapping
Mappings []mapper.FieldMapping `json:"mappings,omitempty" extensions:"x-order=3"` // Simple field mappings (for stateless operation)
Config *mapper.MappingConfig `json:"config,omitempty" extensions:"x-order=4"` // Advanced mapping configuration with conditional rules (for stateless operation)
}
MapQueryRequest represents a request to map fields in a query @Description Request to map fields in an SPL query. For stateless operation, provide either 'mappings' for simple field mappings or 'config' for advanced mapping configuration with conditional rules.
type MapQueryResponse ¶
type MapQueryResponse struct {
OriginalQuery string `json:"original_query" example:"search src_ip=192.168.1.1" extensions:"x-order=1"` // Original input query
MappedQuery string `json:"mapped_query" example:"search source_ip=192.168.1.1" extensions:"x-order=2"` // Query with mapped field names
Success bool `json:"success" example:"true" extensions:"x-order=3"` // Whether the mapping was successful
}
MapQueryResponse represents the response from mapping a query @Description Response from mapping an SPL query
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the API server
func NewServer ¶
func NewServer() *Server
NewServer creates a new API server instance with default configuration
func NewServerWithConfig ¶
func NewServerWithConfig(config ServerConfig) *Server
NewServerWithConfig creates a new API server instance with custom configuration
func NewServerWithConfigAndVersion ¶
func NewServerWithConfigAndVersion(config ServerConfig, version string) *Server
NewServerWithConfigAndVersion creates a new API server instance with custom configuration and version
func NewServerWithVersion ¶
NewServerWithVersion creates a new API server instance with version
type ServerConfig ¶
type ServerConfig struct {
CORSAllowedOrigins []string
CORSAllowedMethods []string
CORSAllowedHeaders []string
EnableAdminEndpoints bool
}
ServerConfig holds configuration for the API server
type ValidateQueryRequest ¶
type ValidateQueryRequest struct {
Query string `json:"query" validate:"required" example:"search index=web | stats count"` // SPL query to validate
}
ValidateQueryRequest represents a request to validate a query @Description Request to validate an SPL query
type ValidateQueryResponse ¶
type ValidateQueryResponse struct {
Query string `json:"query" example:"search index=web | stats count" extensions:"x-order=1"` // Original query
Valid bool `json:"valid" example:"true" extensions:"x-order=2"` // Whether the query is valid
Success bool `json:"success" example:"true" extensions:"x-order=3"` // Whether the validation was successful
Error string `json:"error,omitempty" example:"syntax error at position 10" extensions:"x-order=4"` // Error message if validation failed
}
ValidateQueryResponse represents the response from query validation @Description Response from validating an SPL query
type ValidationError ¶
type ValidationError struct {
Field string `json:"field" example:"query" extensions:"x-order=1"` // Field that failed validation
Message string `json:"message" example:"field is required" extensions:"x-order=2"` // Validation error message
}
ValidationError represents a validation error for specific fields @Description Validation error for a specific field
type ValidationErrorResponse ¶
type ValidationErrorResponse struct {
Error bool `json:"error" example:"true" extensions:"x-order=1"` // Always true for error responses
Message string `json:"message" example:"Validation failed" extensions:"x-order=2"` // General error message
Code int `json:"code" example:"400" extensions:"x-order=3"` // HTTP status code
Errors []ValidationError `json:"validation_errors" extensions:"x-order=4"` // List of specific validation errors
}
ValidationErrorResponse represents a response with validation errors @Description Response with detailed validation errors