Documentation
¶
Index ¶
- func Bool(v bool) *bool
- func CheckResponse(r *http.Response) error
- func Int(v int) *int
- func String(v string) *string
- func Stringify(message interface{}) string
- type Client
- type Error
- type ErrorResponse
- type ForkedFromProject
- type Group
- type GroupsService
- type Key
- type Label
- type ListOptions
- type Namespace
- type Project
- type ProjectCommit
- type ProjectCommitDiff
- type ProjectEvent
- type ProjectEventData
- type ProjectEventDataCommit
- type ProjectEventDataCommitAuthor
- type ProjectEventDataRepository
- type ProjectFile
- type ProjectFileParameters
- type ProjectsService
- func (s *ProjectsService) Create(project *Project) (*Project, *Response, error)
- func (s *ProjectsService) Delete(project int) (*Response, error)
- func (s *ProjectsService) Get(projectid int) (*Project, *Response, error)
- func (s *ProjectsService) GetCommit(projectID int, commitID string) (*ProjectCommit, *Response, error)
- func (s *ProjectsService) GetCommitDiff(projectID int, commitID string) (*ProjectCommitDiff, *Response, error)
- func (s *ProjectsService) GetFileContents(projectID int, sha, filepath string) (*bytes.Buffer, *Response, error)
- func (s *ProjectsService) List() ([]Project, *Response, error)
- func (s *ProjectsService) ListAll() ([]Project, *Response, error)
- func (s *ProjectsService) ListCommits(projectID int) ([]ProjectCommit, *Response, error)
- func (s *ProjectsService) ListEvents(projectid int) ([]ProjectEvent, *Response, error)
- func (s *ProjectsService) ListLabels(projectid int) ([]Label, *Response, error)
- func (s *ProjectsService) ListOwned() ([]Project, *Response, error)
- func (s *ProjectsService) Tree(projectID int, path string, ref_name string) (*[]ProjectFile, *Response, error)
- func (s *ProjectsService) UpdateFile(projectID int, parameters ProjectFileParameters, content []byte) (interface{}, *Response, error)
- type Response
- type SearchOptions
- type SearchService
- type Timestamp
- type UploadOptions
- type User
- type UsersService
- func (s *UsersService) CreateKey(key *Key) (*Key, *Response, error)
- func (s *UsersService) CreateKeyForUser(uid int, key *Key) (*Key, *Response, error)
- func (s *UsersService) DeleteKey(id int) (*Response, error)
- func (s *UsersService) DeleteKeyForUser(uid int, id int) (*Response, error)
- func (s *UsersService) Edit(user *User) (*User, *Response, error)
- func (s *UsersService) Get(user string) (*User, *Response, error)
- func (s *UsersService) GetKey(id int) (*Key, *Response, error)
- func (s *UsersService) ListAll() ([]User, *Response, error)
- func (s *UsersService) ListKeys(user string, opt *ListOptions) ([]Key, *Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
func Int ¶
Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL should // always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating with the GitLab API. UserAgent string // Private token used when communicating with the GitLab API PrivateToken string // Services used for talking to different parts of the GitLab API. // Activity *ActivityService // Gists *GistsService // Git *GitService // Gitignores *GitignoresService // Issues *IssuesService Groups *GroupsService // PullRequests *PullRequestsService Projects *ProjectsService Search *SearchService Users *UsersService // contains filtered or unexported fields }
A Client manages communication with the GitLab API.
func NewClient ¶
NewClient returns a new GitLab API client. To use API methods which require authentication, provide a private token string that will be used when making requests.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type Error ¶
type Error struct { Resource string `json:"resource"` // resource on which the error occurred Field string `json:"field"` // field on which the error occurred Code string `json:"code"` // validation error code }
An Error reports more details on an individual error in an ErrorResponse. These are the possible validation error codes:
missing: resource does not exist missing_field: a required field on a resource has not been set invalid: the formatting of a field is invalid already_exists: another resource has the same valid as this field
GitHub API docs: http://developer.github.com/v3/#client-errors
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message Errors []Error `json:"errors"` // more detail on individual errors }
An ErrorResponse reports one or more errors caused by an API request.
GitHub API docs: http://developer.github.com/v3/#client-errors
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ForkedFromProject ¶
type ForkedFromProject struct { ID *int `json:"id,omitempty"` Name *string `json:"name,omitempty"` NameWithNamespace *string `json:"name_with_namespace,omitempty"` Path *string `json:"path,omitempty"` PathWithNamespace *string `json:"path_with_namespace,omitempty"` }
ForkedFromProject represents the source project for a project.
type Group ¶
type Group struct { ID *int `json:"id,omitempty"` Name *string `json:"name,omitempty"` Path *string `json:"path,omitempty"` OwnerID *int `json:"owner_id,omitempty"` }
Group represents a GitLab group.
type GroupsService ¶
type GroupsService struct {
// contains filtered or unexported fields
}
GroupsService provides access to the group related functions in the GitLab API.
GitLab API docs: http://doc.gitlab.com/ce/api/groups.html
func (*GroupsService) Get ¶
func (s *GroupsService) Get(groupid int) (*Group, *Response, error)
Get fetches a group by name.
GitLab API docs: http://doc.gitlab.com/ce/api/groups.html#details-of-a-group
func (*GroupsService) List ¶
func (s *GroupsService) List() ([]Group, *Response, error)
List the groups. When the token is an admin it will list all groups, when it is a user, it will list only their groups.
GitLab API docs: http://doc.gitlab.com/ce/api/groups.html#list-project-groups
func (*GroupsService) ListMembers ¶
func (s *GroupsService) ListMembers(groupid int) ([]User, *Response, error)
ListMembers lists the members for a group.
GitLab API docs: http://doc.gitlab.com/ce/api/groups.html#group-members
func (*GroupsService) RemoveMember ¶
func (s *GroupsService) RemoveMember(groupid, userid int) (*Response, error)
RemoveMember removes a user from a group.
GitLab API docs: http://doc.gitlab.com/ce/api/groups.html#remove-user-team-member
type Key ¶
type Key struct { ID *int `json:"id,omitempty"` Key *string `json:"key,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` Title *string `json:"title,omitempty"` }
Key represents a public SSH key used to authenticate a user or deploy script.
type Label ¶
type Label struct {
Name *string `json:"name,omitempty"`
}
Label represents a GitLab label.
type ListOptions ¶
type ListOptions struct { // For paginated result sets, page of results to retrieve. Page int `url:"page,omitempty"` // For paginated result sets, the number of results to include per page. PerPage int `url:"per_page,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support pagination.
type Namespace ¶
type Namespace struct { CreatedAt *Timestamp `json:"created_at,omitempty"` Description *string `json:"description,omitempty"` ID *int `json:"id,omitempty"` Name *string `json:"name,omitempty"` OwnerID *int `json:"owner_id,omitempty"` Path *string `json:"path,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` }
Namespace represents a GitLab namespace.
type Project ¶
type Project struct { ID *int `json:"id,omitempty"` Archived *bool `json:"archived,omitempty"` DefaultBranch *string `json:"default_branch,omitempty"` Description *string `json:"description,omitempty"` HTTPURLToRepo *string `json:"http_url_to_repo,omitempty"` ImportURL *string `json:"import_url,omitempty"` LastActivityAt *Timestamp `json:"last_activity_at,omitempty"` ForkedFromProject *ForkedFromProject `json:"forked_from_project,omitempty"` Name *string `json:"name,omitempty"` NamespaceID *int `json:"namespace_id,omitempty"` NameWithNamespace *string `json:"name_with_namespace,omitempty"` Namespace *Namespace `json:"namespace,omitempty"` Owner *User `json:"owner,omitempty"` Path *string `json:"path,omitempty"` PathWithNamespace *string `json:"path_with_namespace,omitempty"` SSHURLToRepo *string `json:"ssh_url_to_repo,omitempty"` UserID *int `json:"user_id,omitempty"` VisibilityLevel *int `json:"visibility_level,omitempty"` WebURL *string `json:"web_url,omitempty"` // Additional mutable fields when creating and editing a project IssuesEnabled *bool `json:"issues_enabled,omitempty"` MergeRequestsEnabled *bool `json:"merge_requests_enabled,omitempty"` Public *bool `json:"public,omitempty"` SnippetsEnabled *bool `json:"snippets_enabled,omitempty"` WallEnabled *bool `json:"wall_enabled,omitempty"` WikiEnabled *bool `json:"wiki_enabled,omitempty"` }
Project represents a GitLab project.
type ProjectCommit ¶
type ProjectCommit struct { ID *string `json:"id,omitempty"` AuthorName *string `json:"author_name,omitempty"` AuthorEmail *string `json:"author_email,omitempty"` AuthoredDate *Timestamp `json:"authored_date,omitempty"` CommittedDate *Timestamp `json:"comitted_date,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` ParentIDs []string `json:"parent_ids,omitempty"` ShortID *string `json:"short_id,omitempty"` Title *string `json:"title,omitempty"` }
ProjectCommit represents a commit in a project.
func (ProjectCommit) String ¶
func (p ProjectCommit) String() string
type ProjectCommitDiff ¶
type ProjectCommitDiff struct { AMode *string `json:"a_mode,omitempty"` BMode *string `json:"b_mode,omitempty"` Diff *string `json:"diff,omitempty"` NewPath *string `json:"new_path,omitempty"` OldPath *string `json:"old_path,omitempty"` NewFile *bool `json:"new_file,omitempty"` DeletedFile *bool `json:"deleted_file,omitempty"` RenamedFile *bool `json:"renamed_file,omitempty"` }
ProjectCommitDiff represents a file diff inside a commit
func (ProjectCommitDiff) String ¶
func (p ProjectCommitDiff) String() string
type ProjectEvent ¶
type ProjectEvent struct { Title *string `json:"title,omitempty"` ProjectID *int `json:"project_id,omitempty"` ActionName *string `json:"action_name,omitempty"` TargetID *int `json:"target_id,omitempty"` AuthorID *int `json:"author_id,omitempty"` Data *ProjectEventData `json:"data,omitempty"` TargetTitle *string `json:"target_title"` }
ProjectEvent represents a GitLab project event.
func (ProjectEvent) String ¶
func (p ProjectEvent) String() string
type ProjectEventData ¶
type ProjectEventData 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"` Repository *ProjectEventDataRepository `json:"repository,omitempty"` Commits []ProjectEventDataCommit `json:"commits,omitempty"` TotalCommitCount *int `json:"total_commits_count,omitempty"` }
ProjectEventData represents a project event data blob.
type ProjectEventDataCommit ¶
type ProjectEventDataCommit struct { ID *string `json:"id,omitempty"` Message *string `json:"message,omitempty"` Timestamp *Timestamp `json:"timestamp,omitempty"` URL *string `json:"url,omitempty"` Author *ProjectEventDataCommitAuthor `json:"author,omitempty"` }
ProjectEventDataCommit represents a commit in a project event data blob.
type ProjectEventDataCommitAuthor ¶
type ProjectEventDataCommitAuthor struct { Name *string `json:"name,omitempty"` Email *string `json:"email,omitempty"` }
ProjectEventDataCommitAuthor represents the author of a commit in a project event data blob.
type ProjectEventDataRepository ¶
type ProjectEventDataRepository struct { Name *string `json:"name,omitempty"` URL *string `json:"url,omitempty"` Description *string `json:"description,omitempty"` Homepage *string `json:"homepage,omitempty"` }
ProjectEventDataRepository represents a repository in a project event data blob.
type ProjectFile ¶
type ProjectFile struct { ID *string `json:"id,omitempty"` Mode *string `json:"mode,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` }
func (ProjectFile) String ¶
func (p ProjectFile) String() string
type ProjectFileParameters ¶
type ProjectsService ¶
type ProjectsService struct {
// contains filtered or unexported fields
}
ProjectsService handles communication with the project related methods of the GitLab API.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html
func (*ProjectsService) Create ¶
func (s *ProjectsService) Create(project *Project) (*Project, *Response, error)
Create a new project. If Project.UserID is defined, it will create the project under that user, provided you are an admin.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#create-project
http://doc.gitlab.com/ce/api/projects.html#create-project-for-user
func (*ProjectsService) Delete ¶
func (s *ProjectsService) Delete(project int) (*Response, error)
Delete a project.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#remove-project
func (*ProjectsService) Get ¶
func (s *ProjectsService) Get(projectid int) (*Project, *Response, error)
Get fetches a project.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#get-single-project
func (*ProjectsService) GetCommit ¶
func (s *ProjectsService) GetCommit(projectID int, commitID string) (*ProjectCommit, *Response, error)
GetCommit fetches the specified commit, including all details about it.
GitLab API docs: http://doc.gitlab.com/ce/api/commits.html#get-a-single-commit
func (*ProjectsService) GetCommitDiff ¶
func (s *ProjectsService) GetCommitDiff(projectID int, commitID string) (*ProjectCommitDiff, *Response, error)
Get the diff of a commit
GitLab API docs: http://doc.gitlab.com/ce/api/commits.html#get-the-diff-of-a-commit
func (*ProjectsService) GetFileContents ¶
func (s *ProjectsService) GetFileContents(projectID int, sha, filepath string) (*bytes.Buffer, *Response, error)
Get the raw file contents for a file by commit sha and path. Returns a *bytes.Buffer with the file data.
GitLab API docs: http://doc.gitlab.com/ce/api/repositories.html#raw-file-content
func (*ProjectsService) List ¶
func (s *ProjectsService) List() ([]Project, *Response, error)
List the repositories accessible by authenticated user. Passing the empty string will list repositories for the authenticated user.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-projects
func (*ProjectsService) ListAll ¶
func (s *ProjectsService) ListAll() ([]Project, *Response, error)
ListAll lists all GitLab projects. For admins only.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-all-projects
func (*ProjectsService) ListCommits ¶
func (s *ProjectsService) ListCommits(projectID int) ([]ProjectCommit, *Response, error)
ListCommits lists the commits of a project.
GitLab API docs: http://doc.gitlab.com/ce/api/commits.html#list-repository-commits
func (*ProjectsService) ListEvents ¶
func (s *ProjectsService) ListEvents(projectid int) ([]ProjectEvent, *Response, error)
Get project events.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#get-project-events
func (*ProjectsService) ListLabels ¶
func (s *ProjectsService) ListLabels(projectid int) ([]Label, *Response, error)
List project labels.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-project-labels
func (*ProjectsService) ListOwned ¶
func (s *ProjectsService) ListOwned() ([]Project, *Response, error)
ListOwned lists all GitLab projects that are owned by the user.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-owned-projects
func (*ProjectsService) Tree ¶
func (s *ProjectsService) Tree(projectID int, path string, ref_name string) (*[]ProjectFile, *Response, error)
Get a list of repository files and directories in a project.
TODO: GitLab API docs: http://doc.gitlab.com/ce/api/repositories.html#list-repository-tree
func (*ProjectsService) UpdateFile ¶
func (s *ProjectsService) UpdateFile(projectID int, parameters ProjectFileParameters, content []byte) (interface{}, *Response, error)
Update an existing file in project
TODO: GitLab API docs: http://doc.gitlab.com/ce/api/repository_files.html#update-existing-file-in-repository
type Response ¶
Response is a GitLab API response. This wraps the standard http.Response returned from GitLab and provides convenient access to things like pagination links.
type SearchOptions ¶
type SearchOptions struct {
ListOptions
}
SearchOptions specifies optional parameters to the SearchService methods.
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
SearchService provides access to the search related functions in the GitLab API.
func (*SearchService) Projects ¶
func (s *SearchService) Projects(name string, opt *SearchOptions) (*[]Project, *Response, error)
Projects searches projects by name.
GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#search-for-projects-by-name
type Timestamp ¶
Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.
type UploadOptions ¶
type UploadOptions struct {
Name string `url:"name,omitempty"`
}
UploadOptions specifies the parameters to methods that support uploads.
type User ¶
type User struct { Username *string `json:"username,omitempty"` ID *int `json:"id,omitempty"` Email *string `json:"email,omitempty"` Name *string `json:"name,omitempty"` State *string `json:"state,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` Bio *string `json:"bio,omitempty"` Skype *string `json:"skype,omitempty"` Linkedin *string `json:"linkedin,omitempty"` Twitter *string `json:"twitter,omitempty"` WebsiteURL *string `json:"website_url,omitempty"` ExternUID *string `json:"extern_uid,omitempty"` Provider *string `json:"provider,omitempty"` ThemeID *int `json:"theme_id,omitempty"` ColorSchemeID *int `json:"color_scheme_id,omitempty"` IsAdmin *bool `json:"is_admin,omitempty"` CanCreateGroup *bool `json:"can_create_group,omitempty"` CanCreateProject *bool `json:"can_create_project,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` PrivateToken *string `json:"private_token,omitempty"` AccessLevel *int `json:"access_level,omitempty"` }
User represents a GitLab user.
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
UsersService handles communication with the user related methods of the GitLab API.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html
func (*UsersService) CreateKey ¶
func (s *UsersService) CreateKey(key *Key) (*Key, *Response, error)
CreateKey adds a public key for the authenticated user.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#add-ssh-key
func (*UsersService) CreateKeyForUser ¶
CreateKeyForUser adds a public key for the specified user.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#add-ssh-key-for-user
func (*UsersService) DeleteKey ¶
func (s *UsersService) DeleteKey(id int) (*Response, error)
DeleteKey deletes a public key.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#delete-ssh-key
func (*UsersService) DeleteKeyForUser ¶
func (s *UsersService) DeleteKeyForUser(uid int, id int) (*Response, error)
DeleteKeyForUser deletes a public key for the specified user.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#delete-ssh-key
func (*UsersService) Edit ¶
func (s *UsersService) Edit(user *User) (*User, *Response, error)
Edit the authenticated user.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#user-modification
func (*UsersService) Get ¶
func (s *UsersService) Get(user string) (*User, *Response, error)
Get fetches a user. Passing the empty string will fetch the authenticated user.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#single-user
func (*UsersService) GetKey ¶
func (s *UsersService) GetKey(id int) (*Key, *Response, error)
GetKey fetches a single public key.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#single-ssh-key
func (*UsersService) ListAll ¶
func (s *UsersService) ListAll() ([]User, *Response, error)
ListAll lists all GitLab users.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#list-users
func (*UsersService) ListKeys ¶
func (s *UsersService) ListKeys(user string, opt *ListOptions) ([]Key, *Response, error)
ListKeys lists the verified public keys for a user. Passing the empty string will fetch keys for the authenticated user.
GitLab API docs: http://doc.gitlab.com/ce/api/users.html#list-ssh-keys
Source Files
¶
- gitlab.go
- groups.go
- groups_members.go
- hooks.go
- issues.go
- misc.go
- namespace.go
- projects.go
- projects_branches.go
- projects_commits.go
- projects_contents.go
- projects_events.go
- projects_files.go
- projects_forks.go
- projects_hooks.go
- projects_issues.go
- projects_issues_notes.go
- projects_keys.go
- projects_labels.go
- projects_members.go
- projects_merge_requests.go
- projects_merge_requests_notes.go
- projects_milestones.go
- projects_notes.go
- projects_snippets.go
- projects_snippets_notes.go
- projects_tags.go
- search.go
- strings.go
- timestamp.go
- users.go
- users_keys.go