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

Side by Side Diff: scripts/master/buildbucket/client.py

Issue 968053003: BuildBucket-based build triggering (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: re stip Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « scripts/master/buildbucket/__init__.py ('k') | scripts/master/buildbucket/trigger.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 Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """This file contains buildbucket service client.""" 5 """This file contains buildbucket service client."""
6 6
7 import json 7 import json
8 import logging 8 import logging
9 import sys 9 import sys
10 10
11 from master import auth 11 from master import auth
12 from master.buildbucket import common 12 from master.buildbucket import common
13 from master.deferred_resource import DeferredResource 13 from master.deferred_resource import DeferredResource
14 14
15 from oauth2client.client import SignedJwtAssertionCredentials 15 from oauth2client.client import SignedJwtAssertionCredentials
16 import httplib2 16 import httplib2
17 import apiclient 17 import apiclient
18 18
19 19
20 BUILDBUCKET_HOSTNAME_PRODUCTION = 'cr-buildbucket.appspot.com' 20 BUILDBUCKET_HOSTNAME_PRODUCTION = 'cr-buildbucket.appspot.com'
21 BUILDBUCKET_HOSTNAME_TESTING = 'cr-buildbucket-test.appspot.com' 21 BUILDBUCKET_HOSTNAME_TESTING = 'cr-buildbucket-test.appspot.com'
22 22
23 23
24 def buildbucket_api_discovery_url(hostname=None): 24 def buildbucket_api_discovery_url(hostname=None):
25 return ( 25 return (
26 'https://%s/_ah/api/discovery/v1/apis/{api}/{apiVersion}/rest' % hostname) 26 'https://%s/_ah/api/discovery/v1/apis/{api}/{apiVersion}/rest' % hostname)
27 27
28
29 def get_default_buildbucket_hostname(master):
30 return (
31 BUILDBUCKET_HOSTNAME_PRODUCTION if master.is_production_host
32 else BUILDBUCKET_HOSTNAME_TESTING)
33
34
28 def create_buildbucket_service( 35 def create_buildbucket_service(
29 master, hostname=None, verbose=None): 36 master, hostname=None, verbose=None):
30 """Asynchronously creates buildbucket API resource. 37 """Asynchronously creates buildbucket API resource.
31 38
32 Returns: 39 Returns:
33 A DeferredResource as Deferred. 40 A DeferredResource as Deferred.
34 """ 41 """
35 hostname = hostname or ( 42 hostname = hostname or get_default_buildbucket_hostname(master)
36 BUILDBUCKET_HOSTNAME_PRODUCTION if master.is_production_host
37 else BUILDBUCKET_HOSTNAME_TESTING)
38 return DeferredResource.build( 43 return DeferredResource.build(
39 'buildbucket', 44 'buildbucket',
40 'v1', 45 'v1',
41 http_factory=lambda: auth.create_http(master), 46 http_factory=lambda: auth.create_http(master),
42 discoveryServiceUrl=buildbucket_api_discovery_url(hostname), 47 discoveryServiceUrl=buildbucket_api_discovery_url(hostname),
43 verbose=verbose or False, 48 verbose=verbose or False,
44 log_prefix=common.LOG_PREFIX, 49 log_prefix=common.LOG_PREFIX,
45 ) 50 )
OLDNEW
« no previous file with comments | « scripts/master/buildbucket/__init__.py ('k') | scripts/master/buildbucket/trigger.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698