blob: 4b017852f0ee5e209059adfb03081fe6212c9dba [file] [log] [blame]
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +02001# Copyright 2022 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file or at
4# https://developers.google.com/open-source/licenses/bsd
5"""This file sets up all the urls for monorail pages."""
6
7import logging
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +02008import settings
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +02009
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020010import flask
11
12from features import banspammer
13from features import inboundemail
14from features import hotlistcreate
15from features import savedqueries
16from features import userhotlists
17from framework import banned
18from framework import clientmon
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +020019from framework import csp_report
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020020from framework import warmup
21from framework import reap
22from framework import deleteusers
23from framework import excessiveactivity
24from framework import ts_mon_js
25from framework import trimvisitedpages
26from project import peopledetail
27from project import peoplelist
28from project import projectadmin
29from project import projectadminadvanced
30from project import projectexport
31from project import projectsummary
32from project import projectupdates
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020033from project import project_constants
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020034from project import redirects
35from services import cachemanager_svc
36from services import client_config_svc
37from sitewide import custom_404
38from sitewide import hostinghome
39from sitewide import moved
40from sitewide import userclearbouncing
41from sitewide import userupdates
42from sitewide import userprofile
43from sitewide import projectcreate
44from sitewide import usersettings
45from sitewide import groupadmin
46from sitewide import groupcreate
47from sitewide import groupdetail
48from sitewide import grouplist
49from features import rerankhotlist
50from features import hotlistdetails
51from features import hotlistissues
52from features import hotlistissuescsv
53from features import hotlistpeople
54from features import dateaction
55from features import filterrules
56from features import pubsub
57from features import notify
58from features import hotlistcreate
59from features import savedqueries
60from features import userhotlists
61from features import banspammer
62from search import backendnonviewable
63from search import backendsearch
64from tracker import componentcreate
65from tracker import fltconversion
66from tracker import fieldcreate
67from tracker import fielddetail
68from tracker import templatecreate
69from tracker import templatedetail
70from tracker import issueadmin
71from tracker import issueadvsearch
72from tracker import issueattachment
73from tracker import issueattachmenttext
74from tracker import issuebulkedit
75from tracker import issuedetailezt
76from tracker import issueentry
77from tracker import issueentryafterlogin
78from tracker import issueexport
79from tracker import issueoriginal
80from tracker import issuereindex
81from tracker import issuetips
82from tracker import issueimport
83
84from tracker import webcomponentspage
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020085
86
87class ServletRegistry(object):
88
89 _PROJECT_NAME_REGEX = project_constants.PROJECT_NAME_PATTERN
90 _USERNAME_REGEX = r'[-+\w=.%]+(@([-a-z0-9]+\.)*[a-z0-9]+)?'
91 _HOTLIST_ID_NAME_REGEX = r'\d+|[a-zA-Z][-0-9a-zA-Z\.]*'
92
93 def __init__(self):
94 self.routes = []
95
96 def _AddRoute(
97 self, path_regex, servlet_handler, method='GET', does_write=False):
98 """Add a GET or POST handler to our flask route list.
99
100 Args:
101 path_regex: string with flask URL template regex.
102 servlet_handler: a servlet handler function.
103 method: string 'GET' or 'POST'.
104 does_write: True if the servlet could write to the database, we skip
105 registering such servlets when the site is in read_only mode. GET
106 handlers never write. Most, but not all, POST handlers do write.
107 """
108 if settings.read_only and does_write:
109 logging.info('Not registring %r because site is read-only', path_regex)
110 else:
111 self.routes.append([path_regex, servlet_handler, [method]])
112
113 def _SetupServlets(self, spec_dict, base='', post_does_write=True):
114 """Register each of the given servlets."""
115 for get_uri, servlet_handler in spec_dict.items():
116 self._AddRoute(base + get_uri, servlet_handler, 'GET')
117 post_uri = get_uri + ('edit.do' if get_uri.endswith('/') else '.do')
118 self._AddRoute(
119 base + post_uri, servlet_handler, 'POST', does_write=post_does_write)
120
121 def Register(self):
122 """Register all the monorail request handlers."""
123 return self.routes
124
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200125 def _AddFlaskUrlRules(self, flask_instance, rule_tuple):
126 """Add url rules to a given Flask instance.
127
128 Args:
129 flask_instance: The Flask app to add URLs to.
130 rule_tuple: List of tuple of path, module and method to call, HTTP method
131
132 Returns:
133 The Flask instance.
134 """
135 for rule in rule_tuple:
136 flask_instance.add_url_rule(rule[0], view_func=rule[1], methods=rule[2])
137 return flask_instance
138
139 # pylint: disable=unused-argument
140 def RegisterGroupUrls(self, services):
141 flaskapp_group = flask.Flask(__name__)
142 _GROUP_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200143 (
144 '/', grouplist.FlaskGroupList(services=services).GetGroupList,
145 ['GET']),
146 (
147 '/<string:viewed_username>/',
148 groupdetail.GroupDetail(services=services).GetGroupDetail, ['GET']),
149 (
150 '/<string:viewed_username>/edit.do',
151 groupdetail.GroupDetail(services=services).PostGroupDetail,
152 ['POST']),
153 (
154 '/<string:viewed_username>/groupadmin',
155 groupadmin.GroupAdmin(services=services).GetGroupAdmin, ['GET']),
156 (
157 '/<string:viewed_username>/groupadmin.do',
158 groupadmin.GroupAdmin(services=services).PostGroupAdmin, ['POST']),
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200159 ]
160
161 return self._AddFlaskUrlRules(flaskapp_group, _GROUP_URL)
162
163 # pylint: disable=unused-argument
164 def RegisterHostingUrl(self, service):
165 flaskapp_hosting = flask.Flask(__name__)
166 _HOSTING_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200167 (
168 '/excessiveActivity',
169 excessiveactivity.ExcessiveActivity(
170 services=service).GetExcessiveActivity, ['GET']),
171 (
172 '/settings',
173 usersettings.UserSettings(services=service).GetUserSetting, ['GET'
174 ]),
175 (
176 '/settings.do',
177 usersettings.UserSettings(services=service).PostUserSetting,
178 ['POST']),
179 ('/noAccess', banned.Banned(services=service).GetNoAccessPage, ['GET']),
180 (
181 '/moved', moved.ProjectMoved(services=service).GetProjectMoved,
182 ['GET']),
183 (
184 '/createProject',
185 projectcreate.ProjectCreate(services=service).GetCreateProject,
186 ['GET']),
187 (
188 '/createProject.do',
189 projectcreate.ProjectCreate(services=service).PostCreateProject,
190 ['POST']),
191 (
192 '/createHotlist',
193 hotlistcreate.HotlistCreate(services=service).GetCreateHotlist,
194 ['GET']),
195 (
196 '/createHotlist.do',
197 hotlistcreate.HotlistCreate(services=service).PostCreateHotlist,
198 ['POST']),
199 (
200 '/createGroup',
201 groupcreate.GroupCreate(services=service).GetGroupCreate, ['GET']),
202 (
203 '/createGroup.do',
204 groupcreate.GroupCreate(services=service).PostGroupCreate, ['POST'
205 ]),
206 (
207 '/deleteGroup',
208 grouplist.FlaskGroupList(services=service).GetGroupDelete, ['GET']),
209 (
210 '/deleteGroup.do',
211 grouplist.FlaskGroupList(services=service).PostGroupDelete,
212 ['POST']),
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200213 ]
214
215 flaskapp_hosting = self._AddFlaskUrlRules(flaskapp_hosting, _HOSTING_URL)
216
217 # pylint: disable=unused-variable
218 # for url /hosting/
219 @flaskapp_hosting.route('/')
220 def DefaultToMainPage():
221 url = flask.request.host_url
222 return flask.redirect(url)
223
224 return flaskapp_hosting
225
226 def RegisterOldHostUrl(self, service):
227 flaskapp_hosting_old = flask.Flask(__name__)
228
229 # pylint: disable=unused-variable
230 @flaskapp_hosting_old.route('/')
231 def GetHostingOld():
232 return hostinghome.HostingHome(services=service).GetOldHostingHome()
233
234 return flaskapp_hosting_old
235
236 def RegisterRedirectProjectUrl(self):
237 flaskapp_project_redirect = flask.Flask(__name__)
238
239 # pylint: disable=unused-variable
240 @flaskapp_project_redirect.route('/')
241 def GetRedirectProject():
242 url = flask.request.host_url
243 return flask.redirect(url)
244
245 return flaskapp_project_redirect
246
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200247 def RegisterCspUrl(self):
248 flaskapp_csp = flask.Flask(__name__)
249 flaskapp_csp.add_url_rule(
250 '/', view_func=csp_report.postCsp, methods=['POST'])
251
252 return flaskapp_csp
253
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200254 def RegisterProjectUrls(self, service):
255 flaskapp_project = flask.Flask(__name__)
256 _PROJECT_URLS = [
257 # (
258 # '/<string:project_name>/<string:unrecognized>',
259 # custom_404.ErrorPage(services=service).Get404Page,
260 # ['GET'],
261 # ),
262 # (
263 # '/<string:project_name>/adminComponents',
264 # issueadmin.AdminComponents(
265 # services=service).GetAdminComponentsPage, ['GET']),
266 # (
267 # '/<string:project_name>/adminComponents.do',
268 # issueadmin.AdminComponents(
269 # services=service).PostAdminComponentsPage, ['POST']),
270 # (
271 # '/<string:project_name>/adminIntro',
272 # projectsummary.ProjectSummary(
273 # services=service).GetProjectSummaryPage, ['GET']),
274 # (
275 # '/<string:project_name>/adminLabels',
276 # issueadmin.AdminLabels(services=service).GetAdminLabelsPage,
277 # ['GET']),
278 # (
279 # '/<string:project_name>/adminLabels.do',
280 # issueadmin.AdminLabels(services=service).PostAdminLabelsPage,
281 # ['POST']),
282 # (
283 # '/<string:project_name>/adminRules',
284 # issueadmin.AdminRules(services=service).GetAdminRulesPage,
285 # ['GET']),
286 # (
287 # '/<string:project_name>/adminRules.do',
288 # issueadmin.AdminRules(services=service).PostAdminRulesPage,
289 # ['POST']),
290 # (
291 # '/<string:project_name>/adminStatuses',
292 # issueadmin.AdminStatuses(services=service).GetAdminStatusesPage,
293 # ['GET']),
294 # (
295 # '/<string:project_name>/adminStatuses.do',
296 # issueadmin.AdminStatuses(services=service).PostAdminStatusesPage,
297 # ['POST']),
298 # (
299 # '/<string:project_name>/adminTemplates',
300 # issueadmin.AdminTemplates(services=service).GetAdminTemplatesPage,
301 # ['GET']),
302 # (
303 # '/<string:project_name>/adminTemplates.do',
304 # issueadmin.AdminTemplates(
305 # services=service).PostAdminTemplatesPage, ['POST']),
306 # (
307 # '/<string:project_name>/adminViews',
308 # issueadmin.AdminViews(services=service).GetAdminViewsPage,
309 # ['GET']),
310 # (
311 # '/<string:project_name>/adminViews.do',
312 # issueadmin.AdminViews(services=service).PostAdminViewsPage,
313 # ['POST']),
314 # (
315 # '/<string:project_name>/admin',
316 # projectadmin.ProjectAdmin(services=service).GetProjectAdminPage,
317 # ['GET']),
318 # (
319 # '/<string:project_name>/admin.do',
320 # projectadmin.ProjectAdmin(services=service).PostProjectAdminPage,
321 # ['POST']),
322 # (
323 # '/<string:project_name>/adminAdvanced',
324 # projectadminadvanced.ProjectAdminAdvanced(
325 # services=service).GetProjectAdminAdvancedPage, ['GET']),
326 # (
327 # '/<string:project_name>/adminAdvanced.do',
328 # projectadminadvanced.ProjectAdminAdvanced(
329 # services=service).PostProjectAdminAdvancedPage, ['POST']),
330 # (
331 # '/<string:project_name>/components/create',
332 # componentcreate.ComponentCreate(
333 # services=service).GetComponentCreatePage, ['GET']),
334 # (
335 # '/<string:project_name>/components/create.do',
336 # componentcreate.ComponentCreate(
337 # services=service).PostComponentCreatePage, ['POST']),
338 # (
339 # '/<string:project_name>/fields/create',
340 # fieldcreate.FieldCreate(
341 # services=service).GetFieldCreate, ['GET']),
342 # (
343 # '/<string:project_name>/fields/create.do',
344 # fieldcreate.FieldCreate(
345 # services=service).PostFieldCreate, ['POST']),
346 # (
347 # '/<string:project_name>/fields/detail',
348 # fielddetail.FieldDetail(
349 # services=service).GetFieldDetail, ['GET']),
350 # (
351 # '/<string:project_name>/fields/detail.do',
352 # fielddetail.FieldDetail(
353 # services=service).PostFieldDetail, ['POST']),
354 # (
355 # '/<string:project_name>/issues/advsearch',
356 # issueadvsearch.IssueAdvancedSearch(
357 # services=service).GetIssueAdvSearchPage, ['GET']),
358 # (
359 # '/<string:project_name>/issues/advsearch.do',
360 # issueadvsearch.IssueAdvancedSearch(
361 # services=service).PostIssueAdvSearchPage, ['POST']),
362 # (
363 # '/<string:project_name>/issues/detail',
364 # webcomponentspage.WebComponentsPage(
365 # services=service).GetWebComponentsIssueDetail, ['GET']),
366 # (
367 # '/<string:project_name>/issues/export',
368 # issueexport.IssueExport(services=service).GetIssueExport,
369 # ['GET']),
370 # (
371 # '/<string:project_name>/issues/export/json',
372 # issueexport.IssueExportJSON(services=service).GetIssueExportJSON,
373 # ['GET']),
374 # (
375 # '/<string:project_name>/issues/export/json.do',
376 # issueexport.IssueExportJSON(services=service).PostIssueExportJSON,
377 # ['POST']),
378 # (
379 # '/<string:project_name>/issues/import',
380 # issueimport.IssueImport(services=service).GetIssueImport,
381 # ['GET']),
382 # (
383 # '/<string:project_name>/issues/import.do',
384 # issueimport.IssueImport(services=service).PostIssueImport, ['POST'
385 # ]),
386 # (
387 # '/<string:project_name>/issues/original',
388 # issueoriginal.IssueOriginal(services=service).GetIssueOriginal,
389 # ['GET']),
390 # (
391 # '/<string:project_name>/issues/entry',
392 # issueentry.IssueEntry(
393 # services=service).GetIssueEntry, ['GET']),
394 # (
395 # '/<string:project_name>/issues/entry.do',
396 # issueentry.IssueEntry(
397 # services=service).PostIssueEntry, ['POST']),
398 # (
399 # '/<string:project_name>/issues/entry_new',
400 # webcomponentspage.WebComponentsPage(
401 # services=service).GetWebComponentsIssueNewEntry, ['GET']),
402 # (
403 # '/<string:project_name>/issues/list',
404 # webcomponentspage.WebComponentsPage(
405 # services=service).GetWebComponentsIssueList, ['GET']),
406 # (
407 # '/<string:project_name>/issues/reindex',
408 # issuereindex.IssueReindex(
409 # services=service).GetIssueReindex, ['GET']),
410 # (
411 # '/<string:project_name>/issues/reindex.do',
412 # issuereindex.IssueReindex(
413 # services=service).PostIssueReindex, ['POST']),
414 # (
415 # '/<string:project_name>/issues/detail/list',
416 # issuedetailezt.FlipperList(
417 # services=service).GetFlipperList, ['GET']),
418 # (
419 # '/<string:project_name>/issues/detail/flipper',
420 # issuedetailezt.FlipperIndex(
421 # services=service).GetFlipperIndex, ['GET']),
422 # (
423 # '/<string:project_name>/issues/detail/flipper.do',
424 # issuedetailezt.FlipperIndex(
425 # services=service).PostFlipperIndex, ['POST']),
426 # (
427 # '/<string:project_name>/issues/wizard',
428 # webcomponentspage.WebComponentsPage(
429 # services=service).GetWebComponentsIssueWizard, ['GET']),
430 # (
431 # '/<string:project_name>/templates/create',
432 # templatecreate.TemplateCreate(
433 # services=service).GetTemplateCreate, ['GET']),
434 # (
435 # '/<string:project_name>/templates/create.do',
436 # templatecreate.TemplateCreate(
437 # services=service).PostTemplateCreate, ['POST']),
438 # (
439 # '/<string:project_name>/templates/detail',
440 # templatedetail.TemplateDetail(
441 # services=service).GetTemplateDetail, ['GET']),
442 # (
443 # '/<string:project_name>/templates/detail.do',
444 # templatedetail.TemplateDetail(
445 # services=service).PostTemplateDetail, ['POST']),
446 # (
447 # '/<string:project_name>/people/list',
448 # peoplelist.PeopleList(services=service).GetPeopleListPage,
449 # ['GET']),
450 # (
451 # '/<string:project_name>/people/list.do',
452 # peoplelist.PeopleList(services=service).PostPeopleListPage,
453 # ['POST']),
454 # (
455 # '/<string:project_name>/people/detail',
456 # peopledetail.PeopleDetail(services=service).GetPeopleDetailPage,
457 # ['GET']),
458 # (
459 # '/<string:project_name>/people/detail.do',
460 # peopledetail.PeopleDetail(services=service).PostPeopleDetailPage,
461 # ['POST']),
462 # (
463 # '/<string:project_name>/projectExport',
464 # projectexport.ProjectExport(
465 # services=service).GetProjectExportPage, ['GET']),
466 # (
467 # '/<string:project_name>/projectExport/json',
468 # projectexport.ProjectExportJSON(
469 # services=service).GetProjectExportJSONPage, ['GET']),
470 # (
471 # '/<string:project_name>/projectExport/json.do',
472 # projectexport.ProjectExportJSON(
473 # services=service).PostProjectExportJSONPage, ['POST']),
474 # (
475 # '/<string:project_name>/updates/list',
476 # projectupdates.ProjectUpdates(
477 # services=service).GetProjectUpdatesPage, ['GET']),
478 # (
479 # '/<string:project_name>/w/list',
480 # redirects.WikiRedirect(
481 # services=service).GetWikiListRedirect, ['GET']),
482 # (
483 # '/<string:project_name>/wiki/<string:wiki_page>',
484 # redirects.WikiRedirect(
485 # services=service).GetWikiRedirect, ['GET']),
486 # (
487 # '/<string:project_name>/source/<string:source_page>',
488 # redirects.SourceRedirect(
489 # services=service).GetSourceRedirect, ['GET']),
490 # '/<string:project_name>/issues/entryafterlogin',
491 # issueentryafterlogin.IssueEntryAfterLogin(
492 # services=service).GetIssueEntryAfterLogin,
493 # ['GET'],
494 # ),
495 # (
496 # '/<string:project_name>/issues/searchtips',
497 # issuetips.IssueSearchTips(services=service).GetIssueSearchTips,
498 # ['GET'],
499 # ),
500 # (
501 # '/<string:project_name>/issues/attachment',
502 # issueattachment.AttachmentPage(services=service).GetAttachmentPage,
503 # ['GET'],
504 # ),
505 # (
506 # '/<string:project_name>/issues/attachmentText',
507 # issueattachmenttext.AttachmentText(
508 # services=service).GetAttachmentText,
509 # ['GET'],
510 # ),
511 # (
512 # '/<string:project_name>/issues/bulkedit',
513 # issuebulkedit.IssueBulkEdit(
514 # services=service).GetIssueBulkEdit, ['GET']),
515 # (
516 # '/<string:project_name>/issues/bulkedit.do',
517 # issuebulkedit.IssueBulkEdit(
518 # services=service).PostIssueBulkEdit, ['POST']),
519 # (
520 # '/<string:project_name>/issues/detail/next',
521 # issuedetailezt.FlipperNext(
522 # services=service).GetFlipperNextRedirectPage, ['GET']),
523 # (
524 # '/<string:project_name>/issues/detail/previous',
525 # issuedetailezt.FlipperPrev(
526 # services=service).GetFlipperPrevRedirectPage, ['GET']),
527 ]
528 flaskapp_project = self._AddFlaskUrlRules(flaskapp_project, _PROJECT_URLS)
529
530 # pylint: disable=unused-variable
531 @flaskapp_project.route('/<string:project_name>/issues/approval')
532 @flaskapp_project.route('/<string:project_name>/issues/detail_ezt')
533 def ProjectRedirectToIssueDetail(project_name):
534 host_url = flask.request.host_url
535 url = host_url + 'p/' + project_name + '/issues/detail'
536 query_string = flask.request.query_string
537 if query_string:
538 url = '%s?%s' % (url, query_string)
539 return flask.redirect(url)
540
541 # pylint: disable=unused-variable
542 @flaskapp_project.route('/<string:project_name>/issues/list_new')
543 @flaskapp_project.route('/<string:project_name>/')
544 @flaskapp_project.route('/<string:project_name>/issues/')
545 def ProjectRedirectToIssueList(project_name):
546 host_url = flask.request.host_url
547 url = host_url + 'p/' + project_name + '/issues/list'
548 query_string = flask.request.query_string
549 if query_string:
550 url = '%s?%s' % (url, query_string)
551 return flask.redirect(url)
552
553 # pylint: disable=unused-variable
554 @flaskapp_project.route('/')
555 def ProjectRedirectToMainPage():
556 url = flask.request.host_url
557 return flask.redirect(url)
558
559 # pylint: disable=unused-variable
560 @flaskapp_project.route('/<string:project_name>/people/')
561 def ProjectRedirectToPeopleList(project_name):
562 host_url = flask.request.host_url
563 url = host_url + 'p/' + project_name + '/people/list'
564 return flask.redirect(url)
565
566 return flaskapp_project
567
568 def RegisterUserUrls(self, service):
569 flaskapp_user = flask.Flask(__name__)
570 _USER_URLS = [
571 # (
572 # '/<string:viewed_username>/queries',
573 # savedqueries.SavedQueries(services=service).GetSavedQueriesPage,
574 # ['GET']),
575 # (
576 # '/<string:viewed_username>/queries.do',
577 # savedqueries.SavedQueries(services=service).PostSavedQueriesPage,
578 # ['Post']),
579 # (
580 # '/<string:viewed_username>/hotlists',
581 # userhotlists.UserHotlists(services=service).GetUserHotlistsPage,
582 # ['GET']),
583 # (
584 # '/<string:viewed_username>/hotlists.do',
585 # userhotlists.UserHotlists(services=service).PostUserHotlistsPage,
586 # ['Post']),
587 # (
588 # '/<string:viewed_username>/',
589 # userprofile.UserProfile(services=service).GetUserProfilePage,
590 # ['GET']),
591 # (
592 # '/<string:viewed_username>/edit.do',
593 # userprofile.UserProfile(services=service).PostUserProfilePage,
594 # ['POST']),
595 # (
596 # '/<string:viewed_username>/ban.do',
597 # userprofile.BanUser(services=service).PostBanUserPage,
598 # ['POST']),
599 # (
600 # '/<string:viewed_username>/banSpammer.do',
601 # banspammer.BanSpammer(services=service).PostBanSpammerPage,
602 # ['POST']),
603 # (
604 # '/<string:viewed_username>/clearBouncing',
605 # userclearbouncing.UserClearBouncing(
606 # services=service).GetUserClearBouncingPage, ['GET']),
607 # (
608 # '/<string:viewed_username>/clearBouncing.do',
609 # userclearbouncing.UserClearBouncing(
610 # services=service).PostUserClearBouncingPage, ['Post']),
611 # (
612 # '/<string:viewed_username>/updates/projects',
613 # userupdates.UserUpdatesProjects(
614 # services=service).GetUserUpdatesProjectsPage, ['GET']),
615 # (
616 # '/<string:viewed_username>/updates/developers',
617 # userupdates.UserUpdatesDevelopers(
618 # services=service).GetUserUpdatesDevelopersPage, ['GET']),
619 # (
620 # '/<string:viewed_username>/updates',
621 # userupdates.UserUpdatesIndividual(
622 # services=service).GetUserUpdatesPage, ['GET']),
623 # (
624 # '/<string:viewed_username>/hotlists/<string:hotlist_id>',
625 # hotlistissues.HotlistIssues(services=service).GetHotlistIssuesPage,
626 # ['GET']),
627 # (
628 # '/<string:viewed_username>/hotlists/<string:hotlist_id>.do',
629 # hotlistissues.HotlistIssues(services=service).PostHotlistIssuesPage,
630 # ['POST']),
631 # (
632 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/csv',
633 # hotlistissuescsv.HotlistIssuesCsv(
634 # services=service).GetHotlistIssuesCsvPage, ['GET']),
635 # (
636 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/people',
637 # hotlistpeople.HotlistPeopleList(
638 # services=service).GetHotlistPeoplePage, ['GET']),
639 # (
640 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/people.do',
641 # hotlistpeople.HotlistPeopleList(
642 # services=service).PostHotlistPeoplePage, ['POST']),
643 # (
644 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/details',
645 # hotlistdetails.HotlistDetails(
646 # services=service).GetHotlistDetailsPage, ['GET']),
647 # (
648 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/details.do',
649 # hotlistdetails.HotlistDetails(
650 # services=service).PostHotlistDetailsPage, ['POST']),
651 # (
652 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/rerank',
653 # rerankhotlist.RerankHotlistIssue(
654 # services=service).GetRerankHotlistIssuePage, ['GET']),
655 # (
656 # '/<string:viewed_username>/hotlists/<string:hotlist_id>/rerank.do',
657 # rerankhotlist.RerankHotlistIssue(
658 # services=service).PostRerankHotlistIssuePage, ['POST']),
659 ]
660
661 flaskapp_user = self._AddFlaskUrlRules(flaskapp_user, _USER_URLS)
662
663 # pylint: disable=unused-variable
664 # for url /u/
665 @flaskapp_user.route('/')
666 def UserRedirectToMainPage():
667 url = flask.request.host_url
668 return flask.redirect(url)
669
670 return flaskapp_user
671
672 # pylint: disable=unused-argument
673 def RegisterTaskUrl(self, service):
674 flaskapp_task = flask.Flask(__name__)
675 _TASK_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200676 (
677 '/banSpammer.do',
678 banspammer.BanSpammerTask(services=service).PostBanSpammer,
679 ['POST']),
680 (
681 '/sendWipeoutUserListsTask.do',
682 deleteusers.SendWipeoutUserListsTask(
683 services=service).PostSendWipeoutUserListsTask, ['POST']),
684 (
685 '/deleteWipeoutUsersTask.do',
686 deleteusers.DeleteWipeoutUsersTask(
687 services=service).PostDeleteWipeoutUsersTask, ['POST']),
688 (
689 '/deleteUsersTask.do',
690 deleteusers.DeleteUsersTask(services=service).PostDeleteUsersTask,
691 ['POST']),
692 (
693 '/notifyRulesDeleted.do',
694 notify.NotifyRulesDeletedTask(
695 services=service).PostNotifyRulesDeletedTask, ['POST']),
696 (
697 '/notifyIssueChange.do',
698 notify.NotifyIssueChangeTask(
699 services=service).PostNotifyIssueChangeTask, ['POST']),
700 (
701 '/notifyBlockingChange.do',
702 notify.NotifyBlockingChangeTask(
703 services=service).PostNotifyBlockingChangeTask, ['POST']),
704 (
705 '/notifyBulkEdit.do', notify.NotifyBulkChangeTask(
706 services=service).PostNotifyBulkChangeTask, ['POST']),
707 (
708 '/notifyApprovalChange.do',
709 notify.NotifyApprovalChangeTask(
710 services=service).PostNotifyApprovalChangeTask, ['POST']),
711 (
712 '/publishPubsubIssueChange.do',
713 pubsub.PublishPubsubIssueChangeTask(
714 services=service).PostPublishPubsubIssueChangeTask, ['POST']),
715 (
716 '/issueDateAction.do',
717 dateaction.IssueDateActionTask(
718 services=service).PostIssueDateActionTask, ['POST']),
719 (
720 '/fltConversionTask.do',
721 fltconversion.FLTConvertTask(services=service).PostFLTConvertTask,
722 ['POST']),
723 (
724 '/outboundEmail.do',
725 notify.OutboundEmailTask(services=service).PostOutboundEmailTask,
726 ['POST']),
727 (
728 '/recomputeDerivedFields.do',
729 filterrules.RecomputeDerivedFieldsTask(
730 services=service).PostRecomputeDerivedFieldsTask, ['POST']),
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200731 ]
732
733 for rule in _TASK_URL:
734 flaskapp_task.add_url_rule(rule[0], view_func=rule[1], methods=rule[2])
735
736 return flaskapp_task
737
738 # pylint: disable=unused-argument
739 def RegisterCronUrl(self, service):
740 flaskapp_cron = flask.Flask(__name__)
741 _CRON_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200742 (
743 '/wipeoutSync',
744 deleteusers.WipeoutSyncCron(services=service).GetWipeoutSyncCron,
745 ['GET']),
746 (
747 '/reindexQueue',
748 filterrules.ReindexQueueCron(services=service).GetReindexQueueCron,
749 ['GET']),
750 (
751 '/dateAction',
752 dateaction.DateActionCron(services=service).GetDateActionCron,
753 ['GET']),
754 (
755 '/ramCacheConsolidate',
756 cachemanager_svc.RamCacheConsolidate(
757 services=service).GetRamCacheConsolidate, ['GET']),
758 ('/reap', reap.Reap(services=service).GetReap, ['GET']),
759 (
760 '/loadApiClientConfigs', client_config_svc.GetLoadApiClientConfigs,
761 ['GET']),
762 (
763 '/trimVisitedPages',
764 trimvisitedpages.TrimVisitedPages(
765 services=service).GetTrimVisitedPages, ['GET']),
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200766 ]
767
768 for rule in _CRON_URL:
769 flaskapp_cron.add_url_rule(rule[0], view_func=rule[1], methods=rule[2])
770
771 return flaskapp_cron
772
773 # pylint: disable=unused-argument
774 def RegisterBackendUrl(self, service):
775 flaskapp_backend = flask.Flask(__name__)
776 _BACKEND_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200777 (
778 '/search',
779 backendsearch.BackendSearch(services=service).GetBackendSearch,
780 ['GET']),
781 (
782 '/nonviewable',
783 backendnonviewable.BackendNonviewable(
784 services=service).GetBackendNonviewable, ['GET']),
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200785 ]
786
787 for rule in _BACKEND_URL:
788 flaskapp_backend.add_url_rule(rule[0], view_func=rule[1], methods=rule[2])
789
790 return flaskapp_backend
791
792 # pylint: disable=unused-argument
793 def RegisterMONSetUrl(self, service):
794 flaskapp_mon = flask.Flask(__name__)
795 _MON_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200796 (
797 '/clientmon.do',
798 clientmon.ClientMonitor(services=service).PostClientMonitor,
799 ['POST']),
800 (
801 '/jstsmon.do',
802 ts_mon_js.FlaskMonorailTSMonJSHandler(
803 services=service).PostMonorailTSMonJSHandler,
804 ['POST'],
805 )
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200806 ]
807
808 flaskapp_mon = self._AddFlaskUrlRules(flaskapp_mon, _MON_URL)
809 return flaskapp_mon
810
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200811 def RegisterAHUrl(self, service):
812 flaskapp_ah = flask.Flask(__name__)
813 _AH_URL = [
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +0200814 ('/warmup', warmup.Warmup, ['GET']), ('/start', warmup.Start, ['GET']),
815 ('/stop', warmup.Stop, ['GET']),
816 (
817 '/bounce',
818 inboundemail.BouncedEmail(services=service).postBouncedEmail,
819 ['POST']),
820 (
821 '/mail/<string:project_addr>',
822 inboundemail.InboundEmail(services=service).HandleInboundEmail,
823 ['GET', 'POST'])
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200824 ]
825
826 flaskapp_ah = self._AddFlaskUrlRules(flaskapp_ah, _AH_URL)
827
828 return flaskapp_ah