Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 datetime | |
| 6 import functools | 5 import functools |
| 7 import json | 6 import json |
| 8 import logging | 7 import logging |
| 9 | 8 |
| 10 from google.appengine.ext import ndb | 9 from google.appengine.ext import ndb |
| 11 | 10 |
| 12 from components import auth | 11 from components import auth |
| 13 from components import utils | 12 from components import utils |
| 14 from protorpc import messages | 13 from protorpc import messages |
| 15 from protorpc import message_types | 14 from protorpc import message_types |
| 16 from protorpc import remote | 15 from protorpc import remote |
| 16 import gae_ts_mon | |
| 17 | 17 |
| 18 import endpoints | 18 import endpoints |
| 19 import errors | 19 import errors |
| 20 import model | 20 import model |
| 21 import service | 21 import service |
| 22 | 22 |
| 23 | 23 |
| 24 class ErrorReason(messages.Enum): | 24 class ErrorReason(messages.Enum): |
| 25 LEASE_EXPIRED = 1 | 25 LEASE_EXPIRED = 1 |
| 26 CANNOT_LEASE_BUILD = 2 | 26 CANNOT_LEASE_BUILD = 2 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 165 |
| 166 | 166 |
| 167 def buildbucket_api_method( | 167 def buildbucket_api_method( |
| 168 request_message_class, response_message_class, **kwargs): | 168 request_message_class, response_message_class, **kwargs): |
| 169 """Extends auth.endpoints_method by converting service errors.""" | 169 """Extends auth.endpoints_method by converting service errors.""" |
| 170 | 170 |
| 171 endpoints_decorator = auth.endpoints_method( | 171 endpoints_decorator = auth.endpoints_method( |
| 172 request_message_class, response_message_class, **kwargs) | 172 request_message_class, response_message_class, **kwargs) |
| 173 | 173 |
| 174 def decorator(fn): | 174 def decorator(fn): |
| 175 def ts_mon_time(): | |
| 176 return utils.datetime_to_timestamp(utils.utcnow()) / 1000000.0 | |
| 177 fn = gae_ts_mon.instrument_endpoint(time_fn=ts_mon_time)(fn) | |
|
Sergey Berezin
2016/04/18 22:45:16
You shouldn't need to specify time here - it's onl
| |
| 175 fn = catch_errors(fn, response_message_class) | 178 fn = catch_errors(fn, response_message_class) |
| 176 fn = endpoints_decorator(fn) | 179 fn = endpoints_decorator(fn) |
| 177 fn = ndb.toplevel(fn) | 180 fn = ndb.toplevel(fn) |
| 178 return fn | 181 return fn |
| 179 | 182 |
| 180 return decorator | 183 return decorator |
| 181 | 184 |
| 182 | 185 |
| 183 def parse_json(json_data, param_name): | 186 def parse_json(json_data, param_name): |
| 184 if not json_data: | 187 if not json_data: |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 ), | 610 ), |
| 608 DeleteManyBuildsResponse, | 611 DeleteManyBuildsResponse, |
| 609 path='bucket/{bucket}/delete', http_method='POST') | 612 path='bucket/{bucket}/delete', http_method='POST') |
| 610 @auth.public | 613 @auth.public |
| 611 def delete_many_builds(self, request): | 614 def delete_many_builds(self, request): |
| 612 """Deletes scheduled or started builds in a bucket.""" | 615 """Deletes scheduled or started builds in a bucket.""" |
| 613 service.delete_many_builds( | 616 service.delete_many_builds( |
| 614 request.bucket, request.status, | 617 request.bucket, request.status, |
| 615 tags=request.tag[:], created_by=request.created_by) | 618 tags=request.tag[:], created_by=request.created_by) |
| 616 return self.DeleteManyBuildsResponse() | 619 return self.DeleteManyBuildsResponse() |
| OLD | NEW |