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

systemhooks

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 systemhooks implements MCP tools for GitLab instance system hooks.

The package wraps the GitLab System hooks API:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, client *gitlabclient.Client, input DeleteInput) error

Delete removes a system hook.

func DeleteURLVariable

func DeleteURLVariable(ctx context.Context, client *gitlabclient.Client, input DeleteURLVariableInput) error

DeleteURLVariable deletes a URL variable from a system hook.

func FormatAddMarkdown

func FormatAddMarkdown(output AddOutput) *mcp.CallToolResult

FormatAddMarkdown formats a single system_hook_add response.

func FormatEditMarkdown

func FormatEditMarkdown(output EditOutput) *mcp.CallToolResult

FormatEditMarkdown formats a single system_hook_edit response.

func FormatGetMarkdown

func FormatGetMarkdown(output GetOutput) *mcp.CallToolResult

FormatGetMarkdown formats a single system_hook_get response.

func FormatHookMarkdown

func FormatHookMarkdown(item HookItem) *mcp.CallToolResult

FormatHookMarkdown renders a single system hook as the card of one object, with its URL variables and custom headers as the nested collections they are. Both carry keys only: GitLab never sends either value back.

func FormatListMarkdown

func FormatListMarkdown(output ListOutput) *mcp.CallToolResult

FormatListMarkdown renders the instance's system hooks as a Markdown table: a collection of objects that share columns.

func FormatTestMarkdown

func FormatTestMarkdown(output TestOutput) *mcp.CallToolResult

FormatTestMarkdown renders the result of asking GitLab to deliver a test event to a system hook.

It reports what was sent and never how it was received. GitLab's test endpoint fires its own fixed sample payload — a project_create event about a stand-in project — and answers with that payload, not with the receiver's response, so the previous "Hook Test Event" heading over a table of the sample's fields read as a delivery outcome the response does not carry.

func SetURLVariable

func SetURLVariable(ctx context.Context, client *gitlabclient.Client, input SetURLVariableInput) error

SetURLVariable creates or updates a URL variable for a system hook.

Types

type AddInput

type AddInput struct {
	URL                    string `json:"url"                       jsonschema:"Hook URL to receive events,required"`
	Name                   string `json:"name,omitempty"            jsonschema:"Descriptive name for the hook"`
	Description            string `json:"description,omitempty"     jsonschema:"Description for the hook"`
	Token                  string `json:"token,omitempty"           jsonschema:"Secret token for payload validation"`
	SigningToken           string `json:"signing_token,omitempty"   jsonschema:"Write-only signing token for webhook signature validation"`
	PushEvents             *bool  `json:"push_events,omitempty"             jsonschema:"Trigger on push events"`
	PushEventsBranchFilter string `json:"push_events_branch_filter,omitempty" jsonschema:"Branch filter for push events (wildcard, regex, or branch name)"`
	BranchFilterStrategy   string `json:"branch_filter_strategy,omitempty" jsonschema:"Branch filter strategy: wildcard, regex, or all_branches"`
	CustomWebhookTemplate  string `json:"custom_webhook_template,omitempty" jsonschema:"Custom payload template (JSON) sent instead of the default webhook body"`
	TagPushEvents          *bool  `json:"tag_push_events,omitempty"         jsonschema:"Trigger on tag push events"`
	MergeRequestsEvents    *bool  `json:"merge_requests_events,omitempty"   jsonschema:"Trigger on merge request events"`
	RepositoryUpdateEvents *bool  `json:"repository_update_events,omitempty" jsonschema:"Trigger on repository update events"`
	EnableSSLVerification  *bool  `json:"enable_ssl_verification,omitempty" jsonschema:"Enable SSL verification for the hook URL"`
}

AddInput is the input for adding a system hook.

type AddOutput

type AddOutput struct {
	toolutil.HintableOutput
	Hook HookItem `json:"hook"`
}

AddOutput wraps the added hook.

func Add

func Add(ctx context.Context, client *gitlabclient.Client, input AddInput) (AddOutput, error)

Add creates a new system hook.

type DeleteInput

type DeleteInput struct {
	ID int64 `json:"id" jsonschema:"System hook ID to delete,required"`
}

DeleteInput is the input for deleting a system hook.

type DeleteURLVariableInput

type DeleteURLVariableInput struct {
	ID  int64  `json:"id"  jsonschema:"System hook ID,required"`
	Key string `json:"key" jsonschema:"URL variable key name to delete,required"`
}

DeleteURLVariableInput is the input for deleting a system hook URL variable.

type EditInput

type EditInput struct {
	ID                     int64  `json:"id"                        jsonschema:"System hook ID to edit,required"`
	URL                    string `json:"url,omitempty"             jsonschema:"Updated hook URL"`
	Name                   string `json:"name,omitempty"            jsonschema:"Updated hook name"`
	Description            string `json:"description,omitempty"     jsonschema:"Updated hook description"`
	Token                  string `json:"token,omitempty"           jsonschema:"Updated secret token for payload validation"`
	SigningToken           string `json:"signing_token,omitempty"   jsonschema:"Updated write-only signing token for webhook signature validation"`
	PushEvents             *bool  `json:"push_events,omitempty"             jsonschema:"Trigger on push events"`
	PushEventsBranchFilter string `json:"push_events_branch_filter,omitempty" jsonschema:"Branch filter for push events (wildcard, regex, or branch name)"`
	BranchFilterStrategy   string `json:"branch_filter_strategy,omitempty" jsonschema:"Branch filter strategy: wildcard, regex, or all_branches"`
	CustomWebhookTemplate  string `` /* 133-byte string literal not displayed */
	TagPushEvents          *bool  `json:"tag_push_events,omitempty"         jsonschema:"Trigger on tag push events"`
	MergeRequestsEvents    *bool  `json:"merge_requests_events,omitempty"   jsonschema:"Trigger on merge request events"`
	RepositoryUpdateEvents *bool  `json:"repository_update_events,omitempty" jsonschema:"Trigger on repository update events"`
	EnableSSLVerification  *bool  `json:"enable_ssl_verification,omitempty" jsonschema:"Enable SSL verification for the hook URL"`
}

EditInput is the input for editing a system hook.

type EditOutput

type EditOutput struct {
	toolutil.HintableOutput
	Hook HookItem `json:"hook"`
}

EditOutput wraps the edited hook.

func Edit

func Edit(ctx context.Context, client *gitlabclient.Client, input EditInput) (EditOutput, error)

Edit updates an existing system hook.

type GetInput

type GetInput struct {
	ID int64 `json:"id" jsonschema:"System hook ID,required"`
}

GetInput is the input for getting a system hook.

type GetOutput

type GetOutput struct {
	toolutil.HintableOutput
	Hook HookItem `json:"hook"`
}

GetOutput wraps a single hook.

func Get

func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (GetOutput, error)

Get retrieves a single system hook.

type HookCustomHeader

type HookCustomHeader struct {
	Key string `json:"key"`
}

HookCustomHeader represents a custom header the hook sends with every delivery. Only the name is surfaced: GitLab masks the value, which is secret-bearing.

type HookEventItem

type HookEventItem struct {
	EventName  string `json:"event_name"`
	Name       string `json:"name"`
	Path       string `json:"path"`
	ProjectID  int64  `json:"project_id"`
	OwnerName  string `json:"owner_name"`
	OwnerEmail string `json:"owner_email"`
}

HookEventItem represents a hook test event.

type HookItem

type HookItem struct {
	ID                     int64              `json:"id"`
	URL                    string             `json:"url"`
	Name                   string             `json:"name,omitempty"`
	Description            string             `json:"description,omitempty"`
	CreatedAt              string             `json:"created_at,omitempty"`
	PushEvents             bool               `json:"push_events"`
	PushEventsBranchFilter string             `json:"push_events_branch_filter,omitempty"`
	BranchFilterStrategy   string             `json:"branch_filter_strategy,omitempty"`
	TagPushEvents          bool               `json:"tag_push_events"`
	MergeRequestsEvents    bool               `json:"merge_requests_events"`
	RepositoryUpdateEvents bool               `json:"repository_update_events"`
	EnableSSLVerification  bool               `json:"enable_ssl_verification"`
	URLVariables           []HookURLVariable  `json:"url_variables,omitempty"`
	CustomHeaders          []HookCustomHeader `json:"custom_headers,omitempty"`
	CustomWebhookTemplate  string             `json:"custom_webhook_template,omitempty"`
	AlertStatus            string             `json:"alert_status,omitempty"`
	DisabledUntil          string             `json:"disabled_until,omitempty"`
	OrganizationID         int64              `json:"organization_id,omitempty"`
	TokenPresent           bool               `json:"token_present"`
	SigningTokenPresent    bool               `json:"signing_token_present"`
}

HookItem represents a system hook.

type HookURLVariable

type HookURLVariable struct {
	Key string `json:"key"`
}

HookURLVariable represents a masked URL variable configured on a system hook.

type ListInput

type ListInput struct {
	toolutil.PaginationInput
}

ListInput holds the page of system hooks to list. GitLab pages GET /hooks, and client-go's ListHooks takes no options struct, so the page travels as a request option.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Hooks      []HookItem                `json:"hooks"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListOutput contains one page of system hooks and the pagination GitLab sent with it.

func List

func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)

List retrieves one page of the instance's system hooks.

type SetURLVariableInput

type SetURLVariableInput struct {
	ID    int64  `json:"id"    jsonschema:"System hook ID,required"`
	Key   string `json:"key"   jsonschema:"URL variable key name. Letters and underscores only. GitLab rejects keys containing digits,required"`
	Value string `json:"value" jsonschema:"URL variable value. Must be non-empty,required"`
}

SetURLVariableInput is the input for creating or updating a system hook URL variable.

type TestInput

type TestInput struct {
	ID int64 `json:"id" jsonschema:"System hook ID to test,required"`
}

TestInput is the input for testing a system hook.

type TestOutput

type TestOutput struct {
	toolutil.HintableOutput
	Event HookEventItem `json:"event"`
}

TestOutput wraps the test event result.

func Test

func Test(ctx context.Context, client *gitlabclient.Client, input TestInput) (TestOutput, error)

Test triggers a test event for a system hook.

Jump to

Keyboard shortcuts

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