package pkg import ( "errors" "strings" ) type ClassificationProfile struct { ProfileCommon AppDetection string `json:"app_detection"` IRuleEvent string `json:"irule_event"` LogPublisher string `json:"log_publisher"` Preset string `json:"preset"` URLCat string `json:"urlcat"` } func ParseClassificationProfile(raw string) (*ClassificationProfile, error) { p := new(ClassificationProfile) split := strings.Split(raw, "\n") if !strings.Contains(split[0], "ltm profile classification") { return nil, errors.New("not a classification profile") } p.ProfileCommon = parseCommon(raw) for _, line := range split { f := strings.Fields(line) switch strings.ToLower(f[0]) { case "app-detection": p.AppDetection = strings.Join(f[1:], " ") case "irule-event": p.IRuleEvent = strings.Join(f[1:], " ") case "log-publisher": p.LogPublisher = strings.Join(f[1:], " ") case "preset": p.Preset = strings.Join(f[1:], " ") case "urlcat": p.URLCat = strings.Join(f[1:], " ") } } return p, nil }