Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/properties/normalized.go
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,18 @@ func (spec *Normalization) HasEntryName() bool {
return spec.Entry != nil
}

func (spec *Normalization) HasAuditComments() bool {
var hasVsysLocation bool
for _, location := range spec.Locations {
if location.Name.CamelCase == "Vsys" {
hasVsysLocation = true
break
}
}

return hasVsysLocation && spec.HasEntryUuid()
}

func (spec *Normalization) HasEntryUuid() bool {
_, found := spec.Spec.Params["uuid"]
return found
Expand Down
17 changes: 13 additions & 4 deletions templates/sdk/service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ package {{packageName .GoSdkPath}}
{{- if .Entry}}
{{- if $.Imports}}
{{- if $.Spec.Params.uuid}}
{{- if $.HasAuditComments }}
{{renderImports "service" "filtering" "sync" "audit" "rule" "version" "movement"}}
{{- else }}
{{renderImports "service" "filtering" "sync" "rule" "version" "movement"}}
{{- end }}
{{- else}}
{{renderImports "service" "filtering" "sync"}}
{{- end}}
{{- else}}
{{- if $.Spec.Params.uuid}}
{{- if $.HasAuditComments }}
{{renderImports "service" "filtering" "audit" "movement"}}
{{- else }}
{{renderImports "service" "filtering" "movement"}}
{{- end }}
{{- else}}
{{renderImports "service" "filtering"}}
{{- end}}
Expand Down Expand Up @@ -793,7 +801,7 @@ func (s *Service) filterEntriesByLocation(location Location, entries []*Entry) [
return filtered
}

{{- if $.Spec.Params.uuid}}
{{- if $.Spec.Params.uuid }}
// MoveGroup arranges the given rules in the order specified.
// Any rule with a UUID specified is ignored.
// Only the rule names are considered for the purposes of the rule placement.
Expand Down Expand Up @@ -853,7 +861,7 @@ func (s *Service) MoveGroup(ctx context.Context, loc Location, position movement
return nil
}


{{- if $.HasAuditComments }}
// HITCOUNT returns the hit count for the given rule.
func (s *Service) HitCount(ctx context.Context, loc Location, rules ...string) ([]util.HitCount, error) {
switch {
Expand All @@ -873,7 +881,7 @@ func (s *Service) MoveGroup(ctx context.Context, loc Location, position movement

return nil, fmt.Errorf("unsupported location")
}

// SetAuditComment sets the given audit comment for the given rule.
func (s *Service) SetAuditComment(ctx context.Context, loc Location, name, comment string) error {
if name == "" {
Expand Down Expand Up @@ -989,6 +997,7 @@ func (s *Service) MoveGroup(ctx context.Context, loc Location, position movement
}

return resp.Comments, nil
}
}
{{- end}}
{{- end }}
{{- end}}