Documentation ¶
Index ¶
- func ParseTime(t string) (time.Time, error)
- type APIError
- type APIOption
- type Branch
- type Commit
- type CommitStats
- type GitLab
- func (g *GitLab) AddProjectHook(pid, url string, opts *ProjectHookOption) (ret Webhook, err error)
- func (g *GitLab) CreateBranch(pid string, name, ref string) (ret Branch, err error)
- func (g *GitLab) DeleteBranch(pid string, name string) (err error)
- func (g *GitLab) DeleteProjectHook(pid string, hid int) (err error)
- func (g *GitLab) EditProjectHook(pid string, hid int, url string, opts *ProjectHookOption) (ret Webhook, err error)
- func (g *GitLab) ListBranches(pid string, opts *ListOption) (ret []Branch, page *Pagination, err error)
- func (g *GitLab) Me() (ret User, err error)
- func (g *GitLab) ProjectHooks(pid string, opts *ListOption) (ret []Webhook, page *Pagination, err error)
- func (g *GitLab) WithOAuth(source oauth2.TokenSource) *GitLab
- func (g *GitLab) WithPAT(token string) *GitLab
- func (g *GitLab) WithRaw(c *http.Client) *GitLab
- type ListOption
- type Pagination
- type ProjectHookOption
- type User
- type UserIdentity
- type Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIError ¶
type APIError int
const ( ErrMissingAttr APIError = 400 // at least one required attribute is missing ErrForbidden APIError = 403 // action is not allowed for current user ErrNotFound APIError = 404 // resource cannot be accessed ErrNotSupported APIError = 405 // action is not supported ErrConflict APIError = 409 // resource confliction ErrUnprocessable APIError = 422 // entity cannot be processed ErrServerError APIError = 500 // internal server error )
type APIOption ¶
type APIOption interface { // accepts an url.Values so we can combine multiple APIOptions by // opt1.Encode(opt2.Encode(nil)) // or even // var val url.Values // for _, o := range options { // val = o.Encode(val) // } Encode(v url.Values) url.Values }
APIOption abstracts all options, so we're easier to construct requests
type Branch ¶
type Branch struct { Name string `json:"name"` Protected bool `json:"protected,omitempty"` DevelopersCanPush bool `json:"developers_can_push,omitempty"` DevelopersCanMerge bool `json:"developers_can_merge,omitempty"` Commit Commit `json:"commit"` }
Branch represents info of a branch
type Commit ¶
type Commit struct { // These fields are listed at // http://docs.gitlab.com/ce/api/commits.html#list-repository-commits ID string `json:"id"` ShortID string `json:"short_id,omitempty"` Title string `json:"title,omitempty"` AuthorName string `json:"author_name,omitempty"` AuthorEmail string `json:"author_email,omitempty"` CreatedAt string `json:"created_at,omitempty"` Message string `json:"message,omitempty"` AllowFailure string `json:"allow_failure,omitempty"` // These fields are listed at // http://docs.gitlab.com/ce/api/commits.html#get-a-single-commit CommittedDate string `json:"committed_date,omitempty"` AuthoredDate string `json:"authored_date,omitempty"` ParentIDs []string `json:"parent_ids,omitempty"` Stats CommitStats `json:"stats,omitempty"` Status string `json:"status,omitempty"` }
Commit represents a commit in a repository
type CommitStats ¶
type CommitStats struct { Additions int `json:"additions,omitempty"` Deletions int `json:"deletions,omitempty"` Total int `json:"total,omitempty"` }
CommitStats represents states of a commit
type GitLab ¶
type GitLab struct {
// contains filtered or unexported fields
}
GitLab maps all gitlab apis to method calls
func RawClient ¶
RawClient creates non-wrapped GitLab API client. Since most apis need authorization, use this with caution.
Note: passing client from oauth2.Config.Client to this will make api calls authorized by oauth token.
func (*GitLab) AddProjectHook ¶
func (g *GitLab) AddProjectHook(pid, url string, opts *ProjectHookOption) (ret Webhook, err error)
AddProjectHook add a webhook to project
func (*GitLab) CreateBranch ¶
CreateBranch creates new branch in a project
See http://docs.gitlab.com/ce/api/branches.html#create-repository-branch
func (*GitLab) DeleteBranch ¶
DeleteBranch deletes a branch from project
See http://docs.gitlab.com/ce/api/branches.html#delete-repository-branch
func (*GitLab) DeleteProjectHook ¶
DeleteProjectHook deletes specified project webhook
func (*GitLab) EditProjectHook ¶
func (g *GitLab) EditProjectHook(pid string, hid int, url string, opts *ProjectHookOption) (ret Webhook, err error)
EditProjectHook updates project hook info
func (*GitLab) ListBranches ¶
func (g *GitLab) ListBranches(pid string, opts *ListOption) (ret []Branch, page *Pagination, err error)
ListBranches retrieves all branches in a project
See http://docs.gitlab.com/ce/api/branches.html#list-repository-branches
func (*GitLab) ProjectHooks ¶
func (g *GitLab) ProjectHooks(pid string, opts *ListOption) (ret []Webhook, page *Pagination, err error)
ProjectHooks retrieves all webhooks of a project
func (*GitLab) WithOAuth ¶
func (g *GitLab) WithOAuth(source oauth2.TokenSource) *GitLab
WithOAuth creates a new GitLab client using current http.Client and OAuth token
type ListOption ¶
ListOption represents pagination related options
type Pagination ¶
type Pagination struct { Total int // the total number of items TotalPages int // the total number of pages PerPage int // the number of items per page Page int // the index of current page, started from 1 NextPage int // the index of next page PrevPage int // the index of previous page LinkHeader string // raw Link header }
Pagination represents pagination info from header
func ParsePagination ¶
func ParsePagination(h http.Header) *Pagination
ParsePagination extracts pagination info from http headers
func (*Pagination) Links ¶
func (p *Pagination) Links() map[string]string
Links parses LinkHeader and returns a map[rel]url
This method does not test against comma and colon, since they are not expected to exist in reply of gitlab. The malformed input is also ignored. You should be aware of this.
type ProjectHookOption ¶
type ProjectHookOption struct { PushEvents bool IssuesEvents bool MergeRequestsEvents bool TagPushEvents bool NoteEvents bool BuildEvents bool PipelineEvents bool WikiPageEvents bool EnableSSLVerification bool // contains filtered or unexported fields }
ProjectHookOption represents optional parameters needed for AddProjectHook
type User ¶
type User struct { // These fields are listed as // http://docs.gitlab.com/ce/api/users.html#for-normal-users ID int `json:"id"` Username string `json:"username"` Name string `json:"name"` State string `json:"state"` AvatarURL string `json:"avatar_url"` WebURL string `json:"web_url"` // These fields are listed as // http://docs.gitlab.com/ce/api/users.html#for-admins Email string `json:"email,omitempty"` CreatedAt string `json:"created_at,omitempty"` IsAdmin bool `json:"is_admin,omitempty"` Bio string `json:"bio,omitempty"` Location string `json:"location,omitempty"` Skype string `json:"skype,omitempty"` Linkedin string `json:"linkedin,omitempty"` Twitter string `json:"twitter,omitempty"` WebsiteURL string `json:"website_url,omitempty"` LastSignInAt string `json:"last_sign_in_at,omitempty"` ConfirmedAt string `json:"confirmed_at,omitempty"` ThemeID int `json:"theme_id,omitempty"` ColorThemeID int `json:"color_theme_id,omitempty"` ProjectLimit int `json:"project_limit,omitempty"` CurrentSignInAt string `json:"current_sign_in_at,omitempty"` Identities []UserIdentity `json:"identities,omitempty"` CanCreateGroup bool `json:"can_create_group,omitempty"` CanCreateProject bool `json:"can_create_project,omitempty"` TwoFactorEnabled bool `json:"two_factor_enabled,omitempty"` External bool `json:"external,omitempty"` }
User represents info of a user
type UserIdentity ¶
type UserIdentity struct { Provider string `json:"provider"` ExternUID string `json:"extern_uid,omitempty"` }
UserIdentity represents an external identity of a user
type Webhook ¶
type Webhook struct { // These fields are listed at // http://docs.gitlab.com/ce/api/projects.html#list-project-hooks ID int `json:"id"` URL string `json:"url"` ProjectID int `json:"project_id"` PushEvents bool `json:"push_events"` IssuesEvents bool `json:"issues_events"` MergeRequestsEvents bool `json:"merge_requests_events"` TagPushEvents bool `json:"tag_push_events"` NoteEvents bool `json:"note_events"` BuildEvents bool `json:"build_events"` PipelineEvents bool `json:"pipeline_events"` WikiPageEvents bool `json:"wiki_page_events"` EnableSSLVerification bool `json:"enable_ssl_verification"` CreatedAt string `json:"created_at"` }
Webhook represents a project hook
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package webhook defines payload format of GitLab webhook It also provides a simple wrapper for you to easily create applications handle webhooks.
|
Package webhook defines payload format of GitLab webhook It also provides a simple wrapper for you to easily create applications handle webhooks. |