You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
988 B
47 lines
988 B
package compute
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
type PFWDelRequest struct {
|
|
ComputeID uint64 `url:"computeId"`
|
|
PFWID uint64 `url:"ruleId,omitempty"`
|
|
PublicPortStart uint64 `url:"publicPortStart,omitempty"`
|
|
PublicPortEnd uint64 `url:"publicPortEnd,omitempty"`
|
|
LocalBasePort uint64 `url:"localBasePort,omitempty"`
|
|
Proto string `url:"proto,omitempty"`
|
|
}
|
|
|
|
func (crq PFWDelRequest) Validate() error {
|
|
if crq.ComputeID == 0 {
|
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
|
err := req.Validate()
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
url := "/cloudapi/compute/pfwDel"
|
|
|
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
result, err := strconv.ParseBool(string(res))
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|