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

Side by Side Diff: appengine/cr-buildbucket/api.py

Issue 2005333002: swarmbucket: add get_builders api (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: fix tests Created 4 years, 7 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/cr-buildbucket/main.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import functools 5 import functools
6 import json 6 import json
7 import logging 7 import logging
8 8
9 from google.appengine.ext import ndb 9 from google.appengine.ext import ndb
10 from protorpc import messages
11 from protorpc import message_types
12 from protorpc import remote
10 13
11 from components import auth 14 from components import auth
12 from components import utils 15 from components import utils
13 from protorpc import messages
14 from protorpc import message_types
15 from protorpc import remote
16 import gae_ts_mon 16 import gae_ts_mon
17 17
18 import acl 18 import acl
19 import config 19 import config
20 import endpoints 20 import endpoints
21 import errors 21 import errors
22 import model 22 import model
23 import service 23 import service
24 24
25 25
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 logging.warning( 169 logging.warning(
170 'Authorization error.\n%s\nPeer: %s\nIP: %s', 170 'Authorization error.\n%s\nPeer: %s\nIP: %s',
171 ex.message, auth.get_peer_identity().to_bytes(), 171 ex.message, auth.get_peer_identity().to_bytes(),
172 svc.request_state.remote_address) 172 svc.request_state.remote_address)
173 raise endpoints.ForbiddenException(ex.message) 173 raise endpoints.ForbiddenException(ex.message)
174 return decorated 174 return decorated
175 175
176 176
177 def buildbucket_api_method( 177 def buildbucket_api_method(
178 request_message_class, response_message_class, **kwargs): 178 request_message_class, response_message_class, **kwargs):
179 """Extends auth.endpoints_method by converting service errors.""" 179 """Defines a buildbucket API method."""
180 180
181 endpoints_decorator = auth.endpoints_method( 181 endpoints_decorator = auth.endpoints_method(
182 request_message_class, response_message_class, **kwargs) 182 request_message_class, response_message_class, **kwargs)
183 183
184 def decorator(fn): 184 def decorator(fn):
185 fn = catch_errors(fn, response_message_class) 185 fn = catch_errors(fn, response_message_class)
186 fn = endpoints_decorator(fn) 186 fn = endpoints_decorator(fn)
187 fn = ndb.toplevel(fn) 187 fn = ndb.toplevel(fn)
188 def ts_mon_time(): 188 def ts_mon_time():
189 return utils.datetime_to_timestamp(utils.utcnow()) / 1000000.0 189 return utils.datetime_to_timestamp(utils.utcnow()) / 1000000.0
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 bucket = config.Bucket.get_by_id(request.bucket) 645 bucket = config.Bucket.get_by_id(request.bucket)
646 if not bucket: 646 if not bucket:
647 raise endpoints.NotFoundException('bucket %s not found' % request.bucket) 647 raise endpoints.NotFoundException('bucket %s not found' % request.bucket)
648 return BucketMessage( 648 return BucketMessage(
649 name=request.bucket, 649 name=request.bucket,
650 project_id=bucket.project_id, 650 project_id=bucket.project_id,
651 config_file_content=bucket.config_content, 651 config_file_content=bucket.config_content,
652 config_file_rev=bucket.revision, 652 config_file_rev=bucket.revision,
653 config_file_url=config.get_buildbucket_cfg_url(bucket.project_id), 653 config_file_url=config.get_buildbucket_cfg_url(bucket.project_id),
654 ) 654 )
OLDNEW
« no previous file with comments | « no previous file | appengine/cr-buildbucket/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698