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/findit/common/pubsub_util.py

Issue 1852383002: [Findit] Integrate with Fracas through Pub/Sub. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Just rebase. Created 4 years, 8 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 | « appengine/findit/common/constants.py ('k') | appengine/findit/crash-backend-fracas.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import base64
6
7 import httplib2
8 from googleapiclient import discovery
9 from oauth2client import client as oauth2client
10
11
12 PUBSUB_SCOPES = [
13 'https://www.googleapis.com/auth/pubsub',
14 ]
15
16
17 def CreatePubSubClient(): # pragma: no cover.
18 credentials = oauth2client.GoogleCredentials.get_application_default()
19 if credentials.create_scoped_required():
20 credentials = credentials.create_scoped(PUBSUB_SCOPES)
21 http = httplib2.Http()
22 credentials.authorize(http)
23 return discovery.build('pubsub', 'v1', http=http)
24
25
26 def PublishMessagesToTopic(messages_data, topic): # pragma: no cover.
27 messages = []
28 for message_data in messages_data:
29 messages.append({'data': base64.b64encode(message_data)})
30 return CreatePubSubClient().projects().topics().publish(
31 topic=topic, body={'messages': messages}).execute()
OLDNEW
« no previous file with comments | « appengine/findit/common/constants.py ('k') | appengine/findit/crash-backend-fracas.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698