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 import os | |
| 9 | 10 |
| 10 from google.appengine.api import datastore_errors | 11 from google.appengine.api import datastore_errors |
| 11 from google.appengine.ext import ndb | 12 from google.appengine.ext import ndb |
| 12 import endpoints | 13 import endpoints |
| 13 import gae_ts_mon | 14 import gae_ts_mon |
| 14 from protorpc import messages | 15 from protorpc import messages |
| 15 from protorpc import message_types | 16 from protorpc import message_types |
| 16 from protorpc import protojson | 17 from protorpc import protojson |
| 17 from protorpc import remote | 18 from protorpc import remote |
| 18 | 19 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 | 127 |
| 127 @swarming_api.api_class(resource_name='server', path='server') | 128 @swarming_api.api_class(resource_name='server', path='server') |
| 128 class SwarmingServerService(remote.Service): | 129 class SwarmingServerService(remote.Service): |
| 129 @gae_ts_mon.instrument_endpoint() | 130 @gae_ts_mon.instrument_endpoint() |
| 130 @auth.endpoints_method( | 131 @auth.endpoints_method( |
| 131 message_types.VoidMessage, swarming_rpcs.ServerDetails, | 132 message_types.VoidMessage, swarming_rpcs.ServerDetails, |
| 132 http_method='GET') | 133 http_method='GET') |
| 133 @auth.require(acl.is_bot_or_user) | 134 @auth.require(acl.is_bot_or_user) |
| 134 def details(self, _request): | 135 def details(self, _request): |
| 135 """Returns information about the server.""" | 136 """Returns information about the server.""" |
| 136 return swarming_rpcs.ServerDetails(server_version=utils.get_app_version()) | 137 host = 'https://' + os.environ['HTTP_HOST'] |
| 138 return swarming_rpcs.ServerDetails( | |
| 139 bot_version = bot_code.get_bot_version(host), | |
| 140 server_version = utils.get_app_version() | |
| 141 ) | |
|
M-A Ruel
2016/09/26 16:36:15
FTR, I'm really not a fan of terminating ) on a ne
kjlubick
2016/09/26 16:50:38
Fixed.
| |
| 137 | 142 |
| 138 @gae_ts_mon.instrument_endpoint() | 143 @gae_ts_mon.instrument_endpoint() |
| 139 @auth.endpoints_method( | 144 @auth.endpoints_method( |
| 145 message_types.VoidMessage, swarming_rpcs.BootstrapToken, | |
| 146 http_method='GET') | |
|
M-A Ruel
2016/09/26 16:36:15
I think this should be a POST, since it's generati
kjlubick
2016/09/26 16:50:38
Done.
| |
| 147 @auth.require(acl.is_bootstrapper) | |
| 148 def token(self, _request): | |
| 149 """Returns a token to bootstrap a new bot.""" | |
| 150 return swarming_rpcs.BootstrapToken( | |
| 151 bootstrap_token = bot_code.generate_bootstrap_token(), | |
| 152 ) | |
| 153 | |
| 154 @gae_ts_mon.instrument_endpoint() | |
| 155 @auth.endpoints_method( | |
| 140 message_types.VoidMessage, swarming_rpcs.ClientPermissions, | 156 message_types.VoidMessage, swarming_rpcs.ClientPermissions, |
| 141 http_method='GET') | 157 http_method='GET') |
| 142 @auth.public | 158 @auth.public |
| 143 def permissions(self, _request): | 159 def permissions(self, _request): |
| 144 """Returns the caller's permissions.""" | 160 """Returns the caller's permissions.""" |
| 145 return swarming_rpcs.ClientPermissions( | 161 return swarming_rpcs.ClientPermissions( |
| 146 delete_bot = acl.is_admin(), | 162 delete_bot = acl.is_admin(), |
| 147 terminate_bot = acl.is_privileged_user(), | 163 terminate_bot = acl.is_privileged_user(), |
| 148 get_configs = acl.is_user(), | 164 get_configs = acl.is_user(), |
| 149 put_configs = acl.is_admin(), | 165 put_configs = acl.is_admin(), |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 def get_routes(): | 731 def get_routes(): |
| 716 return ( | 732 return ( |
| 717 endpoints_webapp2.api_routes(SwarmingServerService) + | 733 endpoints_webapp2.api_routes(SwarmingServerService) + |
| 718 endpoints_webapp2.api_routes(SwarmingTaskService) + | 734 endpoints_webapp2.api_routes(SwarmingTaskService) + |
| 719 endpoints_webapp2.api_routes(SwarmingTasksService) + | 735 endpoints_webapp2.api_routes(SwarmingTasksService) + |
| 720 endpoints_webapp2.api_routes(SwarmingBotService) + | 736 endpoints_webapp2.api_routes(SwarmingBotService) + |
| 721 endpoints_webapp2.api_routes(SwarmingBotsService) + | 737 endpoints_webapp2.api_routes(SwarmingBotsService) + |
| 722 # components.config endpoints for validation and configuring of luci-config | 738 # components.config endpoints for validation and configuring of luci-config |
| 723 # service URL. | 739 # service URL. |
| 724 endpoints_webapp2.api_routes(config.ConfigApi)) | 740 endpoints_webapp2.api_routes(config.ConfigApi)) |
| OLD | NEW |