rule

package
v0.260331.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(router *swagger.RouteGroup, handler *Handler)

RegisterRoutes registers all rule routes with swagger documentation

Types

type CreateRuleRequest

type CreateRuleRequest typ.Rule

CreateRuleRequest represents the request to create a rule

type DeleteRuleResponse

type DeleteRuleResponse struct {
	Success bool   `json:"success" example:"true"`
	Message string `json:"message" example:"Rule deleted successfully"`
}

DeleteRuleResponse represents the response for deleting a rule

type Handler

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

Handler handles rule HTTP requests

func NewHandler

func NewHandler(cfg *config.Config) *Handler

NewHandler creates a new rule handler

func (*Handler) CreateRule

func (h *Handler) CreateRule(c *gin.Context)

CreateRule creates a new rule

func (*Handler) DeleteRule

func (h *Handler) DeleteRule(c *gin.Context)

DeleteRule deletes a rule

func (*Handler) GetRule

func (h *Handler) GetRule(c *gin.Context)

GetRule returns a specific rule by UUID

func (*Handler) GetRules

func (h *Handler) GetRules(c *gin.Context)

GetRules returns all rules, filtered by scenario

func (*Handler) ImportRule

func (h *Handler) ImportRule(c *gin.Context)

ImportRule imports a rule from base64 encoded data

func (*Handler) UpdateRule

func (h *Handler) UpdateRule(c *gin.Context)

UpdateRule creates or updates a rule

type ImportRuleRequest

type ImportRuleRequest struct {
	Data string `json:"data" binding:"required" description:"Base64 encoded rule export data" example:"TGB64:1.0:..."`
	// OnProviderConflict specifies what to do when a provider already exists.
	// "use" - use existing provider, "skip" - skip this provider, "suffix" - create with suffixed name
	OnProviderConflict string `json:"on_provider_conflict" description:"How to handle provider conflicts" example:"use"`
	// OnRuleConflict specifies what to do when a rule already exists.
	// "skip" - skip import, "update" - update existing rule, "new" - create with new name
	OnRuleConflict string `json:"on_rule_conflict" description:"How to handle rule conflicts" example:"new"`
}

ImportRuleRequest represents request to import a rule from base64 encoded data

type ImportRuleResponse

type ImportRuleResponse struct {
	Success bool   `json:"success" example:"true"`
	Message string `json:"message" example:"Rule imported successfully"`
	Data    struct {
		RuleCreated      bool           `json:"rule_created" example:"true"`
		RuleUpdated      bool           `json:"rule_updated" example:"false"`
		ProvidersCreated int            `json:"providers_created" example:"1"`
		ProvidersUsed    int            `json:"providers_used" example:"0"`
		Providers        []ProviderInfo `json:"providers,omitempty"`
	} `json:"data"`
}

ImportRuleResponse represents the response for importing a rule

type ProviderInfo

type ProviderInfo struct {
	UUID   string `json:"uuid" example:"123e4567-e89b-12d3-a456-426614174000"`
	Name   string `json:"name" example:"openai"`
	Action string `json:"action" example:"created"` // "created", "used", "skipped"
}

ProviderInfo contains basic information about an imported or used provider

type RuleResponse

type RuleResponse struct {
	Success bool      `json:"success" example:"true"`
	Data    *typ.Rule `json:"data"`
}

RuleResponse represents a rule configuration response

type RulesResponse

type RulesResponse struct {
	Success bool        `json:"success" example:"true"`
	Data    interface{} `json:"data"`
}

RulesResponse represents the response for getting all rules

type UpdateRuleRequest

type UpdateRuleRequest typ.Rule

UpdateRuleRequest represents the request to set/update a rule

type UpdateRuleResponse

type UpdateRuleResponse struct {
	Success bool   `json:"success" example:"true"`
	Message string `json:"message" example:"Rule saved successfully"`
	Data    struct {
		UUID          string                      `json:"uuid"`
		RequestModel  string                      `json:"request_model" example:"gpt-3.5-turbo"`
		ResponseModel string                      `json:"response_model" example:"gpt-3.5-turbo"`
		Description   string                      `json:"description" example:"My rule description"`
		Provider      string                      `json:"provider" example:"openai"`
		DefaultModel  string                      `json:"default_model" example:"gpt-3.5-turbo"`
		Active        bool                        `json:"active" example:"true"`
		SmartEnabled  bool                        `json:"smart_enabled" example:"false"`
		SmartRouting  []smartrouting.SmartRouting `json:"smart_routing,omitempty"`
	} `json:"data"`
}

UpdateRuleResponse represents the response for setting/updating a rule

Jump to

Keyboard shortcuts

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