mirror of https://github.com/matrix-org/go-neb.git
Browse Source
List possible GH repos on /getSession
List possible GH repos on /getSession
Add an Info() method to pull out info about an auth session.pull/29/head
Kegan Dougal
9 years ago
6 changed files with 91 additions and 19 deletions
-
4src/github.com/matrix-org/go-neb/api.go
-
29src/github.com/matrix-org/go-neb/realms/github/github.go
-
5src/github.com/matrix-org/go-neb/realms/jira/jira.go
-
51src/github.com/matrix-org/go-neb/services/github/client/client.go
-
20src/github.com/matrix-org/go-neb/services/github/github.go
-
1src/github.com/matrix-org/go-neb/types/types.go
@ -0,0 +1,51 @@ |
|||||
|
package client |
||||
|
|
||||
|
import ( |
||||
|
"github.com/google/go-github/github" |
||||
|
"golang.org/x/oauth2" |
||||
|
) |
||||
|
|
||||
|
// TrimmedRepository represents a cut-down version of github.Repository with only the keys the end-user is
|
||||
|
// likely to want.
|
||||
|
type TrimmedRepository struct { |
||||
|
Name *string `json:"name"` |
||||
|
Description *string `json:"description"` |
||||
|
Private *bool `json:"private"` |
||||
|
HTMLURL *string `json:"html_url"` |
||||
|
CreatedAt *github.Timestamp `json:"created_at"` |
||||
|
UpdatedAt *github.Timestamp `json:"updated_at"` |
||||
|
PushedAt *github.Timestamp `json:"pushed_at"` |
||||
|
Fork *bool `json:"fork"` |
||||
|
FullName *string `json:"full_name"` |
||||
|
Permissions *map[string]bool `json:"permissions"` |
||||
|
} |
||||
|
|
||||
|
// TrimRepository trims a github repo into important fields only.
|
||||
|
func TrimRepository(repo *github.Repository) TrimmedRepository { |
||||
|
return TrimmedRepository{ |
||||
|
Name: repo.Name, |
||||
|
Description: repo.Description, |
||||
|
Private: repo.Private, |
||||
|
HTMLURL: repo.HTMLURL, |
||||
|
CreatedAt: repo.CreatedAt, |
||||
|
UpdatedAt: repo.UpdatedAt, |
||||
|
PushedAt: repo.PushedAt, |
||||
|
Permissions: repo.Permissions, |
||||
|
Fork: repo.Fork, |
||||
|
FullName: repo.FullName, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// New returns a github Client which can perform Github API operations.
|
||||
|
// If `token` is empty, a non-authenticated client will be created. This should be
|
||||
|
// used sparingly where possible as you only get 60 requests/hour like that (IP locked).
|
||||
|
func New(token string) *github.Client { |
||||
|
var tokenSource oauth2.TokenSource |
||||
|
if token != "" { |
||||
|
tokenSource = oauth2.StaticTokenSource( |
||||
|
&oauth2.Token{AccessToken: token}, |
||||
|
) |
||||
|
} |
||||
|
httpCli := oauth2.NewClient(oauth2.NoContext, tokenSource) |
||||
|
return github.NewClient(httpCli) |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue