octokit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2013 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RepositoryURL       = Hyperlink("/repos/{owner}/{repo}")
	ForksURL            = Hyperlink("/repos/{owner}/{repo}/forks")
	UserRepositoriesURL = Hyperlink("/user/repos")
	OrgRepositoriesURL  = Hyperlink("/orgs/{org}/repos")
)
View Source
var (
	CurrentUserURL = Hyperlink("/user")
	UserURL        = Hyperlink("/users{/user}{?since}")
)
View Source
var (
	AuthorizationsURL = Hyperlink("/authorizations{/auth_id}")
)
View Source
var (
	PullRequestsURL = Hyperlink("/repos/{owner}/{repo}/pulls{/number}")
)
View Source
var (
	ReleasesURL = Hyperlink("/repos/{owner}/{repo}/releases{/id}")
)
View Source
var (
	RepoIssuesURL = Hyperlink("/repos/{owner}/{repo}/issues{/number}")
)
View Source
var (
	RootURL = Hyperlink("/")
)
View Source
var (
	StatusesURL = Hyperlink("/repos/{owner}/{repo}/statuses/{ref}")
)

Functions

func NewResponseError

func NewResponseError(resp *sawyer.Response) (err error)

Types

type App

type App struct {
	*hypermedia.HALResource

	ClientID string `json:"client_id,omitempty"`
	URL      string `json:"url,omitempty"`
	Name     string `json:"name,omitempty"`
}

type Asset

type Asset struct {
	ID            int        `json:"id,omitempty"`
	Name          string     `json:"name,omitempty"`
	Label         string     `json:"label,omitempty"`
	ContentType   string     `json:"content_type,omitempty"`
	State         string     `json:"state,omitempty"`
	Size          int        `json:"size,omitempty"`
	DownloadCount int        `json:"download_count,omitempty"`
	URL           string     `json:"url,omitempty"`
	CreatedAt     *time.Time `json:"created_at,omitempty"`
	UpdatedAt     *time.Time `json:"updated_at,omitempty"`
}

type AuthMethod

type AuthMethod interface {
	fmt.Stringer
}

See http://developer.github.com/v3/auth/

type Authorization

type Authorization struct {
	*hypermedia.HALResource

	ID        int       `json:"id,omitempty"`
	URL       string    `json:"url,omitempty"`
	App       App       `json:"app,omitempty"`
	Token     string    `json:"token,omitempty"`
	Note      string    `json:"note,omitempty"`
	NoteURL   string    `json:"note_url,omitempty"`
	Scopes    []string  `json:"scopes,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type AuthorizationParams

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

type AuthorizationsService

type AuthorizationsService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*AuthorizationsService) Create

func (a *AuthorizationsService) Create(params interface{}) (auth *Authorization, result *Result)

func (*AuthorizationsService) Get

func (a *AuthorizationsService) Get() (auth *Authorization, result *Result)

func (*AuthorizationsService) GetAll

func (a *AuthorizationsService) GetAll() (auths []Authorization, result *Result)

type BasicAuth

type BasicAuth struct {
	Login           string
	Password        string
	OneTimePassword string // for two-factor authentication
}

func (BasicAuth) String

func (b BasicAuth) String() string

type Client

type Client struct {
	UserAgent  string
	AuthMethod AuthMethod
	// contains filtered or unexported fields
}

func NewClient

func NewClient(authMethod AuthMethod) *Client

func NewClientWith

func NewClientWith(baseURL string, httpClient *http.Client, authMethod AuthMethod) *Client

func (*Client) Authorizations

func (c *Client) Authorizations(link *Hyperlink, m M) (auths *AuthorizationsService, err error)

Create a AuthorizationsService with the base Hyperlink and the params M to expand the Hyperlink If no Hyperlink is passed in, it will use AuthorizationsURL.

func (*Client) Delete

func (c *Client) Delete(url *url.URL, output interface{}) (result *Result)

func (*Client) Get

func (c *Client) Get(url *url.URL, output interface{}) (result *Result)

func (*Client) Head

func (c *Client) Head(url *url.URL, output interface{}) (result *Result)

func (*Client) Issues

func (c *Client) Issues(link *Hyperlink, m M) (issues *IssuesService, err error)

Create a IssuesService with the base Hyperlink and the params M to expand the Hyperlink If no Hyperlink is passed in, it will use RepoIssuesURL.

func (*Client) NewRequest

func (c *Client) NewRequest(urlStr string) (req *Request, err error)

func (*Client) Post

func (c *Client) Post(url *url.URL, input interface{}, output interface{}) (result *Result)

func (*Client) PullRequests

func (c *Client) PullRequests(link *Hyperlink, m M) (pullRequests *PullRequestsService, err error)

Create a PullRequestsService with the base Hyperlink and the params M to expand the Hyperlink If no Hyperlink is passed in, it will use PullRequestsHyperlink.

func (*Client) Put

func (c *Client) Put(url *url.URL, input interface{}, output interface{}) (result *Result)

func (*Client) Releases

func (c *Client) Releases(link *Hyperlink, m M) (releases *ReleasesService, err error)

Create a ReleasesService with the base Hyperlink and the params M to expand the Hyperlink If no Hyperlink is passed in, it will use ReleasesURL.

func (*Client) Repositories

func (c *Client) Repositories(link *Hyperlink, m M) (repos *RepositoriesService, err error)

func (*Client) Root

func (c *Client) Root(link *Hyperlink) (root *RootService, err error)

Create a RooService with the base Hyperlink If no Hyperlink is passed in, it will use RootHyperlink.

func (*Client) Statuses

func (c *Client) Statuses(link *Hyperlink, m M) (statuses *StatusesService, err error)

Create a StatusesService with the base Hyperlink and the params M to expand the Hyperlink If no Hyperlink is passed in, it will use StatusesURL.

func (*Client) Users

func (c *Client) Users(link *Hyperlink, m M) (users *UsersService, err error)

Create a UsersService with the base Hyperlink and the params M to expand the Hyperlink If no Hyperlink is passed in, it will use CurrentUserHyperlink.

type Commit

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

type ErrorObject

type ErrorObject struct {
	Resource string `json:"resource,omitempty"`
	Code     string `json:"code,omitempty"`
	Field    string `json:"field,omitempty"`
	Message  string `json:"message,omitempty"`
}

func (*ErrorObject) Error

func (e *ErrorObject) Error() string
type Hyperlink string

func (*Hyperlink) Expand

func (l *Hyperlink) Expand(m M) (u *url.URL, err error)

type Issue

type Issue struct {
	*hypermedia.HALResource

	URL     string `json:"url,omitempty,omitempty"`
	HTMLURL string `json:"html_url,omitempty,omitempty"`
	Number  int    `json:"number,omitempty"`
	State   string `json:"state,omitempty"`
	Title   string `json:"title,omitempty"`
	Body    string `json:"body,omitempty"`
	User    User   `json:"user,omitempty"`
	Labels  []struct {
		URL   string `json:"url,omitempty"`
		Name  string `json:"name,omitempty"`
		Color string `json:"color,omitempty"`
	}
	Assignee  User `json:"assignee,omitempty"`
	Milestone struct {
		URL          string     `json:"url,omitempty"`
		Number       int        `json:"number,omitempty"`
		State        string     `json:"state,omitempty"`
		Title        string     `json:"title,omitempty"`
		Description  string     `json:"description,omitempty"`
		Creator      User       `json:"creator,omitempty"`
		OpenIssues   int        `json:"open_issues,omitempty"`
		ClosedIssues int        `json:"closed_issues,omitempty"`
		CreatedAt    time.Time  `json:"created_at,omitempty"`
		DueOn        *time.Time `json:"due_on,omitempty"`
	}
	Comments    int `json:"comments,omitempty"`
	PullRequest struct {
		HTMLURL  string `json:"html_url,omitempty"`
		DiffURL  string `json:"diff_url,omitempty"`
		PatchURL string `json:"patch_url,omitempty"`
	} `json:"pull_request,omitempty"`
	CreatedAt time.Time  `json:"created_at,omitempty"`
	ClosedAt  *time.Time `json:"closed_at,omitempty"`
	UpdatedAt time.Time  `json:"updated_at,omitempty"`
}

type IssuesService

type IssuesService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*IssuesService) Get

func (i *IssuesService) Get() (issue *Issue, result *Result)

func (*IssuesService) GetAll

func (i *IssuesService) GetAll() (issues []Issue, result *Result)

type M

type M map[string]interface{}

type Organization

type Organization struct {
	AvatarURL        string `json:"avatar_url,omitempty"`
	PublicMembersURL string `json:"public_member_url,omitempty"`
	MembersURL       string `json:"members_url,omitempty"`
	EventsURL        string `json:"events_url,omitempty"`
	ReposURL         string `json:"repos_url,omitempty"`
	URL              string `json:"url,omitempty"`
	ID               int    `json:"id,omitempty"`
	Login            string `json:"login,omitempty"`
}

type PullRequest

type PullRequest struct {
	*hypermedia.HALResource

	URL               string     `json:"url,omitempty"`
	ID                int        `json:"id,omitempty"`
	HTMLURL           string     `json:"html_url,omitempty"`
	DiffURL           string     `json:"diff_url,omitempty"`
	PatchURL          string     `json:"patch_url,omitempty"`
	IssueURL          string     `json:"issue_url,omitempty"`
	Number            int        `json:"number,omitempty"`
	State             string     `json:"state,omitempty"`
	Title             string     `json:"title,omitempty"`
	User              User       `json:"user,omitempty"`
	Body              string     `json:"body,omitempty"`
	CreatedAt         time.Time  `json:"created_at,omitempty"`
	UpdatedAt         time.Time  `json:"updated_at,omitempty"`
	ClosedAt          *time.Time `json:"closed_at,omitempty"`
	MergedAt          *time.Time `json:"merged_at,omitempty"`
	MergeCommitSha    string     `json:"merge_commit_sha,omitempty"`
	Assignee          *User      `json:"assignee,omitempty"`
	CommitsURL        string     `json:"commits_url,omitempty"`
	ReviewCommentsURL string     `json:"review_comments_url,omitempty"`
	ReviewCommentURL  string     `json:"review_comment_url,omitempty"`
	CommentsURL       string     `json:"comments_url,omitempty"`
	Head              Commit     `json:"head,omitempty"`
	Base              Commit     `json:"base,omitempty"`
	Merged            bool       `json:"merged,omitempty"`
	MergedBy          User       `json:"merged_by,omitempty"`
	Comments          int        `json:"comments,omitempty"`
	ReviewComments    int        `json:"review_comments,omitempty"`
	Commits           int        `json:"commits,omitempty"`
	Additions         int        `json:"additions,omitempty"`
	Deletions         int        `json:"deletions,omitempty"`
	ChangedFiles      int        `json:"changed_files,omitempty"`
}

type PullRequestForIssueParams

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

type PullRequestParams

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

type PullRequestsService

type PullRequestsService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*PullRequestsService) Create

func (p *PullRequestsService) Create(params interface{}) (pull *PullRequest, result *Result)

func (*PullRequestsService) Get

func (p *PullRequestsService) Get() (pull *PullRequest, result *Result)

func (*PullRequestsService) GetAll

func (p *PullRequestsService) GetAll() (pulls []PullRequest, result *Result)

type Release

type Release struct {
	*hypermedia.HALResource

	ID              int        `json:"id,omitempty"`
	URL             string     `json:"url,omitempty"`
	HTMLURL         string     `json:"html_url,omitempty"`
	AssetsURL       string     `json:"assets_url,omitempty"`
	UploadURL       string     `json:"upload_url,omitempty"`
	TagName         string     `json:"tag_name,omitempty"`
	TargetCommitish string     `json:"target_commitish,omitempty"`
	Name            string     `json:"name,omitempty"`
	Body            string     `json:"body,omitempty"`
	Draft           bool       `json:"draft,omitempty"`
	Prerelease      bool       `json:"prerelease,omitempty"`
	CreatedAt       *time.Time `json:"created_at,omitempty"`
	PublishedAt     *time.Time `json:"published_at,omitempty"`
	Assets          []Asset    `json:"assets,omitempty"`
}

type ReleaseParams

type ReleaseParams struct {
	TagName         string `json:"tag_name,omitempty"`
	TargetCommitish string `json:"target_commitish,omitempty"`
	Name            string `json:"name,omitempty"`
	Body            string `json:"body,omitempty"`
	Draft           bool   `json:"draft,omitempty"`
	Prerelease      bool   `json:"prerelease,omitempty"`
}

type ReleasesService

type ReleasesService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*ReleasesService) Create

func (r *ReleasesService) Create(params interface{}) (release *Release, result *Result)

func (*ReleasesService) GetAll

func (r *ReleasesService) GetAll() (releases []Release, result *Result)

type RepositoriesService

type RepositoriesService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*RepositoriesService) Create

func (r *RepositoriesService) Create(params interface{}) (repo *Repository, result *Result)

func (*RepositoriesService) Get

func (r *RepositoriesService) Get() (repo *Repository, result *Result)

func (*RepositoriesService) GetAll

func (r *RepositoriesService) GetAll() (repos []Repository, result *Result)

type Repository

type Repository struct {
	*hypermedia.HALResource

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

type Request

type Request struct {
	// contains filtered or unexported fields
}

func (*Request) Delete

func (r *Request) Delete(output interface{}) (resp *Response, err error)

func (*Request) Get

func (r *Request) Get(output interface{}) (resp *Response, err error)

func (*Request) Head

func (r *Request) Head(output interface{}) (resp *Response, err error)

func (*Request) Post

func (r *Request) Post(input interface{}, output interface{}) (resp *Response, err error)

func (*Request) Put

func (r *Request) Put(input interface{}, output interface{}) (resp *Response, err error)

type Response

type Response struct {
	MediaType   *mediatype.MediaType
	MediaHeader *mediaheader.MediaHeader
	*http.Response
}

type ResponseError

type ResponseError struct {
	Response         *http.Response    `json:"-"`
	Type             ResponseErrorType `json:"-"`
	Message          string            `json:"message,omitempty"`
	Err              string            `json:"error,omitempty"`
	Errors           []ErrorObject     `json:"errors,omitempty"`
	DocumentationURL string            `json:"documentation_url,omitempty"`
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type ResponseErrorType

type ResponseErrorType int
const (
	ErrorClientError             ResponseErrorType = iota // 400-499
	ErrorBadRequest              ResponseErrorType = iota // 400
	ErrorUnauthorized            ResponseErrorType = iota // 401
	ErrorOneTimePasswordRequired ResponseErrorType = iota // 401
	ErrorForbidden               ResponseErrorType = iota // 403
	ErrorTooManyRequests         ResponseErrorType = iota // 403
	ErrorTooManyLoginAttempts    ResponseErrorType = iota // 403
	ErrorNotFound                ResponseErrorType = iota // 404
	ErrorNotAcceptable           ResponseErrorType = iota // 406
	ErrorUnsupportedMediaType    ResponseErrorType = iota // 414
	ErrorUnprocessableEntity     ResponseErrorType = iota // 422
	ErrorServerError             ResponseErrorType = iota // 500-599
	ErrorInternalServerError     ResponseErrorType = iota // 500
	ErrorNotImplemented          ResponseErrorType = iota // 501
	ErrorBadGateway              ResponseErrorType = iota // 502
	ErrorServiceUnavailable      ResponseErrorType = iota // 503
	ErrorMissingContentType      ResponseErrorType = iota
	ErrorUnknownError            ResponseErrorType = iota
)

type Result

type Result struct {
	Response *Response
	Err      error
	// contains filtered or unexported fields
}

func (*Result) Error

func (r *Result) Error() string

func (*Result) HasError

func (r *Result) HasError() bool

type Root

type Root struct {
	*hypermedia.HALResource

	UserSearchURL               Hyperlink `json:"user_search_url,omitempty"`
	UserRepositoriesURL         Hyperlink `json:"user_repositories_url,omitempty"`
	UserOrganizationsURL        Hyperlink `json:"user_organizations_url,omitempty"`
	UserURL                     Hyperlink `json:"user_url,omitempty"`
	TeamURL                     Hyperlink `json:"team_url,omitempty"`
	StarredGistsURL             Hyperlink `json:"starred_gists_url,omitempty"`
	StarredURL                  Hyperlink `json:"starred_url,omitempty"`
	CurrentUserRepositoriesURL  Hyperlink `json:"current_user_repositories_url,omitempty"`
	RepositorySearchURL         Hyperlink `json:"repository_search_url,omitempty"`
	RepositoryURL               Hyperlink `json:"repository_url,omitempty"`
	RateLimitURL                Hyperlink `json:"rate_limit_url,omitempty"`
	GistsURL                    Hyperlink `json:"gists_url,omitempty"`
	FollowingURL                Hyperlink `json:"following_url,omitempty"`
	FeedsURL                    Hyperlink `json:"feeds_url,omitempty"`
	EventsURL                   Hyperlink `json:"events_url,omitempty"`
	EmojisURL                   Hyperlink `json:"emojis_url,omitempty"`
	EmailsURL                   Hyperlink `json:"emails_url,omitempty"`
	AuthorizationsURL           Hyperlink `json:"authorizations_url,omitempty"`
	CurrentUserURL              Hyperlink `json:"current_user_url,omitempty"`
	HubURL                      Hyperlink `json:"hub_url,omitempty"`
	IssueSearchURL              Hyperlink `json:"issue_search_url,omitempty"`
	IssuesURL                   Hyperlink `json:"issues_url,omitempty"`
	KeysURL                     Hyperlink `json:"keys_url,omitempty"`
	NotificationsURL            Hyperlink `json:"notifications_url,omitempty"`
	OrganizationRepositoriesURL Hyperlink `json:"organization_repositories_url,omitempty"`
	OrganizationURL             Hyperlink `json:"organization_url,omitempty"`
	PublicGistsURL              Hyperlink `json:"public_gists_url,omitempty"`
	PullsURL                    Hyperlink `json:"-"`
}

type RootService

type RootService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*RootService) Get

func (r *RootService) Get() (root *Root, result *Result)

type Status

type Status struct {
	*hypermedia.HALResource

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

type StatusesService

type StatusesService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*StatusesService) GetAll

func (s *StatusesService) GetAll() (statuses []Status, result *Result)

type TokenAuth

type TokenAuth struct {
	AccessToken string
}

func (TokenAuth) String

func (t TokenAuth) String() string

type User

type User struct {
	*hypermedia.HALResource

	Login             string     `json:"login,omitempty"`
	ID                int        `json:"id,omitempty"`
	AvatarURL         string     `json:"avatar_url,omitempty"`
	GravatarID        string     `json:"gravatar_id,omitempty"`
	URL               string     `json:"url,omitempty"`
	Name              string     `json:"name,omitempty"`
	Company           string     `json:"company,omitempty"`
	Blog              string     `json:"blog,omitempty"`
	Location          string     `json:"location,omitempty"`
	Email             string     `json:"email,omitempty"`
	Hireable          bool       `json:"hireable,omitempty"`
	Bio               string     `json:"bio,omitempty"`
	PublicRepos       int        `json:"public_repos,omitempty"`
	PublicGists       int        `json:"public_gists,omitempty"`
	Followers         int        `json:"followers,omitempty"`
	Following         int        `json:"following,omitempty"`
	HTMLURL           string     `json:"html_url,omitempty"`
	CreatedAt         *time.Time `json:"created_at,omitempty"`
	UpdatedAt         *time.Time `json:"updated_at,omitempty"`
	Type              string     `json:"type,omitempty"`
	FollowingURL      Hyperlink  `json:"following_url,omitempty"`
	FollowersURL      Hyperlink  `json:"followers_url,omitempty"`
	GistsURL          Hyperlink  `json:"gists_url,omitempty"`
	StarredURL        Hyperlink  `json:"starred_url,omitempty"`
	SubscriptionsURL  Hyperlink  `json:"subscriptions_url,omitempty"`
	OrganizationsURL  Hyperlink  `json:"organizations_url,omitempty"`
	ReposURL          Hyperlink  `json:"repos_url,omitempty"`
	EventsURL         Hyperlink  `json:"events_url,omitempty"`
	ReceivedEventsURL Hyperlink  `json:"received_events_url,omitempty"`
}

type UsersService

type UsersService struct {
	URL *url.URL
	// contains filtered or unexported fields
}

A service to return user records

func (*UsersService) Get

func (u *UsersService) Get() (user *User, result *Result)

Get a user based on UserService#URL

func (*UsersService) GetAll

func (u *UsersService) GetAll() (users []User, result *Result)

Get a list of users based on UserService#URL

func (*UsersService) Update

func (u *UsersService) Update(params interface{}) (user *User, result *Result)

Update a user based on UserService#URL

Jump to

Keyboard shortcuts

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