dnscontrol/pkg/cloudflare-go/stack_rulesest.go
Tom Limoncelli 7fd6a74e0c
CLOUDFLAREAPI: CF_REDIRECT/CF_TEMP_REDIRECT should dtrt using Single Redirects (#3002)
Co-authored-by: Josh Zhang <jzhang1@stackoverflow.com>
2024-06-18 17:38:50 -04:00

29 lines
866 B
Go

package cloudflare
import (
"context"
"errors"
"fmt"
"net/http"
)
// DeleteRulesetRule removes a ruleset rule based on the ruleset ID +
// ruleset rule ID.
//
// API reference: https://developers.cloudflare.com/api/operations/deleteZoneRulesetRule
func (api *API) DeleteRulesetRule(ctx context.Context, rc *ResourceContainer, rulesetID, rulesetRuleID string) error {
uri := fmt.Sprintf("/%s/%s/rulesets/%s/rules/%s", rc.Level, rc.Identifier, rulesetID, rulesetRuleID)
res, err := api.makeRequestContext(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
}
// The API is not implementing the standard response blob but returns an
// empty response (204) in case of a success. So we are checking for the
// response body size here.
if len(res) > 0 {
return fmt.Errorf(errMakeRequestError+": %w", errors.New(string(res)))
}
return nil
}