From 6d1afa7b1c0ce792ab577a44dc411c9abd34e36a Mon Sep 17 00:00:00 2001 From: Ayrton Date: Mon, 26 Oct 2026 17:54:09 +0100 Subject: [PATCH 1/2] Use the change requests endpoint for Neki --- internal/planetscale/neki_changes.go | 2 +- internal/planetscale/neki_changes_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/planetscale/neki_changes.go b/internal/planetscale/neki_changes.go index e361481b..3e5d66d8 100644 --- a/internal/planetscale/neki_changes.go +++ b/internal/planetscale/neki_changes.go @@ -125,7 +125,7 @@ func (s *nekiChangesService) Cancel(ctx context.Context, r *CancelNekiChangeRequ } func nekiChangesAPIPath(org, database, branch string) string { - return path.Join(databaseBranchAPIPath(org, database, branch), "neki-changes") + return path.Join(databaseBranchAPIPath(org, database, branch), "change-requests") } func nekiChangeAPIPath(org, database, branch, change string) string { diff --git a/internal/planetscale/neki_changes_test.go b/internal/planetscale/neki_changes_test.go index 0def54f2..7f2ab477 100644 --- a/internal/planetscale/neki_changes_test.go +++ b/internal/planetscale/neki_changes_test.go @@ -12,7 +12,7 @@ import ( func TestNekiChangesService(t *testing.T) { c := qt.New(t) - const basePath = "/v1/organizations/acme/databases/app/branches/main/neki-changes" + const basePath = "/v1/organizations/acme/databases/app/branches/main/change-requests" ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch { From 8ed62965fd180f7c8a76beefae84c7ea965163a5 Mon Sep 17 00:00:00 2001 From: Ayrton Date: Mon, 26 Oct 2026 18:25:04 +0100 Subject: [PATCH 2/2] Use change-requests in Neki resource URLs --- internal/planetscale/neki_admins.go | 2 +- internal/planetscale/neki_admins_test.go | 6 +++--- internal/planetscale/neki_routers.go | 2 +- internal/planetscale/neki_routers_test.go | 6 +++--- internal/planetscale/neki_shard_configuration_profiles.go | 2 +- .../planetscale/neki_shard_configuration_profiles_test.go | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/planetscale/neki_admins.go b/internal/planetscale/neki_admins.go index be42d1f8..c17e7a96 100644 --- a/internal/planetscale/neki_admins.go +++ b/internal/planetscale/neki_admins.go @@ -196,7 +196,7 @@ func nekiAdminAPIPath(org, database, branch string) string { } func nekiAdminChangesAPIPath(org, database, branch string) string { - return path.Join(nekiAdminAPIPath(org, database, branch), "changes") + return path.Join(nekiAdminAPIPath(org, database, branch), "change-requests") } func nekiAdminChangeAPIPath(org, database, branch, change string) string { diff --git a/internal/planetscale/neki_admins_test.go b/internal/planetscale/neki_admins_test.go index 1afe6a55..2c0216fa 100644 --- a/internal/planetscale/neki_admins_test.go +++ b/internal/planetscale/neki_admins_test.go @@ -39,17 +39,17 @@ func TestNekiAdminsService(t *testing.T) { case r.Method == http.MethodGet && r.URL.Path == adminPath+"/parameters": _, _ = w.Write([]byte(`[{"name":"recovery-poll-interval","display_name":"Recovery poll interval","namespace":"admin","advanced":false,"category":null,"description":"How often the admin runs recovery analysis and repairs.","parameter_type":"time","default_value":"10s","value":"20s","required":false,"created_at":"2026-08-04T12:00:00Z","updated_at":null,"restart":false,"url":"https://example.test/parameter"}]`)) - case r.Method == http.MethodGet && r.URL.Path == adminPath+"/changes": + case r.Method == http.MethodGet && r.URL.Path == adminPath+"/change-requests": c.Assert(r.URL.Query().Get("period"), qt.Equals, "24h") c.Assert(r.URL.Query().Get("completed_at"), qt.Equals, "2026-08-04") c.Assert(r.URL.Query().Get("page"), qt.Equals, "2") c.Assert(r.URL.Query().Get("per_page"), qt.Equals, "25") _, _ = w.Write([]byte(`{"data":[{"id":"change-1","state":"pending","created_at":"2026-08-04T12:00:00Z","updated_at":"2026-08-04T12:00:00Z","admin_size":"NKA_1","admin_size_display_name":"NKA-1","previous_admin_size":"NKA_0","previous_admin_size_display_name":"NKA-0","parameters":{"admin":{"recovery-poll-interval":"20s"}},"previous_parameters":{"admin":{"recovery-poll-interval":"10s"}}}]}`)) - case r.Method == http.MethodGet && r.URL.Path == adminPath+"/changes/change-1": + case r.Method == http.MethodGet && r.URL.Path == adminPath+"/change-requests/change-1": _, _ = w.Write([]byte(`{"id":"change-1","state":"pending","created_at":"2026-08-04T12:00:00Z","updated_at":"2026-08-04T12:00:00Z","admin_size":"NKA_1","admin_size_display_name":"NKA-1","previous_admin_size":"NKA_0","previous_admin_size_display_name":"NKA-0","parameters":{"admin":{"recovery-poll-interval":"20s"}},"previous_parameters":{"admin":{"recovery-poll-interval":"10s"}}}`)) - case r.Method == http.MethodDelete && r.URL.Path == adminPath+"/changes/change-1": + case r.Method == http.MethodDelete && r.URL.Path == adminPath+"/change-requests/change-1": w.WriteHeader(http.StatusNoContent) case r.Method == http.MethodPost && r.URL.Path == adminPath: diff --git a/internal/planetscale/neki_routers.go b/internal/planetscale/neki_routers.go index 9b0aca74..9f65e5f5 100644 --- a/internal/planetscale/neki_routers.go +++ b/internal/planetscale/neki_routers.go @@ -292,7 +292,7 @@ func nekiRouterAPIPath(org, database, branch, router string) string { } func nekiRouterChangesAPIPath(org, database, branch, router string) string { - return path.Join(nekiRouterAPIPath(org, database, branch, router), "changes") + return path.Join(nekiRouterAPIPath(org, database, branch, router), "change-requests") } func nekiRouterChangeAPIPath(org, database, branch, router, change string) string { diff --git a/internal/planetscale/neki_routers_test.go b/internal/planetscale/neki_routers_test.go index 12317c2b..5c60bbd6 100644 --- a/internal/planetscale/neki_routers_test.go +++ b/internal/planetscale/neki_routers_test.go @@ -117,17 +117,17 @@ func TestNekiRoutersService(t *testing.T) { "url":"https://planetscale.com/docs" }]`)) - case r.Method == http.MethodGet && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics/changes": + case r.Method == http.MethodGet && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics/change-requests": c.Assert(r.URL.Query().Get("period"), qt.Equals, "24h") c.Assert(r.URL.Query().Get("completed_at"), qt.Equals, "2026-08-04") c.Assert(r.URL.Query().Get("page"), qt.Equals, "2") c.Assert(r.URL.Query().Get("per_page"), qt.Equals, "25") _, _ = w.Write([]byte(`{"data":[{"id":"change-1","state":"pending","created_at":"2026-08-04T12:00:00Z","updated_at":"2026-08-04T12:00:00Z","router_size":"NKR_10","previous_router_size":"NKR_5","replicas_per_cell":2,"previous_replicas_per_cell":1,"parameters":{"router":{"replication-lag-tolerable-max":"15m"}},"previous_parameters":{"router":{"replication-lag-tolerable-max":"10m"}}}]}`)) - case r.Method == http.MethodGet && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics/changes/change-1": + case r.Method == http.MethodGet && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics/change-requests/change-1": _, _ = w.Write([]byte(`{"id":"change-1","state":"pending","created_at":"2026-08-04T12:00:00Z","updated_at":"2026-08-04T12:00:00Z","router_size":"NKR_10","previous_router_size":"NKR_5","replicas_per_cell":2,"previous_replicas_per_cell":1}`)) - case r.Method == http.MethodDelete && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics/changes/change-1": + case r.Method == http.MethodDelete && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics/change-requests/change-1": w.WriteHeader(http.StatusNoContent) case r.Method == http.MethodDelete && r.URL.Path == "/v1/organizations/acme/databases/app/branches/main/routers/analytics": diff --git a/internal/planetscale/neki_shard_configuration_profiles.go b/internal/planetscale/neki_shard_configuration_profiles.go index d42e26f7..114a6379 100644 --- a/internal/planetscale/neki_shard_configuration_profiles.go +++ b/internal/planetscale/neki_shard_configuration_profiles.go @@ -390,7 +390,7 @@ func nekiDefaultShardConfigurationProfileAPIPath(org, database, branch string) s } func nekiShardConfigurationProfileChangesAPIPath(org, database, branch, profile string) string { - return path.Join(nekiShardConfigurationProfileAPIPath(org, database, branch, profile), "changes") + return path.Join(nekiShardConfigurationProfileAPIPath(org, database, branch, profile), "change-requests") } func nekiShardConfigurationProfileChangeAPIPath(org, database, branch, profile, change string) string { diff --git a/internal/planetscale/neki_shard_configuration_profiles_test.go b/internal/planetscale/neki_shard_configuration_profiles_test.go index f3d548cf..8bdd2a65 100644 --- a/internal/planetscale/neki_shard_configuration_profiles_test.go +++ b/internal/planetscale/neki_shard_configuration_profiles_test.go @@ -105,17 +105,17 @@ func TestNekiShardConfigurationProfilesService(t *testing.T) { case r.Method == http.MethodGet && r.URL.Path == profilePath+"/extensions": _, _ = w.Write([]byte(`[{"name":"pg_stat_statements","description":"Stats","enabled":true,"can_enable":true,"internal":false,"loader":"shared_preload_libraries","url":"https://example.test/extension","parameters":[]}]`)) - case r.Method == http.MethodGet && r.URL.Path == profilePath+"/changes": + case r.Method == http.MethodGet && r.URL.Path == profilePath+"/change-requests": c.Assert(r.URL.Query().Get("period"), qt.Equals, "24h") c.Assert(r.URL.Query().Get("completed_at"), qt.Equals, "2026-08-04") c.Assert(r.URL.Query().Get("page"), qt.Equals, "2") c.Assert(r.URL.Query().Get("per_page"), qt.Equals, "25") _, _ = w.Write([]byte(`{"data":[{"id":"change-1","state":"pending","created_at":"2026-08-04T12:00:00Z","updated_at":"2026-08-04T12:00:00Z","name":"metal","previous_name":"default","cluster_size":"M1-10","cluster_display_name":"Metal 10","metal":true,"cluster_rank":1,"replicas":2,"read_only_replicas":3,"previous_read_only_replicas":1,"parameters":{},"previous_cluster_size":"PS-10","previous_cluster_display_name":"PS 10","previous_metal":false,"previous_cluster_rank":2,"previous_replicas":0,"previous_parameters":{}}]}`)) - case r.Method == http.MethodGet && r.URL.Path == profilePath+"/changes/change-1": + case r.Method == http.MethodGet && r.URL.Path == profilePath+"/change-requests/change-1": _, _ = w.Write([]byte(`{"id":"change-1","state":"pending","created_at":"2026-08-04T12:00:00Z","updated_at":"2026-08-04T12:00:00Z","name":"metal","cluster_size":"M1-10","replicas":2,"read_only_replicas":0,"previous_read_only_replicas":3,"parameters":{},"previous_parameters":{}}`)) - case r.Method == http.MethodDelete && r.URL.Path == profilePath+"/changes/change-1": + case r.Method == http.MethodDelete && r.URL.Path == profilePath+"/change-requests/change-1": w.WriteHeader(http.StatusNoContent) default: