forked from the-blue-alliance/the-blue-alliance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_main.py
140 lines (137 loc) · 10.9 KB
/
api_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python
import webapp2
import tba_config
from controllers.api.api_district_controller import ApiDistrictListController, ApiDistrictTeamsController, ApiDistrictRankingsController, \
ApiDistrictEventsController
from controllers.api.api_team_controller import ApiTeamController, ApiTeamEventsController, ApiTeamEventAwardsController, \
ApiTeamEventMatchesController, ApiTeamMediaController, ApiTeamListController, \
ApiTeamYearsParticipatedController, ApiTeamHistoryEventsController, \
ApiTeamHistoryAwardsController, ApiTeamHistoryRobotsController, \
ApiTeamHistoryDistrictsController
from controllers.api.api_event_controller import ApiEventController, ApiEventTeamsController, \
ApiEventMatchesController, ApiEventStatsController, \
ApiEventRankingsController, ApiEventAwardsController, \
ApiEventDistrictPointsController, ApiEventListController
from controllers.api.api_match_controller import ApiMatchController
from controllers.api.api_status_controller import ApiStatusController
from controllers.api.api_trusted_controller import ApiTrustedEventAllianceSelectionsUpdate, ApiTrustedEventAwardsUpdate, \
ApiTrustedEventMatchesUpdate, ApiTrustedEventMatchesDelete, ApiTrustedEventMatchesDeleteAll, ApiTrustedEventRankingsUpdate, \
ApiTrustedEventTeamListUpdate, ApiTrustedAddMatchYoutubeVideo, \
ApiTrustedAddEventMedia, ApiTrustedUpdateEventInfo, ApiTrustedAddMatchZebraMotionWorks
# Ensure that APIv2 routes include OPTIONS method for CORS preflight compatibility
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests
app = webapp2.WSGIApplication([webapp2.Route(r'/api/v2/team/<team_key:>',
ApiTeamController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/events',
ApiTeamEventsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/<year:([0-9]*)>/events',
ApiTeamEventsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/event/<event_key:>/awards',
ApiTeamEventAwardsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/event/<event_key:>/matches',
ApiTeamEventMatchesController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/media',
ApiTeamMediaController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/<year:([0-9]*)>/media',
ApiTeamMediaController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/history/events',
ApiTeamHistoryEventsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/history/awards',
ApiTeamHistoryAwardsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/history/robots',
ApiTeamHistoryRobotsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/history/districts',
ApiTeamHistoryDistrictsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/team/<team_key:>/years_participated',
ApiTeamYearsParticipatedController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/teams/<page_num:([0-9]+)>',
ApiTeamListController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>',
ApiEventController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>/teams',
ApiEventTeamsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>/matches',
ApiEventMatchesController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>/stats',
ApiEventStatsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>/rankings',
ApiEventRankingsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>/awards',
ApiEventAwardsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/event/<event_key:>/district_points',
ApiEventDistrictPointsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/events/<year:([0-9]*)>',
ApiEventListController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/match/<match_key:>',
ApiMatchController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/districts/<year:([0-9]*)>',
ApiDistrictListController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/district/<district_abbrev:>/<year:([0-9]*)>/events',
ApiDistrictEventsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/district/<district_abbrev:>/<year:([0-9]*)>/teams',
ApiDistrictTeamsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/district/<district_abbrev:>/<year:([0-9]*)>/rankings',
ApiDistrictRankingsController,
methods=['GET', 'OPTIONS']),
webapp2.Route(r'/api/v2/status',
ApiStatusController,
methods=['GET']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/alliance_selections/update',
ApiTrustedEventAllianceSelectionsUpdate,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/awards/update',
ApiTrustedEventAwardsUpdate,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/matches/update',
ApiTrustedEventMatchesUpdate,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/matches/delete',
ApiTrustedEventMatchesDelete,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/matches/delete_all',
ApiTrustedEventMatchesDeleteAll,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/rankings/update',
ApiTrustedEventRankingsUpdate,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/team_list/update',
ApiTrustedEventTeamListUpdate,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/match_videos/add',
ApiTrustedAddMatchYoutubeVideo,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/media/add',
ApiTrustedAddEventMedia,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/info/update',
ApiTrustedUpdateEventInfo,
methods=['POST', 'OPTIONS']),
webapp2.Route(r'/api/trusted/v1/event/<event_key:>/zebra_motionworks/add',
ApiTrustedAddMatchZebraMotionWorks,
methods=['POST', 'OPTIONS']),
], debug=tba_config.DEBUG)