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

     1  package hosts
     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 UpdateOpts struct {
    10  	// Whether a proxy is used for the domain name.
    11  	// If your website has no layer-7 proxy server such as CDN and cloud
    12  	// acceleration service deployed in front of WAF and uses only layer-4 load balancers (or NAT),
    13  	// set Proxy Configured to No. Otherwise, Proxy Configured must be set to Yes.
    14  	// This ensures that WAF obtains real IP addresses of website visitors and
    15  	// takes protective actions configured in protection policies.
    16  	Proxy *bool `json:"proxy"`
    17  	// HTTPS certificate ID. It can be obtained by calling the ListCertificates API.
    18  	CertificateId string `json:"certificateid"`
    19  	// HTTPS certificate name. It can be obtained by calling the ListCertificates API.
    20  	// Certifacteid and certificatename are required at the same.
    21  	// If certificateid does not match certificatename, an error is reported.
    22  	CertificateName string `json:"certificatename"`
    23  	// Minimum TLS version supported.
    24  	// TLS v1.0 is used by default.
    25  	// The value can be:TLS v1.0TLS v1.1TLS v1.2TLS v1.3
    26  	Tls string `json:"tls"`
    27  	// Cipher suite. The value can be:
    28  	// cipher_1: ECDHE-ECDSA-AES256-GCM-SHA384:HIGH:!MEDIUM:!LOW:!aNULL:!eNULL:!DES:!MD5:!PSK:!RC4:!kRSA:!SRP:!3DES:!DSS:!EXP:!CAMELLIA:@STRENGTH
    29  	// cipher_2: EECDH+AESGCM:EDH+AESGCM
    30  	// cipher_3: ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH
    31  	// cipher_4. ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!EDH n - cipher_default: ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM
    32  	Cipher string `json:"cipher"`
    33  	// WAF status of the protected domain name.
    34  	// -1: Bypassed. Requests are directly sent to the backend servers without passing through WAF.
    35  	// 0: Suspended. WAF only forwards requests for the domain name but does not detect attacks.
    36  	// -1: Enabled. WAF detects attacks based on the configured policy.
    37  	ProtectStatus int `json:"protect_status"`
    38  	// Alarm configuration page.
    39  	BlockPage *BlockPage `json:"block_page"`
    40  	// Feature switch for configuring compliance certification
    41  	// checks for domain names protected with the dedicated WAF instance.
    42  	Flag *FlagObject `json:"flag"`
    43  	// Traffic identifier
    44  	TrafficMark *TrafficMarkObject `json:"traffic_mark"`
    45  	// Circuit breaker configuration
    46  	CircuitBreaker *CircuitBreakerObject `json:"circuit_breaker"`
    47  	// Timeout settings
    48  	TimeoutConfig *TimeoutConfigObject `json:"timeout_config"`
    49  	// Website name
    50  	WebTag string `json:"web_tag"`
    51  	// Description
    52  	Description string `json:"description"`
    53  }
    54  
    55  type BlockPage struct {
    56  	// Template name
    57  	Template string `json:"template" required:"true"`
    58  	// Custom alarm page
    59  	CustomPage *CustomPage `json:"custom_page"`
    60  	// Redirection URL
    61  	RedirectUrl string `json:"redirect_url"`
    62  }
    63  
    64  type CustomPage struct {
    65  	// Status Codes
    66  	StatusCode string `json:"status_code" required:"true"`
    67  	// Content type of alarm page
    68  	ContentType string `json:"content_type" required:"true"`
    69  	// Page content
    70  	Content string `json:"content" required:"true"`
    71  }
    72  
    73  func Update(client *golangsdk.ServiceClient, id string, opts UpdateOpts) (*Host, error) {
    74  	b, err := build.RequestBody(opts, "")
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  
    79  	// PUT /v1/{project_id}/premium-waf/host
    80  	raw, err := client.Put(client.ServiceURL("premium-waf", "host", id), b, nil, &golangsdk.RequestOpts{
    81  		OkCodes:     []int{200},
    82  		MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"},
    83  	})
    84  	if err != nil {
    85  		return nil, err
    86  	}
    87  
    88  	var res Host
    89  	return &res, extract.Into(raw.Body, &res)
    90  }