OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 /* | 5 /* |
6 Utilities for interacting with the GoogleCode issue tracker. | 6 Utilities for interacting with the GoogleCode issue tracker. |
7 | 7 |
8 Example usage: | 8 Example usage: |
9 issueTracker := issue_tracker.MakeIssueTraker(myOAuthConfigFile) | 9 issueTracker := issue_tracker.MakeIssueTraker(myOAuthConfigFile) |
10 authURL := issueTracker.MakeAuthRequestURL() | 10 authURL := issueTracker.MakeAuthRequestURL() |
11 // Visit the authURL to obtain an authorization code. | 11 // Visit the authURL to obtain an authorization code. |
12 issueTracker.UpgradeCode(code) | 12 issueTracker.UpgradeCode(code) |
13 // Now issueTracker can be used to retrieve and edit issues. | 13 // Now issueTracker can be used to retrieve and edit issues. |
14 */ | 14 */ |
15 package issue_tracker | 15 package issue_tracker |
16 | 16 |
17 import ( | 17 import ( |
18 "bytes" | 18 "bytes" |
19 "code.google.com/p/goauth2/oauth" | |
20 "encoding/json" | 19 "encoding/json" |
21 "fmt" | 20 "fmt" |
22 "io/ioutil" | 21 "io/ioutil" |
23 "net/http" | 22 "net/http" |
24 "net/url" | 23 "net/url" |
25 "strconv" | 24 "strconv" |
26 "strings" | 25 "strings" |
| 26 |
| 27 "code.google.com/p/goauth2/oauth" |
27 ) | 28 ) |
28 | 29 |
29 // BugPriorities are the possible values for "Priority-*" labels for issues. | 30 // BugPriorities are the possible values for "Priority-*" labels for issues. |
30 var BugPriorities = []string{"Critical", "High", "Medium", "Low", "Never"} | 31 var BugPriorities = []string{"Critical", "High", "Medium", "Low", "Never"} |
31 | 32 |
32 var apiScope = []string{ | 33 var apiScope = []string{ |
33 "https://www.googleapis.com/auth/projecthosting", | 34 "https://www.googleapis.com/auth/projecthosting", |
34 "https://www.googleapis.com/auth/userinfo.email", | 35 "https://www.googleapis.com/auth/userinfo.email", |
35 } | 36 } |
36 | 37 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 return fmt.Errorf(errFmt, err) | 295 return fmt.Errorf(errFmt, err) |
295 } | 296 } |
296 defer resp.Body.Close() | 297 defer resp.Body.Close() |
297 body, _ := ioutil.ReadAll(resp.Body) | 298 body, _ := ioutil.ReadAll(resp.Body) |
298 if resp.StatusCode != http.StatusOK { | 299 if resp.StatusCode != http.StatusOK { |
299 return fmt.Errorf(errFmt, fmt.Sprintf( | 300 return fmt.Errorf(errFmt, fmt.Sprintf( |
300 "Issue tracker returned code %d:%v", resp.StatusCode, st
ring(body))) | 301 "Issue tracker returned code %d:%v", resp.StatusCode, st
ring(body))) |
301 } | 302 } |
302 return nil | 303 return nil |
303 } | 304 } |
OLD | NEW |