Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINOR: Add edgeDeployment confirmation request. #61

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading