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
7 changes: 6 additions & 1 deletion pkg/apiclient/decisions_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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" {
Expand All @@ -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
}

Expand Down
24 changes: 24 additions & 0 deletions pkg/apiclient/decisions_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) {
ScenariosNotContaining string
CommunityPull bool
AdditionalPull bool
Dedup bool
}

tests := []struct {
Expand All @@ -461,6 +462,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) {
fields: fields{
CommunityPull: true,
AdditionalPull: true,
Dedup: true,
},
},
{
Expand All @@ -469,6 +471,7 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) {
Startup: true,
CommunityPull: true,
AdditionalPull: true,
Dedup: true,
},
expected: baseURLString + "?startup=true",
},
Expand All @@ -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",
},
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/modelscapi/centralapi_swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading