pullzone_edgerule_add_update.go raw

   1  package bunny
   2  
   3  import (
   4  	"context"
   5  	"fmt"
   6  )
   7  
   8  // AddOrUpdateEdgeRuleOptions is the message that is sent to the
   9  // Add/Update Edge Rule API Endpoint.
  10  //
  11  // Bunny.net API docs: https://docs.bunny.net/reference/pullzonepublic_addedgerule
  12  type AddOrUpdateEdgeRuleOptions struct {
  13  	// GUID must only be set when updating an Edge Rule. When creating an
  14  	// Edge Rule it must be unset. The API Endpoint will generate a GUID.
  15  	GUID                *string            `json:"Guid,omitempty"`
  16  	ActionType          *int               `json:"ActionType,omitempty"`
  17  	ActionParameter1    *string            `json:"ActionParameter1,omitempty"`
  18  	ActionParameter2    *string            `json:"ActionParameter2,omitempty"`
  19  	Triggers            []*EdgeRuleTrigger `json:"Triggers,omitempty"`
  20  	TriggerMatchingType *int               `json:"TriggerMatchingType,omitempty"`
  21  	Description         *string            `json:"Description,omitempty"`
  22  	Enabled             *bool              `json:"Enabled,omitempty"`
  23  }
  24  
  25  // AddOrUpdateEdgeRule adds or updates an Edge Rule of a Pull Zone.
  26  //
  27  // Bunny.net API docs: https://docs.bunny.net/reference/pullzonepublic_addedgerule
  28  func (s *PullZoneService) AddOrUpdateEdgeRule(ctx context.Context, pullZoneID int64, opts *AddOrUpdateEdgeRuleOptions) error {
  29  	path := fmt.Sprintf("pullzone/%d/edgerules/addOrUpdate", pullZoneID)
  30  	return resourcePost(ctx, s.client, path, opts)
  31  }
  32