-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update airbyte server block(s) script
- Loading branch information
1 parent
f36b58f
commit dba8002
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.core.management.base import BaseCommand | ||
from ddpui.models.org import Org, OrgPrefectBlockv1 | ||
from ddpui.ddpprefect import prefect_service | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Update airbyte server blocks in prefect""" | ||
|
||
help = "Update airbyte server blocks in prefect" | ||
|
||
def add_arguments(self, parser): | ||
"""adds command line arguments""" | ||
parser.add_argument("org", type=str, help="Org slug, use 'all' to update for all orgs") | ||
|
||
def handle(self, *args, **options): | ||
"""Use airbyte host and port from the .env""" | ||
orgs = Org.objects.all() | ||
if options["org"] != "all": | ||
orgs = orgs.filter(slug=options["org"]) | ||
|
||
print(f"Updating airbyte server blocks in prefect for {len(orgs)} orgs") | ||
|
||
for org in orgs: | ||
server_block = OrgPrefectBlockv1.objects.filter(org=org).first() | ||
|
||
if not server_block: | ||
print(f"Org {org.slug} does not have a server block") | ||
continue | ||
|
||
# update host and port | ||
prefect_service.update_airbyte_server_block(server_block.block_name) | ||
|
||
print(f"Updated airbyte server block for org {org.slug}") |