From 576d76bd987a1a34004eb2e5d2af197f1d59210b Mon Sep 17 00:00:00 2001 From: debidong <1953531014@qq.com> Date: Tue, 12 May 2026 11:22:14 +0800 Subject: [PATCH] feat: add statuspage migration url name input --- statuspage.go | 9 +++++++-- statuspage_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/statuspage.go b/statuspage.go index cf57dfa..ac167d0 100644 --- a/statuspage.go +++ b/statuspage.go @@ -280,6 +280,7 @@ func (c *Client) CreateChangeTimeline(ctx context.Context, input *CreateChangeTi type StartStatusPageMigrationInput struct { SourceAPIKey string // Required. API key for the source provider (e.g. Atlassian Statuspage) SourcePageID string // Required. Page identifier in the source provider + URLName string // Optional. URL name to use when creating a new Flashduty public status page } // StartStatusPageEmailSubscriberMigrationInput contains parameters for starting @@ -336,10 +337,14 @@ func (c *Client) StartStatusPageMigration(ctx context.Context, input *StartStatu if input == nil { return nil, errors.New("input is required") } - return c.startStatusPageMigration(ctx, "/status-page/migrate-structure", map[string]any{ + body := map[string]any{ "api_key": input.SourceAPIKey, "source_page_id": input.SourcePageID, - }) + } + if input.URLName != "" { + body["url_name"] = input.URLName + } + return c.startStatusPageMigration(ctx, "/status-page/migrate-structure", body) } // StartStatusPageEmailSubscriberMigration starts an asynchronous migration of diff --git a/statuspage_test.go b/statuspage_test.go index 1fb20c2..0bc6078 100644 --- a/statuspage_test.go +++ b/statuspage_test.go @@ -51,11 +51,43 @@ func TestStartStatusPageMigration(t *testing.T) { if gotBody["source_page_id"] != "page_123" { t.Errorf("source_page_id = %v, want page_123", gotBody["source_page_id"]) } + if _, ok := gotBody["url_name"]; ok { + t.Errorf("url_name should be omitted when empty, got %v", gotBody["url_name"]) + } if out.JobID != "job-1" { t.Errorf("JobID = %s, want job-1", out.JobID) } } +func TestStartStatusPageMigrationSendsURLName(t *testing.T) { + var gotBody map[string]any + + client := newSDKExtensionsTestClient(t, func(w http.ResponseWriter, r *http.Request) { + gotBody = decodeJSONBody(t, r) + + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode(map[string]any{ + "data": map[string]any{"job_id": "job-url"}, + }) + }) + + out, err := client.StartStatusPageMigration(context.Background(), &StartStatusPageMigrationInput{ + SourceAPIKey: "atlassian-key", + SourcePageID: "page_123", + URLName: "desired-page", + }) + if err != nil { + t.Fatalf("StartStatusPageMigration() error = %v", err) + } + + if gotBody["url_name"] != "desired-page" { + t.Errorf("url_name = %v, want desired-page", gotBody["url_name"]) + } + if out.JobID != "job-url" { + t.Errorf("JobID = %s, want job-url", out.JobID) + } +} + func TestStartStatusPageEmailSubscriberMigration(t *testing.T) { var gotMethod, gotPath string var gotBody map[string]any