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

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

Issue 2272193004: Add endpoint for permissions (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@migrate-botlist
Patch Set: Consolidate permissions Created 4 years, 3 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
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 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
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(
M-A Ruel 2016/08/25 19:49:47 Server is kind of odd, it's ClientPermissions ?
kjlubick 2016/08/25 20:21:02 Done.
146 can_delete_bot = acl.is_admin(),
M-A Ruel 2016/08/25 19:49:47 Can we remove the "can_" prefixes? :)
kjlubick 2016/08/25 20:21:02 Done.
147 can_terminate_bot = acl.is_privileged_user(),
148 can_get_configs = acl.is_user(),
149 can_put_configs = acl.is_admin(),
150 can_cancel_task = acl.is_user(),
151 can_get_bootstrap_token = acl.is_bootstrapper(),
152 )
153
154 @gae_ts_mon.instrument_endpoint()
155 @auth.endpoints_method(
140 VersionRequest, swarming_rpcs.FileContent, 156 VersionRequest, swarming_rpcs.FileContent,
141 http_method='GET') 157 http_method='GET')
142 @auth.require(acl.is_bot_or_user) 158 @auth.require(acl.is_bot_or_user)
143 def get_bootstrap(self, request): 159 def get_bootstrap(self, request):
144 """Retrieves the current or a previous version of bootstrap.py.""" 160 """Retrieves the current or a previous version of bootstrap.py."""
145 obj = bot_code.get_bootstrap('', '', request.version) 161 obj = bot_code.get_bootstrap('', '', request.version)
146 if not obj: 162 if not obj:
147 return swarming_rpcs.FileContent() 163 return swarming_rpcs.FileContent()
148 return swarming_rpcs.FileContent( 164 return swarming_rpcs.FileContent(
149 content=obj.content.decode('utf-8'), 165 content=obj.content.decode('utf-8'),
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 def get_routes(): 714 def get_routes():
699 return ( 715 return (
700 endpoints_webapp2.api_routes(SwarmingServerService) + 716 endpoints_webapp2.api_routes(SwarmingServerService) +
701 endpoints_webapp2.api_routes(SwarmingTaskService) + 717 endpoints_webapp2.api_routes(SwarmingTaskService) +
702 endpoints_webapp2.api_routes(SwarmingTasksService) + 718 endpoints_webapp2.api_routes(SwarmingTasksService) +
703 endpoints_webapp2.api_routes(SwarmingBotService) + 719 endpoints_webapp2.api_routes(SwarmingBotService) +
704 endpoints_webapp2.api_routes(SwarmingBotsService) + 720 endpoints_webapp2.api_routes(SwarmingBotsService) +
705 # components.config endpoints for validation and configuring of luci-config 721 # components.config endpoints for validation and configuring of luci-config
706 # service URL. 722 # service URL.
707 endpoints_webapp2.api_routes(config.ConfigApi)) 723 endpoints_webapp2.api_routes(config.ConfigApi))
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints_test.py » ('j') | appengine/swarming/swarming_rpcs.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698