Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 @auth.endpoints_method( | 130 @auth.endpoints_method( |
| 131 message_types.VoidMessage, swarming_rpcs.ServerDetails, | 131 message_types.VoidMessage, swarming_rpcs.ServerDetails, |
| 132 http_method='GET') | 132 http_method='GET') |
| 133 @auth.require(acl.is_bot_or_user) | 133 @auth.require(acl.is_bot_or_user) |
| 134 def details(self, _request): | 134 def details(self, _request): |
| 135 """Returns information about the server.""" | 135 """Returns information about the server.""" |
| 136 return swarming_rpcs.ServerDetails(server_version=utils.get_app_version()) | 136 return swarming_rpcs.ServerDetails(server_version=utils.get_app_version()) |
| 137 | 137 |
| 138 @gae_ts_mon.instrument_endpoint() | 138 @gae_ts_mon.instrument_endpoint() |
| 139 @auth.endpoints_method( | 139 @auth.endpoints_method( |
| 140 message_types.VoidMessage, swarming_rpcs.ServerPermissions, | |
| 141 http_method='GET') | |
| 142 @auth.public | |
| 143 def permissions(self, _request): | |
| 144 """Returns the caller's permissions.""" | |
| 145 return swarming_rpcs.ServerPermissions( | |
| 146 can_delete_bot = acl.is_admin(), | |
| 147 can_terminate_bot = acl.is_privileged_user(), | |
| 148 can_get_bootstrap_py = acl.is_user(), | |
|
M-A Ruel
2016/08/25 18:22:22
bootstrap and bot_config are redundant
kjlubick
2016/08/25 19:33:37
Consolidated to can_get_configs and can_put_config
| |
| 149 can_put_bootstrap_py = acl.is_admin(), | |
| 150 can_get_bot_config_py = acl.is_user(), | |
| 151 can_put_bot_config_py = acl.is_admin(), | |
| 152 can_cancel_task = acl.is_user(), | |
| 153 can_get_bootstrap_token = acl.is_bootstrapper(), | |
| 154 ) | |
| 155 | |
| 156 @gae_ts_mon.instrument_endpoint() | |
| 157 @auth.endpoints_method( | |
| 140 VersionRequest, swarming_rpcs.FileContent, | 158 VersionRequest, swarming_rpcs.FileContent, |
| 141 http_method='GET') | 159 http_method='GET') |
| 142 @auth.require(acl.is_bot_or_user) | 160 @auth.require(acl.is_bot_or_user) |
| 143 def get_bootstrap(self, request): | 161 def get_bootstrap(self, request): |
| 144 """Retrieves the current or a previous version of bootstrap.py.""" | 162 """Retrieves the current or a previous version of bootstrap.py.""" |
| 145 obj = bot_code.get_bootstrap('', '', request.version) | 163 obj = bot_code.get_bootstrap('', '', request.version) |
| 146 if not obj: | 164 if not obj: |
| 147 return swarming_rpcs.FileContent() | 165 return swarming_rpcs.FileContent() |
| 148 return swarming_rpcs.FileContent( | 166 return swarming_rpcs.FileContent( |
| 149 content=obj.content.decode('utf-8'), | 167 content=obj.content.decode('utf-8'), |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 def get_routes(): | 716 def get_routes(): |
| 699 return ( | 717 return ( |
| 700 endpoints_webapp2.api_routes(SwarmingServerService) + | 718 endpoints_webapp2.api_routes(SwarmingServerService) + |
| 701 endpoints_webapp2.api_routes(SwarmingTaskService) + | 719 endpoints_webapp2.api_routes(SwarmingTaskService) + |
| 702 endpoints_webapp2.api_routes(SwarmingTasksService) + | 720 endpoints_webapp2.api_routes(SwarmingTasksService) + |
| 703 endpoints_webapp2.api_routes(SwarmingBotService) + | 721 endpoints_webapp2.api_routes(SwarmingBotService) + |
| 704 endpoints_webapp2.api_routes(SwarmingBotsService) + | 722 endpoints_webapp2.api_routes(SwarmingBotsService) + |
| 705 # components.config endpoints for validation and configuring of luci-config | 723 # components.config endpoints for validation and configuring of luci-config |
| 706 # service URL. | 724 # service URL. |
| 707 endpoints_webapp2.api_routes(config.ConfigApi)) | 725 endpoints_webapp2.api_routes(config.ConfigApi)) |
| OLD | NEW |