Skip to content

Feat: Migrations API#1

Open
mrrobot47 wants to merge 21 commits intomainfrom
feat/migrations-api
Open

Feat: Migrations API#1
mrrobot47 wants to merge 21 commits intomainfrom
feat/migrations-api

Conversation

@mrrobot47
Copy link
Copy Markdown
Member

migration.mp4

This pull request introduces full support for site migration operations in the SDK, including new API clients, models, and example scripts for end-to-end migration workflows. The most significant changes are the addition of migration and response ticket functionality, integration into the main AtomicClient, and comprehensive examples to guide users through migration steps.

Migration and Response Ticket API Support:

  • Added MigrationsClient in atomic_sdk/api/migrations.py to manage site migrations, including methods to create, get, update, run preflight checks, and set migrations as ready.
  • Added ResponseTicketsClient in atomic_sdk/api/response_tickets.py to monitor asynchronous operations like migrations, with methods to fetch summary and full details of response tickets.

Model Additions for Migration Workflow:

  • Introduced new models in atomic_sdk/models.py for migration operations: MigrationCreationResponse, ResponseTicket, and Migration, supporting response parsing and property access for migration details.

SDK Integration:

  • Registered the new clients (migrations and response_tickets) as properties of AtomicClient, making them available for all SDK users. [1] [2]

End-to-End Migration Examples:

  • Added a complete set of migration example scripts under examples/migrations/, demonstrating how to prepare a destination site, create a migration and install the SSH key, run preflight checks, and start/monitor the migration. [1] [2] [3]
  • Updated examples/README.md to document the new migration workflow, prerequisites, and step-by-step instructions for users.

Comment thread examples/migrations/02_create_migration_with_new_key.py Fixed
mrrobot47 and others added 3 commits August 26, 2025 17:18
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Arittra-Bag Arittra-Bag linked an issue Apr 21, 2026 that may be closed by this pull request
@Arittra-Bag Arittra-Bag marked this pull request as ready for review April 21, 2026 08:31
Copilot AI review requested due to automatic review settings April 21, 2026 08:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class site migration support to the Atomic SDK by introducing migrations/response-ticket API clients, new migration-related models, wiring the clients into AtomicClient, and providing step-by-step migration example scripts and documentation.

Changes:

  • Add MigrationsClient and ResponseTicketsClient API wrappers and register them on AtomicClient.
  • Introduce migration/response-ticket Pydantic models for parsing API responses.
  • Add end-to-end migration example scripts and document the workflow in examples/README.md.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
atomic_sdk/api/migrations.py New migrations API client (create/get/update/preflight/ready).
atomic_sdk/api/response_tickets.py New response ticket client for monitoring async operations.
atomic_sdk/client.py Registers migrations and response_tickets on AtomicClient.
atomic_sdk/models.py Adds MigrationCreationResponse, ResponseTicket, and Migration models.
examples/migrations/01_prepare_destination_site.py Creates a migration-ready destination site (example).
examples/migrations/02_create_migration_with_new_key.py Creates migration + attempts SSH key install (example).
examples/migrations/03_run_preflight_and_monitor.py Runs preflight and polls migration state (example).
examples/migrations/04_start_migration_and_monitor.py Sets migration ready and polls migration state (example).
examples/README.md Documents the new migration example workflow and prerequisites.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/migrations/03_run_preflight_and_monitor.py Outdated
Comment thread examples/migrations/03_run_preflight_and_monitor.py Outdated
Comment thread examples/migrations/03_run_preflight_and_monitor.py
Comment thread examples/migrations/04_start_migration_and_monitor.py Outdated
Comment thread atomic_sdk/api/response_tickets.py Outdated
Comment thread examples/migrations/04_start_migration_and_monitor.py Outdated
Comment thread examples/migrations/04_start_migration_and_monitor.py Outdated
Comment thread atomic_sdk/api/response_tickets.py Outdated
Comment thread atomic_sdk/api/migrations.py Outdated
Comment thread examples/migrations/02_create_migration_with_new_key.py Outdated
@Arittra-Bag Arittra-Bag self-requested a review April 21, 2026 10:45
- Add bounded timeout + monotonic deadline to example poll loops
- Fetch response_tickets.get_full() on failure/timeout for diagnostics (matches what the docstrings claimed)
- Print the preflight response-ticket id (use the previously-unused ticket var)
- Fix ticket_id annotation: int -> str to match ResponseTicket.response_ticket_id
- Only log state transitions, not every poll tick
- models: switch Migration/ResponseTicket/MigrationCreationResponse to pydantic v2 ConfigDict (consistency with Task model)
- ex/02: pipe public key via stdin & drop shell=True to eliminate quoting / command-injection risk in the example
- ex/03 & ex/04: print actionable error when ATOMIC_API_KEY/CLIENT_ID is missing instead of silently returning
@Arittra-Bag
Copy link
Copy Markdown
Collaborator

@codex Please review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 124c12f62e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/migrations/02_create_migration_with_new_key.py Outdated
Comment thread examples/migrations/02_create_migration_with_new_key.py Outdated
Arittra-Bag
Arittra-Bag previously approved these changes Apr 21, 2026
- sites.allow_ssh_migration(site_id|domain): one-way consent gate marking
  a destination site as willing to accept an incoming SSH migration.
  Destructive — the destination's files and DB are overwritten when the
  migration runs. Returns {ready_for_migration: bool}.
- ssh.get_user(username): reverse lookup; given a username returns the
  owning site_id plus created/last_updated timestamps. Inverse of
  list_users(site).

Both wrap single documented endpoints. No Pydantic models (consistent
with edge_cache/ssh/cron/custom_certificates). No changes to client.py.
README's Supported resources updated. Examples added under sites/ and
ssh/ with a typed-confirmation gate on the destructive one.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds SDK support for WP.Cloud site migration workflows by introducing new API clients/models and providing end-to-end example scripts and documentation updates.

Changes:

  • Introduces MigrationsClient and ResponseTicketsClient and wires them into AtomicClient.
  • Adds Pydantic models to represent migration create responses, migrations, and response tickets.
  • Adds/updates example scripts + docs to guide users through destination prep, migration creation, preflight, and execution/monitoring.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
examples/ssh/06_lookup_ssh_user.py New example for reverse-lookup of SSH/SFTP users by username.
examples/sites/08_allow_ssh_migration.py New example for one-way migration consent gate on destination sites.
examples/migrations/01_prepare_destination_site.py Creates a migration-ready destination site and polls the creation job.
examples/migrations/02_create_migration_with_new_key.py Creates a migration, retrieves a public key, and attempts SSH auto-install; stores migration id.
examples/migrations/03_run_preflight_and_monitor.py Runs migration preflight and monitors state until terminal outcome.
examples/migrations/04_start_migration_and_monitor.py Marks migration ready and monitors state until terminal outcome.
examples/README.md Documents the migration workflow examples and prerequisites.
atomic_sdk/models.py Adds migration/response-ticket models.
atomic_sdk/client.py Registers migrations and response_tickets on AtomicClient.
atomic_sdk/api/ssh.py Adds SSHClient.get_user() reverse-lookup endpoint wrapper.
atomic_sdk/api/sites.py Adds SitesClient.allow_ssh_migration() consent gate endpoint wrapper.
atomic_sdk/api/response_tickets.py New client for retrieving response ticket summary/full details.
atomic_sdk/api/migrations.py New client for create/get/update/preflight/ready migration operations.
README.md Updates top-level README to mention new migration/SSH features.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/migrations/02_create_migration_with_new_key.py Outdated
Comment thread atomic_sdk/models.py Outdated
- ex/02: print explicit env-var error instead of silent return; matches
  ex/03 and ex/04 patterns.
- models.Migration: type created/updated as datetime (was str). Brings
  Migration in line with Task and Backup; Pydantic v2 handles ISO 8601
  parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(api): wrap site-allow-ssh-migration and get-ssh-user endpoints WPC Site Migration

4 participants