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

Side by Side Diff: dashboard/dashboard/services/issue_tracker_service.py

Issue 2706813003: Add new endpoint to get bug details as JSON. (Closed)
Patch Set: Added polymer ui Created 3 years, 10 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 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 """Provides a layer of abstraction for the issue tracker API.""" 5 """Provides a layer of abstraction for the issue tracker API."""
6 6
7 import json 7 import json
8 import logging 8 import logging
9 9
10 from apiclient import discovery 10 from apiclient import discovery
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 projectId='chromium', 163 projectId='chromium',
164 sendEmail=True, 164 sendEmail=True,
165 body=body) 165 body=body)
166 logging.info('Making create issue request with body %s', body) 166 logging.info('Making create issue request with body %s', body)
167 response = self._ExecuteRequest(request) 167 response = self._ExecuteRequest(request)
168 if response and 'id' in response: 168 if response and 'id' in response:
169 return response['id'] 169 return response['id']
170 logging.error('Failed to create new bug; response %s', response) 170 logging.error('Failed to create new bug; response %s', response)
171 return None 171 return None
172 172
173 def GetIssueComments(self, bug_id):
174 """Gets all the comments for the given bug.
175
176 Args:
177 bug_id: Bug ID of the issue to update.
178
179 Returns:
180 A list of comments
181 """
182 if not bug_id or bug_id < 0:
183 return None
184 response = self._MakeGetCommentsRequest(bug_id)
185 logging.info(response)
186 return [{
187 'author': r['author'].get('name'),
188 'content': r['content'],
189 'published': r['published']
190 } for r in response.get('items')]
191
173 def GetLastBugCommentsAndTimestamp(self, bug_id): 192 def GetLastBugCommentsAndTimestamp(self, bug_id):
174 """Gets last updated comments and timestamp in the given bug. 193 """Gets last updated comments and timestamp in the given bug.
175 194
176 Args: 195 Args:
177 bug_id: Bug ID of the issue to update. 196 bug_id: Bug ID of the issue to update.
178 197
179 Returns: 198 Returns:
180 A dictionary with last comment and timestamp, or None on failure. 199 A dictionary with last comment and timestamp, or None on failure.
181 """ 200 """
182 if not bug_id or bug_id < 0: 201 if not bug_id or bug_id < 0:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if 'cc' in request_body['updates']: 251 if 'cc' in request_body['updates']:
233 del request_body['updates']['cc'] 252 del request_body['updates']['cc']
234 253
235 254
236 def _GetErrorReason(request_error): 255 def _GetErrorReason(request_error):
237 if request_error.resp.get('content-type', '').startswith('application/json'): 256 if request_error.resp.get('content-type', '').startswith('application/json'):
238 error_json = json.loads(request_error.content).get('error') 257 error_json = json.loads(request_error.content).get('error')
239 if error_json: 258 if error_json:
240 return error_json.get('message') 259 return error_json.get('message')
241 return None 260 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698