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

events

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package events implements MCP tools for GitLab event operations.

The package wraps the GitLab Events API:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckActionFilter added in v3.1.0

func CheckActionFilter(action string) error

CheckActionFilter refuses an action filter outside eventActions, naming the values GitLab filters on, and accepts an empty one, which asks for no filter. GitLab never refuses such an action (see above): it answers with the whole feed, which a caller cannot tell from a filtered one, so every event listing calls this before its request.

func EnrichContributionEventURLs added in v3.1.0

func EnrichContributionEventURLs(ctx context.Context, client *gitlabclient.Client, events []ContributionEventOutput)

EnrichContributionEventURLs resolves project web URLs and sets TargetURL on each event, for either contribution listing (ToContributionEventOutput).

func FilterSchemaOverrides added in v3.1.0

func FilterSchemaOverrides() []toolutil.InputSchemaOverride

FilterSchemaOverrides returns the input-schema overrides every event listing serves on its action and target_type filters: the value set GitLab filters each on as the enum, and a description naming the same values, so the schema a model reads and the prose beside it come from one list. user.contribution_events serves it too, since its route takes the same filters.

func FormatContributionListMarkdown

func FormatContributionListMarkdown(out ListContributionEventsOutput) *mcp.CallToolResult

FormatContributionListMarkdown formats contribution events as a Markdown CallToolResult.

func FormatContributionListMarkdownString

func FormatContributionListMarkdownString(out ListContributionEventsOutput) string

FormatContributionListMarkdownString renders contribution events as a Markdown string.

func FormatListMarkdown

func FormatListMarkdown(out ListProjectEventsOutput) *mcp.CallToolResult

FormatListMarkdown formats project events as a Markdown CallToolResult.

func FormatListMarkdownString

func FormatListMarkdownString(out ListProjectEventsOutput) string

FormatListMarkdownString renders project events as a Markdown string.

func UserActionSpecs

func UserActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec

UserActionSpecs returns canonical specs for event actions exposed through gitlab_user.

Types

type ContributionEventOutput

type ContributionEventOutput struct {
	ID             int64                            `json:"id"`
	ProjectID      int64                            `json:"project_id"`
	ActionName     string                           `json:"action_name"`
	TargetID       int64                            `json:"target_id,omitempty"`
	TargetIID      int64                            `json:"target_iid,omitempty"`
	TargetType     string                           `json:"target_type,omitempty"`
	TargetURL      string                           `json:"target_url,omitempty"`
	AuthorID       int64                            `json:"author_id"`
	TargetTitle    string                           `json:"target_title,omitempty"`
	CreatedAt      string                           `json:"created_at,omitempty"`
	PushData       *ContributionEventPushDataOutput `json:"push_data,omitempty"`
	Note           *NoteOutput                      `json:"note,omitempty"`
	Author         *UserOutput                      `json:"author,omitempty"`
	AuthorUsername string                           `json:"author_username,omitempty"`
	WikiPage       *WikiPageOutput                  `json:"wiki_page,omitempty"`
	Imported       bool                             `json:"imported"`
	ImportedFrom   string                           `json:"imported_from,omitempty"`
}

ContributionEventOutput mirrors gitlab.ContributionEvent.

func ToContributionEventOutput added in v3.1.0

func ToContributionEventOutput(e *gl.ContributionEvent) ContributionEventOutput

ToContributionEventOutput converts one event of a contribution listing to the tool output format. It is exported because a user's contribution events (internal/tools/users) are the same entity on another route, and the two listings used to publish it through two converters, one of them missing eight of its keys.

type ContributionEventPushDataOutput

type ContributionEventPushDataOutput struct {
	CommitCount int64  `json:"commit_count"`
	Action      string `json:"action,omitempty"`
	RefType     string `json:"ref_type,omitempty"`
	CommitFrom  string `json:"commit_from,omitempty"`
	CommitTo    string `json:"commit_to,omitempty"`
	Ref         string `json:"ref,omitempty"`
	CommitTitle string `json:"commit_title,omitempty"`
}

ContributionEventPushDataOutput mirrors gitlab.ContributionEventPushData.

type LinePositionOutput

type LinePositionOutput struct {
	LineCode string `json:"line_code,omitempty"`
	Type     string `json:"type,omitempty"`
	OldLine  int64  `json:"old_line,omitempty"`
	NewLine  int64  `json:"new_line,omitempty"`
}

LinePositionOutput mirrors gitlab.LinePosition.

type LineRangeOutput

type LineRangeOutput struct {
	StartRange *LinePositionOutput `json:"start,omitempty"`
	EndRange   *LinePositionOutput `json:"end,omitempty"`
}

LineRangeOutput mirrors gitlab.LineRange.

type ListContributionEventsInput

type ListContributionEventsInput struct {
	Action     string `json:"action,omitempty" jsonschema:"Filter by event action"`
	TargetType string `json:"target_type,omitempty" jsonschema:"Filter by event target type"`
	Before     string `json:"before,omitempty" jsonschema:"Return events before this date (YYYY-MM-DD)"`
	After      string `json:"after,omitempty" jsonschema:"Return events after this date (YYYY-MM-DD)"`
	Sort       string `json:"sort,omitempty" jsonschema:"Sort order (asc or desc)"`
	Scope      string `json:"scope,omitempty" jsonschema:"Include events from all projects (all) or only user's projects"`
	OrderBy    string `json:"order_by,omitempty" jsonschema:"Column by which to order keyset-paginated results (id)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListContributionEventsInput contains parameters for listing current user contribution events. The served schema's enum and description for Action and TargetType come from FilterSchemaOverrides, which replaces these tags' descriptions, so the values are listed in one place.

type ListContributionEventsOutput

type ListContributionEventsOutput struct {
	toolutil.HintableOutput
	Events     []ContributionEventOutput `json:"events"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListContributionEventsOutput holds a paginated list of contribution events.

func ListCurrentUserContributionEvents

func ListCurrentUserContributionEvents(ctx context.Context, client *gitlabclient.Client, input ListContributionEventsInput) (ListContributionEventsOutput, error)

ListCurrentUserContributionEvents returns contribution events for the authenticated user.

type ListProjectEventsInput

type ListProjectEventsInput struct {
	ProjectID  toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Action     string               `json:"action,omitempty" jsonschema:"Filter by event action"`
	TargetType string               `json:"target_type,omitempty" jsonschema:"Filter by event target type"`
	Before     string               `json:"before,omitempty" jsonschema:"Return events before this date (YYYY-MM-DD)"`
	After      string               `json:"after,omitempty" jsonschema:"Return events after this date (YYYY-MM-DD)"`
	Sort       string               `json:"sort,omitempty" jsonschema:"Sort order (asc or desc, default desc)"`
	OrderBy    string               `json:"order_by,omitempty" jsonschema:"Column by which to order keyset-paginated results (id)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListProjectEventsInput contains parameters for listing project visible events. As on ListContributionEventsInput, the served enum and description of Action and TargetType come from FilterSchemaOverrides.

type ListProjectEventsOutput

type ListProjectEventsOutput struct {
	toolutil.HintableOutput
	Events     []ProjectEventOutput      `json:"events"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListProjectEventsOutput holds a paginated list of project events.

func ListProjectEvents

func ListProjectEvents(ctx context.Context, client *gitlabclient.Client, input ListProjectEventsInput) (ListProjectEventsOutput, error)

ListProjectEvents returns a paginated list of visible events for a project.

type NoteAuthorOutput

type NoteAuthorOutput struct {
	ID        int64  `json:"id"`
	Username  string `json:"username,omitempty"`
	Email     string `json:"email,omitempty"`
	Name      string `json:"name,omitempty"`
	State     string `json:"state,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
	WebURL    string `json:"web_url,omitempty"`
}

NoteAuthorOutput mirrors gitlab.NoteAuthor / gitlab.NoteResolvedBy.

type NoteOutput

type NoteOutput struct {
	ID           int64               `json:"id"`
	Type         string              `json:"type,omitempty"`
	Body         string              `json:"body,omitempty"`
	Attachment   string              `json:"attachment,omitempty"`
	Title        string              `json:"title,omitempty"`
	FileName     string              `json:"file_name,omitempty"`
	Author       *NoteAuthorOutput   `json:"author,omitempty"`
	System       bool                `json:"system"`
	CreatedAt    string              `json:"created_at,omitempty"`
	UpdatedAt    string              `json:"updated_at,omitempty"`
	ExpiresAt    string              `json:"expires_at,omitempty"`
	CommitID     string              `json:"commit_id,omitempty"`
	Position     *NotePositionOutput `json:"position,omitempty"`
	NoteableID   int64               `json:"noteable_id,omitempty"`
	NoteableType string              `json:"noteable_type,omitempty"`
	ProjectID    int64               `json:"project_id,omitempty"`
	NoteableIID  int64               `json:"noteable_iid,omitempty"`
	Resolvable   bool                `json:"resolvable"`
	Resolved     bool                `json:"resolved"`
	ResolvedAt   string              `json:"resolved_at,omitempty"`
	ResolvedBy   *NoteAuthorOutput   `json:"resolved_by,omitempty"`
	Internal     bool                `json:"internal"`
	Confidential bool                `json:"confidential"`
}

NoteOutput mirrors gitlab.Note as embedded on a ContributionEvent.

type NotePositionOutput

type NotePositionOutput struct {
	BaseSHA      string           `json:"base_sha,omitempty"`
	StartSHA     string           `json:"start_sha,omitempty"`
	HeadSHA      string           `json:"head_sha,omitempty"`
	PositionType string           `json:"position_type,omitempty"`
	NewPath      string           `json:"new_path,omitempty"`
	NewLine      int64            `json:"new_line,omitempty"`
	OldPath      string           `json:"old_path,omitempty"`
	OldLine      int64            `json:"old_line,omitempty"`
	LineRange    *LineRangeOutput `json:"line_range,omitempty"`
}

NotePositionOutput mirrors gitlab.NotePosition.

type ProjectEventNoteOutput

type ProjectEventNoteOutput struct {
	ID           int64             `json:"id"`
	Body         string            `json:"body,omitempty"`
	Attachment   string            `json:"attachment,omitempty"`
	Author       *NoteAuthorOutput `json:"author,omitempty"`
	CreatedAt    string            `json:"created_at,omitempty"`
	System       bool              `json:"system"`
	NoteableID   int64             `json:"noteable_id,omitempty"`
	NoteableType string            `json:"noteable_type,omitempty"`
	NoteableIID  int64             `json:"noteable_iid,omitempty"`
}

ProjectEventNoteOutput mirrors gitlab.ProjectEventNote.

type ProjectEventOutput

type ProjectEventOutput struct {
	ID             int64                       `json:"id"`
	ProjectID      int64                       `json:"project_id"`
	ActionName     string                      `json:"action_name"`
	TargetID       int64                       `json:"target_id,omitempty"`
	TargetIID      int64                       `json:"target_iid,omitempty"`
	TargetType     string                      `json:"target_type,omitempty"`
	TargetURL      string                      `json:"target_url,omitempty"`
	AuthorID       int64                       `json:"author_id"`
	TargetTitle    string                      `json:"target_title,omitempty"`
	CreatedAt      string                      `json:"created_at,omitempty"`
	Author         *UserOutput                 `json:"author,omitempty"`
	AuthorUsername string                      `json:"author_username,omitempty"`
	Note           *ProjectEventNoteOutput     `json:"note,omitempty"`
	PushData       *ProjectEventPushDataOutput `json:"push_data,omitempty"`
	WikiPage       *WikiPageOutput             `json:"wiki_page,omitempty"`
	Imported       bool                        `json:"imported"`
	ImportedFrom   string                      `json:"imported_from,omitempty"`
}

ProjectEventOutput mirrors gitlab.ProjectEvent.

type ProjectEventPushDataOutput

type ProjectEventPushDataOutput struct {
	CommitCount int64  `json:"commit_count"`
	Action      string `json:"action,omitempty"`
	RefType     string `json:"ref_type,omitempty"`
	CommitFrom  string `json:"commit_from,omitempty"`
	CommitTo    string `json:"commit_to,omitempty"`
	Ref         string `json:"ref,omitempty"`
	CommitTitle string `json:"commit_title,omitempty"`
}

ProjectEventPushDataOutput mirrors gitlab.ProjectEventPushData.

type UserOutput

type UserOutput struct {
	ID        int64  `json:"id"`
	Username  string `json:"username,omitempty"`
	Name      string `json:"name,omitempty"`
	State     string `json:"state,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
	WebURL    string `json:"web_url,omitempty"`
}

UserOutput mirrors gitlab.BasicUser embedded as an event author.

type WikiPageOutput

type WikiPageOutput struct {
	Format         string `json:"format,omitempty"`
	Slug           string `json:"slug,omitempty"`
	Title          string `json:"title,omitempty"`
	WikiPageMetaID int64  `json:"wiki_page_meta_id,omitempty"`
}

WikiPageOutput is the wiki page an event happened to, which GitLab sends on an event about a wiki.

Jump to

Keyboard shortcuts

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