api/rule_set.go
func (a *API) SearchRuleSets(searchCriteria *SearchQueryType, filterCriteria *SearchFilterType) (*[]RuleSet, error) {
	q := url.Values{}

	if searchCriteria != nil && *searchCriteria != "" {
		q.Set("search", string(*searchCriteria))
	}

	if filterCriteria != nil && len(*filterCriteria) > 0 {
		for filter, criteria := range *filterCriteria {
			for _, val := range criteria {
				q.Add(filter, val)
			}
		}
	}

	if q.Encode() == "" {
		return a.FetchRuleSets()
	}

	reqURL := url.URL{
		Path:     config.RuleSetPrefix,
		RawQuery: q.Encode(),
	}

	result, err := a.Get(reqURL.String())
	if err != nil {
		return nil, fmt.Errorf("[ERROR] API call error %+v", err)
	}

	var rulesets []RuleSet
	if err := json.Unmarshal(result, &rulesets); err != nil {
		return nil, err
	}

	return &rulesets, nil
}
func (a *API) SearchRuleSets(searchCriteria *SearchQueryType, filterCriteria *SearchFilterType) (*[]RuleSet, error) {
	q := url.Values{}

	if searchCriteria != nil && *searchCriteria != "" {
		q.Set("search", string(*searchCriteria))
	}

	if filterCriteria != nil && len(*filterCriteria) > 0 {
		for filter, criteria := range *filterCriteria {
			for _, val := range criteria {
				q.Add(filter, val)
			}
		}
	}

	if q.Encode() == "" {
		return a.FetchRuleSets()
	}

	reqURL := url.URL{
		Path:     config.RuleSetPrefix,
		RawQuery: q.Encode(),
	}

	result, err := a.Get(reqURL.String())
	if err != nil {
		return nil, fmt.Errorf("[ERROR] API call error %+v", err)
	}

	var rulesets []RuleSet
	if err := json.Unmarshal(result, &rulesets); err != nil {
		return nil, err
	}

	return &rulesets, nil
}
func ( a * API ) SearchRuleSets ( searchCriteria * SearchQueryType , filterCriteria * SearchFilterType ) ( * [ ] RuleSet , error ) { q := url . Values { } if searchCriteria != nil && * searchCriteria != " " { q . Set ( " " , string ( * searchCriteria ) ) } if filterCriteria != nil && len ( * filterCriteria ) > 0 { for filter , criteria := range * filterCriteria { for _ , val := range criteria { q . Add ( filter , val ) } } } if q . Encode ( ) == " " { return a . FetchRuleSets ( ) } reqURL := url . URL { Path : config . RuleSetPrefix , RawQuery : q . Encode ( ) , } result , err := a . Get ( reqURL . String ( ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } var rulesets [ ] RuleSet if err := json . Unmarshal ( result , & rulesets ) ; err != nil { return nil , err } return & rulesets , nil }
// SearchRuleSets returns rule sets matching the specified search
// query and/or filter. If nil is passed for both parameters all
// rule sets will be returned.
SearchRuleSets returns rule sets matching the specified search query and / or filter . If nil is passed for both parameters all rule sets will be returned .