| 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 datetime | 7 import datetime |
| 8 import logging | 8 import logging |
| 9 | 9 |
| 10 from google.appengine.api import datastore_errors | 10 from google.appengine.api import datastore_errors |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 """ | 621 """ |
| 622 logging.info('%s', request) | 622 logging.info('%s', request) |
| 623 now = utils.utcnow() | 623 now = utils.utcnow() |
| 624 q = bot_management.BotInfo.query() | 624 q = bot_management.BotInfo.query() |
| 625 try: | 625 try: |
| 626 q = bot_management.filter_dimensions(q, request.dimensions) | 626 q = bot_management.filter_dimensions(q, request.dimensions) |
| 627 q = bot_management.filter_availability( | 627 q = bot_management.filter_availability( |
| 628 q, swarming_rpcs.to_bool(request.quarantined), | 628 q, swarming_rpcs.to_bool(request.quarantined), |
| 629 swarming_rpcs.to_bool(request.is_dead), now) | 629 swarming_rpcs.to_bool(request.is_dead), now) |
| 630 except ValueError as e: | 630 except ValueError as e: |
| 631 raise endpoints.BadRequestException('%s' % e) | 631 raise endpoints.BadRequestException(str(e)) |
| 632 | 632 |
| 633 bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor) | 633 bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor) |
| 634 return swarming_rpcs.BotList( | 634 return swarming_rpcs.BotList( |
| 635 cursor=cursor, | 635 cursor=cursor, |
| 636 death_timeout=config.settings().bot_death_timeout_secs, | 636 death_timeout=config.settings().bot_death_timeout_secs, |
| 637 items=[message_conversion.bot_info_to_rpc(bot, now) for bot in bots], | 637 items=[message_conversion.bot_info_to_rpc(bot, now) for bot in bots], |
| 638 now=now) | 638 now=now) |
| 639 | 639 |
| 640 @gae_ts_mon.instrument_endpoint() | 640 @gae_ts_mon.instrument_endpoint() |
| 641 @auth.endpoints_method( | 641 @auth.endpoints_method( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 def get_routes(): | 684 def get_routes(): |
| 685 return ( | 685 return ( |
| 686 endpoints_webapp2.api_routes(SwarmingServerService) + | 686 endpoints_webapp2.api_routes(SwarmingServerService) + |
| 687 endpoints_webapp2.api_routes(SwarmingTaskService) + | 687 endpoints_webapp2.api_routes(SwarmingTaskService) + |
| 688 endpoints_webapp2.api_routes(SwarmingTasksService) + | 688 endpoints_webapp2.api_routes(SwarmingTasksService) + |
| 689 endpoints_webapp2.api_routes(SwarmingBotService) + | 689 endpoints_webapp2.api_routes(SwarmingBotService) + |
| 690 endpoints_webapp2.api_routes(SwarmingBotsService) + | 690 endpoints_webapp2.api_routes(SwarmingBotsService) + |
| 691 # components.config endpoints for validation and configuring of luci-config | 691 # components.config endpoints for validation and configuring of luci-config |
| 692 # service URL. | 692 # service URL. |
| 693 endpoints_webapp2.api_routes(config.ConfigApi)) | 693 endpoints_webapp2.api_routes(config.ConfigApi)) |
| OLD | NEW |