Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidSender(ip string) bool
- type Author
- type Base
- type Client
- type Commit
- type CommitRepo
- type CommitStatus
- type Content
- type ContentResource
- type Email
- type EmailResource
- type Head
- type Hook
- type HookConfig
- type HookResource
- func (r *HookResource) Create(owner, repo, link string) (*Hook, error)
- func (r *HookResource) CreateUpdate(owner, repo, link string) (*Hook, error)
- func (r *HookResource) Delete(owner, repo string, id int) error
- func (r *HookResource) DeleteUrl(owner, repo, link string) error
- func (r *HookResource) Find(owner, repo string, id int) (*Hook, error)
- func (r *HookResource) FindUrl(owner, repo, link string) (*Hook, error)
- func (r *HookResource) List(owner, repo string) ([]*Hook, error)
- func (r *HookResource) Update(owner, repo string, hook *Hook) (*Hook, error)
- type Key
- type KeyResource
- func (r *KeyResource) Create(key, title string) (*Key, error)
- func (r *KeyResource) CreateUpdate(key, title string) (*Key, error)
- func (r *KeyResource) Delete(id int) error
- func (r *KeyResource) DeleteName(title string) error
- func (r *KeyResource) Find(id int) (*Key, error)
- func (r *KeyResource) FindName(title string) (*Key, error)
- func (r *KeyResource) List() ([]*Key, error)
- func (r *KeyResource) Update(key, title string, id int) (*Key, error)
- type Org
- type OrgResource
- type Owner
- type Permissions
- type PostReceiveHook
- type PullRequest
- type PullRequestHook
- type Repo
- type RepoKeyResource
- func (r *RepoKeyResource) Create(owner, repo, key, title string) (*Key, error)
- func (r *RepoKeyResource) CreateUpdate(owner, repo, key, title string) (*Key, error)
- func (r *RepoKeyResource) Delete(owner, repo string, id int) error
- func (r *RepoKeyResource) DeleteName(owner, repo, label string) error
- func (r *RepoKeyResource) Find(owner, repo string, id int) (*Key, error)
- func (r *RepoKeyResource) FindName(owner, repo, title string) (*Key, error)
- func (r *RepoKeyResource) List(owner, repo string) ([]*Key, error)
- func (r *RepoKeyResource) Update(owner, repo, key, title string, id int) (*Key, error)
- type RepoResource
- func (r *RepoResource) CreateStatus(owner, repo, state, link, comment, sha string) error
- func (r *RepoResource) Find(owner, repo string) (*Repo, error)
- func (r *RepoResource) FindRaw(owner, repo string) ([]byte, error)
- func (r *RepoResource) List() ([]*Repo, error)
- func (r *RepoResource) ListAll() ([]*Repo, error)
- func (r *RepoResource) ListOrg(orgname string) ([]*Repo, error)
- func (r *RepoResource) ListUser(username string) ([]*Repo, error)
- type Source
- type User
- type UserResource
Constants ¶
const ( // Any git push to a Repository. HookPush = "push" // Any time an Issue is opened or closed. HookIssues = "issues" // Any time an Issue is commented on. HookIssueComment = "issue_comment" // Any time a Commit is commented on. HookCommitComment = "commit_comment" // Any time a Pull Request is opened, closed, or synchronized. HookPullRequest = "pull_request" // Any time a Commit is commented on while inside a Pull Request review. HookRequestReivewComment = "pull_request_review_comment" // Any time a Wiki page is updated. HookGollum = "gollum" // Any time a User watches the Repository. HookWatch = "watch" // Any time a Download is added to the Repository. HookDownload = "download" // Any time a Repository is forked. HookForm = "fork" // Any time a patch is applied to the Repository from the Fork Queue. HookForkApply = "fork_apply" // Any time a User is added as a collaborator to a non-Organization Repository. HookMember = "member" // Any time a Repository changes from private to public. HookPublic = "public" // Any time a team is added or modified on a Repository. HookTeamAdd = "team_add" // Any time a Repository has a status update from the API HookStatus = "status" )
Different types of Hooks. See http://developer.github.com/v3/repos/hooks/
Variables ¶
var ( // Returned if the specified resource does not exist. ErrNotFound = errors.New("Not Found") // Returned if the caller attempts to make a call or modify a resource // for which the caller is not authorized. // // The request was a valid request, the caller's authentication credentials // succeeded but those credentials do not grant the caller permission to // access the resource. ErrForbidden = errors.New("Forbidden") // Returned if the call requires authentication and either the credentials // provided failed or no credentials were provided. ErrNotAuthorized = errors.New("Unauthorized") // Returned if the caller submits a badly formed request. For example, // the caller can receive this return if you forget a required parameter. ErrBadRequest = errors.New("Bad Request") )
var DefaultClient = http.DefaultClient
DefaultClient uses DefaultTransport, and is used internall to execute all http.Requests. This may be overriden for unit testing purposes.
IMPORTANT: this is not thread safe and should not be touched with the exception overriding for mock unit testing.
var ErrInvalidPostReceiveHook = errors.New("Invalid Post Receive Hook")
var Guest = New("")
Guest Client that can be used to access public APIs that do not require authentication.
Functions ¶
func IsValidSender ¶
Check's to see if the Post-Receive Build Hook is coming from a valid sender (IP Address)
Types ¶
type Base ¶
type Base struct { Label string `json:"label"` Ref string `json:"ref"` Sha string `json:"sha"` User *User `json:"user"` Repo *CommitRepo `json:"repo"` }
type Client ¶
type Client struct { ApiUrl string Token string Repos *RepoResource Users *UserResource Orgs *OrgResource Emails *EmailResource Keys *KeyResource Hooks *HookResource Contents *ContentResource RepoKeys *RepoKeyResource }
type CommitRepo ¶
type CommitStatus ¶
type Content ¶
type Content struct { Type string `json:"type"` Name string `json:"name"` Path string `json:"path"` Encoding string `json:"encoding"` Content string `json:"content"` Size int64 `json:"size"` Sha string `json:"sha"` }
func (*Content) DecodeContent ¶
type ContentResource ¶
type ContentResource struct {
// contains filtered or unexported fields
}
These API methods let you retrieve the contents of files within a repository as Base64 encoded content.
func (*ContentResource) Find ¶
func (r *ContentResource) Find(owner, repo, path string) (*Content, error)
This method returns the contents of a file or directory in a repository.
type EmailResource ¶
type EmailResource struct {
// contains filtered or unexported fields
}
An account can have one or more email addresses associated with it. Use this end point to list, change, or create an email address.
func (*EmailResource) Create ¶
func (r *EmailResource) Create(address string) error
Adds additional email addresses to an account.
func (*EmailResource) Delete ¶
func (r *EmailResource) Delete(address string) error
Deletes an email addresses from an account.
func (*EmailResource) Find ¶
func (r *EmailResource) Find(address string) (*Email, error)
Gets an individual email address associated with an account.
func (*EmailResource) FindPrimary ¶
func (r *EmailResource) FindPrimary() (*Email, error)
Gets an individual's primary email address.
func (*EmailResource) List ¶
func (r *EmailResource) List() ([]*Email, error)
Gets the email addresses associated with the account.
type Head ¶
type Head struct { Label string `json:"label"` Ref string `json:"ref"` Sha string `json:"sha"` User *User `json:"user"` Repo *CommitRepo `json:"repo"` }
type Hook ¶
type Hook struct { Id int `json:"id"` Name string `json:"name"` Active bool `json:"active"` Events []string `json:"events"` Config *HookConfig `json:"config"` }
type HookConfig ¶
type HookResource ¶
type HookResource struct {
// contains filtered or unexported fields
}
func (*HookResource) Create ¶
func (r *HookResource) Create(owner, repo, link string) (*Hook, error)
func (*HookResource) CreateUpdate ¶
func (r *HookResource) CreateUpdate(owner, repo, link string) (*Hook, error)
func (*HookResource) DeleteUrl ¶
func (r *HookResource) DeleteUrl(owner, repo, link string) error
type KeyResource ¶
type KeyResource struct {
// contains filtered or unexported fields
}
func (*KeyResource) Create ¶
func (r *KeyResource) Create(key, title string) (*Key, error)
Creates a key on the specified account. You must supply a valid key that is unique across the Github service.
func (*KeyResource) CreateUpdate ¶
func (r *KeyResource) CreateUpdate(key, title string) (*Key, error)
Creates a key on the specified account, assuming it does not already exist in the system
func (*KeyResource) Delete ¶
func (r *KeyResource) Delete(id int) error
Deletes the key specified by the id value.
func (*KeyResource) DeleteName ¶
func (r *KeyResource) DeleteName(title string) error
Deletes the named key.
func (*KeyResource) Find ¶
func (r *KeyResource) Find(id int) (*Key, error)
Gets the key associated with the specified id.
func (*KeyResource) FindName ¶
func (r *KeyResource) FindName(title string) (*Key, error)
Gets the key associated with specified title.
func (*KeyResource) List ¶
func (r *KeyResource) List() ([]*Key, error)
Gets a list of the keys associated with an account.
type OrgResource ¶
type OrgResource struct {
// contains filtered or unexported fields
}
func (*OrgResource) List ¶
func (r *OrgResource) List() ([]*Org, error)
type Owner ¶
type Owner struct { Type string `json:"type"` Login string `json:"login"` Name string `json:"name"` }
Owner represents the owner of a Github Repository.
type Permissions ¶
type Permissions struct { Push bool `json:"push"` Pull bool `json:"pull"` Admin bool `json:"admin"` }
Permissions
type PostReceiveHook ¶
type PostReceiveHook struct { Before string `json:"before"` After string `json:"after"` Ref string `json:"ref"` Repo *CommitRepo `json:"repository"` Commits []*Commit `json:"commits"` Head *Commit `json:"head_commit"` Deleted bool `json:"deleted"` }
func ParseHook ¶
func ParseHook(raw []byte) (*PostReceiveHook, error)
func (*PostReceiveHook) Branch ¶
func (h *PostReceiveHook) Branch() string
func (*PostReceiveHook) IsDeleted ¶
func (h *PostReceiveHook) IsDeleted() bool
func (*PostReceiveHook) IsGithubPages ¶
func (h *PostReceiveHook) IsGithubPages() bool
func (*PostReceiveHook) IsHead ¶
func (h *PostReceiveHook) IsHead() bool
func (*PostReceiveHook) IsTag ¶
func (h *PostReceiveHook) IsTag() bool
type PullRequest ¶
type PullRequest struct { Id int `json:"int"` Number int `json:"number"` Url string `json:"url"` State string `json:"state"` // open, closed, etc Title string `json:"title"` Merged bool `json:"merged"` Commits int `json:"commits"` Additions int `json:"additions"` Deletions int `json:"deletions"` Changed int `json:"changed_files"` Base *Base `json:"base"` Head *Head `json:"head"` User *User `json:"user"` }
type PullRequestHook ¶
type PullRequestHook struct { Action string `json:"action"` Number int `json:"number"` Sender *User `json:"sender"` Repo *CommitRepo `json:"repository"` PullRequest *PullRequest `json:"pull_request"` }
func ParsePullRequestHook ¶
func ParsePullRequestHook(raw []byte) (*PullRequestHook, error)
func (*PullRequestHook) IsOpened ¶
func (h *PullRequestHook) IsOpened() bool
type Repo ¶
type Repo struct { ID int64 `json:"id"` Name string `json:"name"` FullName string `json:"full_name"` Private bool `json:"private"` Fork bool `json:"fork"` SshUrl string `json:"ssh_url"` GitUrl string `json:"git_url"` CloneUrl string `json:"clone_url"` HtmlUrl string `json:"html_url"` Owner *Owner `json:"owner"` Permissions *Permissions `json:"permissions"` Source *Source `json:"source"` }
Repo represents a Github-hosted Git Repository.
type RepoKeyResource ¶
type RepoKeyResource struct {
// contains filtered or unexported fields
}
func (*RepoKeyResource) Create ¶
func (r *RepoKeyResource) Create(owner, repo, key, title string) (*Key, error)
Creates a key on the specified repo. You must supply a valid key that is unique across the Github service.
func (*RepoKeyResource) CreateUpdate ¶
func (r *RepoKeyResource) CreateUpdate(owner, repo, key, title string) (*Key, error)
Creates a key for the specified repo, assuming it does not already exist in the system
func (*RepoKeyResource) Delete ¶
func (r *RepoKeyResource) Delete(owner, repo string, id int) error
Deletes the key specified by the id value.
func (*RepoKeyResource) DeleteName ¶
func (r *RepoKeyResource) DeleteName(owner, repo, label string) error
func (*RepoKeyResource) Find ¶
func (r *RepoKeyResource) Find(owner, repo string, id int) (*Key, error)
Gets the key associated with the specified id.
func (*RepoKeyResource) FindName ¶
func (r *RepoKeyResource) FindName(owner, repo, title string) (*Key, error)
Gets the key associated with specified title.
type RepoResource ¶
type RepoResource struct {
// contains filtered or unexported fields
}
func (*RepoResource) CreateStatus ¶
func (r *RepoResource) CreateStatus(owner, repo, state, link, comment, sha string) error
func (*RepoResource) List ¶
func (r *RepoResource) List() ([]*Repo, error)
func (*RepoResource) ListAll ¶
func (r *RepoResource) ListAll() ([]*Repo, error)
type User ¶
type User struct { ID int64 `json:"id"` Login string `json:"login"` Type string `json:"type"` Name string `json:"name"` Email string `json:"email"` Company string `json:"company"` Location string `json:"location"` Blog string `json:"blog"` Avatar string `json:"avatar_url"` GravatarId string `json:"gravatar_id"` Url string `json:"html_url"` }
type UserResource ¶
type UserResource struct {
// contains filtered or unexported fields
}
func (*UserResource) Current ¶
func (r *UserResource) Current() (*User, error)