Skip to content

Commit

Permalink
MINOR: Add edgeDeployment confirmation request. (#61)
Browse files Browse the repository at this point in the history
* add confirm call

* rename function to GetEdgeDeployment
  • Loading branch information
jeremy-cxf authored Apr 25, 2024
1 parent 1b937d5 commit 92ef742
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,36 @@ func (sc *Client) doRequestDetailed(method, url, reqBody string) (*http.Response
return resp, err
}

// FastlyService contains details about a Fastly Service mapped a site.
type FastlyService struct {
ID string `json:"id"`
AccountID string `json:"accountID"`
Created time.Time `json:"created"`
CreatedBy string `json:"createdBy"`
}

// EdgeDeployment contains details about an Edge Deployment
type EdgeDeployment struct {
AgentHostName string `json:"AgentHostName"`
ServicesAttached []FastlyService `json:"ServicesAttached"`
}

// GetEdgeDeployment retrieves currently deployed EdgeWafs and Fastly Services mapped to a site..
func (sc *Client) GetEdgeDeployment(corpName, siteName string) (EdgeDeployment, error) {
resp, err := sc.doRequest("GET", fmt.Sprintf("/v0/corps/%s/sites/%s/edgeDeployment", corpName, siteName), "")
if err != nil {
return EdgeDeployment{}, err
}

var edgeDeployment EdgeDeployment
err = json.Unmarshal(resp, &edgeDeployment)
if err != nil {
return EdgeDeployment{}, err
}

return edgeDeployment, nil
}

// CreateOrUpdateEdgeDeployment initializes the Next-Gen WAF deployment in Compute@Edge and configures the site for Edge Deployment.
func (sc *Client) CreateOrUpdateEdgeDeployment(corpName, siteName string) error {
_, err := sc.doRequest("PUT", fmt.Sprintf("/v0/corps/%s/sites/%s/edgeDeployment", corpName, siteName), "")
Expand Down

0 comments on commit 92ef742

Please sign in to comment.