Documentation
¶
Index ¶
- Constants
- func EncodeProjectPath(projectPath string) string
- type APIError
- type Branch
- type BranchListOpts
- type Client
- func (c *Client) APIPath(resource string) string
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) DeleteWithBody(ctx context.Context, path string, body any) error
- func (c *Client) DownloadTo(ctx context.Context, path string, w io.Writer) error
- func (c *Client) Get(ctx context.Context, path string) ([]byte, error)
- func (c *Client) GetWithPagination(ctx context.Context, path string) ([]byte, Pagination, error)
- func (c *Client) Host() string
- func (c *Client) Post(ctx context.Context, path string, body any) ([]byte, error)
- func (c *Client) Put(ctx context.Context, path string, body any) ([]byte, error)
- func (c *Client) RawGet(ctx context.Context, path string, headers map[string]string) (int, []byte, error)
- func (c *Client) Upload(ctx context.Context, path, fieldName, filePath string) ([]byte, error)
- type Commit
- type CommitListOpts
- type FileWriteBody
- type Issue
- type IssueAPI
- func (a *IssueAPI) AddNote(ctx context.Context, projectID string, iid int, body string) (*IssueNote, error)
- func (a *IssueAPI) Create(ctx context.Context, projectID string, opts IssueCreateOpts) (*Issue, error)
- func (a *IssueAPI) DeleteNote(ctx context.Context, projectID string, iid, noteID int) error
- func (a *IssueAPI) Get(ctx context.Context, projectID string, iid int) (*Issue, error)
- func (a *IssueAPI) List(ctx context.Context, projectID string, opts *IssueListOpts) ([]Issue, error)
- func (a *IssueAPI) ListNotes(ctx context.Context, projectID string, iid, limit int) ([]IssueNote, error)
- func (a *IssueAPI) Update(ctx context.Context, projectID string, iid int, opts IssueUpdateOpts) (*Issue, error)
- type IssueCreateOpts
- type IssueListOpts
- type IssueNote
- type IssueUpdateOpts
- type Job
- type JobAPI
- func (a *JobAPI) Artifacts(ctx context.Context, projectID string, jobID int) ([]byte, error)
- func (a *JobAPI) ArtifactsTo(ctx context.Context, projectID string, jobID int, w io.Writer) error
- func (a *JobAPI) Cancel(ctx context.Context, projectID string, jobID int) (*Job, error)
- func (a *JobAPI) Get(ctx context.Context, projectID string, jobID int) (*Job, error)
- func (a *JobAPI) Log(ctx context.Context, projectID string, jobID int) ([]byte, error)
- func (a *JobAPI) LogStream(ctx context.Context, projectID string, jobID int, w io.Writer, ...) error
- func (a *JobAPI) Retry(ctx context.Context, projectID string, jobID int) (*Job, error)
- type Label
- type LabelAPI
- func (a *LabelAPI) Create(ctx context.Context, projectID string, opts LabelCreateOpts) (*Label, error)
- func (a *LabelAPI) Delete(ctx context.Context, projectID string, labelID int) error
- func (a *LabelAPI) List(ctx context.Context, projectID string, limit int) ([]Label, error)
- func (a *LabelAPI) Update(ctx context.Context, projectID string, labelID int, opts LabelUpdateOpts) (*Label, error)
- type LabelCreateOpts
- type LabelUpdateOpts
- type MergeRequest
- type MergeRequestAPI
- func (a *MergeRequestAPI) AddNote(ctx context.Context, projectID string, iid int, body string) (*MergeRequestNote, error)
- func (a *MergeRequestAPI) Approve(ctx context.Context, projectID string, iid int) error
- func (a *MergeRequestAPI) Close(ctx context.Context, projectID string, iid int) (*MergeRequest, error)
- func (a *MergeRequestAPI) Create(ctx context.Context, projectID string, req *MergeRequestCreateRequest) (*MergeRequest, error)
- func (a *MergeRequestAPI) DeleteNote(ctx context.Context, projectID string, iid, noteID int) error
- func (a *MergeRequestAPI) Get(ctx context.Context, projectID string, iid int) (*MergeRequest, error)
- func (a *MergeRequestAPI) GetRawDiff(ctx context.Context, projectID string, iid int) (string, error)
- func (a *MergeRequestAPI) List(ctx context.Context, projectID string, opts *MergeRequestListOpts) ([]MergeRequest, error)
- func (a *MergeRequestAPI) ListNotes(ctx context.Context, projectID string, iid, limit int) ([]MergeRequestNote, error)
- func (a *MergeRequestAPI) Merge(ctx context.Context, projectID string, iid int, req *MergeRequestMergeRequest) (*MergeRequest, error)
- func (a *MergeRequestAPI) Reopen(ctx context.Context, projectID string, iid int) (*MergeRequest, error)
- func (a *MergeRequestAPI) Unapprove(ctx context.Context, projectID string, iid int) error
- func (a *MergeRequestAPI) Update(ctx context.Context, projectID string, iid int, req *MergeRequestUpdateRequest) (*MergeRequest, error)
- type MergeRequestCreateRequest
- type MergeRequestListOpts
- type MergeRequestMergeRequest
- type MergeRequestNote
- type MergeRequestUpdateRequest
- type Milestone
- type MilestoneAPI
- func (a *MilestoneAPI) Create(ctx context.Context, projectID string, opts MilestoneCreateOpts) (*Milestone, error)
- func (a *MilestoneAPI) Delete(ctx context.Context, projectID string, milestoneID int) error
- func (a *MilestoneAPI) GetByID(ctx context.Context, projectID string, milestoneID int) (*Milestone, error)
- func (a *MilestoneAPI) List(ctx context.Context, projectID string, opts *MilestoneListOpts) ([]Milestone, error)
- func (a *MilestoneAPI) Update(ctx context.Context, projectID string, milestoneID int, ...) (*Milestone, error)
- type MilestoneCreateOpts
- type MilestoneListOpts
- type MilestoneUpdateOpts
- type Pagination
- type Pipeline
- type PipelineAPI
- func (a *PipelineAPI) Cancel(ctx context.Context, projectID string, pipelineID int) (*Pipeline, error)
- func (a *PipelineAPI) Create(ctx context.Context, projectID string, body PipelineCreateBody) (*Pipeline, error)
- func (a *PipelineAPI) Get(ctx context.Context, projectID string, pipelineID int) (*Pipeline, error)
- func (a *PipelineAPI) Jobs(ctx context.Context, projectID string, pipelineID int, scope []string) ([]Job, error)
- func (a *PipelineAPI) List(ctx context.Context, projectID string, opts *PipelineListOpts) ([]Pipeline, error)
- func (a *PipelineAPI) Retry(ctx context.Context, projectID string, pipelineID int) (*Pipeline, error)
- type PipelineCreateBody
- type PipelineListOpts
- type PipelineVariable
- type Project
- type ProjectAPI
- type ProjectListOpts
- type ProjectMember
- type Release
- type ReleaseAPI
- func (a *ReleaseAPI) Create(ctx context.Context, projectID string, body ReleaseCreateBody) (*Release, error)
- func (a *ReleaseAPI) Delete(ctx context.Context, projectID, tagName string) error
- func (a *ReleaseAPI) Get(ctx context.Context, projectID, tagName string) (*Release, error)
- func (a *ReleaseAPI) List(ctx context.Context, projectID string, limit int) ([]Release, error)
- func (a *ReleaseAPI) Update(ctx context.Context, projectID, tagName string, body ReleaseUpdateBody) (*Release, error)
- type ReleaseAssets
- type ReleaseCreateBody
- type ReleaseUpdateBody
- type RepoAPI
- func (a *RepoAPI) CreateBranch(ctx context.Context, projectID, name, ref string) (*Branch, error)
- func (a *RepoAPI) CreateFile(ctx context.Context, projectID, filePath string, body FileWriteBody) error
- func (a *RepoAPI) DeleteBranch(ctx context.Context, projectID, name string) error
- func (a *RepoAPI) DeleteFile(ctx context.Context, projectID, filePath, branch, commitMessage string) error
- func (a *RepoAPI) GetCommit(ctx context.Context, projectID, sha string) (*Commit, error)
- func (a *RepoAPI) GetFile(ctx context.Context, projectID, filePath, ref string) (*RepoFile, error)
- func (a *RepoAPI) GetFileRaw(ctx context.Context, projectID, filePath, ref string) ([]byte, error)
- func (a *RepoAPI) ListBranches(ctx context.Context, projectID string, opts *BranchListOpts) ([]Branch, error)
- func (a *RepoAPI) ListCommits(ctx context.Context, projectID string, opts *CommitListOpts) ([]Commit, error)
- func (a *RepoAPI) ListTree(ctx context.Context, projectID string, opts *TreeOpts) ([]TreeEntry, error)
- func (a *RepoAPI) UpdateFile(ctx context.Context, projectID, filePath string, body FileWriteBody) error
- type RepoFile
- type SearchAPI
- func (a *SearchAPI) Code(ctx context.Context, query, project string, limit int) ([]SearchBlob, error)
- func (a *SearchAPI) Commits(ctx context.Context, query, project string, limit int) ([]SearchCommit, error)
- func (a *SearchAPI) Issues(ctx context.Context, query, project string, limit int) ([]SearchIssue, error)
- func (a *SearchAPI) MergeRequests(ctx context.Context, query, project string, limit int) ([]SearchMR, error)
- func (a *SearchAPI) Projects(ctx context.Context, query string, limit int) ([]SearchProject, error)
- type SearchBlob
- type SearchCommit
- type SearchIssue
- type SearchMR
- type SearchProject
- type TreeEntry
- type TreeOpts
- type User
- type UserAPI
- type Variable
- type VariableAPI
- func (a *VariableAPI) Create(ctx context.Context, projectID string, opts *VariableCreateOpts) (*Variable, error)
- func (a *VariableAPI) Delete(ctx context.Context, projectID, key, envScope string) error
- func (a *VariableAPI) Get(ctx context.Context, projectID, key, envScope string) (*Variable, error)
- func (a *VariableAPI) List(ctx context.Context, projectID string, limit int) ([]Variable, error)
- func (a *VariableAPI) Update(ctx context.Context, projectID, key, envScope string, opts *VariableUpdateOpts) (*Variable, error)
- type VariableCreateOpts
- type VariableUpdateOpts
Constants ¶
const APIBasePath = "/api/v4"
APIBasePath is the GitLab REST API v4 base path.
Variables ¶
This section is empty.
Functions ¶
func EncodeProjectPath ¶
EncodeProjectPath URL-encodes a "group/subgroup/project" path for use in /api/v4/projects/:id endpoints. A numeric project ID is left as-is.
Types ¶
type Branch ¶
type Branch struct {
Name string `json:"name"`
Merged bool `json:"merged"`
Protected bool `json:"protected"`
Default bool `json:"default"`
DevelopersCanPush bool `json:"developers_can_push"`
DevelopersCanMerge bool `json:"developers_can_merge"`
CanPush bool `json:"can_push"`
WebURL string `json:"web_url"`
Commit *Commit `json:"commit"`
}
Branch is returned by GET /projects/:id/repository/branches
type BranchListOpts ¶
BranchListOpts are options for listing branches.
type Client ¶
type Client struct {
// DownloadClient is used for large/binary downloads (artifacts, etc.).
DownloadClient *http.Client
// API groups — populated by NewClient. Subagents implement methods on each
// API type in their own file (e.g. internal/api/mr.go). Always alphabetical.
Issues *IssueAPI
Jobs *JobAPI
Labels *LabelAPI
MergeRequests *MergeRequestAPI
Milestones *MilestoneAPI
Pipelines *PipelineAPI
Projects *ProjectAPI
Releases *ReleaseAPI
Repos *RepoAPI
Search *SearchAPI
Users *UserAPI
Variables *VariableAPI
// contains filtered or unexported fields
}
Client wraps the GitLab REST API v4 HTTP client.
func (*Client) DeleteWithBody ¶
DeleteWithBody sends a DELETE request with a JSON body. Required for GitLab endpoints that take parameters in the body on DELETE (e.g. repository file deletion takes branch + commit_message in the body).
func (*Client) DownloadTo ¶
DownloadTo streams a GET response body to w using DownloadClient (long timeout).
func (*Client) GetWithPagination ¶
GetWithPagination sends a GET request and returns body + pagination metadata from the response headers. Useful for list endpoints.
func (*Client) RawGet ¶
func (c *Client) RawGet(ctx context.Context, path string, headers map[string]string) (int, []byte, error)
RawGet performs a GET with optional extra headers and returns (statusCode, body, error). It retries on 429/5xx but NOT on 416 (range not satisfiable — expected for streaming).
type Commit ¶
type Commit struct {
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
Message string `json:"message"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
AuthoredDate string `json:"authored_date"`
CommitterName string `json:"committer_name"`
CommitterEmail string `json:"committer_email"`
CommittedDate string `json:"committed_date"`
WebURL string `json:"web_url"`
ParentIDs []string `json:"parent_ids"`
}
Commit is returned by GET /projects/:id/repository/commits
type CommitListOpts ¶
CommitListOpts are options for listing commits.
type FileWriteBody ¶
type FileWriteBody struct {
Branch string `json:"branch"`
Content string `json:"content"`
CommitMessage string `json:"commit_message"`
Encoding string `json:"encoding,omitempty"`
}
FileWriteBody is the request body for create/update file.
type Issue ¶
type Issue struct {
IID int `json:"iid"`
ID int `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
Labels []string `json:"labels"`
Confidential bool `json:"confidential"`
WebURL string `json:"web_url"`
Author *User `json:"author"`
Assignee *User `json:"assignee"`
Milestone *struct {
ID int `json:"id"`
Title string `json:"title"`
} `json:"milestone"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Issue represents a GitLab project issue.
type IssueAPI ¶
type IssueAPI struct {
// contains filtered or unexported fields
}
IssueAPI wraps issue-related API calls.
Endpoint reference: https://docs.gitlab.com/api/issues/
func (*IssueAPI) AddNote ¶
func (a *IssueAPI) AddNote(ctx context.Context, projectID string, iid int, body string) (*IssueNote, error)
AddNote adds a comment to an issue.
POST /api/v4/projects/:id/issues/:iid/notes
func (*IssueAPI) Create ¶
func (a *IssueAPI) Create(ctx context.Context, projectID string, opts IssueCreateOpts) (*Issue, error)
Create creates a new issue.
POST /api/v4/projects/:id/issues
func (*IssueAPI) DeleteNote ¶
DeleteNote deletes a comment from an issue.
DELETE /api/v4/projects/:id/issues/:iid/notes/:note_id
func (*IssueAPI) List ¶
func (a *IssueAPI) List(ctx context.Context, projectID string, opts *IssueListOpts) ([]Issue, error)
List returns issues for a project.
GET /api/v4/projects/:id/issues
type IssueCreateOpts ¶
type IssueCreateOpts struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
AssigneeIDs []int `json:"assignee_ids,omitempty"`
Labels string `json:"labels,omitempty"`
MilestoneID int `json:"milestone_id,omitempty"`
Confidential bool `json:"confidential,omitempty"`
}
IssueCreateOpts holds parameters for creating an issue.
type IssueListOpts ¶
type IssueListOpts struct {
State string // opened|closed|all
AssigneeUsername string
AuthorUsername string
Labels string // comma-separated
Search string
Milestone string
Limit int
}
IssueListOpts holds query parameters for listing issues.
type IssueNote ¶
type IssueNote struct {
ID int `json:"id"`
Body string `json:"body"`
Author *User `json:"author"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
System bool `json:"system"`
}
IssueNote represents a comment on an issue.
type IssueUpdateOpts ¶
type IssueUpdateOpts struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
AssigneeIDs []int `json:"assignee_ids,omitempty"`
AddLabels string `json:"add_labels,omitempty"`
RemoveLabels string `json:"remove_labels,omitempty"`
MilestoneID int `json:"milestone_id,omitempty"`
StateEvent string `json:"state_event,omitempty"` // close|reopen
}
IssueUpdateOpts holds parameters for updating an issue.
type Job ¶
type Job struct {
ID int `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Stage string `json:"stage"`
Ref string `json:"ref"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
Duration float64 `json:"duration"`
User *User `json:"user"`
Pipeline *Pipeline `json:"pipeline"`
}
Job represents a GitLab CI job.
type JobAPI ¶
type JobAPI struct {
// contains filtered or unexported fields
}
JobAPI wraps CI job–related API calls.
Endpoint reference: https://docs.gitlab.com/api/jobs/
Methods are implemented in this file by Phase 1 Wave A.
func (*JobAPI) Artifacts ¶
Artifacts downloads the artifacts archive for a job and returns the raw bytes.
GET /api/v4/projects/:id/jobs/:job_id/artifacts
func (*JobAPI) ArtifactsTo ¶
ArtifactsTo streams the artifacts archive for a job to w.
GET /api/v4/projects/:id/jobs/:job_id/artifacts
func (*JobAPI) Log ¶
Log returns the plain-text trace for a job.
GET /api/v4/projects/:id/jobs/:job_id/trace
func (*JobAPI) LogStream ¶
func (a *JobAPI) LogStream(ctx context.Context, projectID string, jobID int, w io.Writer, interval time.Duration) error
LogStream polls the job trace endpoint and writes new bytes to w until the job reaches a terminal state or ctx is cancelled. interval is the poll interval; defaults to 3s if zero.
type Label ¶
type Label struct {
ID int `json:"id"`
Name string `json:"name"`
Color string `json:"color"`
Description string `json:"description"`
Priority *int `json:"priority"`
}
Label represents a GitLab project label.
type LabelAPI ¶
type LabelAPI struct {
// contains filtered or unexported fields
}
LabelAPI wraps label-related API calls.
Endpoint reference: https://docs.gitlab.com/api/labels/
func (*LabelAPI) Create ¶
func (a *LabelAPI) Create(ctx context.Context, projectID string, opts LabelCreateOpts) (*Label, error)
Create creates a new label.
POST /api/v4/projects/:id/labels
type LabelCreateOpts ¶
type LabelCreateOpts struct {
Name string `json:"name"`
Color string `json:"color"`
Description string `json:"description,omitempty"`
Priority *int `json:"priority,omitempty"`
}
LabelCreateOpts holds parameters for creating a label.
type LabelUpdateOpts ¶
type LabelUpdateOpts struct {
NewName string `json:"new_name,omitempty"`
Color string `json:"color,omitempty"`
Description string `json:"description,omitempty"`
Priority *int `json:"priority,omitempty"`
}
LabelUpdateOpts holds parameters for updating a label.
type MergeRequest ¶
type MergeRequest struct {
IID int `json:"iid"`
Title string `json:"title"`
State string `json:"state"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
WebURL string `json:"web_url"`
Description string `json:"description"`
Draft bool `json:"draft"`
Squash bool `json:"squash"`
Author *User `json:"author"`
Assignee *User `json:"assignee"`
Labels []string `json:"labels"`
SHA string `json:"sha"`
MergeStatus string `json:"merge_status"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
MergeRequest mirrors the GitLab MR object (subset of fields the CLI surfaces).
type MergeRequestAPI ¶
type MergeRequestAPI struct {
// contains filtered or unexported fields
}
MergeRequestAPI wraps Merge-Request-related API calls.
Endpoint reference: https://docs.gitlab.com/api/merge_requests/
Methods are implemented in this file by Phase 1 Wave A.
func (*MergeRequestAPI) AddNote ¶
func (a *MergeRequestAPI) AddNote(ctx context.Context, projectID string, iid int, body string) (*MergeRequestNote, error)
AddNote adds a comment to an MR.
func (*MergeRequestAPI) Close ¶
func (a *MergeRequestAPI) Close(ctx context.Context, projectID string, iid int) (*MergeRequest, error)
Close closes an MR via state_event.
func (*MergeRequestAPI) Create ¶
func (a *MergeRequestAPI) Create(ctx context.Context, projectID string, req *MergeRequestCreateRequest) (*MergeRequest, error)
Create creates a new MR.
func (*MergeRequestAPI) DeleteNote ¶
DeleteNote deletes a comment from an MR.
func (*MergeRequestAPI) Get ¶
func (a *MergeRequestAPI) Get(ctx context.Context, projectID string, iid int) (*MergeRequest, error)
Get returns a single MR by IID.
func (*MergeRequestAPI) GetRawDiff ¶
func (a *MergeRequestAPI) GetRawDiff(ctx context.Context, projectID string, iid int) (string, error)
GetRawDiff returns the unified diff text for an MR.
func (*MergeRequestAPI) List ¶
func (a *MergeRequestAPI) List(ctx context.Context, projectID string, opts *MergeRequestListOpts) ([]MergeRequest, error)
List returns merge requests for a project.
func (*MergeRequestAPI) ListNotes ¶
func (a *MergeRequestAPI) ListNotes(ctx context.Context, projectID string, iid, limit int) ([]MergeRequestNote, error)
ListNotes returns comments for an MR.
func (*MergeRequestAPI) Merge ¶
func (a *MergeRequestAPI) Merge(ctx context.Context, projectID string, iid int, req *MergeRequestMergeRequest) (*MergeRequest, error)
Merge merges an MR.
func (*MergeRequestAPI) Reopen ¶
func (a *MergeRequestAPI) Reopen(ctx context.Context, projectID string, iid int) (*MergeRequest, error)
Reopen reopens an MR via state_event.
func (*MergeRequestAPI) Update ¶
func (a *MergeRequestAPI) Update(ctx context.Context, projectID string, iid int, req *MergeRequestUpdateRequest) (*MergeRequest, error)
Update updates an existing MR.
type MergeRequestCreateRequest ¶
type MergeRequestCreateRequest struct {
Title string `json:"title"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
Description string `json:"description,omitempty"`
AssigneeID int `json:"assignee_id,omitempty"`
Labels string `json:"labels,omitempty"`
Draft bool `json:"draft,omitempty"`
Squash bool `json:"squash,omitempty"`
RemoveSourceBranch bool `json:"remove_source_branch,omitempty"`
}
MergeRequestCreateRequest is the POST body for creating an MR.
type MergeRequestListOpts ¶
type MergeRequestListOpts struct {
State string // opened|closed|merged|all
AssigneeUser string
AuthorUser string
Labels string // comma-separated
Search string
SourceBranch string
TargetBranch string
Limit int
}
MergeRequestListOpts holds query parameters for listing MRs.
type MergeRequestMergeRequest ¶
type MergeRequestMergeRequest struct {
Squash bool `json:"squash,omitempty"`
ShouldRemoveSourceBranch bool `json:"should_remove_source_branch,omitempty"`
MergeCommitMessage string `json:"merge_commit_message,omitempty"`
SHA string `json:"sha,omitempty"`
}
MergeRequestMergeRequest is the PUT body for merging an MR.
type MergeRequestNote ¶
type MergeRequestNote struct {
ID int `json:"id"`
Body string `json:"body"`
Author *User `json:"author"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
System bool `json:"system"`
}
MergeRequestNote mirrors a GitLab MR note (comment).
type MergeRequestUpdateRequest ¶
type MergeRequestUpdateRequest struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
AssigneeIDs []int `json:"assignee_ids,omitempty"`
AddLabels string `json:"add_labels,omitempty"`
RemoveLabels string `json:"remove_labels,omitempty"`
TargetBranch string `json:"target_branch,omitempty"`
StateEvent string `json:"state_event,omitempty"` // "close" or "reopen"
}
MergeRequestUpdateRequest is the PUT body for updating an MR.
type Milestone ¶
type Milestone struct {
ID int `json:"id"`
IID int `json:"iid"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
StartDate string `json:"start_date"`
DueDate string `json:"due_date"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Milestone represents a GitLab project milestone.
type MilestoneAPI ¶
type MilestoneAPI struct {
// contains filtered or unexported fields
}
MilestoneAPI wraps milestone-related API calls.
Endpoint reference: https://docs.gitlab.com/api/milestones/
func (*MilestoneAPI) Create ¶
func (a *MilestoneAPI) Create(ctx context.Context, projectID string, opts MilestoneCreateOpts) (*Milestone, error)
Create creates a new milestone.
POST /api/v4/projects/:id/milestones
func (*MilestoneAPI) Delete ¶
Delete deletes a milestone.
DELETE /api/v4/projects/:id/milestones/:milestone_id
func (*MilestoneAPI) GetByID ¶
func (a *MilestoneAPI) GetByID(ctx context.Context, projectID string, milestoneID int) (*Milestone, error)
GetByID returns a single milestone by its ID.
GET /api/v4/projects/:id/milestones/:milestone_id
func (*MilestoneAPI) List ¶
func (a *MilestoneAPI) List(ctx context.Context, projectID string, opts *MilestoneListOpts) ([]Milestone, error)
List returns milestones for a project.
GET /api/v4/projects/:id/milestones
func (*MilestoneAPI) Update ¶
func (a *MilestoneAPI) Update(ctx context.Context, projectID string, milestoneID int, opts MilestoneUpdateOpts) (*Milestone, error)
Update updates an existing milestone.
PUT /api/v4/projects/:id/milestones/:milestone_id
type MilestoneCreateOpts ¶
type MilestoneCreateOpts struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
StartDate string `json:"start_date,omitempty"`
DueDate string `json:"due_date,omitempty"`
}
MilestoneCreateOpts holds parameters for creating a milestone.
type MilestoneListOpts ¶
MilestoneListOpts holds query parameters for listing milestones.
type MilestoneUpdateOpts ¶
type MilestoneUpdateOpts struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
StartDate string `json:"start_date,omitempty"`
DueDate string `json:"due_date,omitempty"`
StateEvent string `json:"state_event,omitempty"` // close|activate
}
MilestoneUpdateOpts holds parameters for updating a milestone.
type Pagination ¶
type Pagination struct {
Total int // X-Total (may be empty for very large lists)
TotalPages int // X-Total-Pages
Page int // X-Page
PerPage int // X-Per-Page
NextPage int // X-Next-Page (0 if last)
PrevPage int // X-Prev-Page (0 if first)
Link string // Link header
}
Pagination holds the page metadata returned in GitLab response headers.
func PaginateGET ¶
func PaginateGET(ctx context.Context, c *Client, path string, limit int) ([]byte, Pagination, error)
PaginateGET fetches a GitLab list endpoint across pages using X-Next-Page until limit items are collected or there are no more pages. path may include query parameters; per_page and page are set or overridden by this helper. The returned Pagination reflects the last page fetched (use NextPage for hasMore).
type Pipeline ¶
type Pipeline struct {
ID int `json:"id"`
IID int `json:"iid"`
ProjectID int `json:"project_id"`
Ref string `json:"ref"`
SHA string `json:"sha"`
Status string `json:"status"`
Source string `json:"source"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
User *User `json:"user"`
}
Pipeline represents a GitLab CI pipeline.
type PipelineAPI ¶
type PipelineAPI struct {
// contains filtered or unexported fields
}
PipelineAPI wraps pipeline-related API calls.
Endpoint reference: https://docs.gitlab.com/api/pipelines/
Methods are implemented in this file by Phase 1 Wave A.
func (*PipelineAPI) Cancel ¶
func (a *PipelineAPI) Cancel(ctx context.Context, projectID string, pipelineID int) (*Pipeline, error)
Cancel cancels a pipeline.
POST /api/v4/projects/:id/pipelines/:pipeline_id/cancel
func (*PipelineAPI) Create ¶
func (a *PipelineAPI) Create(ctx context.Context, projectID string, body PipelineCreateBody) (*Pipeline, error)
Create triggers a new pipeline.
POST /api/v4/projects/:id/pipeline
func (*PipelineAPI) Get ¶
Get returns a single pipeline.
GET /api/v4/projects/:id/pipelines/:pipeline_id
func (*PipelineAPI) Jobs ¶
func (a *PipelineAPI) Jobs(ctx context.Context, projectID string, pipelineID int, scope []string) ([]Job, error)
Jobs returns jobs for a pipeline.
GET /api/v4/projects/:id/pipelines/:pipeline_id/jobs
func (*PipelineAPI) List ¶
func (a *PipelineAPI) List(ctx context.Context, projectID string, opts *PipelineListOpts) ([]Pipeline, error)
List returns pipelines for a project.
GET /api/v4/projects/:id/pipelines
type PipelineCreateBody ¶
type PipelineCreateBody struct {
Ref string `json:"ref"`
Variables []PipelineVariable `json:"variables,omitempty"`
}
PipelineCreateBody is the request body for creating a pipeline.
type PipelineListOpts ¶
PipelineListOpts holds query parameters for listing pipelines.
type PipelineVariable ¶
PipelineVariable is a key/value pair for pipeline variables.
type Project ¶
type Project struct {
ID int `json:"id"`
Name string `json:"name"`
PathWithNamespace string `json:"path_with_namespace"`
Visibility string `json:"visibility"`
WebURL string `json:"web_url"`
DefaultBranch string `json:"default_branch"`
Description string `json:"description"`
SSHURLToRepo string `json:"ssh_url_to_repo"`
HTTPURLToRepo string `json:"http_url_to_repo"`
StarCount int `json:"star_count"`
ForksCount int `json:"forks_count"`
CreatedAt string `json:"created_at"`
LastActivityAt string `json:"last_activity_at"`
}
Project mirrors the GitLab project object (subset of fields the CLI surfaces).
type ProjectAPI ¶
type ProjectAPI struct {
// contains filtered or unexported fields
}
ProjectAPI wraps project-related API calls.
Endpoint reference: https://docs.gitlab.com/api/projects/
Methods are implemented in this file by Phase 1 Wave B.
func (*ProjectAPI) List ¶
func (a *ProjectAPI) List(ctx context.Context, opts *ProjectListOpts) ([]Project, error)
List returns projects matching the given options.
GET /api/v4/projects
func (*ProjectAPI) Members ¶
func (a *ProjectAPI) Members(ctx context.Context, idOrPath, query string, limit int) ([]ProjectMember, error)
Members returns members of a project.
GET /api/v4/projects/:id/members
type ProjectListOpts ¶
type ProjectListOpts struct {
Owned bool
Membership bool
Search string
Visibility string // public|internal|private
Limit int
}
ProjectListOpts holds query parameters for listing projects.
type ProjectMember ¶
type ProjectMember struct {
ID int `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
State string `json:"state"`
AccessLevel int `json:"access_level"`
WebURL string `json:"web_url"`
}
ProjectMember mirrors a GitLab project member.
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt string `json:"created_at"`
ReleasedAt string `json:"released_at"`
Author *User `json:"author"`
Commit *Commit `json:"commit"`
Milestones []interface{} `json:"milestones"`
CommitPath string `json:"commit_path"`
TagPath string `json:"tag_path"`
DescriptionHTML string `json:"description_html"`
Assets *ReleaseAssets `json:"assets"`
}
Release is returned by GET /projects/:id/releases
type ReleaseAPI ¶
type ReleaseAPI struct {
// contains filtered or unexported fields
}
ReleaseAPI wraps release-related API calls.
Endpoint reference: https://docs.gitlab.com/api/releases/
func (*ReleaseAPI) Create ¶
func (a *ReleaseAPI) Create(ctx context.Context, projectID string, body ReleaseCreateBody) (*Release, error)
Create creates a new release. POST /api/v4/projects/:id/releases
func (*ReleaseAPI) Delete ¶
func (a *ReleaseAPI) Delete(ctx context.Context, projectID, tagName string) error
Delete deletes a release. DELETE /api/v4/projects/:id/releases/:tag_name
func (*ReleaseAPI) Get ¶
Get returns a single release by tag name. GET /api/v4/projects/:id/releases/:tag_name
func (*ReleaseAPI) Update ¶
func (a *ReleaseAPI) Update(ctx context.Context, projectID, tagName string, body ReleaseUpdateBody) (*Release, error)
Update updates an existing release. PUT /api/v4/projects/:id/releases/:tag_name
type ReleaseAssets ¶
type ReleaseAssets struct {
Count int `json:"count"`
Sources []struct {
Format string `json:"format"`
URL string `json:"url"`
} `json:"sources"`
}
ReleaseAssets holds asset counts for a release.
type ReleaseCreateBody ¶
type ReleaseCreateBody struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Ref string `json:"ref,omitempty"`
Milestones []string `json:"milestones,omitempty"`
}
ReleaseCreateBody is the request body for creating a release.
type ReleaseUpdateBody ¶
type ReleaseUpdateBody struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Milestones []string `json:"milestones,omitempty"`
}
ReleaseUpdateBody is the request body for updating a release.
type RepoAPI ¶
type RepoAPI struct {
// contains filtered or unexported fields
}
RepoAPI wraps repository-related API calls (files, branches, commits, tree).
Endpoint references:
https://docs.gitlab.com/api/repository_files/ https://docs.gitlab.com/api/branches/ https://docs.gitlab.com/api/commits/ https://docs.gitlab.com/api/repositories/
func (*RepoAPI) CreateBranch ¶
CreateBranch creates a new branch.
func (*RepoAPI) CreateFile ¶
func (a *RepoAPI) CreateFile(ctx context.Context, projectID, filePath string, body FileWriteBody) error
CreateFile creates a new file in the repository.
func (*RepoAPI) DeleteBranch ¶
DeleteBranch deletes a branch.
func (*RepoAPI) DeleteFile ¶
func (a *RepoAPI) DeleteFile(ctx context.Context, projectID, filePath, branch, commitMessage string) error
DeleteFile deletes a file from the repository.
func (*RepoAPI) GetFileRaw ¶
GetFileRaw returns the raw bytes of a file.
func (*RepoAPI) ListBranches ¶
func (a *RepoAPI) ListBranches(ctx context.Context, projectID string, opts *BranchListOpts) ([]Branch, error)
ListBranches lists branches for a project.
func (*RepoAPI) ListCommits ¶
func (a *RepoAPI) ListCommits(ctx context.Context, projectID string, opts *CommitListOpts) ([]Commit, error)
ListCommits lists commits for a project.
func (*RepoAPI) ListTree ¶
func (a *RepoAPI) ListTree(ctx context.Context, projectID string, opts *TreeOpts) ([]TreeEntry, error)
ListTree lists tree entries for a project.
func (*RepoAPI) UpdateFile ¶
func (a *RepoAPI) UpdateFile(ctx context.Context, projectID, filePath string, body FileWriteBody) error
UpdateFile updates an existing file in the repository.
type RepoFile ¶
type RepoFile struct {
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
Size int `json:"size"`
Encoding string `json:"encoding"`
Content string `json:"content"`
ContentSHA256 string `json:"content_sha256"`
Ref string `json:"ref"`
BlobID string `json:"blob_id"`
CommitID string `json:"commit_id"`
LastCommitID string `json:"last_commit_id"`
}
RepoFile is returned by GET /projects/:id/repository/files/:path
type SearchAPI ¶
type SearchAPI struct {
// contains filtered or unexported fields
}
SearchAPI wraps the global search API.
Endpoint reference: https://docs.gitlab.com/api/search/
Methods are implemented in this file by Phase 1 Wave B.
func (*SearchAPI) Code ¶
func (a *SearchAPI) Code(ctx context.Context, query, project string, limit int) ([]SearchBlob, error)
Code searches for code (blobs) within a project. project is required.
GET /api/v4/projects/:id/search?scope=blobs&search=<q>
func (*SearchAPI) Commits ¶
func (a *SearchAPI) Commits(ctx context.Context, query, project string, limit int) ([]SearchCommit, error)
Commits searches for commits. If project is non-empty, uses project-scoped endpoint.
GET /api/v4/search?scope=commits&search=<q> GET /api/v4/projects/:id/search?scope=commits&search=<q>
func (*SearchAPI) Issues ¶
func (a *SearchAPI) Issues(ctx context.Context, query, project string, limit int) ([]SearchIssue, error)
Issues searches for issues. If project is non-empty, uses project-scoped endpoint.
GET /api/v4/search?scope=issues&search=<q> GET /api/v4/projects/:id/search?scope=issues&search=<q>
func (*SearchAPI) MergeRequests ¶
func (a *SearchAPI) MergeRequests(ctx context.Context, query, project string, limit int) ([]SearchMR, error)
MergeRequests searches for MRs. If project is non-empty, uses project-scoped endpoint.
GET /api/v4/search?scope=merge_requests&search=<q> GET /api/v4/projects/:id/search?scope=merge_requests&search=<q>
type SearchBlob ¶
type SearchBlob struct {
Basename string `json:"basename"`
Data string `json:"data"`
Path string `json:"path"`
Filename string `json:"filename"`
Ref string `json:"ref"`
StartLine int `json:"startline"`
ProjectID int `json:"project_id"`
}
SearchBlob is a code search result (blob/file match).
type SearchCommit ¶
type SearchCommit struct {
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
CreatedAt string `json:"created_at"`
WebURL string `json:"web_url"`
ProjectID int `json:"project_id"`
}
SearchCommit is a slim commit result from search.
type SearchIssue ¶
type SearchIssue struct {
ID int `json:"id"`
IID int `json:"iid"`
Title string `json:"title"`
State string `json:"state"`
WebURL string `json:"web_url"`
ProjectID int `json:"project_id"`
}
SearchIssue is a slim issue result from search.
type SearchMR ¶
type SearchMR struct {
ID int `json:"id"`
IID int `json:"iid"`
Title string `json:"title"`
State string `json:"state"`
WebURL string `json:"web_url"`
ProjectID int `json:"project_id"`
}
SearchMR is a slim merge request result from search.
type SearchProject ¶
type SearchProject struct {
ID int `json:"id"`
Name string `json:"name"`
PathWithNamespace string `json:"path_with_namespace"`
WebURL string `json:"web_url"`
Visibility string `json:"visibility"`
DefaultBranch string `json:"default_branch"`
}
SearchProject is a slim project result from global search.
type TreeEntry ¶
type TreeEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // "blob" or "tree"
Path string `json:"path"`
Mode string `json:"mode"`
}
TreeEntry is returned by GET /projects/:id/repository/tree
type UserAPI ¶
type UserAPI struct {
// contains filtered or unexported fields
}
UserAPI wraps user-related API calls.
Endpoint reference: https://docs.gitlab.com/api/users/
func (*UserAPI) GetByUsername ¶
GetByUsername fetches a user by username via /users?username=<name>. Returns nil, nil if no user found.
type Variable ¶
type Variable struct {
Key string `json:"key"`
Value string `json:"value"`
VariableType string `json:"variable_type"`
Protected bool `json:"protected"`
Masked bool `json:"masked"`
Raw bool `json:"raw"`
EnvironmentScope string `json:"environment_scope"`
Description string `json:"description"`
}
Variable mirrors a GitLab project-level CI/CD variable.
type VariableAPI ¶
type VariableAPI struct {
// contains filtered or unexported fields
}
VariableAPI wraps CI/CD variable–related API calls.
Endpoint reference: https://docs.gitlab.com/api/project_level_variables/
Methods are implemented in this file by Phase 1 Wave B.
func (*VariableAPI) Create ¶
func (a *VariableAPI) Create(ctx context.Context, projectID string, opts *VariableCreateOpts) (*Variable, error)
Create creates a new CI/CD variable.
POST /api/v4/projects/:id/variables
func (*VariableAPI) Delete ¶
func (a *VariableAPI) Delete(ctx context.Context, projectID, key, envScope string) error
Delete deletes a CI/CD variable.
DELETE /api/v4/projects/:id/variables/:key?filter[env_scope]=<scope>
func (*VariableAPI) Get ¶
Get returns a single variable by key.
GET /api/v4/projects/:id/variables/:key?filter[env_scope]=<scope>
func (*VariableAPI) List ¶
List returns all CI/CD variables for a project.
GET /api/v4/projects/:id/variables?per_page=N
func (*VariableAPI) Update ¶
func (a *VariableAPI) Update(ctx context.Context, projectID, key, envScope string, opts *VariableUpdateOpts) (*Variable, error)
Update updates an existing CI/CD variable.
PUT /api/v4/projects/:id/variables/:key?filter[env_scope]=<scope>
type VariableCreateOpts ¶
type VariableCreateOpts struct {
Key string `json:"key"`
Value string `json:"value"`
VariableType string `json:"variable_type,omitempty"`
Protected bool `json:"protected,omitempty"`
Masked bool `json:"masked,omitempty"`
Raw bool `json:"raw,omitempty"`
EnvironmentScope string `json:"environment_scope,omitempty"`
Description string `json:"description,omitempty"`
}
VariableCreateOpts is the POST body for creating a variable.
type VariableUpdateOpts ¶
type VariableUpdateOpts struct {
Value string `json:"value,omitempty"`
VariableType string `json:"variable_type,omitempty"`
Protected *bool `json:"protected,omitempty"`
Masked *bool `json:"masked,omitempty"`
Raw *bool `json:"raw,omitempty"`
EnvironmentScope string `json:"environment_scope,omitempty"`
Description string `json:"description,omitempty"`
}
VariableUpdateOpts is the PUT body for updating a variable.