octokat

package module
v0.0.0-...-461000c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2013 License: MIT Imports: 10 Imported by: 0

README

Octokat Build Status

Simple Go wrapper for the GitHub API. It's extracted from my other project. The API is inspired by octokit.rb.

GoDoc

http://godoc.org/github.com/jingweno/octokat

Example

Show a user

package main

import "github.com/jingweno/octokat"

func main() {
    client := octokat.NewClient()
    user, err := client.User("jingweno")
    // Do something with user
}

List authorizations

package main

import "github.com/jingweno/octokat"

func main() {
    client := octokat.NewClient().WithLogin("LOGIN", "PASSWORD")
    authorizations, err := client.Authorizations()
    // Do something with authorizations
}

Create a pull request

package main

import "github.com/jingweno/octokat"

func main() {
    client := octokat.NewClient().WithToken("OAUTH_TOKEN")
    repo := octokat.Repo{Name: "octokat", UserName: "jingweno"}
    params := octokat.PullRequestParams{Base: "master", Head: "feature", Title: "A pull request", Body: "A body"}
    pullRequest, err := client.CreatePullRequest(repo, params)
    // Do something with pullRequest
}

Release Notes

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

octokat is released under the MIT license. See LICENSE.md.

Documentation

Index

Constants

View Source
const (
	GitHubAPIURL  string = "https://" + GitHubAPIHost
	GitHubAPIHost string = "api.github.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Url      string `json:"url"`
	Name     string `json:"name"`
	ClientID string `json:"client_id"`
}

type Authorization

type Authorization struct {
	Scopes  []string `json:"scopes"`
	Url     string   `json:"url"`
	App     App      `json:"app"`
	Token   string   `json:"token"`
	Note    string   `json:"note"`
	NoteUrl string   `json:"note_url"`
}

type AuthorizationParams

type AuthorizationParams struct {
	Scopes       []string `json:"scopes"`
	Note         string   `json:"note"`
	NoteUrl      string   `json:"note_url"`
	ClientID     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
}

type Client

type Client struct {
	Login    string
	Password string
	Token    string
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) AuthenticatedUser

func (c *Client) AuthenticatedUser() (*User, error)

func (*Client) Authorizations

func (c *Client) Authorizations() ([]Authorization, error)

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(repo Repo, params PullRequestParams) (*PullRequest, error)

func (*Client) CreatePullRequestForIssue

func (c *Client) CreatePullRequestForIssue(repo Repo, params PullRequestForIssueParams) (*PullRequest, error)

func (*Client) CreateRepository

func (c *Client) CreateRepository(name string, params *Params) (*Repository, error)

func (*Client) CreatedAuthorization

func (c *Client) CreatedAuthorization(params AuthorizationParams) (*Authorization, error)

func (*Client) Fork

func (c *Client) Fork(repo Repo, params *Params) (*Repository, error)

func (*Client) PullRequest

func (c *Client) PullRequest(repo Repo, number string) (*PullRequest, error)

func (*Client) Repository

func (c *Client) Repository(repo Repo) (*Repository, error)

func (*Client) Statuses

func (c *Client) Statuses(repo Repo, sha string) ([]Status, error)

func (*Client) User

func (c *Client) User(login string) (*User, error)

func (*Client) WithLogin

func (c *Client) WithLogin(login, password string) *Client

func (*Client) WithToken

func (c *Client) WithToken(token string) *Client

type Commit

type Commit struct {
	Label string     `json:"label"`
	Ref   string     `json:"ref"`
	Sha   string     `json:"sha"`
	User  User       `json:"user"`
	Repo  Repository `json:"repo"`
}

type Organization

type Organization User

type Params

type Params map[string]interface{}

func (Params) Delete

func (p Params) Delete(key string) interface{}

func (Params) Put

func (p Params) Put(key string, value interface{}) interface{}

func (Params) Size

func (p Params) Size() int

type PullRequest

type PullRequest struct {
	URL               string     `json:"url"`
	Id                int        `json:"id"`
	HTMLURL           string     `json:"html_url"`
	DiffURL           string     `json:"diff_url"`
	PatchURL          string     `json:"patch_url"`
	IssueURL          string     `json:"issue_url"`
	Number            int        `json:"number"`
	State             string     `json:"state"`
	Title             string     `json:"title"`
	User              User       `json:"user"`
	Body              string     `json:"body"`
	CreatedAt         time.Time  `json:"created_at"`
	UpdatedAt         time.Time  `json:"updated_at"`
	ClosedAt          *time.Time `json:"closed_at"`
	MergedAt          *time.Time `json:"merged_at"`
	MergedCommitSha   string     `json:"merged_commit_sha"`
	Assignee          *User      `json:"assignee"`
	CommitsUrl        string     `json:"commits_url"`
	ReviewCommentsUrl string     `json:"review_comments_url"`
	ReviewCommentUrl  string     `json:"review_comment_url"`
	CommentsUrl       string     `json:"comments_url"`
	Head              Commit     `json:"head"`
	Base              Commit     `json:"base"`
	Merged            bool       `json:"merged"`
	MergedBy          User       `json:"merged_by"`
	Comments          int        `json:"comments"`
	ReviewComments    int        `json:"review_comments"`
	Commits           int        `json:"commits"`
	Additions         int        `json:"additions"`
	Deletions         int        `json:"deletions"`
	ChangedFiles      int        `json:"changed_files"`
}

type PullRequestForIssueParams

type PullRequestForIssueParams struct {
	Base  string `json:"base"`
	Head  string `json:"head"`
	Issue string `json:"issue"`
}

type PullRequestParams

type PullRequestParams struct {
	Base  string `json:"base"`
	Head  string `json:"head"`
	Title string `json:"title"`
	Body  string `json:"body"`
}

type Repo

type Repo struct {
	Name     string
	UserName string
}

func (Repo) String

func (r Repo) String() string

type Repository

type Repository struct {
	ID            int           `json:"id"`
	Owner         User          `json:"owner"`
	Name          string        `json:"name"`
	FullName      string        `json:"full_name"`
	Description   string        `json:"description"`
	Private       bool          `json:"private"`
	Fork          bool          `json:"fork"`
	URL           string        `json:"url"`
	HTMLURL       string        `json:"html_url"`
	CloneURL      string        `json:"clone_url"`
	GitURL        string        `json:"git_url"`
	SshURL        string        `json:"ssh_url"`
	SvnURL        string        `json:"svn_url"`
	MirrorURL     string        `json:"mirror_url"`
	Homepage      string        `json:"homepage"`
	Language      string        `json:"language"`
	Forks         int           `json:"forks"`
	ForksCount    int           `json:"forks_count"`
	Watchers      int           `json:"watchers"`
	WatchersCount int           `json:"watchers_count"`
	Size          int           `json:"size"`
	MasterBranch  string        `json:"master_branch"`
	OpenIssues    int           `json:"open_issues"`
	PushedAt      time.Time     `json:"pushed_at"`
	CreatedAt     time.Time     `json:"created_at"`
	UpdatedAt     time.Time     `json:"updated_at"`
	Organization  *Organization `json:"organization"`
	Parent        *Repository   `json:"parent"`
	Source        *Repository   `json:"source"`
	HasIssues     bool          `json:"has_issues"`
	HasWiki       bool          `json:"has_wiki"`
	HasDownloads  bool          `json:"has_downloads"`
}

type Status

type Status struct {
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	State       string    `json:"state"`
	TargetURL   string    `json:"target_url"`
	Description string    `json:"description"`
	ID          int       `json:"id"`
	URL         string    `json:"url"`
	Creator     User      `json:"creator"`
}

type User

type User struct {
	Login       string    `json:"login"`
	ID          int       `json:"id"`
	AvatarURL   string    `json:"avatar_url"`
	GravatarID  string    `json:"gravatar_id"`
	URL         string    `json:"url"`
	Name        string    `json:"name"`
	Company     string    `json:"company"`
	Blog        string    `json:"blog"`
	Location    string    `json:"location"`
	Email       string    `json:"email"`
	Hireable    bool      `json:"hireable"`
	Bio         string    `json:"bio"`
	PublicRepos int       `json:"public_repos"`
	PublicGists int       `json:"jsonpublic_gists"`
	Followers   int       `json:"followers"`
	Following   int       `json:"following"`
	HTMLURL     string    `json:"html_url"`
	CreatedAt   time.Time `json:"created_at"`
	Type        string    `json:"type"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL