| 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 """This module defines Swarming Server endpoints handlers.""" | 5 """This module defines Swarming Server endpoints handlers.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 from google.appengine.api import datastore_errors | 10 from google.appengine.api import datastore_errors |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 @gae_ts_mon.instrument_endpoint() | 483 @gae_ts_mon.instrument_endpoint() |
| 484 @auth.endpoints_method( | 484 @auth.endpoints_method( |
| 485 swarming_rpcs.TasksCountRequest, swarming_rpcs.TasksCount, | 485 swarming_rpcs.TasksCountRequest, swarming_rpcs.TasksCount, |
| 486 http_method='GET') | 486 http_method='GET') |
| 487 @auth.require(acl.is_privileged_user) | 487 @auth.require(acl.is_privileged_user) |
| 488 def count(self, request): | 488 def count(self, request): |
| 489 """Counts number of tasks in a given state.""" | 489 """Counts number of tasks in a given state.""" |
| 490 logging.info('%s', request) | 490 logging.info('%s', request) |
| 491 if not request.start: | 491 if not request.start: |
| 492 raise endpoints.BadRequestException('start (as epoch) is required') | 492 raise endpoints.BadRequestException('start (as epoch) is required') |
| 493 if not request.end: | |
| 494 raise endpoints.BadRequestException('end (as epoch) is required') | |
| 495 now = utils.utcnow() | 493 now = utils.utcnow() |
| 496 try: | 494 try: |
| 497 count = self._query_from_request(request, 'created_ts').count() | 495 count = self._query_from_request(request, 'created_ts').count() |
| 498 except ValueError as e: | 496 except ValueError as e: |
| 499 raise endpoints.BadRequestException( | 497 raise endpoints.BadRequestException( |
| 500 'Inappropriate filter for tasks/count: %s' % e) | 498 'Inappropriate filter for tasks/count: %s' % e) |
| 501 return swarming_rpcs.TasksCount(count=count, now=now) | 499 return swarming_rpcs.TasksCount(count=count, now=now) |
| 502 | 500 |
| 503 def _query_from_request(self, request, sort=None): | 501 def _query_from_request(self, request, sort=None): |
| 504 """Returns a TaskResultSummary query.""" | 502 """Returns a TaskResultSummary query.""" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 def get_routes(): | 800 def get_routes(): |
| 803 return ( | 801 return ( |
| 804 endpoints_webapp2.api_routes(SwarmingServerService) + | 802 endpoints_webapp2.api_routes(SwarmingServerService) + |
| 805 endpoints_webapp2.api_routes(SwarmingTaskService) + | 803 endpoints_webapp2.api_routes(SwarmingTaskService) + |
| 806 endpoints_webapp2.api_routes(SwarmingTasksService) + | 804 endpoints_webapp2.api_routes(SwarmingTasksService) + |
| 807 endpoints_webapp2.api_routes(SwarmingBotService) + | 805 endpoints_webapp2.api_routes(SwarmingBotService) + |
| 808 endpoints_webapp2.api_routes(SwarmingBotsService) + | 806 endpoints_webapp2.api_routes(SwarmingBotsService) + |
| 809 # components.config endpoints for validation and configuring of luci-config | 807 # components.config endpoints for validation and configuring of luci-config |
| 810 # service URL. | 808 # service URL. |
| 811 endpoints_webapp2.api_routes(config.ConfigApi)) | 809 endpoints_webapp2.api_routes(config.ConfigApi)) |
| OLD | NEW |