Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

2.0 KB
Raw Blame
// Reversible DNS cutover (/api/v1/dns-cutover) — snapshot a domain's records
// before a migration cutover so the switch can be reverted.

export async function getCutoverTtlGuidance(records) {
    return this.request('/dns-cutover/ttl-guidance', {
        method: 'POST',
        body: { records },
    });
}

// Server-sourced snapshot: the panel reads live records from the
// provider itself; the client may only pass `names` to filter which record
// names to include (never the record data). Requires a connected provider zone.
export async function snapshotDnsForCutover(domain, providerZoneId, provider = null, names = null) {
    return this.request('/dns-cutover/snapshot', {
        method: 'POST',
        body: { domain, provider_zone_id: providerZoneId, provider, names },
    });
}

export async function getCutoverSnapshots(domain = null) {
    const suffix = domain ? `?domain=${encodeURIComponent(domain)}` : '';
    return this.request(`/dns-cutover/snapshots${suffix}`);
}

export async function getCutoverSnapshot(snapshotId) {
    return this.request(`/dns-cutover/snapshots/${snapshotId}`);
}

// Perform (or dry-run) a cutover. `dryRun: true` returns the exact
// provider ops (create/update, old→new) without writing and needs no provider.
export async function performDnsCutover(snapshotId, target, { recordTypes = ['A'], dryRun = false } = {}) {
    return this.request('/dns-cutover/cutover', {
        method: 'POST',
        body: { snapshot_id: snapshotId, target, record_types: recordTypes, dry_run: dryRun },
    });
}

// Post-cutover resolution check across public resolvers.
export async function verifyDnsCutover(domain, { recordType = 'A', expected = null, snapshotId = null } = {}) {
    return this.request('/dns-cutover/verify', {
        method: 'POST',
        body: { domain, record_type: recordType, expected, snapshot_id: snapshotId },
    });
}

export async function revertDnsCutover(snapshotId) {
    return this.request(`/dns-cutover/snapshots/${snapshotId}/revert`, { method: 'POST' });
}