| OLD | NEW |
| 1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 | 6 |
| 7 from google.appengine.api import memcache | 7 from google.appengine.api import memcache |
| 8 from google.appengine.ext import ndb | 8 from google.appengine.ext import ndb |
| 9 from protorpc import messages | 9 from protorpc import messages |
| 10 from protorpc import message_types | 10 from protorpc import message_types |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 endpoints.ResourceContainer( | 366 endpoints.ResourceContainer( |
| 367 message_types.VoidMessage, | 367 message_types.VoidMessage, |
| 368 config_set=messages.StringField(1, required=True) | 368 config_set=messages.StringField(1, required=True) |
| 369 ), | 369 ), |
| 370 message_types.VoidMessage, | 370 message_types.VoidMessage, |
| 371 http_method='POST', | 371 http_method='POST', |
| 372 path='reimport') | 372 path='reimport') |
| 373 @auth.public # ACL check inside | 373 @auth.public # ACL check inside |
| 374 def reimport(self, request): | 374 def reimport(self, request): |
| 375 """Reimports a config set.""" | 375 """Reimports a config set.""" |
| 376 if not auth.is_admin(): | 376 if not acl.is_admin(): |
| 377 raise endpoints.ForbiddenException('Only admins are allowed to do this') | 377 raise endpoints.ForbiddenException('Only admins are allowed to do this') |
| 378 # Assume it is Gitiles. | 378 # Assume it is Gitiles. |
| 379 try: | 379 try: |
| 380 gitiles_import.import_config_set(request.config_set) | 380 gitiles_import.import_config_set(request.config_set) |
| 381 return message_types.VoidMessage() | 381 return message_types.VoidMessage() |
| 382 except gitiles_import.NotFoundError as e: | 382 except gitiles_import.NotFoundError as e: |
| 383 raise endpoints.NotFoundException(e.message) | 383 raise endpoints.NotFoundException(e.message) |
| 384 except ValueError as e: | 384 except ValueError as e: |
| 385 raise endpoints.BadRequestException(e.message) | 385 raise endpoints.BadRequestException(e.message) |
| 386 except gitiles_import.Error as e: | 386 except gitiles_import.Error as e: |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 def can_read_config_sets(config_sets): | 494 def can_read_config_sets(config_sets): |
| 495 try: | 495 try: |
| 496 return acl.can_read_config_sets(config_sets) | 496 return acl.can_read_config_sets(config_sets) |
| 497 except ValueError as ex: | 497 except ValueError as ex: |
| 498 raise endpoints.BadRequestException(ex.message) | 498 raise endpoints.BadRequestException(ex.message) |
| 499 | 499 |
| 500 | 500 |
| 501 def can_read_config_set(config_set): | 501 def can_read_config_set(config_set): |
| 502 return can_read_config_sets([config_set]).get(config_set) | 502 return can_read_config_sets([config_set]).get(config_set) |
| OLD | NEW |