Migrates an instance.

    @type instance: string
    @param instance: Instance name
    @type mode: string
    @param mode: Migration mode
    @type cleanup: bool
    @param cleanup: Whether to clean up a previously failed migration

def MigrateInstance(r, instance, mode=None, cleanup=None):
    """
    Migrates an instance.

    @type instance: string
    @param instance: Instance name
    @type mode: string
    @param mode: Migration mode
    @type cleanup: bool
    @param cleanup: Whether to clean up a previously failed migration
    """

    body = {}

    if mode is not None:
        body["mode"] = mode

    if cleanup is not None:
        body["cleanup"] = cleanup

    return r.request("put", "/2/instances/%s/migrate" % instance,
                     content=body)