Package pulp :: Package server :: Package webservices :: Package controllers :: Module audit
[hide private]
[frames] | no frames]

Source Code for Module pulp.server.webservices.controllers.audit

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  # 
 4  # Copyright © 2010 Red Hat, Inc. 
 5  # 
 6  # This software is licensed to you under the GNU General Public License, 
 7  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 8  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 9  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
10  # along with this software; if not, see 
11  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
12  # 
13  # Red Hat trademarks are not licensed under GPLv2. No permission is 
14  # granted to use or replicate Red Hat trademarks that are incorporated 
15  # in this software or its documentation. 
16   
17  import web 
18   
19   
20  from pulp.server.auditing import events 
21  from pulp.server.webservices import mongo 
22  from pulp.server.webservices.controllers.base import JSONController 
23  from pulp.server.webservices.role_check import RoleCheck 
24 25 # audit events controller ----------------------------------------------------- 26 27 -class Events(JSONController):
28 29 @JSONController.error_handler 30 @RoleCheck(admin=True)
31 - def GET(self):
32 """ 33 List all available events. 34 This controller supports a number of filters: 35 * principal, api, method=<name>: all filter on event fields 36 * field=<field name>: these filters tell the controller which fields 37 should be returned for each event 38 * limit=<int>: this filter tells the controller the maximum number of 39 events to return 40 * show=errors_only: show only events that have an exception associated 41 with them 42 @return: a list of events. 43 """ 44 valid_filters = ('principal', 'api', 'method', 'field', 'limit', 'show') 45 filters = self.filters(valid_filters) 46 47 show = filters.pop('show', []) 48 errors_only = 'errors_only' in show 49 50 limit = filters.pop('limit', None) 51 if limit is not None: 52 try: 53 limit = int(limit[-1]) # last limit takes precedence 54 except ValueError: 55 return self.bad_request('Invalid value for limit parameter') 56 57 fields = filters.pop('field', None) 58 spec = mongo.filters_to_re_spec(filters) 59 return self.ok(events(spec, fields, limit, errors_only))
60 61 # web.py application ---------------------------------------------------------- 62 63 URLS = ( 64 '/$', Events, 65 ) 66 67 application = web.application(URLS, globals()) 68