from typing import Any
import api


############################################################
# ChangeSet
############################################################

API_ADD = api.API_ADD
API_UPDATE = api.API_UPDATE
API_DELETE = api.API_DELETE

ChangeSet = api.ChangeSet


############################################################
# enum
############################################################

JUNCTION = api.JUNCTION
RESERVOIR = api.RESERVOIR
TANK = api.TANK
PIPE = api.PIPE
PUMP = api.PUMP
VALVE = api.VALVE
PATTERN = api.PATTERN
CURVE = api.CURVE

OVERFLOW_YES = api.OVERFLOW_YES
OVERFLOW_NO = api.OVERFLOW_NO

PIPE_STATUS_OPEN = api.PIPE_STATUS_OPEN
PIPE_STATUS_CLOSED = api.PIPE_STATUS_CLOSED
PIPE_STATUS_CV = api.PIPE_STATUS_CV

VALVES_TYPE_PRV = api.VALVES_TYPE_PRV
VALVES_TYPE_PSV = api.VALVES_TYPE_PSV
VALVES_TYPE_PBV = api.VALVES_TYPE_PBV
VALVES_TYPE_FCV = api.VALVES_TYPE_FCV
VALVES_TYPE_TCV = api.VALVES_TYPE_TCV
VALVES_TYPE_GPV = api.VALVES_TYPE_GPV

TAG_TYPE_NODE = api.TAG_TYPE_NODE
TAG_TYPE_LINK = api.TAG_TYPE_LINK

LINK_STATUS_OPEN = api.LINK_STATUS_OPEN
LINK_STATUS_CLOSED = api.LINK_STATUS_CLOSED
LINK_STATUS_ACTIVE = api.LINK_STATUS_ACTIVE

CURVE_TYPE_PUMP = api.CURVE_TYPE_PUMP
CURVE_TYPE_EFFICIENCY = api.CURVE_TYPE_EFFICIENCY
CURVE_TYPE_VOLUME = api.CURVE_TYPE_VOLUME
CURVE_TYPE_HEADLOSS = api.CURVE_TYPE_HEADLOSS

SOURCE_TYPE_CONCEN = api.SOURCE_TYPE_CONCEN
SOURCE_TYPE_MASS = api.SOURCE_TYPE_MASS
SOURCE_TYPE_FLOWPACED = api.SOURCE_TYPE_FLOWPACED
SOURCE_TYPE_SETPOINT = api.SOURCE_TYPE_SETPOINT

MIXING_MODEL_MIXED = api.MIXING_MODEL_MIXED
MIXING_MODEL_2COMP = api.MIXING_MODEL_2COMP
MIXING_MODEL_FIFO = api.MIXING_MODEL_FIFO
MIXING_MODEL_LIFO = api.MIXING_MODEL_LIFO

TIME_STATISTIC_NONE = api.TIME_STATISTIC_NONE
TIME_STATISTIC_AVERAGED = api.TIME_STATISTIC_AVERAGED
TIME_STATISTIC_MINIMUM = api.TIME_STATISTIC_MINIMUM
TIME_STATISTIC_MAXIMUM = api.TIME_STATISTIC_MAXIMUM
TIME_STATISTIC_RANGE = api.TIME_STATISTIC_RANGE

OPTION_UNITS_CFS = api.OPTION_UNITS_CFS
OPTION_UNITS_GPM = api.OPTION_UNITS_GPM
OPTION_UNITS_MGD = api.OPTION_UNITS_MGD
OPTION_UNITS_IMGD = api.OPTION_UNITS_IMGD
OPTION_UNITS_AFD = api.OPTION_UNITS_AFD
OPTION_UNITS_LPS = api.OPTION_UNITS_LPS
OPTION_UNITS_LPM = api.OPTION_UNITS_LPM
OPTION_UNITS_MLD = api.OPTION_UNITS_MLD
OPTION_UNITS_CMH = api.OPTION_UNITS_CMH
OPTION_UNITS_CMD = api.OPTION_UNITS_CMD

OPTION_HEADLOSS_HW = api.OPTION_HEADLOSS_HW
OPTION_HEADLOSS_DW = api.OPTION_HEADLOSS_DW
OPTION_HEADLOSS_CM = api.OPTION_HEADLOSS_CM

OPTION_UNBALANCED_STOP = api.OPTION_UNBALANCED_STOP
OPTION_UNBALANCED_CONTINUE = api.OPTION_UNBALANCED_CONTINUE

OPTION_DEMAND_MODEL_DDA = api.OPTION_DEMAND_MODEL_DDA
OPTION_DEMAND_MODEL_PDA = api.OPTION_DEMAND_MODEL_PDA

OPTION_QUALITY_NONE = api.OPTION_QUALITY_NONE
OPTION_QUALITY_CHEMICAL = api.OPTION_QUALITY_CHEMICAL
OPTION_QUALITY_AGE = api.OPTION_QUALITY_AGE
OPTION_QUALITY_TRACE = api.OPTION_QUALITY_TRACE


############################################################
# project
############################################################

def have_project(name: str) -> bool:
    return api.have_project(name)

def create_project(name: str) -> None:
    return api.create_project(name)

def delete_project(name: str) -> None:
    return api.delete_project(name)

def is_project_open(name: str) -> bool:
    return api.is_project_open(name)

def get_project_open_count(name: str) -> int:
    return api.get_project_open_count(name)

def open_project(name: str) -> None:
    return api.open_project(name)

def close_project(name: str) -> None:
    return api.close_project(name)

def copy_project(source: str, new: str) -> None:
    return api.copy_project(source, new)

def read_inp(name: str, inp: str) -> None:
    return api.read_inp(name, inp)


############################################################
# operation
############################################################

def list_project() -> list[str]:
    return api.list_project()

def get_current_operation(name: str) -> int:
    return api.get_current_operation(name)

def execute_undo(name: str, discard: bool = False) -> ChangeSet:
    return api.execute_undo(name, discard)

def execute_redo(name: str) -> ChangeSet:
    return api.execute_redo(name)

def have_snapshot(name: str, tag: str) -> bool:
    return api.have_snapshot(name, tag)

def take_snapshot(name: str, tag: str) -> int | None:
    return api.take_snapshot(name, tag)

def pick_snapshot(name: str, tag: str, discard: bool = False) -> ChangeSet:
    return api.pick_snapshot(name, tag, discard)

def pick_operation(name: str, operation: int, discard: bool = False) -> ChangeSet:
    return api.pick_operation(name, operation, discard)

def sync_with_server(name: str, operation: int) -> ChangeSet:
    return api.sync_with_server(name, operation)

def execute_batch_command(name: str, cs: ChangeSet) -> ChangeSet:
    return api.execute_batch_command(name, cs)

def execute_batch_commands(name: str, cs: ChangeSet) -> ChangeSet:
    return api.execute_batch_commands(name, cs)


############################################################
# type
############################################################

def is_node(name: str, node_id: str) -> bool:
    return api.is_node(name, node_id)

def is_junction(name: str, node_id: str) -> bool:
    return api.is_junction(name, node_id)

def is_reservoir(name: str, node_id: str) -> bool:
    return api.is_reservoir(name, node_id)

def is_tank(name: str, node_id: str) -> bool:
    return api.is_tank(name, node_id)

def is_link(name: str, link_id: str) -> bool:
    return api.is_link(name, link_id)

def is_pipe(name: str, link_id: str) -> bool:
    return api.is_pipe(name, link_id)

def is_pump(name: str, link_id: str) -> bool:
    return api.is_pump(name, link_id)

def is_valve(name: str, link_id: str) -> bool:
    return api.is_valve(name, link_id)

def is_curve(name: str, curve_id: str) -> bool:
    return api.is_curve(name, curve_id)

def is_pattern(name: str, pattern_id: str) -> bool:
    return api.is_pattern(name, pattern_id)

def get_nodes(name: str) -> list[str]:
    return api.get_nodes(name)

def get_links(name: str) -> list[str]:
    return api.get_links(name)

def get_curves(name: str) -> list[str]:
    return api.get_curves(name)

def get_patterns(name: str) -> list[str]:
    return api.get_patterns(name)

def get_node_links(name: str, node_id: str) -> list[str]:
    return api.get_node_links(name, node_id)


############################################################
# title 1.[TITLE]
############################################################

def get_title_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_title_schema(name)

def get_title(name: str) -> dict[str, Any]:
    return api.get_title(name)

def set_title(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_title(name, cs)


############################################################
# junction 2.[JUNCTIONS]
############################################################

def get_junction_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_junction_schema(name)

def get_junction(name: str, id: str) -> dict[str, Any]:
    return api.get_junction(name, id)

def set_junction(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_junction(name, cs)

# example: add_junction(p, ChangeSet({'id': 'j0', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
def add_junction(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_junction(name, cs)

def delete_junction(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_junction(name, cs)


############################################################
# reservoir 3.[RESERVOIRS]
############################################################

def get_reservoir_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_reservoir_schema(name)

def get_reservoir(name: str, id: str) -> dict[str, Any]:
    return api.get_reservoir(name, id)

def set_reservoir(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_reservoir(name, cs)

# example: add_reservoir(p, ChangeSet({'id': 'r0', 'x': 0.0, 'y': 10.0, 'head': 20.0}))
def add_reservoir(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_reservoir(name, cs)

def delete_reservoir(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_reservoir(name, cs)


############################################################
# tank 4.[TANKS]
############################################################

def get_tank_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_tank_schema(name)

def get_tank(name: str, id: str) -> dict[str, Any]:
    return api.get_tank(name, id)

def set_tank(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_tank(name, cs)

# example: add_tank(p, ChangeSet({'id': 't0', 'x': 0.0, 'y': 10.0, 'elevation': 20.0, 'init_level': 1.0, 'min_level': 0.0, 'max_level': 2.0, 'diameter': 10.0, 'min_vol': 100.0}))
def add_tank(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_tank(name, cs)

def delete_tank(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_tank(name, cs)


############################################################
# pipe 5.[PIPES]
############################################################

def get_pipe_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_pipe_schema(name)

def get_pipe(name: str, id: str) -> dict[str, Any]:
    return api.get_pipe(name, id)

def set_pipe(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_pipe(name, cs)

# example: add_pipe(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'length': 100.0, 'diameter': 10.0, 'roughness': 0.1, 'minor_loss': 0.5, 'status': PIPE_STATUS_OPEN }))
def add_pipe(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_pipe(name, cs)

def delete_pipe(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_pipe(name, cs)


############################################################
# pump 6.[PUMPS]
############################################################

def get_pump_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_pump_schema(name)

def get_pump(name: str, id: str) -> dict[str, Any]:
    return api.get_pump(name, id)

def set_pump(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_pump(name, cs)

# example: add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'power': 0}))
def add_pump(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_pump(name, cs)

def delete_pump(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_pump(name, cs)


############################################################
# valve 7.[VALVES]
############################################################

def get_valve_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_valve_schema(name)

def get_valve(name: str, id: str) -> dict[str, Any]:
    return api.get_valve(name, id)

def set_valve(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_valve(name, cs)

# example: add_valve(p, ChangeSet({'id': 'v0', 'node1': 'j1', 'node2': 'j2', 'diameter': 10.0, 'v_type': VALVES_TYPE_FCV, 'setting': 0.1, 'minor_loss': 0.5 }))
def add_valve(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_valve(name, cs)

def delete_valve(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_valve(name, cs)


############################################################
# tag 8.[TAGS]
############################################################

def get_tag_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_tag_schema(name)

def get_tag(name: str, t_type: str, id: str) -> dict[str, Any]:
    return api.get_tag(name, t_type, id)

# example:
# set_tag(p, ChangeSet({'t_type': TAG_TYPE_NODE, 'id': 'j1', 'tag': 'j1t' }))
# set_tag(p, ChangeSet({'t_type': TAG_TYPE_LINK, 'id': 'p0', 'tag': 'p0t' }))
def set_tag(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_tag(name, cs)


############################################################
# demand 9.[DEMANDS]
############################################################

def get_demand_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_demand_schema(name)

def get_demand(name: str, junction: str) -> dict[str, Any]:
    return api.get_demand(name, junction)

# example: set_demand(p, ChangeSet({'junction': 'j1', 'demands': [{'demand': 10.0, 'pattern': None, 'category': 'x'}, {'demand': 20.0, 'pattern': None, 'category': None}]}))
def set_demand(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_demand(name, cs)


############################################################
# status 10.[STATUS]
############################################################

def get_status_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_status_schema(name)

def get_status(name: str, link: str) -> dict[str, Any]:
    return api.get_status(name, link)

# example: set_status(p, ChangeSet({'link': 'p0', 'status': LINK_STATUS_OPEN, 'setting': 10.0}))
def set_status(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_status(name, cs)


############################################################
# pattern 11.[PATTERNS]
############################################################

def get_pattern_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_pattern_schema(name)

def get_pattern(name: str, id: str) -> dict[str, Any]:
    return api.get_pattern(name, id)

def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_pattern(name, cs)

# example: add_pattern(p, ChangeSet({'id' : 'p0', 'factors': [1.0, 2.0, 3.0]}))
def add_pattern(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_pattern(name, cs)

def delete_pattern(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_pattern(name, cs)


############################################################
# curve 12.[CURVES]
############################################################

def get_curve_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_curve_schema(name)

def get_curve(name: str, id: str) -> dict[str, Any]:
    return api.get_curve(name, id)

def set_curve(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_curve(name, cs)

# example: add_curve(p, ChangeSet({'id' : 'c0', 'c_type' : CURVE_TYPE_PUMP, 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]}))
def add_curve(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_curve(name, cs)

def delete_curve(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_curve(name, cs)


############################################################
# control 13.[CONTROLS]
############################################################

def get_control_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_control_schema(name)

def get_control(name: str) -> dict[str, Any]:
    return api.get_control(name)

# example: set_control(p, ChangeSet({'control': 'x'}))
def set_control(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_control(name, cs)


############################################################
# rule 14.[RULES]
############################################################

def get_rule_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_rule_schema(name)

def get_rule(name: str) -> dict[str, Any]:
    return api.get_rule(name)

# example: set_rule(p, ChangeSet({'rule': 'x'}))
def set_rule(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_rule(name, cs)


############################################################
# energy 15.[ENERGY]
############################################################

def get_energy_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_energy_schema(name)

def get_energy(name: str) -> dict[str, Any]:
    return api.get_energy(name)

def set_energy(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_energy(name, cs)

def get_pump_energy_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_pump_energy_schema(name)

def get_pump_energy(name: str, pump: str) -> dict[str, Any]:
    return api.get_pump_energy(name, pump)

def set_pump_energy(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_pump_energy(name, cs)


############################################################
# emitter 16.[EMITTERS]
############################################################

def get_emitter_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_emitter_schema(name)

def get_emitter(name: str, junction: str) -> dict[str, Any]:
    return api.get_emitter(name, junction)

# example: set_emitter(p, ChangeSet({'junction': 'j1', 'coefficient': 10.0}))
def set_emitter(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_emitter(name, cs)


############################################################
# quality 17.[QUALITY]
############################################################

def get_quality_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_quality_schema(name)

def get_quality(name: str, node: str) -> dict[str, Any]:
    return api.get_quality(name, node)

# example: set_quality(p, ChangeSet({'node': 'j1', 'quality': 10.0}))
def set_quality(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_quality(name, cs)


############################################################
# source 18.[SOURCES]
############################################################

def get_source_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_source_schema(name)

def get_source(name: str, node: str) -> dict[str, Any]:
    return api.get_source(name, node)

def set_source(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_source(name, cs)

# example: add_source(p, ChangeSet({'node': 'j0', 's_type': SOURCE_TYPE_CONCEN, 'strength': 10.0, 'pattern': 'p0'}))
def add_source(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_source(name, cs)

def delete_source(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_source(name, cs)


############################################################
# reaction 19.[REACTIONS]
############################################################

def get_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_reaction_schema(name)

def get_reaction(name: str) -> dict[str, Any]:
    return api.get_reaction(name)

def set_reaction(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_reaction(name, cs)

def get_pipe_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_pipe_reaction_schema(name)

def get_pipe_reaction(name: str, pipe: str) -> dict[str, Any]:
    return api.get_pipe_reaction(name, pipe)

def set_pipe_reaction(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_pipe_reaction(name, cs)

def get_tank_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_tank_reaction_schema(name)

def get_tank_reaction(name: str, tank: str) -> dict[str, Any]:
    return api.get_tank_reaction(name, tank)

def set_tank_reaction(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_tank_reaction(name, cs)


############################################################
# mixing 20.[MIXING]
############################################################

def get_mixing_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_mixing_schema(name)

def get_mixing(name: str, tank: str) -> dict[str, Any]:
    return api.get_mixing(name, tank)

def set_mixing(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_mixing(name, cs)

# example: add_mixing(p, ChangeSet({'tank': 't0', 'model': MIXING_MODEL_MIXED, 'value': 10.0}))
def add_mixing(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_mixing(name, cs)

def delete_mixing(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_mixing(name, cs)


############################################################
# time 21.[TIMES]
############################################################

def get_time_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_time_schema(name)

def get_time(name: str) -> dict[str, Any]:
    return api.get_time(name)

def set_time(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_time(name, cs)


############################################################
# report 22.[REPORT]
############################################################

# hardcode...


############################################################
# option 23.[OPTIONS]
############################################################

def get_option_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_option_schema(name)

def get_option(name: str) -> dict[str, Any]:
    return api.get_option(name)

def set_option(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_option(name, cs)


############################################################
# coord 24.[COORDINATES]
############################################################

def get_node_coord(name: str, node_id: str) -> dict[str, float] | None:
    return api.get_node_coord(name, node_id)


############################################################
# vertex 25.[VERTICES]
############################################################

def get_vertex_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_vertex_schema(name)

def get_vertex(name: str, link: str) -> dict[str, Any]:
    return api.get_vertex(name, link)

def set_vertex(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_vertex(name, cs)

def add_vertex(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_vertex(name, cs)

def delete_vertex(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_vertex(name, cs)


############################################################
# label 26.[LABELS]
############################################################

def get_label_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_label_schema(name)

def get_label(name: str, x: float, y: float) -> dict[str, Any]:
    return api.get_label(name, x, y)

def set_label(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_label(name, cs)

def add_label(name: str, cs: ChangeSet) -> ChangeSet:
    return api.add_label(name, cs)

def delete_label(name: str, cs: ChangeSet) -> ChangeSet:
    return api.delete_label(name, cs)


############################################################
# backdrop 27.[BACKDROP]
############################################################

def get_backdrop_schema(name: str) -> dict[str, dict[str, Any]]:
    return api.get_backdrop_schema(name)

def get_backdrop(name: str) -> dict[str, Any]:
    return api.get_backdrop(name)

def set_backdrop(name: str, cs: ChangeSet) -> ChangeSet:
    return api.set_backdrop(name, cs)


############################################################
# end 28.[END]
############################################################
