gitlab

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gitlab is the library behind the lab command line: the HTTP client, request shaping, and the typed data models for the GitLab REST API v4 (gitlab.com/api/v4).

The public API requires no key for public projects and users. The Client sets a polite User-Agent, paces requests to 1100ms apart (60 req/min limit), and retries transient failures (429 and 5xx) with a capped backoff.

Index

Constants

View Source
const Host = "gitlab.com"

Host is the GitLab API host.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the GitLab API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Commits

func (c *Client) Commits(ctx context.Context, path string, limit int) ([]Commit, error)

Commits returns recent commits for a project path.

func (*Client) Groups

func (c *Client) Groups(ctx context.Context, name string, limit int) ([]Group, error)

Groups searches groups by name.

func (*Client) Project

func (c *Client) Project(ctx context.Context, path string) (*Project, error)

Project returns detail for one project by path (e.g. "gitlab-org/gitlab") or numeric id.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, limit int) ([]Project, error)

Search searches public projects by query string.

func (*Client) User

func (c *Client) User(ctx context.Context, username string) (*User, error)

User finds a user by username. Returns the first match or an error if none found.

type Commit

type Commit struct {
	ID          string `json:"id"`
	ShortID     string `json:"short_id"`
	Title       string `json:"title"`
	AuthorName  string `json:"author_name"`
	AuthorEmail string `json:"author_email,omitempty"`
	CreatedAt   string `json:"created_at"`
	Message     string `json:"message,omitempty"`
	WebURL      string `json:"web_url,omitempty"`
}

Commit is one repository commit.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for the GitLab API.

type Domain

type Domain struct{}

Domain is the GitLab driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns an input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Group

type Group struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Path        string `json:"full_path"`
	Description string `json:"description,omitempty"`
	Visibility  string `json:"visibility"`
	Stars       int    `json:"star_count,omitempty"`
	WebURL      string `json:"web_url"`
}

Group is one GitLab group or organization.

type Project

type Project struct {
	ID            int    `json:"id"`
	Path          string `json:"path_with_namespace"`
	Name          string `json:"name"`
	Description   string `json:"description,omitempty"`
	Stars         int    `json:"star_count"`
	Forks         int    `json:"forks_count"`
	Visibility    string `json:"visibility"`
	URL           string `json:"web_url"`
	LastActivity  string `json:"last_activity_at,omitempty"`
	OpenIssues    int    `json:"open_issues_count,omitempty"`
	DefaultBranch string `json:"default_branch,omitempty"`
}

Project is one GitLab project.

type User

type User struct {
	ID        int    `json:"id"`
	Username  string `json:"username"`
	Name      string `json:"name"`
	State     string `json:"state,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
	WebURL    string `json:"web_url"`
	Bio       string `json:"bio,omitempty"`
	Location  string `json:"location,omitempty"`
}

User is one GitLab user.

Jump to

Keyboard shortcuts

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