Documentation ¶
Overview ¶
Package github implements a simple client to consume gitlab API.
Index ¶
- type ActivityFeed
- type Branch
- type BranchCommit
- type Commit
- type FeedCommit
- type Gitlab
- func (g *Gitlab) Activity() (ActivityFeed, error)
- func (g *Gitlab) AddKey(title, key string) error
- func (g *Gitlab) AddProjectDeployKey(id, title, key string) error
- func (g *Gitlab) AddProjectHook(id, hook_url string, push_events, issues_events, merge_requests_events bool) error
- func (g *Gitlab) AddUserKey(id, title, key string) error
- func (g *Gitlab) CurrentUser() (User, error)
- func (g *Gitlab) DeleteKey(id string) error
- func (g *Gitlab) DeleteUser(id string) error
- func (g *Gitlab) EditProjectHook(id, hook_id, hook_url string, ...) error
- func (g *Gitlab) Project(id string) (*Project, error)
- func (g *Gitlab) ProjectBranches(id string) ([]*Branch, error)
- func (g *Gitlab) ProjectDeployKey(id, key_id string) (*PublicKey, error)
- func (g *Gitlab) ProjectDeployKeys(id string) ([]*PublicKey, error)
- func (g *Gitlab) ProjectHook(id, hook_id string) (*Hook, error)
- func (g *Gitlab) ProjectHooks(id string) ([]*Hook, error)
- func (g *Gitlab) ProjectMembers(id string) ([]*Member, error)
- func (g *Gitlab) Projects() ([]*Project, error)
- func (g *Gitlab) RemoveProjectDeployKey(id, key_id string) error
- func (g *Gitlab) RemoveProjectHook(id, hook_id string) error
- func (g *Gitlab) RepoActivityFeed(feedPath string) ActivityFeed
- func (g *Gitlab) RepoBranch(id, refName string) (*Branch, error)
- func (g *Gitlab) RepoBranches(id string) ([]*Branch, error)
- func (g *Gitlab) RepoCommits(id string) ([]*Commit, error)
- func (g *Gitlab) RepoRawFile(id, sha, filepath string) ([]byte, error)
- func (g *Gitlab) RepoTags(id string) ([]*Tag, error)
- func (g *Gitlab) ResourceUrl(url string, params map[string]string) string
- func (g *Gitlab) ResourceUrlRaw(u string, params map[string]string) (string, string)
- func (g *Gitlab) User(id string) (*User, error)
- func (g *Gitlab) UserKey(id string) (*PublicKey, error)
- func (g *Gitlab) UserKeys() ([]*PublicKey, error)
- func (g *Gitlab) Users() ([]*User, error)
- type Hook
- type HookObjAttr
- type HookPayload
- type Link
- type Member
- type Namespace
- type Person
- type Project
- type PublicKey
- type Tag
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivityFeed ¶
type Branch ¶
type Branch struct { Name string `json:"name,omitempty"` Protected bool `json:"protected,omitempty"` Commit *BranchCommit `json:"commit,omitempty"` }
type BranchCommit ¶
type BranchCommit struct { Id string `json:"id,omitempty"` Tree string `json:"tree,omitempty"` AuthoredDateRaw string `json:"authored_date,omitempty"` CommittedDateRaw string `json:"committed_date,omitempty"` Message string `json:"message,omitempty"` Author *Person `json:"author,omitempty"` Committer *Person `json:"committer,omitempty"` }
type FeedCommit ¶
type Gitlab ¶
type Gitlab struct { BaseUrl string ApiPath string RepoFeedPath string Token string Client *http.Client }
func (*Gitlab) Activity ¶
func (g *Gitlab) Activity() (ActivityFeed, error)
func (*Gitlab) AddProjectDeployKey ¶
Add deploy key to project.
POST /projects/:id/keys
Parameters:
id The ID of a project title The key title key The key value
func (*Gitlab) AddProjectHook ¶
func (g *Gitlab) AddProjectHook(id, hook_url string, push_events, issues_events, merge_requests_events bool) error
Add new project hook.
POST /projects/:id/hooks
Parameters:
id The ID or NAMESPACE/PROJECT_NAME of a project hook_url The hook URL push_events Trigger hook on push events issues_events Trigger hook on issues events merge_requests_events Trigger hook on merge_requests events
func (*Gitlab) AddUserKey ¶
func (*Gitlab) CurrentUser ¶
func (*Gitlab) DeleteUser ¶
func (*Gitlab) EditProjectHook ¶
func (g *Gitlab) EditProjectHook(id, hook_id, hook_url string, push_events, issues_events, merge_requests_events bool) error
Edit existing project hook.
PUT /projects/:id/hooks/:hook_id
Parameters:
id The ID or NAMESPACE/PROJECT_NAME of a project hook_id The ID of a project hook hook_url The hook URL push_events Trigger hook on push events issues_events Trigger hook on issues events merge_requests_events Trigger hook on merge_requests events
func (*Gitlab) Project ¶
Get a specific project, identified by project ID or NAME, which is owned by the authentication user. Namespaced project may be retrieved by specifying the namespace and its project name like this:
`namespace%2Fproject-name`
func (*Gitlab) ProjectBranches ¶
Lists all branches of a project.
func (*Gitlab) ProjectDeployKey ¶
Get single project deploy key.
GET /projects/:id/keys/:key_id
Parameters:
id The ID of a project key_id The ID of a key
func (*Gitlab) ProjectDeployKeys ¶
Get list of project deploy keys.
GET /projects/:id/keys
Parameters:
id The ID of a project
func (*Gitlab) ProjectHook ¶
Get single project hook.
GET /projects/:id/hooks/:hook_id
Parameters:
id The ID of a project hook_id The ID of a hook
func (*Gitlab) ProjectHooks ¶
Get list of project hooks.
GET /projects/:id/hooks
Parameters:
id The ID of a project
func (*Gitlab) RemoveProjectDeployKey ¶
Remove deploy key from project
DELETE /projects/:id/keys/:key_id
Parameters:
id The ID of a project key_id The ID of a key
func (*Gitlab) RemoveProjectHook ¶
Remove hook from project.
DELETE /projects/:id/hooks/:hook_id
Parameters:
id The ID or NAMESPACE/PROJECT_NAME of a project hook_id The ID of hook to delete
func (*Gitlab) RepoActivityFeed ¶
func (g *Gitlab) RepoActivityFeed(feedPath string) ActivityFeed
func (*Gitlab) RepoBranch ¶
Get a single project repository branch.
GET /projects/:id/repository/branches/:branch
Parameters:
id The ID of a project branch The name of the branch
func (*Gitlab) RepoBranches ¶
Get a list of repository branches from a project, sorted by name alphabetically.
GET /projects/:id/repository/branches
Parameters:
id The ID of a project
Usage:
branches, err := gitlab.RepoBranches("your_projet_id") if err != nil { fmt.Println(err.Error()) } for _, branch := range branches { fmt.Printf("%+v\n", branch) }
func (*Gitlab) RepoCommits ¶
Get a list of repository commits in a project.
GET /projects/:id/repository/commits
Parameters:
id The ID of a project refName The name of a repository branch or tag or if not given the default branch
Usage:
commits, err := gitlab.RepoCommits("your_projet_id") if err != nil { fmt.Println(err.Error()) } for _, commit := range commits { fmt.Printf("%+v\n", commit) }
func (*Gitlab) RepoRawFile ¶
Get Raw file content
func (*Gitlab) RepoTags ¶
Get a list of repository tags from a project, sorted by name in reverse alphabetical order.
GET /projects/:id/repository/tags
Parameters:
id The ID of a project
Usage:
tags, err := gitlab.RepoTags("your_projet_id") if err != nil { fmt.Println(err.Error()) } for _, tag := range tags { fmt.Printf("%+v\n", tag) }
func (*Gitlab) ResourceUrl ¶
func (*Gitlab) ResourceUrlRaw ¶
type HookObjAttr ¶
type HookObjAttr struct { Id int `json:"id,omitempty"` Title string `json:"title,omitempty"` AssigneeId int `json:"assignee_id,omitempty"` AuthorId int `json:"author_id,omitempty"` ProjectId int `json:"project_id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Position int `json:"position,omitempty"` BranchName string `json:"branch_name,omitempty"` Description string `json:"description,omitempty"` MilestoneId int `json:"milestone_id,omitempty"` State string `json:"state,omitempty"` IId int `json:"iid,omitempty"` TargetBranch string `json:"target_branch,omitempty"` SourceBranch string `json:"source_branch,omitempty"` SourceProjectId int `json:"source_project_id,omitempty"` StCommits string `json:"st_commits,omitempty"` StDiffs string `json:"st_diffs,omitempty"` MergeStatus string `json:"merge_status,omitempty"` TargetProjectId int `json:"target_project_id,omitempty"` }
type HookPayload ¶
type HookPayload struct { Before string `json:"before,omitempty"` After string `json:"after,omitempty"` Ref string `json:"ref,omitempty"` UserId int `json:"user_id,omitempty"` UserName string `json:"user_name,omitempty"` ProjectId int `json:"project_id,omitempty"` Repository *hRepository `json:"repository,omitempty"` Commits []hCommit `json:"commits,omitempty"` TotalCommitsCount int `json:"total_commits_count,omitempty"` ObjectKind string `json:"object_kind,omitempty"` ObjectAttributes *HookObjAttr `json:"object_attributes,omitempty"` }
func ParseHook ¶
func ParseHook(payload []byte) (*HookPayload, error)
ParseHook parses hook payload from GitLab
func (*HookPayload) Branch ¶
func (h *HookPayload) Branch() string
Branch returns current branch for push event hook payload This function returns empty string for any other events
func (*HookPayload) Head ¶
func (h *HookPayload) Head() hCommit
Head returns the latest changeset for push event hook payload
type Project ¶
type Project struct { Id int `json:"id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` DefaultBranch string `json:"default_branch,omitempty"` Owner *Member `json:"owner,omitempty"` Public bool `json:"public,omitempty"` Path string `json:"path,omitempty"` PathWithNamespace string `json:"path_with_namespace,omitempty"` IssuesEnabled bool `json:"issues_enabled,omitempty"` MergeRequestsEnabled bool `json:"merge_requests_enabled,omitempty"` WallEnabled bool `json:"wall_enabled,omitempty"` WikiEnabled bool `json:"wiki_enabled,omitempty"` CreatedAtRaw string `json:"created_at,omitempty"` Namespace *Namespace `json:"namespace,omitempty"` SshRepoUrl string `json:"ssh_url_to_repo"` HttpRepoUrl string `json:"http_url_to_repo"` }
A gitlab project
type Tag ¶
type Tag struct { Name string `json:"name,omitempty"` Protected bool `json:"protected,omitempty"` Commit *BranchCommit `json:"commit,omitempty"` }
type User ¶
type User struct { Id int `json:"id,omitempty"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty"` Name string `json:"name,omitempty"` State string `json:"state,omitempty"` CreatedAt string `json:"created_at,omitempty"` Bio string `json:"bio,omitempty"` Skype string `json:"skype,omitempty"` LinkedIn string `json:"linkedin,omitempty"` Twitter string `json:"twitter,omitempty"` ExternUid string `json:"extern_uid,omitempty"` Provider string `json:"provider,omitempty"` ThemeId int `json:"theme_id,omitempty"` ColorSchemeId int `json:"color_scheme_id,color_scheme_id"` }