scouting: Add support for /requests/request/matches_for_team

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I00bf80f2a8ee45db896adf025290e4dad4ba4273
diff --git a/scouting/webserver/requests/debug/BUILD b/scouting/webserver/requests/debug/BUILD
index 189296d..d56c03e 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_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 8020c64..6b47ae9 100644
--- a/scouting/webserver/requests/debug/cli/cli_test.py
+++ b/scouting/webserver/requests/debug/cli/cli_test.py
@@ -78,5 +78,15 @@
         self.assertEqual(exit_code, 0)
         self.assertIn("{MatchList:[]}", stderr)
 
+    def test_request_matches_for_team(self):
+        json_path = write_json({
+            "team": 971,
+        })
+        exit_code, _stdout, stderr = run_debug_cli(["-requestMatchesForTeam", json_path])
+
+        # TODO(phil): Actually add some matches here.
+        self.assertEqual(exit_code, 0)
+        self.assertIn("{MatchList:[]}", 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 204e541..44ae761 100644
--- a/scouting/webserver/requests/debug/cli/main.go
+++ b/scouting/webserver/requests/debug/cli/main.go
@@ -72,6 +72,8 @@
 		"If specified, parse the file as a SubmitDataScouting JSON request.")
 	requestAllMatchesPtr := flag.String("requestAllMatches", "",
 		"If specified, parse the file as a RequestAllMatches JSON request.")
+	requestMatchesForTeamPtr := flag.String("requestMatchesForTeam", "",
+		"If specified, parse the file as a RequestMatchesForTeam JSON request.")
 	flag.Parse()
 
 	// Handle the actual arguments.
@@ -97,4 +99,15 @@
 		}
 		log.Printf("%+v", *response)
 	}
+	if *requestMatchesForTeamPtr != "" {
+		log.Printf("Sending RequestMatchesForTeam to %s", *addressPtr)
+		binaryRequest := parseJson(
+			"scouting/webserver/requests/messages/request_matches_for_team.fbs",
+			*requestMatchesForTeamPtr)
+		response, err := debug.RequestMatchesForTeam(*addressPtr, binaryRequest)
+		if err != nil {
+			log.Fatal("Failed RequestMatchesForTeam: ", err)
+		}
+		log.Printf("%+v", *response)
+	}
 }
diff --git a/scouting/webserver/requests/debug/debug.go b/scouting/webserver/requests/debug/debug.go
index 5984c7a..6add662 100644
--- a/scouting/webserver/requests/debug/debug.go
+++ b/scouting/webserver/requests/debug/debug.go
@@ -10,12 +10,14 @@
 
 	"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_matches_for_team_response"
 	"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/submit_data_scouting_response"
 )
 
 // Use aliases to make the rest of the code more readable.
 type SubmitDataScoutingResponseT = submit_data_scouting_response.SubmitDataScoutingResponseT
 type RequestAllMatchesResponseT = request_all_matches_response.RequestAllMatchesResponseT
+type RequestMatchesForTeamResponseT = request_matches_for_team_response.RequestMatchesForTeamResponseT
 
 // 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.
@@ -99,3 +101,15 @@
 	response := request_all_matches_response.GetRootAsRequestAllMatchesResponse(responseBytes, 0)
 	return response.UnPack(), nil
 }
+
+// Sends a `RequestMatchesForTeam` message to the server and returns the
+// deserialized response.
+func RequestMatchesForTeam(server string, requestBytes []byte) (*RequestMatchesForTeamResponseT, error) {
+	responseBytes, err := performPost(server+"/requests/request/matches_for_team", requestBytes)
+	if err != nil {
+		return nil, err
+	}
+	log.Printf("Parsing RequestMatchesForTeamResponse")
+	response := request_matches_for_team_response.GetRootAsRequestMatchesForTeamResponse(responseBytes, 0)
+	return response.UnPack(), nil
+}