scouting: Add support for /requests/request/data_scouting
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I6a53ed395a187f04c889af506ce6ecacd0a75916
diff --git a/scouting/webserver/requests/debug/BUILD b/scouting/webserver/requests/debug/BUILD
index d56c03e..e3028dc 100644
--- a/scouting/webserver/requests/debug/BUILD
+++ b/scouting/webserver/requests/debug/BUILD
@@ -9,6 +9,7 @@
deps = [
"//scouting/webserver/requests/messages:error_response_go_fbs",
"//scouting/webserver/requests/messages:request_all_matches_response_go_fbs",
+ "//scouting/webserver/requests/messages:request_data_scouting_response_go_fbs",
"//scouting/webserver/requests/messages:request_matches_for_team_response_go_fbs",
"//scouting/webserver/requests/messages:submit_data_scouting_response_go_fbs",
],
diff --git a/scouting/webserver/requests/debug/cli/cli_test.py b/scouting/webserver/requests/debug/cli/cli_test.py
index 6b47ae9..347c828 100644
--- a/scouting/webserver/requests/debug/cli/cli_test.py
+++ b/scouting/webserver/requests/debug/cli/cli_test.py
@@ -88,5 +88,13 @@
self.assertEqual(exit_code, 0)
self.assertIn("{MatchList:[]}", stderr)
+ def test_request_data_scouting(self):
+ json_path = write_json({})
+ exit_code, _stdout, stderr = run_debug_cli(["-requestDataScouting", json_path])
+
+ # TODO(phil): Actually add data here before querying it.
+ self.assertEqual(exit_code, 0)
+ self.assertIn("{StatsList:[]}", stderr)
+
if __name__ == "__main__":
unittest.main()
diff --git a/scouting/webserver/requests/debug/cli/main.go b/scouting/webserver/requests/debug/cli/main.go
index 44ae761..0782d82 100644
--- a/scouting/webserver/requests/debug/cli/main.go
+++ b/scouting/webserver/requests/debug/cli/main.go
@@ -74,6 +74,8 @@
"If specified, parse the file as a RequestAllMatches JSON request.")
requestMatchesForTeamPtr := flag.String("requestMatchesForTeam", "",
"If specified, parse the file as a RequestMatchesForTeam JSON request.")
+ requestDataScoutingPtr := flag.String("requestDataScouting", "",
+ "If specified, parse the file as a RequestDataScouting JSON request.")
flag.Parse()
// Handle the actual arguments.
@@ -110,4 +112,15 @@
}
log.Printf("%+v", *response)
}
+ if *requestDataScoutingPtr != "" {
+ log.Printf("Sending RequestDataScouting to %s", *addressPtr)
+ binaryRequest := parseJson(
+ "scouting/webserver/requests/messages/request_data_scouting.fbs",
+ *requestDataScoutingPtr)
+ response, err := debug.RequestDataScouting(*addressPtr, binaryRequest)
+ if err != nil {
+ log.Fatal("Failed RequestDataScouting: ", err)
+ }
+ log.Printf("%+v", *response)
+ }
}
diff --git a/scouting/webserver/requests/debug/debug.go b/scouting/webserver/requests/debug/debug.go
index 6add662..6515e81 100644
--- a/scouting/webserver/requests/debug/debug.go
+++ b/scouting/webserver/requests/debug/debug.go
@@ -10,6 +10,7 @@
"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/error_response"
"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/request_all_matches_response"
+ "github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/request_data_scouting_response"
"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/request_matches_for_team_response"
"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/submit_data_scouting_response"
)
@@ -18,6 +19,7 @@
type SubmitDataScoutingResponseT = submit_data_scouting_response.SubmitDataScoutingResponseT
type RequestAllMatchesResponseT = request_all_matches_response.RequestAllMatchesResponseT
type RequestMatchesForTeamResponseT = request_matches_for_team_response.RequestMatchesForTeamResponseT
+type RequestDataScoutingResponseT = request_data_scouting_response.RequestDataScoutingResponseT
// A struct that can be used as an `error`. It contains information about the
// why the server was unhappy and what the corresponding request was.
@@ -113,3 +115,15 @@
response := request_matches_for_team_response.GetRootAsRequestMatchesForTeamResponse(responseBytes, 0)
return response.UnPack(), nil
}
+
+// Sends a `RequestDataScouting` message to the server and returns the
+// deserialized response.
+func RequestDataScouting(server string, requestBytes []byte) (*RequestDataScoutingResponseT, error) {
+ responseBytes, err := performPost(server+"/requests/request/data_scouting", requestBytes)
+ if err != nil {
+ return nil, err
+ }
+ log.Printf("Parsing RequestDataScoutingResponse")
+ response := request_data_scouting_response.GetRootAsRequestDataScoutingResponse(responseBytes, 0)
+ return response.UnPack(), nil
+}