Skip to content

Import switch

Import an existing Switch into the service database.

import_switch_subscription(subscription_id)

Take an ImportedSwitch subscription, and turn it into a switch subscription.

Source code in gso/workflows/switch/import_switch.py
@step("Create new switch subscription")
def import_switch_subscription(subscription_id: UUIDstr) -> State:
    """Take an ImportedSwitch subscription, and turn it into a switch subscription."""
    old_switch = ImportedSwitch.from_subscription(subscription_id)
    new_subscription_id = get_product_id_by_name(ProductName.SWITCH)
    new_subscription = Switch.from_other_product(old_switch, new_subscription_id)  # type: ignore[arg-type]

    return {"subscription": new_subscription}

import_switch()

Modify an ImportedSwitch subscription into a Switch subscription to complete the import.

Source code in gso/workflows/switch/import_switch.py
@workflow("Import Switch", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_switch() -> StepList:
    """Modify an ImportedSwitch subscription into a Switch subscription to complete the import."""
    return begin >> store_process_subscription(Target.MODIFY) >> unsync >> import_switch_subscription >> resync >> done