From 167955711766ee7ca0ac0f05315580b7bba47f91 Mon Sep 17 00:00:00 2001 From: Linard Schwendener Date: Sat, 14 Mar 2026 12:55:59 +0100 Subject: [PATCH 1/2] Add dedup param to DecisionsStreamOpts --- pkg/apiclient/decisions_service.go | 7 ++++++- pkg/apiclient/decisions_service_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pkg/apiclient/decisions_service.go b/pkg/apiclient/decisions_service.go index cdfd76193e4..75d6be0db96 100644 --- a/pkg/apiclient/decisions_service.go +++ b/pkg/apiclient/decisions_service.go @@ -33,6 +33,7 @@ type DecisionsStreamOpts struct { Startup bool `url:"startup,omitempty"` CommunityPull bool `url:"community_pull"` AdditionalPull bool `url:"additional_pull"` + Dedup bool `url:"dedup"` Scopes string `url:"scopes,omitempty"` ScenariosContaining string `url:"scenarios_containing,omitempty"` ScenariosNotContaining string `url:"scenarios_not_containing,omitempty"` @@ -45,7 +46,7 @@ func (o *DecisionsStreamOpts) addQueryParamsToURL(url string) (string, error) { return "", err } - // Those 2 are a bit different + // Those 3 are a bit different // They default to true, and we only want to include them if they are false if params.Get("community_pull") == "true" { @@ -56,6 +57,10 @@ func (o *DecisionsStreamOpts) addQueryParamsToURL(url string) (string, error) { params.Del("additional_pull") } + if params.Get("dedup") == "true" { + params.Del("dedup") + } + return fmt.Sprintf("%s?%s", url, params.Encode()), nil } diff --git a/pkg/apiclient/decisions_service_test.go b/pkg/apiclient/decisions_service_test.go index acee0db1b22..190b5c6fc09 100644 --- a/pkg/apiclient/decisions_service_test.go +++ b/pkg/apiclient/decisions_service_test.go @@ -447,6 +447,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) { ScenariosNotContaining string CommunityPull bool AdditionalPull bool + Dedup bool } tests := []struct { @@ -461,6 +462,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) { fields: fields{ CommunityPull: true, AdditionalPull: true, + Dedup: true, }, }, { @@ -469,6 +471,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) { Startup: true, CommunityPull: true, AdditionalPull: true, + Dedup: true, }, expected: baseURLString + "?startup=true", }, @@ -481,6 +484,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) { ScenariosNotContaining: "bf", CommunityPull: true, AdditionalPull: true, + Dedup: true, }, expected: baseURLString + "?scenarios_containing=ssh&scenarios_not_containing=bf&scopes=ip%2Crange&startup=true", }, @@ -489,9 +493,28 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) { fields: fields{ CommunityPull: false, AdditionalPull: false, + Dedup: true, }, expected: baseURLString + "?additional_pull=false&community_pull=false", }, + { + name: "dedup=false", + fields: fields{ + CommunityPull: true, + AdditionalPull: true, + Dedup: false, + }, + expected: baseURLString + "?dedup=false", + }, + { + name: "all pull options false", + fields: fields{ + CommunityPull: false, + AdditionalPull: false, + Dedup: false, + }, + expected: baseURLString + "?additional_pull=false&community_pull=false&dedup=false", + }, } for _, tt := range tests { @@ -503,6 +526,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) { ScenariosNotContaining: tt.fields.ScenariosNotContaining, CommunityPull: tt.fields.CommunityPull, AdditionalPull: tt.fields.AdditionalPull, + Dedup: tt.fields.Dedup, } got, err := o.addQueryParamsToURL(baseURLString) From 73e150ca3beaa70139e357515689dc0c725e63e7 Mon Sep 17 00:00:00 2001 From: Linard Schwendener Date: Sat, 14 Mar 2026 12:59:20 +0100 Subject: [PATCH 2/2] Updated the swagger --- pkg/modelscapi/centralapi_swagger.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/modelscapi/centralapi_swagger.yaml b/pkg/modelscapi/centralapi_swagger.yaml index 6a830ee3820..9213630c465 100644 --- a/pkg/modelscapi/centralapi_swagger.yaml +++ b/pkg/modelscapi/centralapi_swagger.yaml @@ -68,6 +68,12 @@ paths: default: true required: false description: "Fetch additional blocklists content" + - in: query + name: "dedup" + type: "boolean" + default: true + required: false + description: "Enable deduplication of decisions" responses: "200": description: "200 response"