Help us shape the future of Go! Take the 2026 Go Developer Survey

service

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package service is the orchestration between the tools and the REST client: resolving a project once per call, the reads that take more than one request, and turning wire types into the model a result carries, with every piece of other people's text prepared by render on the way (docs/architecture.md §4.1, §4.8).

Index

Constants

View Source
const MaxCommitActions = 100

MaxCommitActions caps one commit's file changes.

View Source
const MaxSuggestions = 100

MaxSuggestions caps the suggestions one call applies.

View Source
const MaxTodos = 100

MaxTodos caps mark_todos_done.

View Source
const SearchExcerptChars = 1000

SearchExcerptChars bounds one search row's excerpt: a blob's matching lines or a note's body.

Variables

View Source
var IssueLinkTypes = []string{"relates_to", "blocks", "is_blocked_by"}

IssueLinkTypes are the link types GitLab takes; blocks and is_blocked_by need Premium.

View Source
var MergeRequestLinkTypes = []string{"blocks", "is_blocked_by"}

MergeRequestLinkTypes are the directions of a dependency, from the first merge request's side: it blocks the other, or the other blocks it.

View Source
var MilestoneStates = []string{"close", "activate"}

MilestoneStates are the state changes update_milestone takes.

View Source
var ReviewerStates = []string{"approved", "requested_changes", "reviewed"}

ReviewerStates are submit_review's reviewer states.

View Source
var SearchScopes = []string{"blobs", "commits", "issues", "merge_requests", "milestones", "notes", "projects", "users", "wiki_blobs"}

SearchScopes are the scopes search takes. Snippet titles are left to the snippets toolset.

View Source
var SnippetFileActions = []string{"create", "update", "delete", "move"}

SnippetFileActions are the actions a file change takes.

View Source
var WikiFormats = []string{"asciidoc", "markdown", "org", "rdoc"}

WikiFormats are the markups a page can be written in.

Functions

This section is empty.

Types

type BlameRequest

type BlameRequest struct {
	Project   string
	Path      string
	Ref       string
	StartLine int
	EndLine   int
}

BlameRequest is get_blame's request.

type BranchDeletion

type BranchDeletion struct {
	Project string
	Branch  string
	// SHA is the head the caller read: a branch pushed to since is not
	// deleted unseen.
	SHA string
	// Unmerged allows a branch whose commits the default branch does not
	// have.
	Unmerged bool
}

BranchDeletion is delete_branch's request.

type Comment

type Comment struct {
	Project      string
	Type         string // issue or merge_request
	IID          int64
	Body         string
	DiscussionID string
	Location     *DiffLocation
	// Thread starts a resolvable thread rather than a standalone comment.
	Thread bool
}

Comment is add_comment's request.

type CommentDeletion

type CommentDeletion struct {
	Project   string
	Type      string // issue or merge_request
	IID       int64
	NoteID    int64
	UpdatedAt string
}

CommentDeletion is delete_comment's request.

type CommentEdit

type CommentEdit struct {
	Project   string
	Type      string // issue or merge_request
	IID       int64
	NoteID    int64
	Body      string
	UpdatedAt string
}

CommentEdit is update_comment's request.

type CommitAction

type CommitAction struct {
	Action       string // create, update, delete or move
	FilePath     string
	PreviousPath string
	Content      string
	Encoding     string // text or base64
	LastCommitID string
}

CommitAction is one file change of create_commit.

type CommitCreate

type CommitCreate struct {
	Project     string
	Branch      string
	StartBranch string
	Message     string
	Actions     []CommitAction
}

CommitCreate is create_commit's request.

type CompareQuery

type CompareQuery struct {
	Project      string
	From, To     string
	Straight     bool
	CommitOffset int
	FileOffset   int
	DiffOffset   int
}

CompareQuery is compare_refs' query.

type DiffLocation

type DiffLocation struct {
	File    string
	Side    string // new or old
	Line    int
	EndLine int // 0 for one line
}

DiffLocation is a line of a merge request's diff, as the caller names it (§6.2).

type DiscussionQuery

type DiscussionQuery struct {
	Project string
	IID     int64
	// Type is issue or merge_request: which IID names.
	Type           string
	IncludeSystem  bool
	UnresolvedOnly bool
	Max            int
	PageToken      string
	// NoteID and Offset read one comment on from an offset, when a
	// previous page cut it.
	NoteID int64
	Offset int
}

DiscussionQuery is list_discussions' query.

type DraftEdit

type DraftEdit struct {
	Project    string
	IID        int64
	DraftID    int64
	Body       string
	NoteSHA256 string
}

DraftEdit is update_review_comment's request.

type EventQuery

type EventQuery struct {
	Project string
	IID     int64
	// Type is issue or merge_request: which IID names.
	Type      string
	Max       int
	PageToken string
}

EventQuery is list_item_events' query.

type IssueCreate

type IssueCreate struct {
	Project      string
	Title        string
	Description  string
	Labels       []string
	Assignees    []string
	Milestone    string
	DueDate      string
	Confidential bool
}

IssueCreate is create_issue's request.

type IssueLinkRequest

type IssueLinkRequest struct {
	Project       string
	IID           int64
	TargetProject string
	TargetIID     int64
	LinkType      string
}

IssueLinkRequest is link_issues' and unlink_issues' request.

type IssueMoveRequest

type IssueMoveRequest struct {
	Project   string
	IID       int64
	ToProject string
	UpdatedAt string
}

IssueMoveRequest is move_issue's request.

type IssueUpdate

type IssueUpdate struct {
	Project         string
	IID             int64
	UpdatedAt       string
	Title           *string
	Description     *string
	AddLabels       []string
	RemoveLabels    []string
	AddAssignees    []string
	RemoveAssignees []string
	Milestone       *string
	ClearMilestone  bool
	State           string // close or reopen
	DueDate         *string
	ClearDueDate    bool
	Confidential    *bool
}

IssueUpdate is update_issue's request. A nil pointer or empty list is a field left as it is.

type ItemSearch

type ItemSearch struct {
	Project string
	Group   string
	Query   gapi.ItemQuery
	List    gapi.ListOptions
}

ItemSearch is search_issues' and search_merge_requests' query. At most one of Project and Group is set.

type JobLogQuery

type JobLogQuery struct {
	Project string
	JobID   int64
	// ByteOffset is where the window starts; nil takes the tail.
	ByteOffset *int
	// ByteLimit is the window's size; 0 takes render.JobLogBytes.
	ByteLimit  int
	FailedOnly bool
}

JobLogQuery is get_job_log's query. Offsets are bytes of the log as GitLab stores it.

type JobVariable

type JobVariable struct {
	Key   string
	Value string
}

JobVariable is one variable play_job sets.

type LabelRequest

type LabelRequest struct {
	Project          string
	LabelID          int64
	Version          string
	Name             string
	Color            string
	Description      *string
	ClearDescription bool
	Priority         *int
	ClearPriority    bool
}

LabelRequest is create_label's and update_label's request. A nil field is left as it is.

type LintQuery

type LintQuery struct {
	Project     string
	Ref         string
	Simulate    bool
	IncludeJobs bool
	Offset      int
	// Content is configuration to lint instead of the committed one.
	Content string
}

LintQuery is lint_ci's query.

type MRVersionQuery

type MRVersionQuery struct {
	Project                  string
	IID                      int64
	FromVersion, ToVersion   int64
	CommitOffset, FileOffset int
	DiffOffset               int
}

MRVersionQuery is compare_mr_versions' query. ToVersion 0 is the newest version.

type MergeRequestCreate

type MergeRequestCreate struct {
	Project            string
	SourceBranch       string
	TargetBranch       string
	Title              string
	Description        string
	Labels             []string
	Assignees          []string
	Reviewers          []string
	Milestone          string
	Draft              bool
	RemoveSourceBranch bool
	Squash             bool
}

MergeRequestCreate is create_merge_request's request.

type MergeRequestLinkRequest

type MergeRequestLinkRequest struct {
	Project       string
	IID           int64
	TargetProject string
	TargetIID     int64
	LinkType      string
}

MergeRequestLinkRequest is link_merge_requests' and unlink_merge_requests' request.

type MergeRequestMerge

type MergeRequestMerge struct {
	Project             string
	IID                 int64
	SHA                 string
	Squash              *bool
	RemoveSourceBranch  *bool
	MergeCommitMessage  string
	SquashCommitMessage string
	AutoMerge           bool
}

MergeRequestMerge is merge_merge_request's request.

type MergeRequestUpdate

type MergeRequestUpdate struct {
	Project            string
	IID                int64
	UpdatedAt          string
	Title              *string
	Description        *string
	AddLabels          []string
	RemoveLabels       []string
	AddAssignees       []string
	RemoveAssignees    []string
	AddReviewers       []string
	RemoveReviewers    []string
	Milestone          *string
	ClearMilestone     bool
	State              string
	TargetBranch       *string
	Draft              *bool
	RemoveSourceBranch *bool
	Squash             *bool
}

MergeRequestUpdate is update_merge_request's request.

type MilestoneRequest

type MilestoneRequest struct {
	Project          string
	ID               int64
	UpdatedAt        string
	Title            string
	Description      *string
	ClearDescription bool
	DueDate          *string
	ClearDueDate     bool
	StartDate        *string
	ClearStartDate   bool
	StateEvent       string
}

MilestoneRequest is create_milestone's and update_milestone's request. A nil field is left as it is. The clear_ inputs are update's: each clears its field.

type MilestoneSearch

type MilestoneSearch struct {
	Project          string
	Group            string
	State            string
	Search           string
	Title            string
	IncludeAncestors bool
	List             gapi.ListOptions
}

MilestoneSearch is list_milestones' query: a project or a group.

type Options

type Options struct {
	// Client is nil when nobody is signed in; every call then answers
	// [auth].
	Client  *gapi.Client
	Config  config.Config
	Granted []string
}

Options are what the service needs.

type PickRequest

type PickRequest struct {
	Project string
	SHA     string
	Branch  string
	Message string
	Revert  bool
}

PickRequest is cherry_pick_commit's and revert_commit's request.

type PipelineRun

type PipelineRun struct {
	Project   string
	Ref       string
	Variables []PipelineVariable
	Inputs    map[string]any
}

PipelineRun is run_pipeline's request.

type PipelineVariable

type PipelineVariable struct {
	Key   string
	Value string
	Type  string // env_var (default) or file
}

PipelineVariable is one variable run_pipeline sets.

type ProjectSearch

type ProjectSearch struct {
	Search           string
	Group            string
	IncludeSubgroups bool
	// Scope is member (default), owned, starred or all.
	Scope           string
	Visibility      string
	IncludeArchived bool
	List            gapi.ListOptions
}

ProjectSearch is search_projects' query.

type Reaction

type Reaction struct {
	Project string
	Type    string // issue or merge_request
	IID     int64
	NoteID  int64 // 0 for the item itself
	Emoji   string
	Remove  bool
}

Reaction is react's request.

type Registered

type Registered struct {
	Name string
	Kind scopes.Kind
}

Registered is one tool the server registered, for get_me and resolve_url to report the surface that exists rather than a second description of the rules that built it.

type ReleaseCreate

type ReleaseCreate struct {
	Project     string
	TagName     string
	Ref         string
	TagMessage  string
	Name        string
	Description string
	Milestones  []string
	ReleasedAt  *time.Time
	Links       []gapi.ReleaseLink
}

ReleaseCreate is create_release's request.

type Rereview

type Rereview struct {
	Project       string
	IID           int64
	Username      string
	ReviewerState string
}

Rereview is rerequest_review's request.

type Review

type Review struct {
	Project       string
	IID           int64
	Summary       string
	ReviewerState string
}

Review is submit_review's request.

type ReviewComment

type ReviewComment struct {
	Project       string
	IID           int64
	Body          string
	DiscussionID  string
	ResolveThread bool
	Location      *DiffLocation
}

ReviewComment is add_review_comment's request.

type SearchQuery

type SearchQuery struct {
	Project string
	Group   string
	Scope   string
	Search  string
	State   string
	Ref     string
	List    gapi.ListOptions
}

SearchQuery is search's query.

type Service

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

Service holds what every call shares.

func New

func New(o Options) *Service

New builds a Service. The instance comes from the client, or from the configuration when there is no client, so resolve_url can still say what a URL is before anyone signs in.

func (*Service) AddComment

func (s *Service) AddComment(ctx context.Context, in Comment) (model.CommentWrite, error)

AddComment posts a comment now: on an issue or a merge request, as a reply in a thread, as a new resolvable thread, or as a new thread on a line of a merge request's diff.

func (*Service) AddReviewComment

func (s *Service) AddReviewComment(ctx context.Context, in ReviewComment) (model.CommentWrite, error)

AddReviewComment creates a draft: a review comment only its author sees until submit_review publishes it.

func (*Service) AddTodo

func (s *Service) AddTodo(ctx context.Context, raw, typ string, iid int64) (model.TodoWrite, error)

AddTodo adds a to-do item for the signed-in account on an issue or a merge request. GitLab adds none while a pending one the account added is there; other pending items, and done ones, do not stop it.

func (*Service) ApplySuggestions

func (s *Service) ApplySuggestions(ctx context.Context, in SuggestionsApplication) (model.SuggestionsApply, error)

ApplySuggestions commits suggestions from a merge request's diff comments to its source branch, as the account, in one commit. GitLab finds a suggestion by its id alone, so each is first found on this merge request. The source branch is held to create_commit's rule (§4.4): never the default branch or a protected one. The text is someone else's and is committed under the account's name, so a text with characters a reader would not see is refused, and the caller passes each text as it read it, which is held against GitLab's: the commit is what was read, and the client's prompt shows it (§4.12). GitLab answers with the suggestions as they were before the commit and without it, so the result is read back.

func (*Service) ApproveMergeRequest

func (s *Service) ApproveMergeRequest(ctx context.Context, raw string, iid int64, sha string) (model.ApprovalWrite, error)

ApproveMergeRequest approves a merge request at the head the caller read. An approval is someone's sign-off another person's merge rule counts, which is why it is Ship (§4.3, §17.2).

func (*Service) Blame

func (s *Service) Blame(ctx context.Context, in BlameRequest) (model.Blame, error)

Blame shows who last changed each line of a file, a run of lines per commit, under the file budget (§4.8).

func (*Service) CancelAutoMerge

func (s *Service) CancelAutoMerge(ctx context.Context, raw string, iid int64) (model.AutoMergeCancel, error)

CancelAutoMerge stops a merge request from merging when its pipeline succeeds. GitLab answers 201 whether or not it canceled, with the outcome in the body (§18 row 109), so the body and a read afterwards say what happened. Nothing is sent when no auto-merge is set.

func (*Service) CancelPipeline

func (s *Service) CancelPipeline(ctx context.Context, raw string, id int64) (model.PipelineWrite, error)

CancelPipeline cancels a pipeline's running and pending jobs.

func (*Service) CompareMRVersions

func (s *Service) CompareMRVersions(ctx context.Context, q MRVersionQuery) (model.MRVersionChanges, error)

CompareMRVersions shows what changed in a merge request between two of its versions (§7.3). GitLab has no route for it; the web page compares the repository from the older version's head to the newer's, straight rather than from their merge base, so a squash or a rebase between them does not hide the change. This does the same, in the target project, where GitLab keeps both heads.

func (*Service) CompareRefs

func (s *Service) CompareRefs(ctx context.Context, q CompareQuery) (model.Compare, error)

CompareRefs compares two refs: the commits in to and not in from, and the diffs, each under its bound (§7.5). GitLab answers unpaged, so the offsets continue within one answer.

func (*Service) CreateBranch

func (s *Service) CreateBranch(ctx context.Context, raw, branch, ref string) (model.BranchWrite, error)

CreateBranch creates a branch at ref, the default branch when ref is empty. A name a protected rule covers is refused as create_commit refuses it: a new protected branch at a ref of the caller's choosing would put code there that no merge request showed (§4.4).

func (*Service) CreateCommit

func (s *Service) CreateCommit(ctx context.Context, in CommitCreate) (model.CommitWrite, error)

CreateCommit commits file changes to a branch. It refuses the default branch and every protected branch, read at call time: code reaches a protected branch only through a merge request (§4.4).

func (*Service) CreateIssue

func (s *Service) CreateIssue(ctx context.Context, in IssueCreate) (model.IssueWrite, error)

CreateIssue creates an issue.

func (*Service) CreateLabel

func (s *Service) CreateLabel(ctx context.Context, in LabelRequest) (model.LabelWrite, error)

CreateLabel creates a project label.

func (*Service) CreateMergeRequest

func (s *Service) CreateMergeRequest(ctx context.Context, in MergeRequestCreate) (model.MergeRequestWrite, error)

CreateMergeRequest opens a merge request.

func (*Service) CreateMilestone

func (s *Service) CreateMilestone(ctx context.Context, in MilestoneRequest) (model.MilestoneWrite, error)

CreateMilestone creates a project milestone.

func (*Service) CreateRelease

func (s *Service) CreateRelease(ctx context.Context, in ReleaseCreate) (model.ReleaseWrite, error)

CreateRelease creates a release, and its tag at ref when the tag does not exist yet.

func (*Service) CreateSnippet

func (s *Service) CreateSnippet(ctx context.Context, in SnippetCreate) (model.SnippetWrite, error)

CreateSnippet creates a private snippet, in a project or the account's own. Visibility is not the caller's to choose: a public snippet from a model is how private content leaves (§4.7, §7.8).

func (*Service) CreateTag

func (s *Service) CreateTag(ctx context.Context, raw, name, ref, message string) (model.TagWrite, error)

CreateTag creates a tag at a ref. A name a protected-tag rule covers is refused: a protected tag's pipelines see protected variables and may deploy, so it is made by a person (§17.13).

func (*Service) DeleteBranch

func (s *Service) DeleteBranch(ctx context.Context, in BranchDeletion) (model.BranchDelete, error)

DeleteBranch deletes a branch. It refuses the default branch and every protected one, and one GitLab does not count merged unless the caller says so.

func (*Service) DeleteComment

func (s *Service) DeleteComment(ctx context.Context, in CommentDeletion) (model.CommentDelete, error)

DeleteComment deletes one of the signed-in account's own comments.

func (*Service) DeleteLabel

func (s *Service) DeleteLabel(ctx context.Context, raw string, id int64, version string) (model.LabelWrite, error)

DeleteLabel deletes a project label, which takes it off every issue and merge request.

func (*Service) DeleteMilestone

func (s *Service) DeleteMilestone(ctx context.Context, raw string, id int64, updatedAt string) (model.MilestoneWrite, error)

DeleteMilestone deletes a project milestone the caller read, which takes it off every issue and merge request.

func (*Service) DeleteReviewComment

func (s *Service) DeleteReviewComment(ctx context.Context, raw string, iid, draftID int64) (model.DraftDelete, error)

DeleteReviewComment deletes one of the signed-in account's drafts.

func (*Service) DeleteSnippet

func (s *Service) DeleteSnippet(ctx context.Context, raw string, id int64, updatedAt string) (model.SnippetDelete, error)

DeleteSnippet deletes one of the signed-in account's own snippets.

func (*Service) DeleteTag

func (s *Service) DeleteTag(ctx context.Context, raw, name, sha string) (model.TagWrite, error)

DeleteTag deletes a tag the caller read. A protected tag is refused.

func (*Service) DeleteWikiPage

func (s *Service) DeleteWikiPage(ctx context.Context, raw, slug, witness string) (model.WikiDelete, error)

DeleteWikiPage deletes a page the caller read.

func (*Service) FindUsers

func (s *Service) FindUsers(ctx context.Context, q gapi.UserQuery, opts gapi.ListOptions) (model.Users, error)

FindUsers finds accounts by exact username or by a search of names and usernames (§6.3).

func (*Service) GetArtifact

func (s *Service) GetArtifact(ctx context.Context, raw string, job int64, path string, offset int) (model.Artifact, error)

GetArtifact shows one text file of a job's artifacts, masked as a job log is (§4.1.4), under the file budget. A binary file is named with its size only.

func (*Service) GetCommit

func (s *Service) GetCommit(ctx context.Context, raw, sha string, fileOffset, diffOffset, messageOffset int) (model.Commit, error)

GetCommit reads a commit and its diffs under the budget, starting at the fileOffset-th changed file. A diff that does not fit is named, and file_offset continues from it. The message is shown from messageOffset, and a cut one says where to continue. The merge requests that contain the commit are read with the diffs, best effort, and only on a first read: a read that continues from any offset leaves them out.

func (*Service) GetFile

func (s *Service) GetFile(ctx context.Context, raw, path, ref string, offset int) (model.File, error)

GetFile reads a file at a ref (§7.5). Text is shown inside a boundary under the budget; binary content is described, never shown.

func (*Service) GetIssue

func (s *Service) GetIssue(ctx context.Context, raw string, iid int64, offset int) (model.Issue, error)

GetIssue reads an issue with a summary of its threads and the merge requests linked to it (§7.2). The reads are independent and run at once. The link reads are best effort, as the summary is, and a read that continues the description from an offset leaves them out.

func (*Service) GetJobLog

func (s *Service) GetJobLog(ctx context.Context, q JobLogQuery) (model.JobLog, error)

GetJobLog shows a window of a job's log: the tail by default, from byte_offset when given, or the section the job failed in (§7.6). What it shows is cleaned as GitLab's page shows it, secret shapes masked (§4.1.4) and hidden characters made visible, inside a boundary. Only the window and what its edges need are read, so a log of any size can be shown (§7.6).

func (*Service) GetMRDiff

func (s *Service) GetMRDiff(ctx context.Context, raw string, iid int64, paths []string, fileOffset, diffOffset int) (model.MRDiff, error)

GetMRDiff shows a merge request's diffs under the budget: the named files, or every file from fileOffset (§7.3). A named file the merge request does not change is refused naming it.

func (*Service) GetMergeRequest

func (s *Service) GetMergeRequest(ctx context.Context, raw string, iid int64, offset int) (model.MergeRequest, error)

GetMergeRequest reads a merge request with its approval state, each reviewer's state, a summary of its threads, the issues linked to it and the merge requests it waits for or holds (§7.2). The reads are independent and run at once. The approval, reviewer, link and dependency reads are best effort: an instance that refuses them still has a merge request to show. A read that continues the description from an offset leaves the links and dependencies out.

func (*Service) GetPipeline

func (s *Service) GetPipeline(ctx context.Context, raw string, id int64) (model.PipelineDetail, error)

GetPipeline reads a pipeline with its failed jobs (§7.6). The two reads are independent and run at once.

func (*Service) GetProject

func (s *Service) GetProject(ctx context.Context, raw string, offset int) (model.Project, error)

GetProject reads one project.

func (*Service) GetRelease

func (s *Service) GetRelease(ctx context.Context, raw, tag string, offset int) (model.Release, error)

GetRelease reads the release of a tag, its notes under the description budget.

func (*Service) GetSnippet

func (s *Service) GetSnippet(ctx context.Context, raw string, id int64, file string, offset int) (model.Snippet, error)

GetSnippet reads a snippet and one of its files: the first unless file names another. A personal snippet has no project.

func (*Service) GetTestReport

func (s *Service) GetTestReport(ctx context.Context, raw string, pipeline int64, offset int) (model.TestReport, error)

GetTestReport reads a pipeline's test report (§7.6): the counts, each suite's, and the failed and errored cases from offset under the budget. GitLab parses the report when read and does not page it, so each call reads it again; one larger than the client reads falls back to the stored summary, which has counts and no cases. The report takes in child pipelines in the project, so a child still running makes it partial too. Case names and output are the project's tests' words: masked like a job log and prepared for the boundary.

func (*Service) GetWikiPage

func (s *Service) GetWikiPage(ctx context.Context, raw, slug string, offset int) (model.WikiPage, error)

GetWikiPage reads a page's content under the file budget, inside a boundary, with the hash a write needs.

func (*Service) LinkIssues

func (s *Service) LinkIssues(ctx context.Context, in IssueLinkRequest) (model.IssueLinkWrite, error)

LinkIssues links two issues. A link that exists is reported unchanged.

func (*Service) LinkMergeRequests

LinkMergeRequests makes one merge request wait for another. A dependency that exists is reported unchanged.

func (*Service) LintCI

func (s *Service) LintCI(ctx context.Context, q LintQuery) (model.Lint, error)

LintCI checks a project's CI configuration at a ref (§7.6). The merged configuration is shown under the file budget.

func (*Service) ListArtifacts

func (s *Service) ListArtifacts(ctx context.Context, raw string, job int64, dir string, recursive bool, opts gapi.ListOptions) (model.Artifacts, error)

ListArtifacts lists a job's artifact files.

func (*Service) ListBoards

func (s *Service) ListBoards(ctx context.Context, raw string, opts gapi.ListOptions) (model.Boards, error)

ListBoards lists a project's issue boards with their lists in board order, and for each list the search_issues arguments that return its issues (§7.7). GitLab returns every list of a board with it, so a page is cut by max and by the boards budget; the token names the next board by id.

func (*Service) ListBranches

func (s *Service) ListBranches(ctx context.Context, raw, search string, opts gapi.ListOptions) (model.Branches, error)

ListBranches lists branches.

func (*Service) ListCommits

func (s *Service) ListCommits(ctx context.Context, raw string, q gapi.CommitQuery, opts gapi.ListOptions) (model.Commits, error)

ListCommits lists commits reachable from a ref.

func (*Service) ListDeployments

func (s *Service) ListDeployments(ctx context.Context, raw string, q gapi.DeploymentQuery, opts gapi.ListOptions) (model.Deployments, error)

ListDeployments lists a project's deployments.

func (*Service) ListDiscussions

func (s *Service) ListDiscussions(ctx context.Context, q DiscussionQuery) (model.Discussions, error)

ListDiscussions lists threads newest first under the character budget (§4.8). Threads of the page that do not fit are named with their author and date, and the next page starts with them.

func (*Service) ListEnvironments

func (s *Service) ListEnvironments(ctx context.Context, raw string, q gapi.EnvironmentQuery, opts gapi.ListOptions) (model.Environments, error)

ListEnvironments lists a project's environments.

func (*Service) ListEvents

func (s *Service) ListEvents(ctx context.Context, raw string, q gapi.EventQuery, opts gapi.ListOptions) (model.Events, error)

ListEvents lists a project's activity, or the signed-in account's own when project is empty.

func (*Service) ListItemEvents

func (s *Service) ListItemEvents(ctx context.Context, q EventQuery) (model.ItemEvents, error)

ListItemEvents merges an issue's or a merge request's label, state, milestone and weight events into one history, newest first (§7.2). Each kind is read whole, up to maxEventPages; when one is cut, the history starts after its oldest event kept, so no kind is missing from the part shown. Weight is an issue's only.

func (*Service) ListJobs

func (s *Service) ListJobs(ctx context.Context, raw string, pipeline int64, q gapi.JobQuery, opts gapi.ListOptions) (model.Jobs, error)

ListJobs lists a pipeline's jobs.

func (*Service) ListLabels

func (s *Service) ListLabels(ctx context.Context, raw string, q gapi.LabelQuery, opts gapi.ListOptions) (model.Labels, error)

ListLabels lists the labels a project's issues and merge requests can carry (§7.7).

func (*Service) ListMRCommits

func (s *Service) ListMRCommits(ctx context.Context, raw string, iid int64, opts gapi.ListOptions) (model.MRCommits, error)

ListMRCommits lists a merge request's commits.

func (*Service) ListMRFiles

func (s *Service) ListMRFiles(ctx context.Context, raw string, iid int64, opts gapi.ListOptions) (model.MRFiles, error)

ListMRFiles lists a merge request's changed files with their line counts and GitLab's markers, and no diff text (§7.3).

func (*Service) ListMRVersions

func (s *Service) ListMRVersions(ctx context.Context, raw string, iid int64, opts gapi.ListOptions) (model.MRVersions, error)

ListMRVersions lists a merge request's diff versions, newest first (§7.3).

func (*Service) ListMembers

func (s *Service) ListMembers(ctx context.Context, raw, query string, opts gapi.ListOptions) (model.Members, error)

ListMembers lists everyone with access to a project, through a group included.

func (*Service) ListMilestones

func (s *Service) ListMilestones(ctx context.Context, q MilestoneSearch) (model.Milestones, error)

ListMilestones lists a project's or a group's milestones (§7.7).

func (*Service) ListPipelines

func (s *Service) ListPipelines(ctx context.Context, raw string, q gapi.PipelineQuery, opts gapi.ListOptions) (model.Pipelines, error)

ListPipelines lists a project's pipelines (§7.6).

func (*Service) ListReleases

func (s *Service) ListReleases(ctx context.Context, raw string, q gapi.ReleaseQuery, opts gapi.ListOptions) (model.Releases, error)

ListReleases lists a project's releases.

func (*Service) ListReviewComments

func (s *Service) ListReviewComments(ctx context.Context, raw string, iid int64, pageToken string) (model.DraftNotes, error)

ListReviewComments lists the signed-in account's unpublished review comments on a merge request, under the discussion budget (§7.3). Drafts that do not fit are named, and the next page starts with them.

func (*Service) ListSnippets

func (s *Service) ListSnippets(ctx context.Context, raw string, opts gapi.ListOptions) (model.Snippets, error)

ListSnippets lists a project's snippets, or the signed-in account's own when project is empty.

func (*Service) ListTags

func (s *Service) ListTags(ctx context.Context, raw string, q gapi.TagQuery, opts gapi.ListOptions) (model.Tags, error)

ListTags lists a project's tags.

func (*Service) ListTodos

func (s *Service) ListTodos(ctx context.Context, q TodoSearch) (model.Todos, error)

ListTodos lists the signed-in account's to-do items (§7.7).

func (*Service) ListTree

func (s *Service) ListTree(ctx context.Context, raw string, q gapi.TreeQuery, opts gapi.ListOptions) (model.Tree, error)

ListTree lists a directory.

func (*Service) ListWikiPages

func (s *Service) ListWikiPages(ctx context.Context, raw string) (model.WikiPages, error)

ListWikiPages lists a project wiki's pages. GitLab answers with every page at once.

func (*Service) MakeIssuePublic

func (s *Service) MakeIssuePublic(ctx context.Context, project string, iid int64, updatedAt string) (model.IssueWrite, error)

MakeIssuePublic makes a confidential issue public, after checking the witness.

func (*Service) MarkTodosDone

func (s *Service) MarkTodosDone(ctx context.Context, ids []int64) (model.TodosDone, error)

MarkTodosDone marks the signed-in account's to-do items done by id. Under GITLAB_MCP_WRITE_NAMESPACES an item whose project is outside it is refused like any other write (§4.7); the items' projects are read once for that, and only then.

func (*Service) Me

func (s *Service) Me(ctx context.Context) (model.Me, error)

Me reads who is signed in and what this server and instance support (§7.9). The account is required; the instance metadata and the token details are reported as unknown when they cannot be read, because the rest of the answer is still worth having. The reads are independent and run at once, and metadata read here is kept for the next call.

func (*Service) MergeMergeRequest

func (s *Service) MergeMergeRequest(ctx context.Context, in MergeRequestMerge) (model.MergeWrite, error)

MergeMergeRequest merges a merge request at the head the caller read, or sets it to merge when its pipeline succeeds.

func (*Service) MoveIssue

func (s *Service) MoveIssue(ctx context.Context, in IssueMoveRequest) (model.IssueMove, error)

MoveIssue moves an issue to another project. Both projects are held to the write allow-list, and a move that would show the issue to more people than can see it now is refused: an injected "move this" is how a private issue would reach a public project (§17.13).

func (*Service) Pick

func (s *Service) Pick(ctx context.Context, in PickRequest) (model.PickWrite, error)

Pick cherry-picks or reverts a commit onto a branch as a new commit. The default branch and protected branches are refused as create_commit refuses them (§4.4). A dry run asks GitLab's own dry run, which says whether the change applies.

func (*Service) PlayJob

func (s *Service) PlayJob(ctx context.Context, raw string, id int64, vars []JobVariable, inputs map[string]any) (model.JobWrite, error)

PlayJob starts a manual job, with variables for this run. Their values are sent and never shown.

func (*Service) PublishReviewComment

func (s *Service) PublishReviewComment(ctx context.Context, raw string, iid, draftID int64) (model.DraftPublish, error)

PublishReviewComment publishes one of the signed-in account's drafts on its own, as the comment, thread or reply it was drafted as.

func (*Service) React

func (s *Service) React(ctx context.Context, in Reaction) (model.ReactionWrite, error)

React adds the signed-in account's reaction to an issue, a merge request or a comment on one, or removes it.

func (*Service) RebaseMergeRequest

func (s *Service) RebaseMergeRequest(ctx context.Context, raw string, iid int64, sha string, skipCI bool) (model.RebaseWrite, error)

RebaseMergeRequest rebases a merge request's source branch onto its target, from the head the caller reviewed. GitLab rebases in the background; the result says whether it is still running.

func (*Service) RerequestReview

func (s *Service) RerequestReview(ctx context.Context, in Rereview) (model.RereviewWrite, error)

RerequestReview asks a reviewer of a merge request for a new review.

func (*Service) ResolveDiscussion

func (s *Service) ResolveDiscussion(ctx context.Context, raw, typ string, iid int64, discussionID string, resolve bool) (model.DiscussionWrite, error)

ResolveDiscussion resolves or reopens a thread of a merge request, or of an issue when typ is issue.

func (*Service) ResolveURL

func (s *Service) ResolveURL(ctx context.Context, raw string) (model.Resolved, error)

ResolveURL turns a web URL on the configured instance into tool arguments (§6.1). It needs the network only when a file or tree URL's ref has slashes in it and could end anywhere: then one branch listing settles where the ref stops and the path starts.

func (*Service) RetryJob

func (s *Service) RetryJob(ctx context.Context, raw string, id int64, inputs map[string]any) (model.JobWrite, error)

RetryJob runs a job again as a new job.

func (*Service) RetryPipeline

func (s *Service) RetryPipeline(ctx context.Context, raw string, id int64) (model.PipelineWrite, error)

RetryPipeline retries a pipeline's failed and canceled jobs.

func (*Service) RunMergeRequestPipeline

func (s *Service) RunMergeRequestPipeline(ctx context.Context, raw string, iid int64) (model.MergeRequestPipelineWrite, error)

RunMergeRequestPipeline runs a merge request's pipeline: merged results where the project has them on, detached otherwise, as GitLab decides (MergeRequests::CreatePipelineService).

func (*Service) RunPipeline

func (s *Service) RunPipeline(ctx context.Context, in PipelineRun) (model.PipelineWrite, error)

RunPipeline runs a pipeline for a ref. Variable values are sent and never shown: a result names their keys (§7.6).

func (*Service) SaveWikiPage

func (s *Service) SaveWikiPage(ctx context.Context, in WikiSave) (model.WikiWrite, error)

SaveWikiPage creates a page, or changes one the caller read.

func (*Service) Search

func (s *Service) Search(ctx context.Context, q SearchQuery) (model.Search, error)

Search runs GitLab's search in one project, one group or the instance (§7.1). A scope the instance or group can only search with advanced search, which it lacks, is [unsupported] and says to search a project.

func (*Service) SearchIssues

func (s *Service) SearchIssues(ctx context.Context, q ItemSearch) (model.ItemList, error)

SearchIssues lists issues.

func (*Service) SearchMergeRequests

func (s *Service) SearchMergeRequests(ctx context.Context, q ItemSearch) (model.ItemList, error)

SearchMergeRequests lists merge requests.

func (*Service) SearchProjects

func (s *Service) SearchProjects(ctx context.Context, q ProjectSearch) (model.ProjectList, error)

SearchProjects lists projects.

func (*Service) SetRegistered

func (s *Service) SetRegistered(r []Registered)

SetRegistered records the tools the server registered.

func (*Service) SubmitReview

func (s *Service) SubmitReview(ctx context.Context, in Review) (model.ReviewSubmit, error)

SubmitReview publishes every draft of the signed-in account on a merge request at once. An approving review is Ship: it is someone's sign-off another person's merge rule counts (§4.3).

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, raw, typ string, iid int64, subscribe bool) (model.SubscriptionWrite, error)

Subscribe subscribes the signed-in account to an issue's or a merge request's notifications, or unsubscribes it. The author, the assignees and anyone who commented are subscribed until they unsubscribe.

func (*Service) TrackTime

func (s *Service) TrackTime(ctx context.Context, in TimeTracking) (model.TimeWrite, error)

TrackTime sets or resets an estimate and adds or resets spent time, after checking the witness, and reads the result back.

func (*Service) UnapproveMergeRequest

func (s *Service) UnapproveMergeRequest(ctx context.Context, raw string, iid int64) (model.ApprovalWrite, error)

UnapproveMergeRequest withdraws the signed-in account's approval.

func (*Service) UnlinkIssues

func (s *Service) UnlinkIssues(ctx context.Context, in IssueLinkRequest) (model.IssueLinkWrite, error)

UnlinkIssues removes the link between two issues. With no link, the result is unchanged.

func (*Service) UnlinkMergeRequests

func (s *Service) UnlinkMergeRequests(ctx context.Context, in MergeRequestLinkRequest) (model.MergeRequestLinkWrite, error)

UnlinkMergeRequests removes a dependency in the direction its link type names. With no such dependency, the result is unchanged.

func (*Service) UpdateComment

func (s *Service) UpdateComment(ctx context.Context, in CommentEdit) (model.CommentUpdate, error)

UpdateComment replaces the text of one of the signed-in account's own comments, keeping it in its thread.

func (*Service) UpdateIssue

func (s *Service) UpdateIssue(ctx context.Context, in IssueUpdate) (model.IssueWrite, error)

UpdateIssue changes the fields given, after checking the witness. It never makes a confidential issue public: that is MakeIssuePublic's.

func (*Service) UpdateLabel

func (s *Service) UpdateLabel(ctx context.Context, in LabelRequest) (model.LabelWrite, error)

UpdateLabel changes a project label. Only the fields given are sent.

func (*Service) UpdateMergeRequest

func (s *Service) UpdateMergeRequest(ctx context.Context, in MergeRequestUpdate) (model.MergeRequestWrite, error)

UpdateMergeRequest changes the fields given, after checking the witness.

func (*Service) UpdateMilestone

func (s *Service) UpdateMilestone(ctx context.Context, in MilestoneRequest) (model.MilestoneWrite, error)

UpdateMilestone changes a project milestone the caller read. Only the fields given are sent.

func (*Service) UpdateReviewComment

func (s *Service) UpdateReviewComment(ctx context.Context, in DraftEdit) (model.DraftUpdate, error)

UpdateReviewComment replaces the text of one of the signed-in account's drafts, keeping it where it is: in its thread, on its line.

func (*Service) UpdateSnippet

func (s *Service) UpdateSnippet(ctx context.Context, in SnippetEdit) (model.SnippetUpdate, error)

UpdateSnippet changes one of the signed-in account's own snippets. Its visibility is left as it is.

func (*Service) UploadFile

func (s *Service) UploadFile(ctx context.Context, in Upload) (model.UploadWrite, error)

UploadFile uploads a local image to a project and returns the Markdown that embeds it. The project is read and held to the write allow-list first, so a call aimed elsewhere reads nothing on this machine; then the image is read and checked, a dry run included.

type SnippetCreate

type SnippetCreate struct {
	Project     string // empty for a personal snippet
	Title       string
	Description string
	Files       []SnippetFile
}

SnippetCreate is create_snippet's request.

type SnippetEdit

type SnippetEdit struct {
	Project     string // empty for a personal snippet
	ID          int64
	Title       *string
	Description *string
	// Content replaces the file of a one-file snippet.
	Content *string
	// Files changes a snippet's files, one action each.
	Files     []SnippetFileChange
	UpdatedAt string
}

SnippetEdit is update_snippet's request. Nil fields are not changed.

type SnippetFile

type SnippetFile struct {
	Path    string
	Content string
}

SnippetFile is one file of a new snippet.

type SnippetFileChange

type SnippetFileChange struct {
	Action       string // create, update, delete or move
	Path         string
	PreviousPath string // the file a move starts from
	Content      string
}

SnippetFileChange is one change to a snippet's files.

type SuggestionRead

type SuggestionRead struct {
	ID   int64
	Text string
}

SuggestionRead is one suggestion to apply and the text the caller read for it: the witness that what GitLab commits is what was read, and what a client's own prompt shows the person.

type SuggestionsApplication

type SuggestionsApplication struct {
	Project       string
	IID           int64
	Suggestions   []SuggestionRead
	CommitMessage string
}

SuggestionsApplication is apply_suggestions' request.

type TimeTracking

type TimeTracking struct {
	Project       string
	Type          string
	IID           int64
	UpdatedAt     string
	Estimate      string
	ResetEstimate bool
	AddSpent      string
	ResetSpent    bool
	// TotalTimeSpent is the spent-time witness, the total in seconds the
	// caller read. GitLab does not move updated_at when spent time is
	// added or reset (§18 row 101), so only the total catches a repeat.
	TotalTimeSpent *int64
}

TimeTracking is track_time's request.

type TodoSearch

type TodoSearch struct {
	Project string
	State   string
	Action  string
	Type    string
	List    gapi.ListOptions
}

TodoSearch is list_todos' query.

type Upload

type Upload struct {
	Project string
	// Path is the image's absolute path on this machine.
	Path string
}

Upload is upload_file's request.

type WikiSave

type WikiSave struct {
	Project       string
	Slug          string
	Title         *string
	Content       *string
	Format        string
	ContentSHA256 string
}

WikiSave is save_wiki_page's request: a new page when Slug is empty, otherwise a change to that page. Nil fields are not changed.

Jump to

Keyboard shortcuts

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