Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions statuspage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions statuspage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down