32 lines
888 B
Java
32 lines
888 B
Java
package template;
|
|
|
|
public class ApiMigration extends DataMigration {
|
|
|
|
private final String endpoint;
|
|
|
|
public ApiMigration(String endpoint) { this.endpoint = endpoint; }
|
|
|
|
@Override protected String getSourceName() { return "API:" + endpoint; }
|
|
|
|
@Override
|
|
protected void connect() {
|
|
System.out.println(" Authenticating with API at " + endpoint + "...");
|
|
}
|
|
|
|
@Override
|
|
protected int readData() {
|
|
System.out.println(" Paginating through API responses...");
|
|
return 320;
|
|
}
|
|
|
|
@Override
|
|
protected int transformData(int rawCount) {
|
|
System.out.println(" Flattening JSON, deduplicating (" + rawCount + " records)...");
|
|
return rawCount - 15; // 15 duplicates removed
|
|
}
|
|
|
|
// Override hook: silent migrations from APIs, no email spam
|
|
@Override
|
|
protected boolean sendNotification() { return false; }
|
|
}
|