github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/ListBlacklist.go (about)

     1  package rules
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type ListBlacklistOpts struct {
     9  	// Number of records on each page.
    10  	// The maximum value is 100. If this parameter is not specified, the default value -1 is used.
    11  	// All policies are queried regardless of the value of Page
    12  	PageSize int64 `q:"pagesize,omitempty"`
    13  	// Page. Default value: 1
    14  	Page int `q:"page,omitempty"`
    15  	// Rule name, Fuzzy search is supported.
    16  	Name string `q:"name,omitempty"`
    17  }
    18  
    19  // ListBlacklists is used to query the list of blacklist and whitelist rules.
    20  func ListBlacklists(client *golangsdk.ServiceClient, policyId string, opts ListBlacklistOpts) ([]BlacklistRule, error) {
    21  	query, err := golangsdk.BuildQueryString(opts)
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  
    26  	// GET /v1/{project_id}/waf/policy/{policy_id}/whiteblackip
    27  	url := client.ServiceURL("waf", "policy", policyId, "whiteblackip") + query.String()
    28  	raw, err := client.Get(url, nil, nil)
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  
    33  	var res []BlacklistRule
    34  	err = extract.IntoSlicePtr(raw.Body, &res, "items")
    35  	return res, err
    36  }