@@ -1310,6 +1310,31 @@ def tunnel_c(remote: str, local_address: str, namespace_and_repository: Optional
13101310 start_repository_tunnel (remote , local_address , namespace_and_repository )
13111311
13121312
1313+ @click .command ("sync-to-seafowl" )
1314+ @click .option ("--remote" , default = "data.splitgraph.com" , help = "Name of the remote registry to use." )
1315+ @click .option ("--password" , prompt = True , hide_input = True , confirmation_prompt = False )
1316+ @click .argument ("vdb_id" , type = str )
1317+ @click .argument ("seafowl_hostname" , type = str )
1318+ def sync_to_seafowl_c (remote : str , password : str , vdb_id : str , seafowl_hostname : str ):
1319+ """
1320+ Sync the tables within a Splitgraph VDB to a Seafowl instance.
1321+
1322+ """
1323+
1324+ from splitgraph .cloud import GQLAPIClient
1325+
1326+ client = GQLAPIClient (remote )
1327+ task_id = client .start_seafowl_sync (vdb_id , seafowl_hostname , password )
1328+ final_status = wait_for_job (task_id , lambda : client .get_export_job_status (task_id ))
1329+ if final_status .status == "SUCCESS" :
1330+ assert final_status .output
1331+ tables = [f"{ sync_item [0 ]} .{ sync_item [1 ]} " for sync_item in final_status .output ["tables" ]]
1332+ tables .sort ()
1333+ click .echo ("Sync complete for tables: %s" % ", " .join (tables ))
1334+ else :
1335+ raise ValueError ("Error running sync." )
1336+
1337+
13131338@click .group ("cloud" )
13141339def cloud_c ():
13151340 """Run actions on Splitgraph Cloud."""
@@ -1338,3 +1363,4 @@ def cloud_c():
13381363cloud_c .add_command (validate_c )
13391364cloud_c .add_command (seed_c )
13401365cloud_c .add_command (tunnel_c )
1366+ cloud_c .add_command (sync_to_seafowl_c )
0 commit comments