Skip to content

Commit

Permalink
Add new EdgeDeployment arguments (#51)
Browse files Browse the repository at this point in the history
* Add new EdgeDeployment arguments

* make CreateOrUpdateEdgeDeploymentServiceBody.ActivateVersion a pointer to bool

* json.Marshal the CreateOrUpdateEdgeDeploymentServiceBody after sc.fastlyKey check

---------

Co-authored-by: Vladimir Vuksan <vladimir@fastly.com>
  • Loading branch information
shawnps and vvuksan committed Mar 22, 2023
1 parent 635a5fd commit 91cd112
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2901,14 +2901,24 @@ func (sc *Client) DeleteEdgeDeployment(corpName, siteName string) error {
return err
}

type CreateOrUpdateEdgeDeploymentServiceBody struct {
ActivateVersion *bool `json:"activateVersion,omitempty"` //Activate Fastly VCL service after clone
PercentEnabled int `json:"percentEnabled,omitempty"` //Percentage of traffic to send to NGWAF@Edge
}

// CreateOrUpdateEdgeDeploymentService copies the backends from the Fastly service to the
// Edge Deployment and pre-configures the Fastly service with an edge dictionary and custom VCL.
func (sc *Client) CreateOrUpdateEdgeDeploymentService(corpName, siteName, fastlySID string) error {
func (sc *Client) CreateOrUpdateEdgeDeploymentService(corpName, siteName, fastlySID string, body CreateOrUpdateEdgeDeploymentServiceBody) error {
if sc.fastlyKey == "" {
return errors.New("please set Fastly-Key with the client.SetFastlyKey method")
}

_, err := sc.doRequest("PUT", fmt.Sprintf("/v0/corps/%s/sites/%s/edgeDeployment/%s", corpName, siteName, fastlySID), "")
b, err := json.Marshal(body)
if err != nil {
return err
}

_, err = sc.doRequest("PUT", fmt.Sprintf("/v0/corps/%s/sites/%s/edgeDeployment/%s", corpName, siteName, fastlySID), string(b))

return err
}
Expand Down

0 comments on commit 91cd112

Please sign in to comment.