Skip to content

Commit

Permalink
Merge pull request #1135 from WalshyDev/walshy/remove-logs-v1
Browse files Browse the repository at this point in the history
Remove Pages logs v1
  • Loading branch information
jacobbednarz committed Nov 30, 2022
2 parents ab3b2f0 + c7ce2d6 commit 69e3425
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .changelog/1135.txt
@@ -0,0 +1,3 @@
```release-note:note
pages: removed the v1 logs endpoint for Pages deployments. Please switch to v2: https://developers.cloudflare.com/api/operations/pages-deployment-get-deployment-logs
```
41 changes: 1 addition & 40 deletions pages_deployment.go
Expand Up @@ -181,46 +181,7 @@ func (api *API) GetPagesDeploymentInfo(ctx context.Context, rc *ResourceContaine
return r.Result, nil
}

// GetPagesDeploymentStageLogs returns the logs for a Pages deployment stage.
//
// API reference: https://api.cloudflare.com/#pages-deployment-get-deployment-stage-logs
//
// Deprecated: Use GetPagesDeploymentLogs instead.
func (api *API) GetPagesDeploymentStageLogs(ctx context.Context, rc *ResourceContainer, params GetPagesDeploymentStageLogsParams) (PagesDeploymentStageLogs, error) {
if rc.Identifier == "" {
return PagesDeploymentStageLogs{}, ErrMissingAccountID
}

if params.ProjectName == "" {
return PagesDeploymentStageLogs{}, ErrMissingProjectName
}

if params.DeploymentID == "" {
return PagesDeploymentStageLogs{}, ErrMissingDeploymentID
}

if params.StageName == "" {
return PagesDeploymentStageLogs{}, ErrMissingStageName
}

uri := buildURI(
fmt.Sprintf("/accounts/%s/pages/projects/%s/deployments/%s/history/%s/logs", rc.Identifier, params.ProjectName, params.DeploymentID, params.StageName),
params.SizeOptions,
)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return PagesDeploymentStageLogs{}, err
}
var r pagesDeploymentStageLogsResponse
err = json.Unmarshal(res, &r)
if err != nil {
return PagesDeploymentStageLogs{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
}
return r.Result, nil
}

// GetPagesDeploymentStageLogs returns the logs for a Pages deployment stage.
// GetPagesDeploymentLogs returns the logs for a Pages deployment.
//
// API reference: https://api.cloudflare.com/#pages-deployment-get-deployment-logs
func (api *API) GetPagesDeploymentLogs(ctx context.Context, rc *ResourceContainer, params GetPagesDeploymentLogsParams) (PagesDeploymentLogs, error) {
Expand Down
29 changes: 0 additions & 29 deletions pages_deployment_test.go
Expand Up @@ -411,35 +411,6 @@ func TestGetPagesDeploymentInfo(t *testing.T) {
}
}

func TestGetPagesDeploymentStageLogs(t *testing.T) {
setup()
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)

w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, `{
"success": true,
"errors": [],
"messages": [],
"result": %s
}`, testPagesDeploymentStageLogsResponse)
}

mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/test/deployments/0012e50b-fa5d-44db-8cb5-1f372785dcbe/history/build/logs", handler)

actual, err := client.GetPagesDeploymentStageLogs(context.Background(), AccountIdentifier(testAccountID), GetPagesDeploymentStageLogsParams{
ProjectName: "test",
DeploymentID: "0012e50b-fa5d-44db-8cb5-1f372785dcbe",
StageName: "build",
SizeOptions: SizeOptions{},
})
if assert.NoError(t, err) {
assert.Equal(t, *expectedPagesDeploymentStageLogs, actual)
}
}

func TestGetPagesDeploymentLogs(t *testing.T) {
setup()
defer teardown()
Expand Down
4 changes: 2 additions & 2 deletions pages_domain.go
Expand Up @@ -44,8 +44,8 @@ type PagesDomainsResponse struct {

// PagesDomainParameters represents parameters for a pages domain request.
type PagesDomainParameters struct {
AccountID string
ProjectName string
AccountID string `json:"-"`
ProjectName string `json:"-"`
DomainName string `json:"name,omitempty"`
}

Expand Down
Empty file modified scripts/generate-changelog-entry.sh 100644 → 100755
Empty file.

0 comments on commit 69e3425

Please sign in to comment.