forked from simplesurance/bunny-go
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpullzone_edgerule_set_enabled.go
More file actions
34 lines (29 loc) · 1.32 KB
/
pullzone_edgerule_set_enabled.go
File metadata and controls
34 lines (29 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package bunny
import (
"context"
"fmt"
)
// SetEdgeRuleEnabledOptions represents the message that is sent to Add/Update Edge Rule endpoint.
//
// Bunny.net API docs: https://docs.bunny.net/reference/pullzonepublic_addedgerule
type SetEdgeRuleEnabledOptions struct {
// ID must be set to the PullZone ID for that the EdgeRule should be enabled.
ID *int64 `json:"Id,omitempty"`
Value *bool `json:"Value,omitempty"`
}
// SetEdgeRuleEnabled enables or disables an Edge Rule of a Pull Zone.
// The edgeRuleGUID field is called edgeRuleID in the API message and
// documentation. It is the same then the GUID field in the EdgeRule message.
//
// Bunny.net API docs: https://docs.bunny.net/reference/pullzonepublic_addedgerule
func (s *PullZoneService) SetEdgeRuleEnabled(ctx context.Context, pullZoneID int64, edgeRuleGUID string, opts *SetEdgeRuleEnabledOptions) error {
if opts != nil {
if opts.ID == nil {
s.client.logf("SetEdgeRuleEnabled: ID field is unset in SetEdgeRuleEnabledOptions")
} else if *opts.ID != pullZoneID {
s.client.logf("SetEdgeRuleEnabled: mismatched pullZoneID %d and SetEdgeRuleEnabledOptions.ID %d were passed, values should be equal", pullZoneID, *opts.ID)
}
}
path := fmt.Sprintf("pullzone/%d/edgerules/%s/setEdgeRuleEnabled", pullZoneID, edgeRuleGUID)
return resourcePost(ctx, s.client, path, opts)
}