from .sections import *
from .database import ChangeSet, API_DELETE, API_UPDATE
from .batch_exe import execute_batch_command


def delete_junction_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s2_junction }
    return execute_batch_command(name, cs)


def delete_reservoir_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s3_reservoir }
    return execute_batch_command(name, cs)


def delete_tank_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s4_tank }
    return execute_batch_command(name, cs)


def delete_pipe_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s5_pipe }
    return execute_batch_command(name, cs)


def delete_pump_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s6_pump }
    return execute_batch_command(name, cs)


def delete_valve_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s7_valve }
    return execute_batch_command(name, cs)


def delete_pattern_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s11_pattern }
    return execute_batch_command(name, cs)


def delete_curve_cascade(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_DELETE, 'type' : s12_curve }
    return execute_batch_command(name, cs)


def set_option_ex(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_UPDATE, 'type' : s23_option }
    return execute_batch_command(name, cs)


def set_option_v3_ex(name: str, cs: ChangeSet) -> ChangeSet:
    cs.operations[0] |= { 'operation' : API_UPDATE, 'type' : s23_option_v3 }
    return execute_batch_command(name, cs)
