# API Contracts

## 1. Migration Payload Additions

The migration execution API endpoint (e.g. `POST /api/v1/migration/run` or similar) needs to accept a new boolean flag.

```json
{
  "source_environment_id": "env_abc",
  "target_environment_id": "env_xyz",
  "resource_uuids": ["1234-abcd-...", "5678-efgh-..."],
  "fix_cross_filters": true
}
```

## 2. Settings API Endpoints

The frontend requires REST endpoints to manage the service settings.

```json
// GET /api/v1/migration/settings
{
  "sync_cron_schedule": "0 * * * *" // Example: every hour
}

// PUT /api/v1/migration/settings
{
  "sync_cron_schedule": "*/30 * * * *"
}

// GET /api/v1/migration/mappings
// Returns paginated list of ResourceMapping records
{
  "items": [
    {
      "environment_id": "prod-env-1",
      "environment_name": "Production",
      "resource_type": "chart",
      "uuid": "123e4567-e89b-12d3-a456-426614174000",
      "remote_integer_id": 42,
      "resource_name": "Monthly Active Users",
      "last_synced_at": "2026-02-25T10:00:00Z"
    }
  ],
  "total": 1
}
```

## 3. IdMappingService Internal Interface

```python
class IdMappingService:
    def sync_environment(self, environment_id: str) -> None:
        """Fully synchronizes mapping for a specific environment."""
        pass
        
    def get_remote_id(self, environment_id: str, resource_type: str, uuid: str) -> int | None:
        """Retrieves the remote integer ID for a given universal UUID."""
        pass

    def get_remote_ids_batch(self, environment_id: str, resource_type: str, uuids: list[str]) -> dict[str, int]:
        """Retrieves remote integer IDs for a list of universal UUIDs."""
        pass
```
