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

     1  package rules
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type UpdateReferenceTableOpts struct {
    10  	// Reference table name. The value can contain a maximum of 64 characters.
    11  	// Only digits, letters, hyphens (-), underscores (_), and periods (.) are allowed
    12  	Name string `json:"name" required:"true"`
    13  	// Reference table type.
    14  	Type string `json:"type" required:"true"`
    15  	// Value of the reference table.
    16  	Values []string `json:"values"`
    17  	// Reference table description.
    18  	Description string `json:"description"`
    19  }
    20  
    21  // UpdateReferenceTable is used to modify a reference table.
    22  func UpdateReferenceTable(client *golangsdk.ServiceClient, tableId string, opts UpdateReferenceTableOpts) (*ReferenceTable, error) {
    23  	b, err := build.RequestBody(opts, "")
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	// PUT /v1/{project_id}/waf/valuelist/{table_id}
    29  	raw, err := client.Put(client.ServiceURL("waf", "valuelist", tableId), b, nil, &golangsdk.RequestOpts{
    30  		OkCodes:     []int{200},
    31  		MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"},
    32  	})
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  	var res ReferenceTable
    37  	return &res, extract.Into(raw.Body, &res)
    38  }