Documentation
¶
Index ¶
- Constants
- func DecodeBase64Export(data string) (string, error)
- type Base64Exporter
- type Base64Importer
- type DataLine
- type Detector
- type ExportRequest
- type ExportResult
- type Exporter
- type Format
- type ImportOptions
- type ImportResult
- type Importer
- type JSONLExporter
- type JSONLImporter
- type Metadata
- type ProviderData
- type ProviderImportInfo
- type RuleData
Constants ¶
const ( // Base64Prefix is the prefix for Base64 format exports/imports Base64Prefix = "TGB64" // CurrentVersion is the current export format version CurrentVersion = "1.0" )
Variables ¶
This section is empty.
Functions ¶
func DecodeBase64Export ¶
DecodeBase64Export decodes a Base64 export back to JSONL content
Types ¶
type Base64Exporter ¶
type Base64Exporter struct {
// contains filtered or unexported fields
}
Base64Exporter exports data in Base64-encoded JSONL format
func NewBase64Exporter ¶
func NewBase64Exporter() *Base64Exporter
NewBase64Exporter creates a new Base64 exporter
func (*Base64Exporter) Export ¶
func (e *Base64Exporter) Export(req *ExportRequest) (*ExportResult, error)
Export performs the export in Base64 format
func (*Base64Exporter) Format ¶
func (e *Base64Exporter) Format() Format
Format returns the format type
type Base64Importer ¶
type Base64Importer struct {
// contains filtered or unexported fields
}
Base64Importer imports data from Base64-encoded JSONL format
func NewBase64Importer ¶
func NewBase64Importer() *Base64Importer
NewBase64Importer creates a new Base64 importer
func (*Base64Importer) Format ¶
func (i *Base64Importer) Format() Format
Format returns the format type
func (*Base64Importer) Import ¶
func (i *Base64Importer) Import(data string, globalConfig *config.Config, opts ImportOptions) (*ImportResult, error)
Import imports data from Base64 format
type DataLine ¶
type DataLine struct {
Type string `json:"type"`
}
DataLine is the base type for all data lines (export/import)
type ExportRequest ¶
ExportRequest contains the data needed for export
type ExportResult ¶
ExportResult represents the result of an export operation
func Export ¶
func Export(req *ExportRequest, format Format) (*ExportResult, error)
Export exports a rule with its providers in the specified format
type Exporter ¶
type Exporter interface {
Export(req *ExportRequest) (*ExportResult, error)
Format() Format
}
Exporter defines the interface for export implementations
func NewExporter ¶
NewExporter creates an exporter for the specified format
type ImportOptions ¶
type ImportOptions struct {
// 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
// OnRuleConflict specifies what to do when a rule already exists.
// "skip" - skip import, "update" - update existing rule, "new" - create with new name
OnRuleConflict string
// Quiet suppresses progress output
Quiet bool
}
ImportOptions controls how imports are handled when conflicts occur
type ImportResult ¶
type ImportResult struct {
RuleCreated bool
RuleUpdated bool
ProvidersCreated int
ProvidersUsed int
Providers []ProviderImportInfo
ProviderMap map[string]string // old UUID -> new UUID
}
ImportResult contains the results of an import operation
func Import ¶
func Import(data string, globalConfig *config.Config, format Format, opts ImportOptions) (*ImportResult, error)
Import imports a rule with providers from data in the specified format
type Importer ¶
type Importer interface {
Import(data string, globalConfig *config.Config, opts ImportOptions) (*ImportResult, error)
Format() Format
}
Importer defines the interface for import implementations
func NewImporter ¶
NewImporter creates an importer for the specified format
type JSONLExporter ¶
type JSONLExporter struct{}
JSONLExporter exports data in JSONL format
func NewJSONLExporter ¶
func NewJSONLExporter() *JSONLExporter
NewJSONLExporter creates a new JSONL exporter
func (*JSONLExporter) Export ¶
func (e *JSONLExporter) Export(req *ExportRequest) (*ExportResult, error)
Export performs the export in JSONL format
func (*JSONLExporter) Format ¶
func (e *JSONLExporter) Format() Format
Format returns the format type
type JSONLImporter ¶
type JSONLImporter struct{}
JSONLImporter imports data from JSONL format
func NewJSONLImporter ¶
func NewJSONLImporter() *JSONLImporter
NewJSONLImporter creates a new JSONL importer
func (*JSONLImporter) Format ¶
func (i *JSONLImporter) Format() Format
Format returns the format type
func (*JSONLImporter) Import ¶
func (i *JSONLImporter) Import(data string, globalConfig *config.Config, opts ImportOptions) (*ImportResult, error)
Import imports data from JSONL format
type Metadata ¶
type Metadata struct {
Type string `json:"type"`
Version string `json:"version"`
ExportedAt string `json:"exported_at"`
}
Metadata represents the metadata line (used for both export and import)
type ProviderData ¶
type ProviderData struct {
Type string `json:"type"`
UUID string `json:"uuid"`
Name string `json:"name"`
APIBase string `json:"api_base"`
APIStyle string `json:"api_style"`
AuthType string `json:"auth_type"`
Token string `json:"token"`
OAuthDetail *typ.OAuthDetail `json:"oauth_detail"`
Enabled bool `json:"enabled"`
ProxyURL string `json:"proxy_url"`
Timeout int64 `json:"timeout"`
Tags []string `json:"tags"`
Models []string `json:"models"`
}
ProviderData represents the provider data (used for both export and import)
type ProviderImportInfo ¶
type ProviderImportInfo struct {
UUID string
Name string
Action string // "created", "used", "skipped"
}
ProviderImportInfo contains information about an imported or used provider
type RuleData ¶
type RuleData struct {
Type string `json:"type"`
UUID string `json:"uuid"`
Scenario string `json:"scenario"`
RequestModel string `json:"request_model"`
ResponseModel string `json:"response_model"`
Description string `json:"description"`
Services []*loadbalance.Service `json:"services"`
LBTactic typ.Tactic `json:"lb_tactic"`
Active bool `json:"active"`
SmartEnabled bool `json:"smart_enabled"`
SmartRouting []interface{} `json:"smart_routing"`
}
RuleData represents the rule data (used for both export and import)