projectserviceaccounts

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package projectserviceaccounts implements MCP tools for GitLab project service accounts.

The package wraps the GitLab project service accounts API:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionSpecs

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

ActionSpecs returns canonical specs for project service account actions.

func Delete

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

Delete deletes a project service account.

func FormatListMarkdownString

func FormatListMarkdownString(out ListOutput) string

FormatListMarkdownString renders a paginated list of project service accounts.

func FormatListPATMarkdownString

func FormatListPATMarkdownString(out ListPATOutput) string

FormatListPATMarkdownString renders a paginated list of project service account PATs.

func FormatMarkdownString

func FormatMarkdownString(out Output) string

FormatMarkdownString renders a project service account as Markdown.

func FormatPATMarkdownString

func FormatPATMarkdownString(out PATOutput) string

FormatPATMarkdownString renders a project service account PAT as Markdown.

func RevokePAT

func RevokePAT(ctx context.Context, client *gitlabclient.Client, input RevokePATInput) error

RevokePAT revokes a personal access token for a project service account.

Types

type CreateInput

type CreateInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Name      string               `json:"name,omitempty" jsonschema:"Service account name"`
	Username  string               `json:"username,omitempty" jsonschema:"Service account username"`
	Email     string               `json:"email,omitempty" jsonschema:"Service account email"`
}

CreateInput holds parameters for creating a project service account.

type CreatePATInput

type CreatePATInput struct {
	ProjectID        toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	ServiceAccountID int64                `json:"service_account_id" jsonschema:"Service account user ID,required"`
	Name             string               `json:"name" jsonschema:"Token name,required"`
	Scopes           []string             `json:"scopes" jsonschema:"Token scopes (e.g. api, read_api, read_user),required"`
	Description      string               `json:"description,omitempty" jsonschema:"Token description"`
	ExpiresAt        string               `json:"expires_at,omitempty" jsonschema:"Expiration date in YYYY-MM-DD format"`
}

CreatePATInput holds parameters for creating a project service account PAT.

type DeleteInput

type DeleteInput struct {
	ProjectID        toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	ServiceAccountID int64                `json:"service_account_id" jsonschema:"Service account user ID,required"`
	HardDelete       *bool                `json:"hard_delete,omitempty" jsonschema:"Hard delete the service account"`
}

DeleteInput holds parameters for deleting a project service account.

type ListInput

type ListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
	OrderBy string `json:"order_by,omitempty" jsonschema:"Order by id or username"`
	Sort    string `json:"sort,omitempty" jsonschema:"Sort direction: asc or desc"`
}

ListInput holds parameters for listing project service accounts.

type ListOutput

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

ListOutput holds a paginated list of project service accounts.

func List

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

List retrieves service accounts for a project.

type ListPATInput

type ListPATInput struct {
	ProjectID        toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	ServiceAccountID int64                `json:"service_account_id" jsonschema:"Service account user ID,required"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
	CreatedAfter   string `json:"created_after,omitempty" jsonschema:"Filter tokens created after RFC3339 datetime or YYYY-MM-DD date"`
	CreatedBefore  string `json:"created_before,omitempty" jsonschema:"Filter tokens created before RFC3339 datetime or YYYY-MM-DD date"`
	ExpiresAfter   string `json:"expires_after,omitempty" jsonschema:"Filter tokens expiring after YYYY-MM-DD date"`
	ExpiresBefore  string `json:"expires_before,omitempty" jsonschema:"Filter tokens expiring before YYYY-MM-DD date"`
	LastUsedAfter  string `json:"last_used_after,omitempty" jsonschema:"Filter tokens last used after RFC3339 datetime or YYYY-MM-DD date"`
	LastUsedBefore string `json:"last_used_before,omitempty" jsonschema:"Filter tokens last used before RFC3339 datetime or YYYY-MM-DD date"`
	Revoked        *bool  `json:"revoked,omitempty" jsonschema:"Filter by revoked state"`
	UserID         int64  `json:"user_id,omitempty" jsonschema:"Filter by user ID"`
	Search         string `json:"search,omitempty" jsonschema:"Search token names"`
	OrderBy        string `json:"order_by,omitempty" jsonschema:"Order tokens by column (keyset pagination)"`
	Sort           string `json:"sort,omitempty" jsonschema:"Sort expression"`
	State          string `json:"state,omitempty" jsonschema:"Token state filter: active or inactive"`
}

ListPATInput holds parameters for listing project service account PATs.

type ListPATOutput

type ListPATOutput struct {
	toolutil.HintableOutput
	Tokens     []PATOutput               `json:"tokens"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListPATOutput holds a paginated list of project service account PATs.

func ListPATs

func ListPATs(ctx context.Context, client *gitlabclient.Client, input ListPATInput) (ListPATOutput, error)

ListPATs retrieves personal access tokens for a project service account.

type Output

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

Output represents a project service account.

func Create

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

Create creates a new project service account.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)

Update updates a project service account.

type PATOutput

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

PATOutput represents a personal access token for a project service account.

func CreatePAT

func CreatePAT(ctx context.Context, client *gitlabclient.Client, input CreatePATInput) (PATOutput, error)

CreatePAT creates a new personal access token for a project service account.

func RotatePAT

func RotatePAT(ctx context.Context, client *gitlabclient.Client, input RotatePATInput) (PATOutput, error)

RotatePAT rotates a personal access token for a project service account.

type RevokePATInput

type RevokePATInput struct {
	ProjectID        toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	ServiceAccountID int64                `json:"service_account_id" jsonschema:"Service account user ID,required"`
	TokenID          int64                `json:"token_id" jsonschema:"Personal access token ID to revoke,required"`
}

RevokePATInput holds parameters for revoking a project service account PAT.

type RotatePATInput

type RotatePATInput struct {
	ProjectID        toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	ServiceAccountID int64                `json:"service_account_id" jsonschema:"Service account user ID,required"`
	TokenID          int64                `json:"token_id" jsonschema:"Personal access token ID to rotate,required"`
	ExpiresAt        string               `json:"expires_at,omitempty" jsonschema:"New expiration date in YYYY-MM-DD format"`
}

RotatePATInput holds parameters for rotating a project service account PAT.

type UpdateInput

type UpdateInput struct {
	ProjectID        toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	ServiceAccountID int64                `json:"service_account_id" jsonschema:"Service account user ID,required"`
	Name             string               `json:"name,omitempty" jsonschema:"New name"`
	Username         string               `json:"username,omitempty" jsonschema:"New username"`
	Email            string               `json:"email,omitempty" jsonschema:"New email"`
}

UpdateInput holds parameters for updating a project service account.

Jump to

Keyboard shortcuts

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