Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: appengine/swarming/handlers_endpoints.py

Issue 2374463002: Add API for bootstrap and bot_code version (Closed) Base URL: git@github.com:luci/luci-py@master
Patch Set: typo Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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))
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698