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

Remove Pages logs v1 #1135

Merged
merged 3 commits into from Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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