Skip to content

Latest commit

 

History

History
126 lines (105 loc) · 7.79 KB

api.md

File metadata and controls

126 lines (105 loc) · 7.79 KB

API Reference

When login is enabled, protected requests require the dashboard session cookie. The health and readiness probes are public. Metrics scrapes use a separate bearer token. An unauthenticated protected API request receives JSON and HTTP 401. A session requiring a password change receives 403. A named operator requesting an administrative route receives a plain-text 404.

Operations

When login is enabled, operations require an administrator unless the table identifies a public, bearer-token, scoped or operator-only operation. A scoped read checks current resource access. Scoped cancel and restart also require ownership and current migration permission.

Method Path Purpose
GET /api/health Public process liveness probe
GET /api/ready Public readiness probe (503 when unavailable)
GET /api/metrics Bearer-token Prometheus migration metrics
GET /api/rate-limits Provider quotas, active count, and GitHub status
POST /api/profile Start a provider profile (201, or 429 with Retry-After when busy)
POST /api/profile/queue Discover and queue enterprise profiles (202) (sourceProvider, scope: "enterprise", enterprise: required enterprise slug on GitHub.com/GHE.com or top-level group on GitLab.com, optional for self-hosted sources). Returns 422 when no namespace remains after the configured scope and 502 with a safe reason when discovery fails
GET /api/profile/queue Read pending and failed-to-start counts for provider
GET /api/profile List profile runs
GET /api/profile/discover Discover a page of visible namespaces for provider; pass the returned next as cursor
GET /api/profile/:id Scoped read of profile status and paginated repository detail
POST /api/profile/:id Operator only. Queue { "grantId": "...", "repos": ["repo"] } for an operator's assigned source and destination. The grant must belong to this user, match this report's source and permit migration. Returns 201 with the batch ID.
GET /api/profile/:id/events Stream profile progress and terminal state
POST /api/migrate Create a migration (201 with the migration record)
GET /api/migrate List or search migrations
GET /api/migrate/activity List recent migration activity
GET /api/migrate/events Stream events across all migrations
POST /api/migrate/batches Create a migration batch (201)
GET /api/migrate/batches List migration batches
GET /api/migrate/batches/:id Read a batch summary and paginated members
DELETE /api/migrate/batches/:id Request cancellation for active batch members
POST /api/migrate/batches/:id/restart Restart eligible batch members
GET /api/migrate/:id Scoped read of the migration record
DELETE /api/migrate/:id Scoped cancellation request
GET /api/migrate/:id/events Scoped event access. Administrators receive SSE and operators receive JSON with recent visible events
POST /api/migrate/:id/confirm-restart Submit {"confirmation":"targetOrg/targetRepo"} after review. Returns the migration record or 409 on conflict
POST /api/migrate/:id/restart Restart an eligible migration. Operators submit an empty JSON object and receive {"status":"restarted"}. Administrators receive the migration record

Pagination

List endpoints accept positive page and limit query parameters and clamp limits to their route maximum. The migration list accepts q. Profile repository detail accepts search and readiness; view=status returns only run status and view=repos returns only the filtered repository page. For Bitbucket profiles, view=lfs returns a JSON download of the captured repositories' default branches and root LFS tracking-rule observations (found, none, or unknown). view=activity&page=1 returns paged repository review observations and coverage across the whole captured inventory.

Starting Migrations

Single requests identify sourceProvider, source API/organization/repository, target profile and organization/repository, plus optional credentials and execution options. Every new batch requires an explicit targetProfileId (ghec for Cloud, or the configured GHES profile ID). All items share that destination; to change platforms, create a new batch rather than restarting the old one. Batch requests carry the common source/target configuration and either a bounded repos path list or an items mapping list. Each items entry identifies sourceRepo and may override targetRepo. The server validates provider scope, target support, duplicate identities, credential policy, and the maximum batch size before persisting work. When a batch refers to a completed GitHub profile, each selected repository with profile warnings or blockers must have a successful repository analysis result. The server rejects missing, active, failed, or cancelled analysis jobs for those repositories. Clear repositories remain eligible without analysis, and GitLab and Bitbucket Server batches do not use this gate.

Browser Workflows

Repository analysis is started, cancelled, and retried through form actions on the profile detail page; its latest detail is returned by GET /api/profile/:id. Mapping approvals, GHES conflict discovery, and mannequin invitations are form actions on /mannequins. Neither workflow currently exposes a public REST mutation endpoint.

Server-Sent Events

For a single migration, download=1 returns NDJSON. Administrators can download the retained history. Operators receive their recent visible events.

Administrator event streams use text/event-stream. Migration event IDs are durable numeric cursors. Clients may reconnect with Last-Event-ID or the after query parameter; only non-negative integer cursors are accepted. With a cursor the server replays a bounded window, then delivers live events. A cursor outside the available window can produce a cursor-stale frame. Terminal per-resource streams close after their final frame.

The global migration stream can contain events from any migration. Consumers must route each event by its migrationId rather than assuming one active repository.

Probes

GET /api/health proves that the HTTP process can respond. GET /api/ready also verifies that initialization completed and SQLite can acquire a write transaction. Deployments should use readiness, not health, before routing operator traffic.

Prometheus Metrics

Set GH_MIGRATE_METRICS_TOKEN in the dashboard process environment to enable GET /api/metrics. Use a separate, cryptographically random token without whitespace. The endpoint requires Authorization: Bearer <token> even when dashboard login is disabled or a browser session is present. It returns 404 when disabled, 401 for a missing or incorrect token, and 503 for invalid token configuration. Protect the token in transit with TLS or a trusted private network; do not put it in a URL.

The endpoint returns Prometheus text exposition format 0.0.4. All metrics are gauges, grouped by source (github, gitlab, bitbucket-server), target (ghec, ghes, or other), mode (single or batch), and current state. Unknown stored states are grouped under other; repository names, organization names, URLs, and failure messages are not labels.

Metric Meaning
gh_migrate_migrations Number of retained migration records in the current state
gh_migrate_migration_duration_observations Retained records with a nonnegative recorded duration
gh_migrate_migration_duration_observed_seconds Sum of those recorded durations in seconds

Counts and duration sums describe retained rows at scrape time. They can decrease after pruning or a restart. A scrape can miss a short-lived migration state.