users

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package users implements GitLab user MCP tools for the current authenticated user, administrator user management, user CRUD, SSH keys, service accounts, personal access tokens, memberships, activities, runner details, and identity deletion.

The package registers both read-only profile tools and administrative actions such as block, unblock, ban, unban, activate, deactivate, approve, reject, disable two-factor authentication, and user-scoped SSH key management. It also provides Markdown formatters for user tool outputs.

Permissions

Read-only current-user actions work with ordinary authenticated tokens, while administrative actions require GitLab administrator permissions. Handlers keep these paths separate so catalog metadata can preserve read-only and mutating behavior for each action.

GitLab API References

The package wraps the GitLab Users API:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionSpecs

func ActionSpecs(client *gitlabclient.Client, _ bool) []toolutil.ActionSpec

ActionSpecs returns canonical specs for user account, status, SSH key, and misc actions, including the Free-tier instance service-account specs. The bool parameter is retained for signature compatibility but ignored: tier gating is handled centrally by the catalog tier filter via each spec's Edition.

func FormatAdminActionMarkdownString

func FormatAdminActionMarkdownString(o AdminActionOutput) string

FormatAdminActionMarkdownString renders an admin action result as Markdown.

func FormatAssociationsCountMarkdown

func FormatAssociationsCountMarkdown(o AssociationsCountOutput) *mcp.CallToolResult

FormatAssociationsCountMarkdown renders user associations count as an MCP CallToolResult.

func FormatAssociationsCountMarkdownString

func FormatAssociationsCountMarkdownString(o AssociationsCountOutput) string

FormatAssociationsCountMarkdownString renders user associations count as a Markdown string.

func FormatContributionEventsMarkdown

func FormatContributionEventsMarkdown(o ContributionEventsOutput) *mcp.CallToolResult

FormatContributionEventsMarkdown renders contribution events as an MCP CallToolResult.

func FormatContributionEventsMarkdownString

func FormatContributionEventsMarkdownString(o ContributionEventsOutput) string

FormatContributionEventsMarkdownString renders contribution events as a Markdown string.

func FormatCurrentUserPATMarkdownString

func FormatCurrentUserPATMarkdownString(out CurrentUserPATOutput) string

FormatCurrentUserPATMarkdownString formats a PAT as Markdown.

func FormatDeleteSSHKeyMarkdownString

func FormatDeleteSSHKeyMarkdownString(o DeleteSSHKeyOutput) string

FormatDeleteSSHKeyMarkdownString renders SSH key deletion output as Markdown.

func FormatDeleteUserIdentityMarkdownString

func FormatDeleteUserIdentityMarkdownString(o DeleteUserIdentityOutput) string

FormatDeleteUserIdentityMarkdownString renders a delete identity result as Markdown.

func FormatDeleteUserMarkdownString

func FormatDeleteUserMarkdownString(o DeleteOutput) string

FormatDeleteUserMarkdownString renders user deletion output as Markdown.

func FormatEmailListMarkdown

func FormatEmailListMarkdown(o EmailListOutput) *mcp.CallToolResult

FormatEmailListMarkdown renders an email list as an MCP CallToolResult.

func FormatEmailListMarkdownString

func FormatEmailListMarkdownString(o EmailListOutput) string

FormatEmailListMarkdownString renders an email list as a Markdown string.

func FormatListMarkdown

func FormatListMarkdown(o ListOutput) *mcp.CallToolResult

FormatListMarkdown renders a user list as an MCP CallToolResult.

func FormatListMarkdownString

func FormatListMarkdownString(o ListOutput) string

FormatListMarkdownString renders a user list as a Markdown string.

func FormatMarkdown

func FormatMarkdown(u Output) *mcp.CallToolResult

FormatMarkdown renders the user as an MCP CallToolResult.

func FormatMarkdownString

func FormatMarkdownString(u Output) string

FormatMarkdownString renders the authenticated user profile as a Markdown summary.

func FormatSSHKeyListMarkdown

func FormatSSHKeyListMarkdown(o SSHKeyListOutput) *mcp.CallToolResult

FormatSSHKeyListMarkdown renders an SSH key list as an MCP CallToolResult.

func FormatSSHKeyListMarkdownString

func FormatSSHKeyListMarkdownString(o SSHKeyListOutput) string

FormatSSHKeyListMarkdownString renders an SSH key list as a Markdown string.

func FormatSSHKeyMarkdown

func FormatSSHKeyMarkdown(o SSHKeyOutput) *mcp.CallToolResult

FormatSSHKeyMarkdown renders a single SSH key as an MCP CallToolResult.

func FormatSSHKeyMarkdownString

func FormatSSHKeyMarkdownString(o SSHKeyOutput) string

FormatSSHKeyMarkdownString renders a single SSH key as a Markdown string.

func FormatServiceAccountListMarkdownString

func FormatServiceAccountListMarkdownString(out ServiceAccountListOutput) string

FormatServiceAccountListMarkdownString formats a list of service accounts as Markdown.

func FormatServiceAccountMarkdownString added in v2.1.2

func FormatServiceAccountMarkdownString(out ServiceAccountOutput) string

FormatServiceAccountMarkdownString formats a single service account as Markdown.

func FormatStatusMarkdown

func FormatStatusMarkdown(o StatusOutput) *mcp.CallToolResult

FormatStatusMarkdown renders a user status as an MCP CallToolResult.

func FormatStatusMarkdownString

func FormatStatusMarkdownString(o StatusOutput) string

FormatStatusMarkdownString renders a user status as a Markdown string.

func FormatUserActivitiesMarkdownString

func FormatUserActivitiesMarkdownString(o UserActivitiesOutput) string

FormatUserActivitiesMarkdownString renders user activities as a Markdown string.

func FormatUserMembershipsMarkdownString

func FormatUserMembershipsMarkdownString(o UserMembershipsOutput) string

FormatUserMembershipsMarkdownString renders user memberships as a Markdown string.

func FormatUserRunnerMarkdownString

func FormatUserRunnerMarkdownString(o UserRunnerOutput) string

FormatUserRunnerMarkdownString renders a user runner as a Markdown string.

Types

type AddSSHKeyForUserInput

type AddSSHKeyForUserInput struct {
	UserID    int64  `json:"user_id" jsonschema:"The ID of the user,required"`
	Title     string `json:"title" jsonschema:"A descriptive title for the SSH key,required"`
	Key       string `json:"key" jsonschema:"The SSH public key content,required"`
	ExpiresAt string `json:"expires_at,omitempty" jsonschema:"Expiration date in ISO 8601 format (YYYY-MM-DD)"`
	UsageType string `json:"usage_type,omitempty" jsonschema:"Usage type: auth or signing (default: auth)"`
}

AddSSHKeyForUserInput holds parameters for adding an SSH key to a specific user.

type AddSSHKeyInput

type AddSSHKeyInput struct {
	Title     string `json:"title" jsonschema:"A descriptive title for the SSH key,required"`
	Key       string `json:"key" jsonschema:"The SSH public key content,required"`
	ExpiresAt string `json:"expires_at,omitempty" jsonschema:"Expiration date in ISO 8601 format (YYYY-MM-DD)"`
	UsageType string `json:"usage_type,omitempty" jsonschema:"Usage type: auth or signing (default: auth)"`
}

AddSSHKeyInput holds parameters for adding an SSH key to the current user.

type AdminActionInput

type AdminActionInput struct {
	UserID int64 `json:"user_id" jsonschema:"The ID of the user,required"`
}

AdminActionInput holds the user_id parameter for admin state actions.

type AdminActionOutput

type AdminActionOutput struct {
	UserID  int64  `json:"user_id"`
	Action  string `json:"action"`
	Success bool   `json:"success"`
}

AdminActionOutput represents the result of an admin state action.

func ActivateUser

func ActivateUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

ActivateUser activates a deactivated GitLab user (admin only).

func ApproveUser

func ApproveUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

ApproveUser approves a pending GitLab user (admin only).

func BanUser

BanUser bans a GitLab user (admin only).

func BlockUser

func BlockUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

BlockUser blocks a GitLab user (admin only).

func DeactivateUser

func DeactivateUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

DeactivateUser deactivates an active GitLab user (admin only).

func DisableTwoFactor

func DisableTwoFactor(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

DisableTwoFactor disables two-factor authentication for a GitLab user (admin only).

func RejectUser

func RejectUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

RejectUser rejects a pending GitLab user (admin only).

func UnbanUser

func UnbanUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

UnbanUser unbans a previously banned GitLab user (admin only).

func UnblockUser

func UnblockUser(ctx context.Context, client *gitlabclient.Client, input AdminActionInput) (AdminActionOutput, error)

UnblockUser unblocks a previously blocked GitLab user (admin only).

type AssociationsCountOutput

type AssociationsCountOutput struct {
	toolutil.HintableOutput
	GroupsCount        int64 `json:"groups_count"`
	ProjectsCount      int64 `json:"projects_count"`
	IssuesCount        int64 `json:"issues_count"`
	MergeRequestsCount int64 `json:"merge_requests_count"`
}

AssociationsCountOutput represents a user's association counts.

func GetAssociationsCount

func GetAssociationsCount(ctx context.Context, client *gitlabclient.Client, input GetAssociationsCountInput) (AssociationsCountOutput, error)

GetAssociationsCount retrieves the count of a user's associations.

type BasicUserOutput added in v2.3.0

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

BasicUserOutput mirrors gl.BasicUser, the compact user object referenced by gl.User.CreatedBy.

type ContributionEventOutput

type ContributionEventOutput struct {
	ID          int64  `json:"id"`
	Title       string `json:"title,omitempty"`
	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"`
	TargetTitle string `json:"target_title,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
}

ContributionEventOutput represents a user contribution event.

type ContributionEventsOutput

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

ContributionEventsOutput holds a paginated list of contribution events.

func ListContributionEvents

func ListContributionEvents(ctx context.Context, client *gitlabclient.Client, input ListContributionEventsInput) (ContributionEventsOutput, error)

ListContributionEvents retrieves contribution events for a user.

type CreateCurrentUserPATInput

type CreateCurrentUserPATInput struct {
	Name        string   `json:"name" jsonschema:"Name of the personal access token,required"`
	Scopes      []string `json:"scopes" jsonschema:"Array of scopes,required"`
	Description string   `json:"description,omitempty" jsonschema:"Description for the token"`
	ExpiresAt   string   `json:"expires_at,omitempty" jsonschema:"Token expiration date (YYYY-MM-DD)"`
}

CreateCurrentUserPATInput holds parameters for creating a PAT for the current user.

type CreateInput

type CreateInput struct {
	Email                          string `json:"email" jsonschema:"The user email address,required"`
	Name                           string `json:"name" jsonschema:"The user display name,required"`
	Username                       string `json:"username" jsonschema:"The username,required"`
	Password                       string `json:"password,omitempty" jsonschema:"The user password (required unless reset_password or force_random_password is set)"`
	ResetPassword                  *bool  `json:"reset_password,omitempty" jsonschema:"Send a password reset email instead of setting password"`
	ForceRandomPassword            *bool  `json:"force_random_password,omitempty" jsonschema:"Set a random password instead of requiring one"`
	SkipConfirmation               *bool  `json:"skip_confirmation,omitempty" jsonschema:"Skip confirmation email and activate user immediately"`
	Admin                          *bool  `json:"admin,omitempty" jsonschema:"Grant admin privileges"`
	Auditor                        *bool  `json:"auditor,omitempty" tier:"premium" jsonschema:"Grant auditor privileges (Premium/Ultimate)"`
	External                       *bool  `json:"external,omitempty" jsonschema:"Mark user as external"`
	CanCreateGroup                 *bool  `json:"can_create_group,omitempty" jsonschema:"Allow the user to create groups"`
	PrivateProfile                 *bool  `json:"private_profile,omitempty" jsonschema:"Make the user's profile private"`
	ViewDiffsFileByFile            *bool  `json:"view_diffs_file_by_file,omitempty" jsonschema:"Show whitespace changes in diffs file by file"`
	Bio                            string `json:"bio,omitempty" jsonschema:"User bio text"`
	Location                       string `json:"location,omitempty" jsonschema:"User location"`
	JobTitle                       string `json:"job_title,omitempty" jsonschema:"User job title"`
	Organization                   string `json:"organization,omitempty" jsonschema:"User organization"`
	Pronouns                       string `json:"pronouns,omitempty" jsonschema:"User pronouns"`
	CommitEmail                    string `json:"commit_email,omitempty" jsonschema:"Email used for commits"`
	PublicEmail                    string `json:"public_email,omitempty" jsonschema:"Publicly visible email address"`
	WebsiteURL                     string `json:"website_url,omitempty" jsonschema:"User website URL"`
	Linkedin                       string `json:"linkedin,omitempty" jsonschema:"LinkedIn account"`
	Twitter                        string `json:"twitter,omitempty" jsonschema:"Twitter/X account"`
	Skype                          string `json:"skype,omitempty" jsonschema:"Skype account"`
	Discord                        string `json:"discord,omitempty" jsonschema:"Discord account"`
	Github                         string `json:"github,omitempty" jsonschema:"GitHub account"`
	Provider                       string `json:"provider,omitempty" jsonschema:"External provider name (use with extern_uid)"`
	ExternUID                      string `json:"extern_uid,omitempty" jsonschema:"External UID for the provider"`
	GroupIDForSAML                 *int64 `json:"group_id_for_saml,omitempty" jsonschema:"Group ID for SAML provisioning"`
	ProjectsLimit                  *int64 `json:"projects_limit,omitempty" jsonschema:"Maximum number of projects the user can create"`
	ThemeID                        *int64 `json:"theme_id,omitempty" jsonschema:"GitLab theme ID for the user's UI"`
	ColorSchemeID                  *int64 `json:"color_scheme_id,omitempty" jsonschema:"Syntax-highlighting color scheme ID"`
	SharedRunnersMinutesLimit      *int64 `` /* 128-byte string literal not displayed */
	ExtraSharedRunnersMinutesLimit *int64 `` /* 134-byte string literal not displayed */
	Note                           string `json:"note,omitempty" jsonschema:"Admin note about the user"`
}

CreateInput holds parameters for creating a new GitLab user (admin only).

type CreateServiceAccountInput

type CreateServiceAccountInput struct {
	Name     string `json:"name,omitempty" jsonschema:"Name for the service account"`
	Username string `json:"username,omitempty" jsonschema:"Username for the service account"`
	Email    string `json:"email,omitempty" jsonschema:"Email for the service account"`
}

CreateServiceAccountInput holds parameters for creating a service account.

type CreateUserRunnerInput

type CreateUserRunnerInput struct {
	RunnerType      string   `json:"runner_type" jsonschema:"Runner type: instance_type or group_type or project_type,required"`
	GroupID         *int64   `json:"group_id,omitempty" jsonschema:"Group ID (required for group_type runners)"`
	ProjectID       *int64   `json:"project_id,omitempty" jsonschema:"Project ID (required for project_type runners)"`
	Description     string   `json:"description,omitempty" jsonschema:"Runner description"`
	Paused          *bool    `json:"paused,omitempty" jsonschema:"Whether the runner should be paused"`
	Locked          *bool    `json:"locked,omitempty" jsonschema:"Whether the runner should be locked"`
	RunUntagged     *bool    `json:"run_untagged,omitempty" jsonschema:"Whether the runner can run untagged jobs"`
	TagList         []string `json:"tag_list,omitempty" jsonschema:"List of runner tags"`
	AccessLevel     string   `json:"access_level,omitempty" jsonschema:"Access level: not_protected or ref_protected"`
	MaximumTimeout  *int64   `json:"maximum_timeout,omitempty" jsonschema:"Maximum timeout for jobs in seconds"`
	MaintenanceNote string   `json:"maintenance_note,omitempty" jsonschema:"Maintenance note for the runner"`
}

CreateUserRunnerInput holds parameters for creating a runner linked to a user.

type CurrentInput

type CurrentInput struct{}

CurrentInput is an empty struct for the current user tool (no parameters needed).

type CurrentUserPATOutput

type CurrentUserPATOutput struct {
	ID          int64    `json:"id"`
	Name        string   `json:"name"`
	Active      bool     `json:"active"`
	Token       string   `json:"token,omitempty"`
	Scopes      []string `json:"scopes"`
	Revoked     bool     `json:"revoked"`
	Description string   `json:"description,omitempty"`
	UserID      int64    `json:"user_id"`
	CreatedAt   string   `json:"created_at,omitempty"`
	ExpiresAt   string   `json:"expires_at,omitempty"`
	LastUsedAt  string   `json:"last_used_at,omitempty"`
}

CurrentUserPATOutput represents a personal access token.

func CreateCurrentUserPAT

func CreateCurrentUserPAT(ctx context.Context, client *gitlabclient.Client, input CreateCurrentUserPATInput) (CurrentUserPATOutput, error)

CreateCurrentUserPAT creates a personal access token for the currently authenticated user.

type CustomAttributeOutput added in v2.3.0

type CustomAttributeOutput struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

CustomAttributeOutput mirrors gl.CustomAttribute, a key/value custom attribute attached to a user.

type DeleteInput

type DeleteInput struct {
	UserID int64 `json:"user_id" jsonschema:"The ID of the user to delete,required"`
}

DeleteInput holds parameters for deleting a GitLab user (admin only).

type DeleteOutput

type DeleteOutput struct {
	UserID  int64 `json:"user_id"`
	Deleted bool  `json:"deleted"`
}

DeleteOutput represents the result of deleting a user.

func Delete

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

Delete deletes a GitLab user (admin only).

type DeleteSSHKeyForUserInput

type DeleteSSHKeyForUserInput struct {
	UserID int64 `json:"user_id" jsonschema:"The ID of the user,required"`
	KeyID  int64 `json:"key_id" jsonschema:"The ID of the SSH key to delete,required"`
}

DeleteSSHKeyForUserInput holds parameters for deleting an SSH key from a specific user.

type DeleteSSHKeyInput

type DeleteSSHKeyInput struct {
	KeyID int64 `json:"key_id" jsonschema:"The ID of the SSH key to delete,required"`
}

DeleteSSHKeyInput holds parameters for deleting an SSH key from the current user.

type DeleteSSHKeyOutput

type DeleteSSHKeyOutput struct {
	KeyID   int64 `json:"key_id"`
	Deleted bool  `json:"deleted"`
}

DeleteSSHKeyOutput represents the result of deleting an SSH key.

func DeleteSSHKey

func DeleteSSHKey(ctx context.Context, client *gitlabclient.Client, input DeleteSSHKeyInput) (DeleteSSHKeyOutput, error)

DeleteSSHKey deletes an SSH key from the current authenticated user.

func DeleteSSHKeyForUser

func DeleteSSHKeyForUser(ctx context.Context, client *gitlabclient.Client, input DeleteSSHKeyForUserInput) (DeleteSSHKeyOutput, error)

DeleteSSHKeyForUser deletes an SSH key from a specific user (admin only).

type DeleteUserIdentityInput

type DeleteUserIdentityInput struct {
	UserID   int64  `json:"user_id" jsonschema:"The ID of the user,required"`
	Provider string `json:"provider" jsonschema:"The external provider name (e.g. ldap or saml),required"`
}

DeleteUserIdentityInput holds parameters for deleting a user's identity provider.

type DeleteUserIdentityOutput

type DeleteUserIdentityOutput struct {
	UserID   int64  `json:"user_id"`
	Provider string `json:"provider"`
	Deleted  bool   `json:"deleted"`
}

DeleteUserIdentityOutput represents the result of deleting a user identity.

func DeleteUserIdentity

func DeleteUserIdentity(ctx context.Context, client *gitlabclient.Client, input DeleteUserIdentityInput) (DeleteUserIdentityOutput, error)

DeleteUserIdentity deletes a user's identity provider (admin only).

type EmailListOutput

type EmailListOutput struct {
	toolutil.HintableOutput
	Emails []EmailOutput `json:"emails"`
}

EmailListOutput holds a list of emails.

func ListEmails

ListEmails retrieves email addresses for the current authenticated user.

type EmailOutput

type EmailOutput struct {
	ID          int64  `json:"id"`
	Email       string `json:"email"`
	ConfirmedAt string `json:"confirmed_at,omitempty"`
}

EmailOutput represents an email address.

type GetAssociationsCountInput

type GetAssociationsCountInput struct {
	UserID int64 `json:"user_id" jsonschema:"The ID of the user,required"`
}

GetAssociationsCountInput holds parameters for getting user association counts.

type GetInput

type GetInput struct {
	UserID               int64 `json:"user_id" jsonschema:"The ID of the user to retrieve,required"`
	WithCustomAttributes *bool `json:"with_custom_attributes,omitempty" jsonschema:"Include custom attributes in the response (admin only)"`
}

GetInput holds parameters for retrieving a single user.

type GetSSHKeyForUserInput

type GetSSHKeyForUserInput struct {
	UserID int64 `json:"user_id" jsonschema:"The ID of the user,required"`
	KeyID  int64 `json:"key_id" jsonschema:"The ID of the SSH key,required"`
}

GetSSHKeyForUserInput holds parameters for retrieving a specific SSH key for a user.

type GetSSHKeyInput

type GetSSHKeyInput struct {
	KeyID int64 `json:"key_id" jsonschema:"The ID of the SSH key,required"`
}

GetSSHKeyInput holds parameters for retrieving a specific SSH key.

type GetStatusInput

type GetStatusInput struct {
	UserID int64 `json:"user_id" jsonschema:"The ID of the user whose status to retrieve,required"`
}

GetStatusInput holds parameters for retrieving a user's status.

type GetUserActivitiesInput

type GetUserActivitiesInput struct {
	From    string `json:"from,omitempty" jsonschema:"Only activities after this date (YYYY-MM-DD)"`
	OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. id)"`
	Sort    string `json:"sort,omitempty" jsonschema:"Sort order for keyset pagination: asc or desc"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

GetUserActivitiesInput holds parameters for listing user activities (admin only).

type GetUserMembershipsInput

type GetUserMembershipsInput struct {
	UserID  int64  `json:"user_id" jsonschema:"The ID of the user,required"`
	Type    string `json:"type,omitempty" jsonschema:"Filter by membership type: Project or Namespace"`
	OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. id)"`
	Sort    string `json:"sort,omitempty" jsonschema:"Sort order for keyset pagination: asc or desc"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

GetUserMembershipsInput holds parameters for listing a user's memberships.

type IdentityOutput added in v2.3.0

type IdentityOutput struct {
	Provider  string `json:"provider"`
	ExternUID string `json:"extern_uid"`
}

IdentityOutput mirrors gl.UserIdentity, a provider/extern_uid pair linking a user to an external authentication source.

type ListContributionEventsInput

type ListContributionEventsInput struct {
	UserID     int64  `json:"user_id" jsonschema:"The ID of the user whose events to retrieve,required"`
	Action     string `` /* 176-byte string literal not displayed */
	TargetType string `` /* 131-byte string literal not displayed */
	Before     string `json:"before,omitempty" jsonschema:"Only events before this date (YYYY-MM-DD)"`
	After      string `json:"after,omitempty" jsonschema:"Only events after this date (YYYY-MM-DD)"`
	Scope      string `json:"scope,omitempty" jsonschema:"Include all events across a user's projects (e.g. 'all')"`
	OrderBy    string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. id)"`
	Sort       string `json:"sort,omitempty" jsonschema:"Sort order: asc or desc"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListContributionEventsInput holds parameters for listing user contribution events.

type ListEmailsInput

type ListEmailsInput struct{}

ListEmailsInput is an empty struct for listing current user's emails.

type ListInput

type ListInput struct {
	Search               string `json:"search,omitempty" jsonschema:"Search users by name or username or email"`
	Username             string `json:"username,omitempty" jsonschema:"Filter by exact username"`
	Active               *bool  `json:"active,omitempty" jsonschema:"Filter for active users only"`
	Blocked              *bool  `json:"blocked,omitempty" jsonschema:"Filter for blocked users only"`
	External             *bool  `json:"external,omitempty" jsonschema:"Filter for external users only"`
	Admins               *bool  `json:"admins,omitempty" jsonschema:"Filter for administrators only"`
	Humans               *bool  `json:"humans,omitempty" jsonschema:"Filter for human (non-bot, non-internal) users only"`
	ExcludeActive        *bool  `json:"exclude_active,omitempty" jsonschema:"Exclude active users from the result"`
	ExcludeExternal      *bool  `json:"exclude_external,omitempty" jsonschema:"Exclude external users from the result"`
	ExcludeHumans        *bool  `json:"exclude_humans,omitempty" jsonschema:"Exclude human users from the result"`
	ExcludeInternal      *bool  `json:"exclude_internal,omitempty" jsonschema:"Exclude internal (bot/system) users from the result"`
	WithoutProjects      *bool  `json:"without_projects,omitempty" jsonschema:"Filter for users without any projects"`
	WithoutProjectBots   *bool  `json:"without_project_bots,omitempty" jsonschema:"Exclude project bot users from the result"`
	WithCustomAttributes *bool  `json:"with_custom_attributes,omitempty" jsonschema:"Include custom attributes in the response (admin only)"`
	TwoFactor            string `json:"two_factor,omitempty" jsonschema:"Filter by 2FA status: enabled or disabled"`
	ExternUID            string `json:"extern_uid,omitempty" jsonschema:"Filter by external UID (use with provider)"`
	Provider             string `json:"provider,omitempty" jsonschema:"Filter by external provider name (use with extern_uid)"`
	PublicEmail          string `json:"public_email,omitempty" jsonschema:"Filter by exact public email address"`
	CreatedAfter         string `json:"created_after,omitempty" jsonschema:"Filter users created after this date (RFC3339)"`
	CreatedBefore        string `json:"created_before,omitempty" jsonschema:"Filter users created before this date (RFC3339)"`
	OrderBy              string `json:"order_by,omitempty" jsonschema:"Order by: id | name | username | created_at | updated_at"`
	Sort                 string `json:"sort,omitempty" jsonschema:"Sort order: asc or desc"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListInput holds parameters for listing GitLab users.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Users      []Output                  `json:"users"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListOutput holds a paginated list of users.

func List

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

List retrieves a paginated list of GitLab users.

type ListSSHKeysForUserInput

type ListSSHKeysForUserInput struct {
	UserID  int64  `json:"user_id" jsonschema:"The ID of the user,required"`
	OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. id)"`
	Sort    string `json:"sort,omitempty" jsonschema:"Sort order for keyset pagination: asc or desc"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListSSHKeysForUserInput holds parameters for listing SSH keys for a specific user.

type ListSSHKeysInput

type ListSSHKeysInput struct {
	OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. id)"`
	Sort    string `json:"sort,omitempty" jsonschema:"Sort order for keyset pagination: asc or desc"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListSSHKeysInput holds parameters for listing SSH keys.

type ListServiceAccountsInput

type ListServiceAccountsInput struct {
	OrderBy string `json:"order_by,omitempty" jsonschema:"Field to order by (id/username/name)"`
	Sort    string `json:"sort,omitempty" jsonschema:"Sort direction (asc/desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListServiceAccountsInput holds parameters for listing service accounts.

type ModifyInput

type ModifyInput struct {
	UserID              int64  `json:"user_id" jsonschema:"The ID of the user to modify,required"`
	Email               string `json:"email,omitempty" jsonschema:"New email address"`
	Name                string `json:"name,omitempty" jsonschema:"New display name"`
	Username            string `json:"username,omitempty" jsonschema:"New username"`
	Password            string `json:"password,omitempty" jsonschema:"New password"`
	Admin               *bool  `json:"admin,omitempty" jsonschema:"Grant or revoke admin privileges"`
	External            *bool  `json:"external,omitempty" jsonschema:"Mark or unmark as external"`
	SkipReconfirmation  *bool  `json:"skip_reconfirmation,omitempty" jsonschema:"Skip reconfirmation on email change"`
	Bio                 string `json:"bio,omitempty" jsonschema:"New bio text"`
	Location            string `json:"location,omitempty" jsonschema:"New location"`
	JobTitle            string `json:"job_title,omitempty" jsonschema:"New job title"`
	Organization        string `json:"organization,omitempty" jsonschema:"New organization"`
	ProjectsLimit       *int64 `json:"projects_limit,omitempty" jsonschema:"New maximum projects limit"`
	Note                string `json:"note,omitempty" jsonschema:"New admin note"`
	PrivateProfile      *bool  `json:"private_profile,omitempty" jsonschema:"Set profile as private"`
	CanCreateGroup      *bool  `json:"can_create_group,omitempty" jsonschema:"Allow user to create groups"`
	ViewDiffsFileByFile *bool  `json:"view_diffs_file_by_file,omitempty" jsonschema:"Show whitespace changes in diffs file by file"`
	CommitEmail         string `json:"commit_email,omitempty" jsonschema:"Email used for commits"`
	PublicEmail         string `json:"public_email,omitempty" jsonschema:"Publicly visible email address"`
	WebsiteURL          string `json:"website_url,omitempty" jsonschema:"User website URL"`
	Linkedin            string `json:"linkedin,omitempty" jsonschema:"LinkedIn account"`
	Twitter             string `json:"twitter,omitempty" jsonschema:"Twitter/X account"`
	Skype               string `json:"skype,omitempty" jsonschema:"Skype account"`
	Provider            string `json:"provider,omitempty" jsonschema:"External provider name (use with extern_uid)"`
	ExternUID           string `json:"extern_uid,omitempty" jsonschema:"External UID for the provider"`
	ThemeID             *int64 `json:"theme_id,omitempty" jsonschema:"GitLab theme ID for the user's UI"`
	Locked              *bool  `json:"locked,omitempty" jsonschema:"Lock or unlock the user account"`
}

ModifyInput holds parameters for modifying an existing GitLab user (admin only).

type Output

type Output struct {
	toolutil.HintableOutput
	ID                             int64                   `json:"id"`
	Username                       string                  `json:"username"`
	Email                          string                  `json:"email"`
	Name                           string                  `json:"name"`
	State                          string                  `json:"state"`
	WebURL                         string                  `json:"web_url"`
	AvatarURL                      string                  `json:"avatar_url"`
	IsAdmin                        bool                    `json:"is_admin"`
	IsAuditor                      bool                    `json:"is_auditor" tier:"premium"`
	Bot                            bool                    `json:"bot"`
	Bio                            string                  `json:"bio,omitempty"`
	Location                       string                  `json:"location,omitempty"`
	JobTitle                       string                  `json:"job_title,omitempty"`
	Organization                   string                  `json:"organization,omitempty"`
	CreatedAt                      string                  `json:"created_at,omitempty"`
	ConfirmedAt                    string                  `json:"confirmed_at,omitempty"`
	PublicEmail                    string                  `json:"public_email,omitempty"`
	Skype                          string                  `json:"skype,omitempty"`
	Linkedin                       string                  `json:"linkedin,omitempty"`
	Twitter                        string                  `json:"twitter,omitempty"`
	WebsiteURL                     string                  `json:"website_url,omitempty"`
	ExternUID                      string                  `json:"extern_uid,omitempty"`
	Provider                       string                  `json:"provider,omitempty"`
	LastActivityOn                 string                  `json:"last_activity_on,omitempty"`
	TwoFactorEnabled               bool                    `json:"two_factor_enabled"`
	External                       bool                    `json:"external"`
	Locked                         bool                    `json:"locked"`
	PrivateProfile                 bool                    `json:"private_profile"`
	CurrentSignInAt                string                  `json:"current_sign_in_at,omitempty"`
	CurrentSignInIP                string                  `json:"current_sign_in_ip,omitempty"`
	LastSignInAt                   string                  `json:"last_sign_in_at,omitempty"`
	LastSignInIP                   string                  `json:"last_sign_in_ip,omitempty"`
	ProjectsLimit                  int64                   `json:"projects_limit"`
	CanCreateProject               bool                    `json:"can_create_project"`
	CanCreateGroup                 bool                    `json:"can_create_group"`
	CanCreateOrganization          bool                    `json:"can_create_organization"`
	Note                           string                  `json:"note,omitempty"`
	UsingLicenseSeat               bool                    `json:"using_license_seat" tier:"premium"`
	ThemeID                        int64                   `json:"theme_id,omitempty"`
	ColorSchemeID                  int64                   `json:"color_scheme_id,omitempty"`
	SharedRunnersMinutesLimit      int64                   `json:"shared_runners_minutes_limit,omitempty" tier:"premium"`
	ExtraSharedRunnersMinutesLimit int64                   `json:"extra_shared_runners_minutes_limit,omitempty" tier:"premium"`
	NamespaceID                    int64                   `json:"namespace_id,omitempty"`
	Identities                     []IdentityOutput        `json:"identities,omitempty"`
	SCIMIdentities                 []SCIMIdentityOutput    `json:"scim_identities,omitempty" tier:"premium"`
	CustomAttributes               []CustomAttributeOutput `json:"custom_attributes,omitempty"`
	CreatedBy                      *BasicUserOutput        `json:"created_by,omitempty"`
}

Output mirrors the top-level fields of gl.User. The GitLab user endpoints return full User objects, so this shape reflects gl.User as completely as practical: every top-level scalar plus the nested identities, SCIM identities, custom attributes, and created_by sub-objects. It is kept in sync with the enterpriseusers package UserOutput for cross-domain consistency.

func Create

func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)

Create creates a new GitLab user (admin only).

func CreateServiceAccount

func CreateServiceAccount(ctx context.Context, client *gitlabclient.Client, input CreateServiceAccountInput) (Output, error)

CreateServiceAccount creates a new service account user.

func Current

func Current(ctx context.Context, client *gitlabclient.Client, _ CurrentInput) (Output, error)

Current retrieves the currently authenticated GitLab user.

func Get

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

Get retrieves a single GitLab user by ID.

func Modify

func Modify(ctx context.Context, client *gitlabclient.Client, input ModifyInput) (Output, error)

Modify modifies an existing GitLab user (admin only).

func UploadCurrentUserAvatar added in v2.3.0

func UploadCurrentUserAvatar(ctx context.Context, client *gitlabclient.Client, input UploadCurrentUserAvatarInput) (Output, error)

UploadCurrentUserAvatar uploads or replaces the avatar for the current authenticated user. Accepts either file_path (local file) or content_base64 (base64-encoded string), mirroring the project avatar upload tool.

type SCIMIdentityOutput

type SCIMIdentityOutput struct {
	ExternUID string `json:"extern_uid"`
	GroupID   int64  `json:"group_id"`
	Active    bool   `json:"active"`
}

SCIMIdentityOutput represents a SCIM identity associated with a user.

type SSHKeyListOutput

type SSHKeyListOutput struct {
	toolutil.HintableOutput
	Keys       []SSHKeyOutput            `json:"keys"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

SSHKeyListOutput holds a paginated list of SSH keys.

func ListSSHKeys

func ListSSHKeys(ctx context.Context, client *gitlabclient.Client, input ListSSHKeysInput) (SSHKeyListOutput, error)

ListSSHKeys retrieves SSH keys for the current authenticated user.

func ListSSHKeysForUser

func ListSSHKeysForUser(ctx context.Context, client *gitlabclient.Client, input ListSSHKeysForUserInput) (SSHKeyListOutput, error)

ListSSHKeysForUser retrieves SSH keys for a specific user.

type SSHKeyOutput

type SSHKeyOutput struct {
	ID        int64  `json:"id"`
	Title     string `json:"title"`
	Key       string `json:"key"`
	CreatedAt string `json:"created_at,omitempty"`
	ExpiresAt string `json:"expires_at,omitempty"`
	UsageType string `json:"usage_type,omitempty"`
}

SSHKeyOutput represents an SSH key.

func AddSSHKey

func AddSSHKey(ctx context.Context, client *gitlabclient.Client, input AddSSHKeyInput) (SSHKeyOutput, error)

AddSSHKey adds an SSH key to the current authenticated user.

func AddSSHKeyForUser

func AddSSHKeyForUser(ctx context.Context, client *gitlabclient.Client, input AddSSHKeyForUserInput) (SSHKeyOutput, error)

AddSSHKeyForUser adds an SSH key to a specific user (admin only).

func GetSSHKey

func GetSSHKey(ctx context.Context, client *gitlabclient.Client, input GetSSHKeyInput) (SSHKeyOutput, error)

GetSSHKey retrieves a specific SSH key for the current user.

func GetSSHKeyForUser

func GetSSHKeyForUser(ctx context.Context, client *gitlabclient.Client, input GetSSHKeyForUserInput) (SSHKeyOutput, error)

GetSSHKeyForUser retrieves a specific SSH key for a user.

type ServiceAccountListOutput

type ServiceAccountListOutput struct {
	Accounts []ServiceAccountOutput `json:"accounts"`
}

ServiceAccountListOutput holds a list of service accounts.

func ListServiceAccounts

func ListServiceAccounts(ctx context.Context, client *gitlabclient.Client, input ListServiceAccountsInput) (ServiceAccountListOutput, error)

ListServiceAccounts lists all service accounts.

type ServiceAccountOutput

type ServiceAccountOutput struct {
	ID               int64  `json:"id"`
	Username         string `json:"username"`
	Name             string `json:"name"`
	Email            string `json:"email,omitempty"`
	UnconfirmedEmail string `json:"unconfirmed_email,omitempty"`
}

ServiceAccountOutput represents a service account.

func UpdateInstanceServiceAccount added in v2.1.2

func UpdateInstanceServiceAccount(ctx context.Context, client *gitlabclient.Client, input UpdateServiceAccountInput) (ServiceAccountOutput, error)

UpdateInstanceServiceAccount updates an instance-level service account.

type SetStatusInput

type SetStatusInput struct {
	Emoji            string `json:"emoji,omitempty" jsonschema:"The emoji to set for the status (e.g. coffee or speech_balloon)"`
	Message          string `json:"message,omitempty" jsonschema:"The status message text"`
	Availability     string `json:"availability,omitempty" jsonschema:"The availability: not_set or busy"`
	ClearStatusAfter string `` /* 153-byte string literal not displayed */
}

SetStatusInput holds parameters for setting the current user's status.

type StatusOutput

type StatusOutput struct {
	toolutil.HintableOutput
	Emoji         string `json:"emoji,omitempty"`
	Availability  string `json:"availability,omitempty"`
	Message       string `json:"message,omitempty"`
	MessageHTML   string `json:"message_html,omitempty"`
	ClearStatusAt string `json:"clear_status_at,omitempty"`
}

StatusOutput represents a user's status.

func CurrentUserStatus

func CurrentUserStatus(ctx context.Context, client *gitlabclient.Client, _ CurrentInput) (StatusOutput, error)

CurrentUserStatus retrieves the status of the current authenticated user.

func GetStatus

func GetStatus(ctx context.Context, client *gitlabclient.Client, input GetStatusInput) (StatusOutput, error)

GetStatus retrieves the status of a specific user.

func SetStatus

func SetStatus(ctx context.Context, client *gitlabclient.Client, input SetStatusInput) (StatusOutput, error)

SetStatus sets the current user's status.

type UpdateServiceAccountInput added in v2.1.2

type UpdateServiceAccountInput struct {
	ServiceAccountID int64  `json:"service_account_id" jsonschema:"Service account ID to update,required"`
	Name             string `json:"name,omitempty"              jsonschema:"New name for the service account"`
	Username         string `json:"username,omitempty"          jsonschema:"New username for the service account"`
	Email            string `json:"email,omitempty"             jsonschema:"New email for the service account"`
}

UpdateServiceAccountInput holds parameters for updating an instance service account.

type UploadCurrentUserAvatarInput added in v2.3.0

type UploadCurrentUserAvatarInput struct {
	Filename      string `json:"filename" jsonschema:"Avatar filename (e.g. avatar.png),required"`
	FilePath      string `` /* 233-byte string literal not displayed */
	ContentBase64 string `` /* 134-byte string literal not displayed */
}

UploadCurrentUserAvatarInput defines parameters for uploading the current authenticated user's avatar. Exactly one of FilePath or ContentBase64 must be provided. There is no user identifier: the GitLab endpoint always targets the token's own user (PUT /user/avatar).

type UserActivitiesOutput

type UserActivitiesOutput struct {
	Activities []UserActivityOutput      `json:"activities"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

UserActivitiesOutput holds a paginated list of user activities.

func GetUserActivities

func GetUserActivities(ctx context.Context, client *gitlabclient.Client, input GetUserActivitiesInput) (UserActivitiesOutput, error)

GetUserActivities retrieves user activity entries (admin only).

type UserActivityOutput

type UserActivityOutput struct {
	Username       string `json:"username"`
	LastActivityOn string `json:"last_activity_on,omitempty"`
}

UserActivityOutput represents a user activity entry.

type UserMembershipOutput

type UserMembershipOutput struct {
	SourceID    int64  `json:"source_id"`
	SourceName  string `json:"source_name"`
	SourceType  string `json:"source_type"`
	AccessLevel int64  `json:"access_level"`
}

UserMembershipOutput represents a user's membership in a project or group.

type UserMembershipsOutput

type UserMembershipsOutput struct {
	Memberships []UserMembershipOutput    `json:"memberships"`
	Pagination  toolutil.PaginationOutput `json:"pagination"`
}

UserMembershipsOutput holds a paginated list of user memberships.

func GetUserMemberships

func GetUserMemberships(ctx context.Context, client *gitlabclient.Client, input GetUserMembershipsInput) (UserMembershipsOutput, error)

GetUserMemberships retrieves a user's project and group memberships.

type UserRunnerOutput

type UserRunnerOutput struct {
	ID             int64  `json:"id"`
	Token          string `json:"token"`
	TokenExpiresAt string `json:"token_expires_at,omitempty"`
}

UserRunnerOutput represents a GitLab runner linked to the current user.

func CreateUserRunner

func CreateUserRunner(ctx context.Context, client *gitlabclient.Client, input CreateUserRunnerInput) (UserRunnerOutput, error)

CreateUserRunner creates a runner linked to the current user.

Jump to

Keyboard shortcuts

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