gitlab

package
v0.0.0-...-7f21696 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthCodeURL

func AuthCodeURL() string

AuthCodeURL returns a URL to OAuth 2.0 provider's consent page that asks for permissions for the required scopes explicitly.

func CheckResponse

func CheckResponse(r *http.Response) error

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 Exchange

func Exchange(c string) (*oauth2.Token, error)

Exchange is

func NewEngine

func NewEngine(c *Config)

New gitlab api client

Types

type Avatar

type Avatar struct {
	Url string `json:"url"`
}

Avatar represents a GitLab avatar.

type Client

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

func NewClient

func NewClient(t *oauth2.Token, pt string) *Client

NewClient creates new client for usage gitlab api

func (*Client) CreateComment

func (g *Client) CreateComment(project_id, issue_id string, com *CommentRequest) (*Comment, *http.Response, error)

CreateComment creates a new note to a single project issue.

GitLab API docs: http://doc.gitlab.com/ce/api/notes.html#create-new-issue-note

func (*Client) CreateIssue

func (g *Client) CreateIssue(project_id string, issue *IssueRequest) (*Issue, *http.Response, error)

CreateIssue creates a new project issue.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html#new-issues

func (*Client) CreateLabel

func (g *Client) CreateLabel(project_id string, label *LabelRequest) (*Label, *http.Response, error)

CreateIssue creates a new project issue.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html#new-issues

func (*Client) CreateMilestone

func (g *Client) CreateMilestone(project_id string, m *MilestoneRequest) (*Milestone, *http.Response, error)

CreateMilestone creates a new project milestone.

GitLab API docs: http://doc.gitlab.com/ce/api/milestones.html#create-new-milestone

func (*Client) CurrentUser

func (g *Client) CurrentUser() (*User, error)

CurrentUser gets currently authenticated user.

GitLab API docs: http://doc.gitlab.com/ce/api/users.html#current-user

func (*Client) DeleteLabel

func (g *Client) DeleteLabel(project_id string, label *LabelRequest) (*Label, *http.Response, error)

DeleteLabel deletes an existing project label

GitLab API docs: http://doc.gitlab.com/ce/api/labels.html#delete-a-label

func (*Client) Do

func (g *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an HTTP request and returns an HTTP response, following policy (e.g. redirects, cookies, auth) as configured on the client.

func (*Client) EditLabel

func (g *Client) EditLabel(project_id string, label *LabelRequest) (*Label, *http.Response, error)

EditLabel updates an existing project labels

GitLab API docs: http://doc.gitlab.com/ce/api/labels.html#edit-an-existing-label

func (*Client) ItemProject

func (g *Client) ItemProject(projectID string) (*Project, error)

ItemProject gets a specific project, identified by project ID or NAMESPACE/PROJECT_NAME, which is owned by the authenticated user.

GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#get-single-project

func (*Client) ListComments

func (g *Client) ListComments(project_id, issue_id string, o *ListOptions) ([]*Comment, error)

ListComments gets a list of all notes for a single issue.

GitLab API docs: http://doc.gitlab.com/ce/api/notes.html#list-project-issue-notes

func (*Client) ListGroupMembers

func (g *Client) ListGroupMembers(group_id string, o *ListOptions) ([]*User, error)

ListProjectMembers gets a list of a group's team members.

GitLab API docs: http://doc.gitlab.com/ce/api/groups.html#list-group-members

func (*Client) ListIssues

func (g *Client) ListIssues(projectID string, o *IssueListOptions) ([]*Issue, *CollectionOptions, error)

ListIssues gets all issues created by authenticated user. This function takes pagination parameters page and per_page to restrict the list of issues.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html#list-issues

func (*Client) ListLabels

func (g *Client) ListLabels(project_id string, o *ListOptions) ([]*Label, error)

ListLabels gets all labels for given project.

GitLab API docs: http://doc.gitlab.com/ce/api/labels.html#list-labels

func (*Client) ListMilestones

func (g *Client) ListMilestones(project_id string, o *ListOptions) ([]*Milestone, error)

ListMilestones returns a list of project milestones.

GitLab API docs: http://doc.gitlab.com/ce/api/milestones.html#list-project-milestones

func (*Client) ListProjectMembers

func (g *Client) ListProjectMembers(project_id string, o *ListOptions) ([]*User, error)

ListProjectMembers gets a list of a project's team members.

GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-project-team-members

func (*Client) ListProjects

func (g *Client) ListProjects(o *ProjectListOptions) ([]*Project, *CollectionOptions, error)

ListProjects gets a list of projects accessible by the authenticated user.

GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-projects

func (*Client) MoveAnIssue

func (g *Client) MoveAnIssue(projectID, issueID, toProjectId string) (*Issue, *http.Response, error)

MoveAnIssue Moves an issue to a different project.

Gitlab API docs: https://docs.gitlab.com/ee/api/issues.html#move-an-issue

func (*Client) NewRequest

func (c *Client) NewRequest(method string, urlStr []string, body interface{}) (*http.Request, error)

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.

func (*Client) StarredProjects

func (g *Client) StarredProjects(opt *ProjectListOptions) ([]*Project, *CollectionOptions, error)

StarredProjects gets a list starred project for user.

GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-starred-projects

func (*Client) UpdateIssue

func (g *Client) UpdateIssue(project_id, issue_id string, issue *IssueRequest) (*Issue, *http.Response, error)

UpdateIssue updates an existing project issue. This function is also used to mark an issue as closed.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html#edit-issues

func (*Client) UpdateMilestone

func (g *Client) UpdateMilestone(project_id string, m_id string, m *MilestoneRequest) (*Milestone, *http.Response, error)

UpdateMilestone updates a project milestone.

GitLab API docs: http://doc.gitlab.com/ce/api/milestones.html#edit-milestone

func (*Client) UploadFile

func (g *Client) UploadFile(projectID, name string, file io.Reader) (*File, error)

UploadFile uploads file to gitlab project

Gitlab API docs: http://docs.gitlab.com/ee/api/projects.html#upload-a-file

type CollectionOptions

type CollectionOptions struct {
	Total      string
	NextPage   string
	TotalPages string
	PerPage    string
	Page       string
	PrevPage   string
}

CollectionOptions represents collection options on http headers

func NewCollectionOption

func NewCollectionOption(resp *http.Response) *CollectionOptions

NewCollectionOption gets pagination options

type Comment

type Comment struct {
	Id        int64     `json:"id"`
	Author    *User     `json:"author"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	System    bool      `json:"system"`
	Upvote    bool      `json:"upvote"`
	Downvote  bool      `json:"downvote"`
}

Comment represents a GitLab note.

GitLab API docs: http://doc.gitlab.com/ce/api/notes.html

type CommentRequest

type CommentRequest struct {
	Body string `json:"body"`
}

CommentRequest represents the available CreateComment() and UpdateComment() options.

GitLab API docs: http://doc.gitlab.com/ce/api/notes.html#create-new-issue-note

type Config

type Config struct {
	BasePath string
	Domain   string
	Oauth2   *oauth2.Config
}

type File

type File struct {
	Alt      string `json:"alt"`
	URL      string `json:"url"`
	Markdown string `json:"markdown"`
}

File represents uploaded file to gitlab

Gitlab API docs: http://docs.gitlab.com/ee/api/projects.html#upload-a-file

type Issue

type Issue struct {
	Assignee       *User      `json:"assignee"`
	Author         *User      `json:"author"`
	Description    string     `json:"description"`
	Milestone      *Milestone `json:"milestone"`
	Id             int64      `json:"id"`
	Iid            int64      `json:"iid"`
	Labels         *[]string  `json:"labels"`
	ProjectId      int64      `json:"project_id"`
	State          string     `json:"state"`
	Title          string     `json:"title"`
	UserNotesCount int        `json:"user_notes_count"`
	Subscribed     bool       `json:"subscribed"`
	CreatedAt      time.Time  `json:"created_at"`
	UpdatedAt      time.Time  `json:"updated_at"`
	DueDate        string     `json:"due_date"`
	Confidential   bool       `json:"confidential"`
	WebURL         string     `json:"web_url"`
}

Issue represents a GitLab issue.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html

type IssueListOptions

type IssueListOptions struct {
	// State filters issues based on their state.  Possible values are: open,
	// closed.  Default is "open".
	State string `url:"state,omitempty"`

	ListOptions
}

ListIssuesOptions represents the available ListIssues() options.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html#list-issues

type IssueRequest

type IssueRequest struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	AssigneeId  *int64 `json:"assignee_id"`
	MilestoneId *int64 `json:"milestone_id"`
	Labels      string `json:"labels"`
	StateEvent  string `json:"state_event,omitempty"`
	DueDate     string `json:"due_date,omitempty"`
}

IssueRequest represents the available CreateIssue() and UpdateIssue() options.

GitLab API docs: http://doc.gitlab.com/ce/api/issues.html#new-issues

type Label

type Label struct {
	ID                    int64  `json:"id"`
	Color                 string `json:"color"`
	Name                  string `json:"name"`
	Description           string `json:"description"`
	OpenIssueCount        int    `json:"open_issue_count"`
	ClosedIssueCount      int    `json:"closed_issue_count"`
	OpenMergeRequestCount int    `json:"open_merge_requests_count"`
	Subscribed            bool   `json:"subscribed"`
	Priority              int    `json:"priority"`
}

Label represents a GitLab label.

GitLab API docs: http://doc.gitlab.com/ce/api/labels.html

type LabelDeleteOptions

type LabelDeleteOptions struct {
	Name string `url:"name,omitempty"`
}

type LabelRequest

type LabelRequest struct {
	Color   string `json:"color"`
	Name    string `json:"name"`
	NewName string `json:"new_name,omitempty"`
}

LabelRequest represents the available CreateLabel() and UpdateLabel() options.

type ListOptions

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Page string `url:"page,omitempty"`

	// For paginated result sets, the number of results to include per page.
	PerPage string `url:"per_page,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type Milestone

type Milestone struct {
	ID          int64  `json:"id"`
	IID         int64  `json:"iid"`
	State       string `json:"state,omitempty"`
	Title       string `json:"title,omitempty"`
	DueDate     string `json:"due_date,omitempty"`
	Description string `json:"description"`
	UpdatedAt   string `json:"updated_at"`
	CreatedAt   string `json:"created_at"`
}

Milestone represents a GitLab milestone.

GitLab API docs: http://doc.gitlab.com/ce/api/branches.html

type MilestoneRequest

type MilestoneRequest struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	DueDate     string `json:"due_date"`
}

MilestoneRequest represents the available CreateMilestone() and UpdateMilestone() options.

GitLab API docs: http://doc.gitlab.com/ce/api/milestones.html#create-new-milestone

type MoveIssueRequest

type MoveIssueRequest struct {
	ToProjectID string `json:"to_project_id"`
}

MoveIssueRequest moved issue to another project

type Namespace

type Namespace struct {
	Id     int64   `json:"id"`
	Name   string  `json:"name,omitempty"`
	Avatar *Avatar `json:"avatar,nil,omitempty"`
}

Namespace represents a GitLab namespace.

GitLab API docs: http://doc.gitlab.com/ce/api/namespaces.html

type Project

type Project struct {
	Id                int64      `json:"id"`
	Name              string     `json:"name"`
	NamespaceWithName string     `json:"name_with_namespace"`
	PathWithNamespace string     `json:"path_with_namespace"`
	Namespace         *Namespace `json:"namespace,nil,omitempty"`
	Description       string     `json:"description"`
	LastModified      string     `json:"last_modified"`
	CreatedAt         string     `json:"created_at"`
	Owner             *User      `json:"owner,nil,omitempty"`
	AvatarUrl         string     `json:"avatar_url,nil,omitempty"`
}

Project represents a GitLab project.

GitLab API docs: http://doc.gitlab.com/ce/api/projects.html

type ProjectListOptions

type ProjectListOptions struct {
	// State filters issues based on their state.  Possible values are: open,
	// closed.  Default is "open".
	Archived string `url:"archived,omitempty"`
	// Search find projects by criteria
	Search string `url:"search,omitempty"`
	// Starred if set to "true" return starred projects only
	Starred string `url:"starred,omitempty"`

	ListOptions
}

ProjectListOptions represents the available ListProjects() options.

GitLab API docs: http://doc.gitlab.com/ce/api/projects.html#list-projects

type ResponseError

type ResponseError struct {
	StatusCode int
	// contains filtered or unexported fields
}

func (ResponseError) Error

func (r ResponseError) Error() string

Type response error for usage logic

type Transport

type Transport struct {
	Token string
	Base  http.RoundTripper
}

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

type User

type User struct {
	Id           int64  `json:"id"`
	Name         string `json:"name,omitempty"`
	AvatarUrl    string `json:"avatar_url,nil,omitempty"`
	State        string `json:"state,omitempty"`
	Username     string `json:"username,omitempty"`
	WebUrl       string `json:"web_url,omitempty"`
	PrivateToken string `json:"private_token"`
}

User represents a GitLab user.

GitLab API docs: http://doc.gitlab.com/ce/api/users.html

Jump to

Keyboard shortcuts

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