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