Compare commits
3 Commits
7efaeb41e8
...
agent-mvp
| Author | SHA1 | Date | |
|---|---|---|---|
| 441979f581 | |||
| e336ffcd46 | |||
| 52b8f07abd |
@@ -71,14 +71,14 @@ def test_auth_stdin_can_be_reused_with_runtime_context_cache(monkeypatch):
|
|||||||
def fake_request_json(ctx, **kwargs):
|
def fake_request_json(ctx, **kwargs):
|
||||||
observed_runtime_ids.append(id(ctx))
|
observed_runtime_ids.append(id(ctx))
|
||||||
assert ctx.auth.access_token == "token-1"
|
assert ctx.auth.access_token == "token-1"
|
||||||
assert kwargs["params"] == {"network": "tjwater", "node": "11"}
|
assert kwargs["params"] == {"network": "tjwater", "junction": "11"}
|
||||||
return {"node": "11"}, 5
|
return {"id": "11"}, 5
|
||||||
|
|
||||||
monkeypatch.setattr(common, "request_json", fake_request_json)
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
app,
|
app,
|
||||||
["--auth-stdin", "network", "get-node-properties", "--node", "11"],
|
["--auth-stdin", "network", "get-junction-properties", "--junction", "11"],
|
||||||
input=json.dumps(
|
input=json.dumps(
|
||||||
{
|
{
|
||||||
"server": "http://server",
|
"server": "http://server",
|
||||||
@@ -93,37 +93,70 @@ def test_auth_stdin_can_be_reused_with_runtime_context_cache(monkeypatch):
|
|||||||
|
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert payload["ok"] is True
|
assert payload["ok"] is True
|
||||||
assert payload["data"] == {"node": "11"}
|
assert payload["data"] == {"id": "11"}
|
||||||
assert len(observed_runtime_ids) == 1
|
assert len(observed_runtime_ids) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_network_get_all_junction_properties_uses_network_context(monkeypatch):
|
def test_network_get_junction_properties_uses_network_context(monkeypatch):
|
||||||
captured = {}
|
captured = {}
|
||||||
|
|
||||||
def fake_request_json(ctx, **kwargs):
|
def fake_request_json(ctx, **kwargs):
|
||||||
captured["access_token"] = ctx.auth.access_token
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
captured["params"] = kwargs["params"]
|
captured["params"] = kwargs["params"]
|
||||||
return [{"id": "J1"}], 5
|
return {"id": "J1"}, 5
|
||||||
|
|
||||||
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
monkeypatch.setattr(common, "request_json", fake_request_json)
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
result = runner.invoke(app, ["network", "get-all-junction-properties"])
|
result = runner.invoke(app, ["network", "get-junction-properties", "--junction", "J1"])
|
||||||
payload = json.loads(result.stdout)
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert payload["ok"] is True
|
assert payload["ok"] is True
|
||||||
assert payload["data"] == [{"id": "J1"}]
|
assert payload["data"] == {"id": "J1"}
|
||||||
assert captured == {"access_token": "abc", "params": {"network": "tjwater"}}
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getjunctionproperties/",
|
||||||
|
"params": {"network": "tjwater", "junction": "J1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_network_get_all_pipe_properties_uses_network_context(monkeypatch):
|
def test_network_get_pipe_properties_uses_network_context(monkeypatch):
|
||||||
captured = {}
|
captured = {}
|
||||||
|
|
||||||
def fake_request_json(ctx, **kwargs):
|
def fake_request_json(ctx, **kwargs):
|
||||||
captured["access_token"] = ctx.auth.access_token
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return {"id": "P1"}, 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-pipe-properties", "--pipe", "P1"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == {"id": "P1"}
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getpipeproperties/",
|
||||||
|
"params": {"network": "tjwater", "pipe": "P1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_all_pipes_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
captured["params"] = kwargs["params"]
|
captured["params"] = kwargs["params"]
|
||||||
return [{"id": "P1"}], 5
|
return [{"id": "P1"}], 5
|
||||||
|
|
||||||
@@ -132,13 +165,233 @@ def test_network_get_all_pipe_properties_uses_network_context(monkeypatch):
|
|||||||
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
monkeypatch.setattr(common, "request_json", fake_request_json)
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
result = runner.invoke(app, ["network", "get-all-pipe-properties"])
|
result = runner.invoke(app, ["network", "get-all-pipes-properties"])
|
||||||
payload = json.loads(result.stdout)
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert payload["ok"] is True
|
assert payload["ok"] is True
|
||||||
assert payload["data"] == [{"id": "P1"}]
|
assert payload["data"] == [{"id": "P1"}]
|
||||||
assert captured == {"access_token": "abc", "params": {"network": "tjwater"}}
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getallpipeproperties/",
|
||||||
|
"params": {"network": "tjwater"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_reservoir_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return {"id": "R1"}, 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-reservoir-properties", "--reservoir", "R1"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == {"id": "R1"}
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getreservoirproperties/",
|
||||||
|
"params": {"network": "tjwater", "reservoir": "R1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_all_reservoir_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return [{"id": "R1"}], 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-all-reservoirs-properties"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == [{"id": "R1"}]
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getallreservoirproperties/",
|
||||||
|
"params": {"network": "tjwater"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_tank_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return {"id": "T1"}, 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-tank-properties", "--tank", "T1"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == {"id": "T1"}
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/gettankproperties/",
|
||||||
|
"params": {"network": "tjwater", "tank": "T1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_all_tank_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return [{"id": "T1"}], 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-all-tanks-properties"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == [{"id": "T1"}]
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getalltankproperties/",
|
||||||
|
"params": {"network": "tjwater"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_pump_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return {"id": "PU1"}, 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-pump-properties", "--pump", "PU1"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == {"id": "PU1"}
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getpumpproperties/",
|
||||||
|
"params": {"network": "tjwater", "pump": "PU1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_all_pump_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return [{"id": "PU1"}], 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-all-pumps-properties"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == [{"id": "PU1"}]
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getallpumpproperties/",
|
||||||
|
"params": {"network": "tjwater"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_valve_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return {"id": "V1"}, 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-valve-properties", "--valve", "V1"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == {"id": "V1"}
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getvalveproperties/",
|
||||||
|
"params": {"network": "tjwater", "valve": "V1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_network_get_all_valve_properties_uses_network_context(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_request_json(ctx, **kwargs):
|
||||||
|
captured["access_token"] = ctx.auth.access_token
|
||||||
|
captured["path"] = kwargs["path"]
|
||||||
|
captured["params"] = kwargs["params"]
|
||||||
|
return [{"id": "V1"}], 5
|
||||||
|
|
||||||
|
monkeypatch.setenv("TJWATER_SERVER", "http://server")
|
||||||
|
monkeypatch.setenv("TJWATER_ACCESS_TOKEN", "abc")
|
||||||
|
monkeypatch.setenv("TJWATER_NETWORK", "tjwater")
|
||||||
|
monkeypatch.setattr(common, "request_json", fake_request_json)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["network", "get-all-valves-properties"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert payload["ok"] is True
|
||||||
|
assert payload["data"] == [{"id": "V1"}]
|
||||||
|
assert captured == {
|
||||||
|
"access_token": "abc",
|
||||||
|
"path": "/getallvalveproperties/",
|
||||||
|
"params": {"network": "tjwater"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_help_outputs_json_lists_commands():
|
def test_help_outputs_json_lists_commands():
|
||||||
@@ -598,6 +851,66 @@ def test_main_invalid_scada_field_is_rejected_before_request(capsys):
|
|||||||
assert "cleaned_value" in stdout
|
assert "cleaned_value" in stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_data_scada_get_rejects_removed_kind_before_request(capsys):
|
||||||
|
exit_code = main(["data", "scada", "get", "--kind", "device", "--id", "D1"])
|
||||||
|
stdout = capsys.readouterr().out
|
||||||
|
|
||||||
|
assert exit_code == 2
|
||||||
|
assert '"code": "INVALID_PARAMETER"' in stdout
|
||||||
|
assert "device" in stdout
|
||||||
|
assert "info" in stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_data_scada_list_help_only_shows_info_kind():
|
||||||
|
result = runner.invoke(app, ["data", "scada", "list", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "info" in result.stdout
|
||||||
|
assert "device" not in result.stdout
|
||||||
|
assert "element" not in result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_data_scada_help_no_longer_lists_schema():
|
||||||
|
result = runner.invoke(app, ["data", "scada", "help"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
commands = {command["command"] for command in payload["commands"]}
|
||||||
|
assert "data scada get" in commands
|
||||||
|
assert "data scada list" in commands
|
||||||
|
assert "data scada schema" not in commands
|
||||||
|
|
||||||
|
|
||||||
|
def test_data_scada_schema_command_is_removed():
|
||||||
|
result = runner.invoke(app, ["data", "scada", "schema", "--kind", "info"])
|
||||||
|
|
||||||
|
assert result.exit_code == 2
|
||||||
|
assert "No such command 'schema'" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_data_help_no_longer_lists_extension_or_misc():
|
||||||
|
result = runner.invoke(app, ["data", "help"])
|
||||||
|
payload = json.loads(result.stdout)
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
commands = {command["command"] for command in payload["commands"]}
|
||||||
|
assert "data timeseries" in commands
|
||||||
|
assert "data scada" in commands
|
||||||
|
assert "data scheme" in commands
|
||||||
|
assert "data extension" not in commands
|
||||||
|
assert "data misc" not in commands
|
||||||
|
|
||||||
|
|
||||||
|
def test_removed_data_extension_and_misc_commands_fail():
|
||||||
|
extension_result = runner.invoke(app, ["data", "extension", "list"])
|
||||||
|
misc_result = runner.invoke(app, ["data", "misc", "sensor-placements"])
|
||||||
|
|
||||||
|
assert extension_result.exit_code == 2
|
||||||
|
assert "No such command 'extension'" in extension_result.output
|
||||||
|
assert misc_result.exit_code == 2
|
||||||
|
assert "No such command 'misc'" in misc_result.output
|
||||||
|
|
||||||
|
|
||||||
def test_main_bare_analysis_returns_typer_help_without_json_error(capsys):
|
def test_main_bare_analysis_returns_typer_help_without_json_error(capsys):
|
||||||
exit_code = main(["analysis"])
|
exit_code = main(["analysis"])
|
||||||
stdout = capsys.readouterr().out
|
stdout = capsys.readouterr().out
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ data_timeseries_scada_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
|||||||
data_timeseries_composite_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
data_timeseries_composite_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
||||||
data_scada_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
data_scada_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
||||||
data_scheme_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
data_scheme_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
||||||
data_extension_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
|
||||||
data_misc_app = typer.Typer(no_args_is_help=True, cls=TJWaterGroup)
|
|
||||||
|
|
||||||
app.add_typer(network_app, name="network")
|
app.add_typer(network_app, name="network")
|
||||||
app.add_typer(component_app, name="component")
|
app.add_typer(component_app, name="component")
|
||||||
@@ -50,8 +48,6 @@ data_timeseries_app.add_typer(data_timeseries_scada_app, name="scada")
|
|||||||
data_timeseries_app.add_typer(data_timeseries_composite_app, name="composite")
|
data_timeseries_app.add_typer(data_timeseries_composite_app, name="composite")
|
||||||
data_app.add_typer(data_scada_app, name="scada")
|
data_app.add_typer(data_scada_app, name="scada")
|
||||||
data_app.add_typer(data_scheme_app, name="scheme")
|
data_app.add_typer(data_scheme_app, name="scheme")
|
||||||
data_app.add_typer(data_extension_app, name="extension")
|
|
||||||
data_app.add_typer(data_misc_app, name="misc")
|
|
||||||
|
|
||||||
GROUP_HELP_APPS: list[tuple[typer.Typer, tuple[str, ...]]] = [
|
GROUP_HELP_APPS: list[tuple[typer.Typer, tuple[str, ...]]] = [
|
||||||
(network_app, ("network",)),
|
(network_app, ("network",)),
|
||||||
@@ -75,8 +71,6 @@ GROUP_HELP_APPS: list[tuple[typer.Typer, tuple[str, ...]]] = [
|
|||||||
(data_timeseries_composite_app, ("data", "timeseries", "composite")),
|
(data_timeseries_composite_app, ("data", "timeseries", "composite")),
|
||||||
(data_scada_app, ("data", "scada")),
|
(data_scada_app, ("data", "scada")),
|
||||||
(data_scheme_app, ("data", "scheme")),
|
(data_scheme_app, ("data", "scheme")),
|
||||||
(data_extension_app, ("data", "extension")),
|
|
||||||
(data_misc_app, ("data", "misc")),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
TOP_LEVEL_COMMANDS = {"help", "network", "component", "simulation", "analysis", "data"}
|
TOP_LEVEL_COMMANDS = {"help", "network", "component", "simulation", "analysis", "data"}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ from typing import Annotated
|
|||||||
import typer
|
import typer
|
||||||
|
|
||||||
from .apps import (
|
from .apps import (
|
||||||
data_extension_app,
|
|
||||||
data_misc_app,
|
|
||||||
data_scada_app,
|
data_scada_app,
|
||||||
data_scheme_app,
|
data_scheme_app,
|
||||||
data_timeseries_composite_app,
|
data_timeseries_composite_app,
|
||||||
@@ -22,7 +20,6 @@ from .option_types import (
|
|||||||
JUNCTION_TIMESERIES_FIELDS,
|
JUNCTION_TIMESERIES_FIELDS,
|
||||||
SCADA_TIMESERIES_FIELDS,
|
SCADA_TIMESERIES_FIELDS,
|
||||||
ScadaListKind,
|
ScadaListKind,
|
||||||
ScadaSchemaKind,
|
|
||||||
SimulationQuery,
|
SimulationQuery,
|
||||||
timeseries_fields_for_element_type,
|
timeseries_fields_for_element_type,
|
||||||
)
|
)
|
||||||
@@ -414,15 +411,6 @@ def data_composite_pipeline_health(
|
|||||||
|
|
||||||
def _scada_mapping(kind: str, action: str) -> tuple[str, dict[str, str]]:
|
def _scada_mapping(kind: str, action: str) -> tuple[str, dict[str, str]]:
|
||||||
mapping = {
|
mapping = {
|
||||||
("device", "schema"): ("/getscadadeviceschema/", {}),
|
|
||||||
("device", "get"): ("/getscadadevice/", {"id_param": "id"}),
|
|
||||||
("device", "list"): ("/getallscadadevices/", {}),
|
|
||||||
("device-data", "schema"): ("/getscadadevicedataschema/", {}),
|
|
||||||
("device-data", "get"): ("/getscadadevicedata/", {"id_param": "device_id"}),
|
|
||||||
("element", "schema"): ("/getscadaelementschema/", {}),
|
|
||||||
("element", "get"): ("/getscadaelement/", {"id_param": "id"}),
|
|
||||||
("element", "list"): ("/getscadaelements/", {}),
|
|
||||||
("info", "schema"): ("/getscadainfoschema/", {}),
|
|
||||||
("info", "get"): ("/getscadainfo/", {"id_param": "id"}),
|
("info", "get"): ("/getscadainfo/", {"id_param": "id"}),
|
||||||
("info", "list"): ("/getallscadainfo/", {}),
|
("info", "list"): ("/getallscadainfo/", {}),
|
||||||
}
|
}
|
||||||
@@ -437,28 +425,10 @@ def _scada_mapping(kind: str, action: str) -> tuple[str, dict[str, str]]:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@data_scada_app.command("schema")
|
|
||||||
def data_scada_schema(
|
|
||||||
ctx: typer.Context,
|
|
||||||
kind: Annotated[ScadaSchemaKind, typer.Option("--kind", help="SCADA 类型,仅支持 device|device-data|element|info")],
|
|
||||||
) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
path, _ = _scada_mapping(kind.value, "schema")
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取 SCADA schema 成功",
|
|
||||||
method="GET",
|
|
||||||
path=path,
|
|
||||||
params={"network": require_network(runtime)},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@data_scada_app.command("get")
|
@data_scada_app.command("get")
|
||||||
def data_scada_get(
|
def data_scada_get(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
kind: Annotated[ScadaSchemaKind, typer.Option("--kind", help="SCADA 类型,仅支持 device|device-data|element|info")],
|
kind: Annotated[ScadaListKind, typer.Option("--kind", help="SCADA 类型,仅支持 info")],
|
||||||
id: Annotated[str, typer.Option("--id", help="记录 ID")],
|
id: Annotated[str, typer.Option("--id", help="记录 ID")],
|
||||||
) -> None:
|
) -> None:
|
||||||
runtime = runtime_context(ctx)
|
runtime = runtime_context(ctx)
|
||||||
@@ -478,7 +448,7 @@ def data_scada_get(
|
|||||||
@data_scada_app.command("list")
|
@data_scada_app.command("list")
|
||||||
def data_scada_list(
|
def data_scada_list(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
kind: Annotated[ScadaListKind, typer.Option("--kind", help="SCADA 类型,仅支持 device|element|info;device-data 无 list 接口")],
|
kind: Annotated[ScadaListKind, typer.Option("--kind", help="SCADA 类型,仅支持 info")],
|
||||||
) -> None:
|
) -> None:
|
||||||
runtime = runtime_context(ctx)
|
runtime = runtime_context(ctx)
|
||||||
path, _ = _scada_mapping(kind.value, "list")
|
path, _ = _scada_mapping(kind.value, "list")
|
||||||
@@ -536,76 +506,3 @@ def data_scheme_list(ctx: typer.Context) -> None:
|
|||||||
require_auth=True,
|
require_auth=True,
|
||||||
require_network_ctx=True,
|
require_network_ctx=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@data_extension_app.command("keys")
|
|
||||||
def data_extension_keys(ctx: typer.Context) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取扩展数据键成功",
|
|
||||||
method="GET",
|
|
||||||
path="/getallextensiondatakeys/",
|
|
||||||
params={"network": require_network(runtime)},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@data_extension_app.command("get")
|
|
||||||
def data_extension_get(
|
|
||||||
ctx: typer.Context,
|
|
||||||
key: Annotated[str, typer.Option("--key", help="扩展键")],
|
|
||||||
) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取扩展数据成功",
|
|
||||||
method="GET",
|
|
||||||
path="/getextensiondata/",
|
|
||||||
params={"network": require_network(runtime), "key": key},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@data_extension_app.command("list")
|
|
||||||
def data_extension_list(ctx: typer.Context) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取扩展数据列表成功",
|
|
||||||
method="GET",
|
|
||||||
path="/getallextensiondata/",
|
|
||||||
params={"network": require_network(runtime)},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@data_misc_app.command("sensor-placements")
|
|
||||||
def data_misc_sensor_placements(ctx: typer.Context) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取传感器位置成功",
|
|
||||||
method="GET",
|
|
||||||
path="/getallsensorplacements/",
|
|
||||||
params={"network": require_network(runtime)},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@data_misc_app.command("burst-location-results")
|
|
||||||
def data_misc_burst_location_results(ctx: typer.Context) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取爆管定位结果成功",
|
|
||||||
method="GET",
|
|
||||||
path="/getallburstlocateresults/",
|
|
||||||
params={"network": require_network(runtime)},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -10,56 +10,42 @@ from .core import CLIError, require_network
|
|||||||
from .option_types import ComponentOptionKind
|
from .option_types import ComponentOptionKind
|
||||||
|
|
||||||
|
|
||||||
@network_app.command("get-node-properties")
|
@network_app.command("get-junction-properties")
|
||||||
def network_get_node_properties(
|
def network_get_junction_properties(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
node: Annotated[str, typer.Option("--node", help="节点 ID")],
|
junction: Annotated[str, typer.Option("--junction", help="节点 ID")],
|
||||||
) -> None:
|
) -> None:
|
||||||
runtime = runtime_context(ctx)
|
runtime = runtime_context(ctx)
|
||||||
emit_api(
|
emit_api(
|
||||||
ctx,
|
ctx,
|
||||||
summary="读取节点属性成功",
|
summary="读取节点属性成功",
|
||||||
method="GET",
|
method="GET",
|
||||||
path="/getnodeproperties/",
|
path="/getjunctionproperties/",
|
||||||
params={"network": require_network(runtime), "node": node},
|
params={"network": require_network(runtime), "junction": junction},
|
||||||
require_auth=True,
|
require_auth=True,
|
||||||
require_network_ctx=True,
|
require_network_ctx=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@network_app.command("get-link-properties")
|
@network_app.command("get-pipe-properties")
|
||||||
def network_get_link_properties(
|
def network_get_pipe_properties(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
link: Annotated[str, typer.Option("--link", help="管线 ID")],
|
pipe: Annotated[str, typer.Option("--pipe", help="管道 ID")],
|
||||||
) -> None:
|
) -> None:
|
||||||
runtime = runtime_context(ctx)
|
runtime = runtime_context(ctx)
|
||||||
emit_api(
|
emit_api(
|
||||||
ctx,
|
ctx,
|
||||||
summary="读取管线属性成功",
|
summary="读取管道属性成功",
|
||||||
method="GET",
|
method="GET",
|
||||||
path="/getlinkproperties/",
|
path="/getpipeproperties/",
|
||||||
params={"network": require_network(runtime), "link": link},
|
params={"network": require_network(runtime), "pipe": pipe},
|
||||||
require_auth=True,
|
require_auth=True,
|
||||||
require_network_ctx=True,
|
require_network_ctx=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@network_app.command("get-all-junction-properties")
|
@network_app.command("get-all-pipes-properties")
|
||||||
def network_get_all_junction_properties(ctx: typer.Context) -> None:
|
def network_get_all_pipes_properties(ctx: typer.Context) -> None:
|
||||||
runtime = runtime_context(ctx)
|
|
||||||
emit_api(
|
|
||||||
ctx,
|
|
||||||
summary="读取全部节点属性成功",
|
|
||||||
method="GET",
|
|
||||||
path="/getalljunctionproperties/",
|
|
||||||
params={"network": require_network(runtime)},
|
|
||||||
require_auth=True,
|
|
||||||
require_network_ctx=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@network_app.command("get-all-pipe-properties")
|
|
||||||
def network_get_all_pipe_properties(ctx: typer.Context) -> None:
|
|
||||||
runtime = runtime_context(ctx)
|
runtime = runtime_context(ctx)
|
||||||
emit_api(
|
emit_api(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -72,6 +58,130 @@ def network_get_all_pipe_properties(ctx: typer.Context) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-reservoir-properties")
|
||||||
|
def network_get_reservoir_properties(
|
||||||
|
ctx: typer.Context,
|
||||||
|
reservoir: Annotated[str, typer.Option("--reservoir", help="水库 ID")],
|
||||||
|
) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取水库属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getreservoirproperties/",
|
||||||
|
params={"network": require_network(runtime), "reservoir": reservoir},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-all-reservoirs-properties")
|
||||||
|
def network_get_all_reservoir_properties(ctx: typer.Context) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取全部水库属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getallreservoirproperties/",
|
||||||
|
params={"network": require_network(runtime)},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-tank-properties")
|
||||||
|
def network_get_tank_properties(
|
||||||
|
ctx: typer.Context,
|
||||||
|
tank: Annotated[str, typer.Option("--tank", help="水箱 ID")],
|
||||||
|
) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取水箱属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/gettankproperties/",
|
||||||
|
params={"network": require_network(runtime), "tank": tank},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-all-tanks-properties")
|
||||||
|
def network_get_all_tank_properties(ctx: typer.Context) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取全部水箱属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getalltankproperties/",
|
||||||
|
params={"network": require_network(runtime)},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-pump-properties")
|
||||||
|
def network_get_pump_properties(
|
||||||
|
ctx: typer.Context,
|
||||||
|
pump: Annotated[str, typer.Option("--pump", help="水泵 ID")],
|
||||||
|
) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取水泵属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getpumpproperties/",
|
||||||
|
params={"network": require_network(runtime), "pump": pump},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-all-pumps-properties")
|
||||||
|
def network_get_all_pump_properties(ctx: typer.Context) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取全部水泵属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getallpumpproperties/",
|
||||||
|
params={"network": require_network(runtime)},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-valve-properties")
|
||||||
|
def network_get_valve_properties(
|
||||||
|
ctx: typer.Context,
|
||||||
|
valve: Annotated[str, typer.Option("--valve", help="阀门 ID")],
|
||||||
|
) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取阀门属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getvalveproperties/",
|
||||||
|
params={"network": require_network(runtime), "valve": valve},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@network_app.command("get-all-valves-properties")
|
||||||
|
def network_get_all_valve_properties(ctx: typer.Context) -> None:
|
||||||
|
runtime = runtime_context(ctx)
|
||||||
|
emit_api(
|
||||||
|
ctx,
|
||||||
|
summary="读取全部阀门属性成功",
|
||||||
|
method="GET",
|
||||||
|
path="/getallvalveproperties/",
|
||||||
|
params={"network": require_network(runtime)},
|
||||||
|
require_auth=True,
|
||||||
|
require_network_ctx=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@component_option_app.command("schema")
|
@component_option_app.command("schema")
|
||||||
def component_option_schema(
|
def component_option_schema(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import typer
|
|||||||
|
|
||||||
SCHEMA_VERSION = "tjwater-cli/v1"
|
SCHEMA_VERSION = "tjwater-cli/v1"
|
||||||
CLI_NAME = "tjwater-cli"
|
CLI_NAME = "tjwater-cli"
|
||||||
DEFAULT_TIMEOUT = 60
|
DEFAULT_TIMEOUT = 180
|
||||||
DEFAULT_SERVER = "http://192.168.1.114:8000"
|
DEFAULT_SERVER = "http://192.168.1.114:8000"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ def _sample_option_value(path: tuple[str, ...], option_name: str) -> str:
|
|||||||
(("component", "option", "schema"), "kind"): "time",
|
(("component", "option", "schema"), "kind"): "time",
|
||||||
(("component", "option", "get"), "kind"): "time",
|
(("component", "option", "get"), "kind"): "time",
|
||||||
(("data", "timeseries", "composite"), "kind"): "scada-simulation",
|
(("data", "timeseries", "composite"), "kind"): "scada-simulation",
|
||||||
(("data", "scada", "schema"), "kind"): "device",
|
(("data", "scada", "get"), "kind"): "info",
|
||||||
(("data", "scada", "get"), "kind"): "device",
|
(("data", "scada", "list"), "kind"): "info",
|
||||||
(("data", "scada", "list"), "kind"): "device",
|
|
||||||
}
|
}
|
||||||
if (path, option_name) in path_specific_samples:
|
if (path, option_name) in path_specific_samples:
|
||||||
return path_specific_samples[(path, option_name)]
|
return path_specific_samples[(path, option_name)]
|
||||||
|
|||||||
@@ -36,16 +36,7 @@ class DataSource(str, Enum):
|
|||||||
SIMULATION = "simulation"
|
SIMULATION = "simulation"
|
||||||
|
|
||||||
|
|
||||||
class ScadaSchemaKind(str, Enum):
|
|
||||||
DEVICE = "device"
|
|
||||||
DEVICE_DATA = "device-data"
|
|
||||||
ELEMENT = "element"
|
|
||||||
INFO = "info"
|
|
||||||
|
|
||||||
|
|
||||||
class ScadaListKind(str, Enum):
|
class ScadaListKind(str, Enum):
|
||||||
DEVICE = "device"
|
|
||||||
ELEMENT = "element"
|
|
||||||
INFO = "info"
|
INFO = "info"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+71
-77
@@ -16,7 +16,7 @@ GROUP_SUMMARIES: dict[tuple[str, ...], str] = {
|
|||||||
("analysis", "burst-location", "schemes"): "爆管定位方案查询命令。",
|
("analysis", "burst-location", "schemes"): "爆管定位方案查询命令。",
|
||||||
("analysis", "risk"): "风险分析相关命令。",
|
("analysis", "risk"): "风险分析相关命令。",
|
||||||
("analysis", "sensor-placement"): "传感器选址相关命令。",
|
("analysis", "sensor-placement"): "传感器选址相关命令。",
|
||||||
("data",): "时序、SCADA、方案和扩展数据查询命令。",
|
("data",): "时序、SCADA 和方案数据查询命令。",
|
||||||
("data", "timeseries"): "时序数据查询命令。",
|
("data", "timeseries"): "时序数据查询命令。",
|
||||||
("data", "timeseries", "realtime"): "实时模拟时序查询命令。",
|
("data", "timeseries", "realtime"): "实时模拟时序查询命令。",
|
||||||
("data", "timeseries", "scheme"): "方案时序查询命令。",
|
("data", "timeseries", "scheme"): "方案时序查询命令。",
|
||||||
@@ -24,8 +24,6 @@ GROUP_SUMMARIES: dict[tuple[str, ...], str] = {
|
|||||||
("data", "timeseries", "composite"): "复合时序查询命令。",
|
("data", "timeseries", "composite"): "复合时序查询命令。",
|
||||||
("data", "scada"): "SCADA 元数据查询命令。",
|
("data", "scada"): "SCADA 元数据查询命令。",
|
||||||
("data", "scheme"): "方案数据查询命令。",
|
("data", "scheme"): "方案数据查询命令。",
|
||||||
("data", "extension"): "扩展数据查询命令。",
|
|
||||||
("data", "misc"): "其他结果数据查询命令。",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN_PATH_PREFIXES: tuple[tuple[str, ...], ...] = (
|
HIDDEN_PATH_PREFIXES: tuple[tuple[str, ...], ...] = (
|
||||||
@@ -34,31 +32,77 @@ HIDDEN_PATH_PREFIXES: tuple[tuple[str, ...], ...] = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
COMMAND_DOCS: dict[tuple[str, ...], CommandDoc] = {
|
COMMAND_DOCS: dict[tuple[str, ...], CommandDoc] = {
|
||||||
("network", "get-node-properties"): CommandDoc(
|
("network", "get-junction-properties"): CommandDoc(
|
||||||
path=("network", "get-node-properties"),
|
path=("network", "get-junction-properties"),
|
||||||
summary="读取节点属性",
|
summary="读取节点属性",
|
||||||
description="调用 /getnodeproperties/。",
|
description="调用 /getjunctionproperties/。",
|
||||||
options=(CommandOptionDoc("node", "节点 ID", required=True),),
|
options=(CommandOptionDoc("junction", "节点 ID", required=True),),
|
||||||
examples=("tjwater-cli network get-node-properties --node J1",),
|
examples=("tjwater-cli network get-junction-properties --junction J1",),
|
||||||
),
|
),
|
||||||
("network", "get-link-properties"): CommandDoc(
|
("network", "get-pipe-properties"): CommandDoc(
|
||||||
path=("network", "get-link-properties"),
|
path=("network", "get-pipe-properties"),
|
||||||
summary="读取管线属性",
|
summary="读取管道属性",
|
||||||
description="调用 /getlinkproperties/。",
|
description="调用 /getpipeproperties/。",
|
||||||
options=(CommandOptionDoc("link", "管线 ID", required=True),),
|
options=(CommandOptionDoc("pipe", "管道 ID", required=True),),
|
||||||
examples=("tjwater-cli network get-link-properties --link P1",),
|
examples=("tjwater-cli network get-pipe-properties --pipe P1",),
|
||||||
),
|
),
|
||||||
("network", "get-all-junction-properties"): CommandDoc(
|
("network", "get-all-pipes-properties"): CommandDoc(
|
||||||
path=("network", "get-all-junction-properties"),
|
path=("network", "get-all-pipes-properties"),
|
||||||
summary="读取全部节点属性",
|
|
||||||
description="调用 /getalljunctionproperties/。",
|
|
||||||
examples=("tjwater-cli network get-all-junction-properties",),
|
|
||||||
),
|
|
||||||
("network", "get-all-pipe-properties"): CommandDoc(
|
|
||||||
path=("network", "get-all-pipe-properties"),
|
|
||||||
summary="读取全部管道属性",
|
summary="读取全部管道属性",
|
||||||
description="调用 /getallpipeproperties/。",
|
description="调用 /getallpipeproperties/。",
|
||||||
examples=("tjwater-cli network get-all-pipe-properties",),
|
examples=("tjwater-cli network get-all-pipes-properties",),
|
||||||
|
),
|
||||||
|
("network", "get-reservoir-properties"): CommandDoc(
|
||||||
|
path=("network", "get-reservoir-properties"),
|
||||||
|
summary="读取水库属性",
|
||||||
|
description="调用 /getreservoirproperties/。",
|
||||||
|
options=(CommandOptionDoc("reservoir", "水库 ID", required=True),),
|
||||||
|
examples=("tjwater-cli network get-reservoir-properties --reservoir R1",),
|
||||||
|
),
|
||||||
|
("network", "get-all-reservoirs-properties"): CommandDoc(
|
||||||
|
path=("network", "get-all-reservoirs-properties"),
|
||||||
|
summary="读取全部水库属性",
|
||||||
|
description="调用 /getallreservoirproperties/。",
|
||||||
|
examples=("tjwater-cli network get-all-reservoirs-properties",),
|
||||||
|
),
|
||||||
|
("network", "get-tank-properties"): CommandDoc(
|
||||||
|
path=("network", "get-tank-properties"),
|
||||||
|
summary="读取水箱属性",
|
||||||
|
description="调用 /gettankproperties/。",
|
||||||
|
options=(CommandOptionDoc("tank", "水箱 ID", required=True),),
|
||||||
|
examples=("tjwater-cli network get-tank-properties --tank T1",),
|
||||||
|
),
|
||||||
|
("network", "get-all-tanks-properties"): CommandDoc(
|
||||||
|
path=("network", "get-all-tanks-properties"),
|
||||||
|
summary="读取全部水箱属性",
|
||||||
|
description="调用 /getalltankproperties/。",
|
||||||
|
examples=("tjwater-cli network get-all-tanks-properties",),
|
||||||
|
),
|
||||||
|
("network", "get-pump-properties"): CommandDoc(
|
||||||
|
path=("network", "get-pump-properties"),
|
||||||
|
summary="读取水泵属性",
|
||||||
|
description="调用 /getpumpproperties/。",
|
||||||
|
options=(CommandOptionDoc("pump", "水泵 ID", required=True),),
|
||||||
|
examples=("tjwater-cli network get-pump-properties --pump PU1",),
|
||||||
|
),
|
||||||
|
("network", "get-all-pumps-properties"): CommandDoc(
|
||||||
|
path=("network", "get-all-pumps-properties"),
|
||||||
|
summary="读取全部水泵属性",
|
||||||
|
description="调用 /getallpumpproperties/。",
|
||||||
|
examples=("tjwater-cli network get-all-pumps-properties",),
|
||||||
|
),
|
||||||
|
("network", "get-valve-properties"): CommandDoc(
|
||||||
|
path=("network", "get-valve-properties"),
|
||||||
|
summary="读取阀门属性",
|
||||||
|
description="调用 /getvalveproperties/。",
|
||||||
|
options=(CommandOptionDoc("valve", "阀门 ID", required=True),),
|
||||||
|
examples=("tjwater-cli network get-valve-properties --valve V1",),
|
||||||
|
),
|
||||||
|
("network", "get-all-valves-properties"): CommandDoc(
|
||||||
|
path=("network", "get-all-valves-properties"),
|
||||||
|
summary="读取全部阀门属性",
|
||||||
|
description="调用 /getallvalveproperties/。",
|
||||||
|
examples=("tjwater-cli network get-all-valves-properties",),
|
||||||
),
|
),
|
||||||
("component", "option", "schema"): CommandDoc(
|
("component", "option", "schema"): CommandDoc(
|
||||||
path=("component", "option", "schema"),
|
path=("component", "option", "schema"),
|
||||||
@@ -422,41 +466,22 @@ COMMAND_DOCS: dict[tuple[str, ...], CommandDoc] = {
|
|||||||
),
|
),
|
||||||
examples=("tjwater-cli data timeseries composite pipeline-health --pipe P1 --start-time 2025-01-02T03:00:00+08:00 --end-time 2025-01-02T04:00:00+08:00",),
|
examples=("tjwater-cli data timeseries composite pipeline-health --pipe P1 --start-time 2025-01-02T03:00:00+08:00 --end-time 2025-01-02T04:00:00+08:00",),
|
||||||
),
|
),
|
||||||
("data", "scada", "schema"): CommandDoc(
|
|
||||||
path=("data", "scada", "schema"),
|
|
||||||
summary="读取 SCADA schema",
|
|
||||||
description="kind 支持 device、device-data、element、info。",
|
|
||||||
options=(CommandOptionDoc("kind", "SCADA 数据类型", required=True),),
|
|
||||||
examples=(
|
|
||||||
"tjwater-cli data scada schema --kind device",
|
|
||||||
"tjwater-cli data scada schema --kind device-data",
|
|
||||||
"tjwater-cli data scada schema --kind element",
|
|
||||||
"tjwater-cli data scada schema --kind info",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
("data", "scada", "get"): CommandDoc(
|
("data", "scada", "get"): CommandDoc(
|
||||||
path=("data", "scada", "get"),
|
path=("data", "scada", "get"),
|
||||||
summary="读取单条 SCADA 元数据",
|
summary="读取单条 SCADA 元数据",
|
||||||
description="kind 支持 device、device-data、element、info。",
|
description="kind 仅支持 info。",
|
||||||
options=(
|
options=(
|
||||||
CommandOptionDoc("kind", "SCADA 数据类型", required=True),
|
CommandOptionDoc("kind", "SCADA 数据类型", required=True),
|
||||||
CommandOptionDoc("id", "记录 ID", required=True),
|
CommandOptionDoc("id", "记录 ID", required=True),
|
||||||
),
|
),
|
||||||
examples=(
|
examples=("tjwater-cli data scada get --kind info --id SCADA-001",),
|
||||||
"tjwater-cli data scada get --kind device --id D1",
|
|
||||||
"tjwater-cli data scada get --kind element --id E1",
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
("data", "scada", "list"): CommandDoc(
|
("data", "scada", "list"): CommandDoc(
|
||||||
path=("data", "scada", "list"),
|
path=("data", "scada", "list"),
|
||||||
summary="列出 SCADA 元数据",
|
summary="列出 SCADA 元数据",
|
||||||
description="kind 支持 device、element、info;device-data 当前后端无 list 接口。",
|
description="kind 仅支持 info。",
|
||||||
options=(CommandOptionDoc("kind", "SCADA 数据类型", required=True),),
|
options=(CommandOptionDoc("kind", "SCADA 数据类型", required=True),),
|
||||||
examples=(
|
examples=("tjwater-cli data scada list --kind info",),
|
||||||
"tjwater-cli data scada list --kind device",
|
|
||||||
"tjwater-cli data scada list --kind element",
|
|
||||||
"tjwater-cli data scada list --kind info",
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
("data", "scheme", "schema"): CommandDoc(
|
("data", "scheme", "schema"): CommandDoc(
|
||||||
path=("data", "scheme", "schema"),
|
path=("data", "scheme", "schema"),
|
||||||
@@ -477,37 +502,6 @@ COMMAND_DOCS: dict[tuple[str, ...], CommandDoc] = {
|
|||||||
description="调用 /getallschemes/。",
|
description="调用 /getallschemes/。",
|
||||||
examples=("tjwater-cli data scheme list",),
|
examples=("tjwater-cli data scheme list",),
|
||||||
),
|
),
|
||||||
("data", "extension", "keys"): CommandDoc(
|
|
||||||
path=("data", "extension", "keys"),
|
|
||||||
summary="列出扩展数据键",
|
|
||||||
description="调用 /getallextensiondatakeys/。",
|
|
||||||
examples=("tjwater-cli data extension keys",),
|
|
||||||
),
|
|
||||||
("data", "extension", "get"): CommandDoc(
|
|
||||||
path=("data", "extension", "get"),
|
|
||||||
summary="读取扩展数据",
|
|
||||||
description="调用 /getextensiondata/。",
|
|
||||||
options=(CommandOptionDoc("key", "扩展键", required=True),),
|
|
||||||
examples=("tjwater-cli data extension get --key my_key",),
|
|
||||||
),
|
|
||||||
("data", "extension", "list"): CommandDoc(
|
|
||||||
path=("data", "extension", "list"),
|
|
||||||
summary="列出扩展数据",
|
|
||||||
description="调用 /getallextensiondata/。",
|
|
||||||
examples=("tjwater-cli data extension list",),
|
|
||||||
),
|
|
||||||
("data", "misc", "sensor-placements"): CommandDoc(
|
|
||||||
path=("data", "misc", "sensor-placements"),
|
|
||||||
summary="列出传感器布置结果",
|
|
||||||
description="调用 /getallsensorplacements/。",
|
|
||||||
examples=("tjwater-cli data misc sensor-placements",),
|
|
||||||
),
|
|
||||||
("data", "misc", "burst-location-results"): CommandDoc(
|
|
||||||
path=("data", "misc", "burst-location-results"),
|
|
||||||
summary="列出爆管定位结果",
|
|
||||||
description="调用 /getallburstlocateresults/。",
|
|
||||||
examples=("tjwater-cli data misc burst-location-results",),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -259,12 +259,8 @@ app/api/v1/endpoints/project_data.py
|
|||||||
| `tjwater-cli data timeseries scada query --device-id ID --start-time TIME --end-time TIME [--device-id ID ...] [--field FIELD]` | `GET /scada/by-ids-time-range`、`GET /scada/by-ids-field-time-range` | SCADA 时序;CLI 把重复 `--device-id` 转换为后端逗号分隔参数 |
|
| `tjwater-cli data timeseries scada query --device-id ID --start-time TIME --end-time TIME [--device-id ID ...] [--field FIELD]` | `GET /scada/by-ids-time-range`、`GET /scada/by-ids-field-time-range` | SCADA 时序;CLI 把重复 `--device-id` 转换为后端逗号分隔参数 |
|
||||||
| `tjwater-cli data timeseries composite --kind scada-simulation\|element-simulation\|element-scada --feature FEATURE --start-time TIME --end-time TIME` | `GET /composite/*` | 复合查询,`--feature` 可重复 |
|
| `tjwater-cli data timeseries composite --kind scada-simulation\|element-simulation\|element-scada --feature FEATURE --start-time TIME --end-time TIME` | `GET /composite/*` | 复合查询,`--feature` 可重复 |
|
||||||
| `tjwater-cli data timeseries composite pipeline-health --pipe PIPE --start-time TIME --end-time TIME` | `GET /composite/pipeline-health-prediction` | 管道健康预测 |
|
| `tjwater-cli data timeseries composite pipeline-health --pipe PIPE --start-time TIME --end-time TIME` | `GET /composite/pipeline-health-prediction` | 管道健康预测 |
|
||||||
| `tjwater-cli data scada schema --kind device\|device-data\|element\|info` | `GET /getscada*schema/` | `SCADA` 元数据 `schema` |
|
| `tjwater-cli data scada get\|list --kind info` | `GET /getscadainfo/`、`GET /getallscadainfo/` | `SCADA info` 元数据 |
|
||||||
| `tjwater-cli data scada get\|list --kind device\|device-data\|element\|info` | `scada.py` 下 `GET` 查询接口 | `SCADA` 元数据 |
|
|
||||||
| `tjwater-cli data scheme schema\|get\|list` | `schemes.py` 下 `GET` 接口 | 当前 project 方案查询 |
|
| `tjwater-cli data scheme schema\|get\|list` | `schemes.py` 下 `GET` 接口 | 当前 project 方案查询 |
|
||||||
| `tjwater-cli data extension keys\|get\|list` | `extension.py` 下 `GET` 查询接口 | 当前 project 扩展数据查询 |
|
|
||||||
| `tjwater-cli data misc sensor-placements` | `GET /getallsensorplacements/` | 当前 project 传感器位置 |
|
|
||||||
| `tjwater-cli data misc burst-location-results` | `GET /getallburstlocateresults/` | 当前 project 爆管定位结果 |
|
|
||||||
|
|
||||||
- `realtime` 是首批 simulation 结果的主读取域;CLI 可以按任务语义组合 `links`、`nodes`、`simulation-by-id-time`、`simulation-by-time-property`,但底层数据源仍以 `realtime.py` 为准。
|
- `realtime` 是首批 simulation 结果的主读取域;CLI 可以按任务语义组合 `links`、`nodes`、`simulation-by-id-time`、`simulation-by-time-property`,但底层数据源仍以 `realtime.py` 为准。
|
||||||
- `realtime`、`scheme`、`composite` 等时间查询命令面向用户时仍按 **UTC+8** 输入;CLI/服务端负责转换为后端使用的 **UTC0** 条件进行检索。若返回结果直接包含时间戳,必须显式带时区,避免把存储时间和展示时间混淆。
|
- `realtime`、`scheme`、`composite` 等时间查询命令面向用户时仍按 **UTC+8** 输入;CLI/服务端负责转换为后端使用的 **UTC0** 条件进行检索。若返回结果直接包含时间戳,必须显式带时区,避免把存储时间和展示时间混淆。
|
||||||
|
|||||||
Reference in New Issue
Block a user