package dcdn

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)

// ModifyDcdnWafRule invokes the dcdn.ModifyDcdnWafRule API synchronously
func (client *Client) ModifyDcdnWafRule(request *ModifyDcdnWafRuleRequest) (response *ModifyDcdnWafRuleResponse, err error) {
	response = CreateModifyDcdnWafRuleResponse()
	err = client.DoAction(request, response)
	return
}

// ModifyDcdnWafRuleWithChan invokes the dcdn.ModifyDcdnWafRule API asynchronously
func (client *Client) ModifyDcdnWafRuleWithChan(request *ModifyDcdnWafRuleRequest) (<-chan *ModifyDcdnWafRuleResponse, <-chan error) {
	responseChan := make(chan *ModifyDcdnWafRuleResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.ModifyDcdnWafRule(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// ModifyDcdnWafRuleWithCallback invokes the dcdn.ModifyDcdnWafRule API asynchronously
func (client *Client) ModifyDcdnWafRuleWithCallback(request *ModifyDcdnWafRuleRequest, callback func(response *ModifyDcdnWafRuleResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *ModifyDcdnWafRuleResponse
		var err error
		defer close(result)
		response, err = client.ModifyDcdnWafRule(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// ModifyDcdnWafRuleRequest is the request struct for api ModifyDcdnWafRule
type ModifyDcdnWafRuleRequest struct {
	*requests.RpcRequest
	RuleConfig string           `position:"Body" name:"RuleConfig"`
	RuleStatus string           `position:"Body" name:"RuleStatus"`
	RuleName   string           `position:"Body" name:"RuleName"`
	RuleId     requests.Integer `position:"Body" name:"RuleId"`
}

// ModifyDcdnWafRuleResponse is the response struct for api ModifyDcdnWafRule
type ModifyDcdnWafRuleResponse struct {
	*responses.BaseResponse
	RequestId string `json:"RequestId" xml:"RequestId"`
}

// CreateModifyDcdnWafRuleRequest creates a request to invoke ModifyDcdnWafRule API
func CreateModifyDcdnWafRuleRequest() (request *ModifyDcdnWafRuleRequest) {
	request = &ModifyDcdnWafRuleRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("dcdn", "2018-01-15", "ModifyDcdnWafRule", "", "")
	request.Method = requests.POST
	return
}

// CreateModifyDcdnWafRuleResponse creates a response to parse from ModifyDcdnWafRule response
func CreateModifyDcdnWafRuleResponse() (response *ModifyDcdnWafRuleResponse) {
	response = &ModifyDcdnWafRuleResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
