github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/ListAntiCrawler.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 ListAntiCrawlerOpts 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  	// JavaScript anti-crawler rule protection mode.
    16  	// anticrawler_except_url: In this mode, all paths are protected except the one specified in the queried anti-crawler rule.
    17  	// anticrawler_specific_url: In this mode, the path specified in the queried rule is protected.
    18  	Type string `q:"type,omitempty"`
    19  }
    20  
    21  // ListAntiCrawlers is used to query the list of JavaScript anti-crawler rules.
    22  func ListAntiCrawlers(client *golangsdk.ServiceClient, policyId string, opts ListAntiCrawlerOpts) ([]AntiCrawlerRule, error) {
    23  	query, err := golangsdk.BuildQueryString(opts)
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	// GET /v1/{project_id}/waf/policy/{policy_id}/anticrawler
    29  	url := client.ServiceURL("waf", "policy", policyId, "anticrawler") + query.String()
    30  	raw, err := client.Get(url, nil, nil)
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  
    35  	var res []AntiCrawlerRule
    36  	err = extract.IntoSlicePtr(raw.Body, &res, "items")
    37  	return res, err
    38  }