Debian Codegraph @

/

debian golang-github-xanzy-go-gitlab 0.110.0-1debian golang-github-xanzy-go-gitlab-dev gomod github.com/xanzy/go-gitlab debiangogoinijsonmakemakefilemarkdownshellyaml 406 files · 11492 symbols
View dependency graph

Depends on

README (full)

go-gitlab

A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way

Build Status Sourcegraph GoDoc Go Report Card Coverage

NOTE

Release v0.6.0 (released on 25-08-2017) no longer supports the older V3 GitLab API. If you need V3 support, please use the f-api-v3 branch. This release contains some backwards incompatible changes that were needed to fully support the V4 GitLab API.

Coverage

This API client package covers most of the existing GitLab API calls and is updated regularly to add new and/or missing endpoints. Currently, the following services are supported:

  • Applications
  • Award Emojis
  • Branches
  • Broadcast Messages
  • Commits
  • Container Registry
  • Custom Attributes
  • Deploy Keys
  • Deployments
  • Discussions (threaded comments)
  • Environments
  • Epic Issues
  • Epics
  • Error Tracking
  • Events
  • Feature Flags
  • Geo Nodes
  • Generic Packages
  • GitLab CI Config Templates
  • Gitignores Templates
  • Group Access Requests
  • Group Issue Boards
  • Group Members
  • Group Milestones
  • Group Wikis
  • Group-Level Variables
  • Groups
  • Instance Clusters
  • Invites
  • Issue Boards
  • Issues
  • Jobs
  • Keys
  • Labels
  • License
  • Markdown
  • Merge Request Approvals
  • Merge Requests
  • Namespaces
  • Notes (comments)
  • Notification Settings
  • Open Source License Templates
  • Packages
  • Pages
  • Pages Domains
  • Personal Access Tokens
  • Pipeline Schedules
  • Pipeline Triggers
  • Pipelines
  • Plan limits
  • Project Access Requests
  • Project Badges
  • Project Clusters
  • Project Import/export
  • Project Members
  • Project Milestones
  • Project Repository Storage Moves
  • Project Snippets
  • Project Vulnerabilities
  • Project-Level Variables
  • Projects (including setting Webhooks)
  • Protected Branches
  • Protected Environments
  • Protected Tags
  • Repositories
  • Repository Files
  • Repository Submodules
  • Runners
  • Search
  • Services
  • Settings
  • Sidekiq Metrics
  • System Hooks
  • Tags
  • Todos
  • Topics
  • Users
  • Validate CI Configuration
  • Version
  • Wikis

Usage

import "github.com/xanzy/go-gitlab"

Construct a new GitLab client, then use the various services on the client to access different parts of the GitLab API. For example, to list all users:

git, err := gitlab.NewClient("yourtokengoeshere")
if err != nil {
  log.Fatalf("Failed to create client: %v", err)
}
users, _, err := git.Users.ListUsers(&gitlab.ListUsersOptions{})

There are a few With... option functions that can be used to customize the API client. For example, to set a custom base URL:

git, err := gitlab.NewClient("yourtokengoeshere", gitlab.WithBaseURL("https://git.mydomain.com/api/v4"))
if err != nil {
  log.Fatalf("Failed to create client: %v", err)
}
users, _, err := git.Users.ListUsers(&gitlab.ListUsersOptions{})

Some API methods have optional parameters that can be passed. For example, to list all projects for user "svanharmelen":

git := gitlab.NewClient("yourtokengoeshere")
opt := &gitlab.ListProjectsOptions{Search: gitlab.Ptr("svanharmelen")}
projects, _, err := git.Projects.ListProjects(opt)

Examples

The examples directory contains a couple for clear examples, of which one is partially listed here as well:

package main

import (
	"log"

	"github.com/xanzy/go-gitlab"
)

func main() {
	git, err := gitlab.NewClient("yourtokengoeshere")
	if err != nil {
		log.Fatalf("Failed to create client: %v", err)
	}

	// Create new project
	p := &gitlab.CreateProjectOptions{
		Name:                     gitlab.Ptr("My Project"),
		Description:              gitlab.Ptr("Just a test project to play with"),
		MergeRequestsAccessLevel: gitlab.Ptr(gitlab.EnabledAccessControl),
		SnippetsAccessLevel:      gitlab.Ptr(gitlab.EnabledAccessControl),
		Visibility:               gitlab.Ptr(gitlab.PublicVisibility),
	}
	project, _, err := git.Projects.CreateProject(p)
	if err != nil {
		log.Fatal(err)
	}

	// Add a new snippet
	s := &gitlab.CreateProjectSnippetOptions{
		Title:           gitlab.Ptr("Dummy Snippet"),
		FileName:        gitlab.Ptr("snippet.go"),
		Content:         gitlab.Ptr("package main...."),
		Visibility:      gitlab.Ptr(gitlab.PublicVisibility),
	}
	_, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s)
	if err != nil {
		log.Fatal(err)
	}
}

For complete usage of go-gitlab, see the full package docs.

ToDo

  • The biggest thing this package still needs is tests :disappointed:

Issues

Author

Sander van Harmelen ([email protected])

Contributing

Contributions are always welcome. For more information, check out the contributing guide

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

dir .github/
dir debian/
dir examples/
dir testdata/
file .gitignore
file .golangci.yml
file CONTRIBUTING.md
file LICENSE
file Makefile
file README.md
file access_requests.go
file access_requests_test.go
file appearance.go
file appearance_test.go
file applications.go
file applications_test.go
file audit_events.go
file audit_events_test.go
file avatar.go
file avatar_test.go
file award_emojis.go
file award_emojis_test.go
file boards.go
file boards_test.go
file branches.go
file branches_test.go
file broadcast_messages.go
file broadcast_messages_test.go
file ci_yml_templates.go
file ci_yml_templates_test.go
file client_options.go
file cluster_agents.go
file cluster_agents_test.go
file commits.go
file commits_test.go
file container_registry.go
file container_registry_test.go
file custom_attributes.go
file custom_attributes_test.go
file deploy_keys.go
file deploy_keys_test.go
file deploy_tokens.go
file deploy_tokens_test.go
file deployments.go
file deployments_merge_requests.go
file deployments_merge_requests_test.go
file deployments_test.go
file discussions.go
file discussions_test.go
file dockerfile_templates.go
file dockerfile_templates_test.go
file dora_metrics.go
file dora_metrics_test.go
file draft_notes.go
file draft_notes_test.go
file environments.go
file environments_test.go
file epic_issues.go
file epic_issues_test.go
file epics.go
file epics_test.go
file error_tracking.go
file error_tracking_test.go
file event_parsing.go
file event_parsing_systemhook_test.go
file event_parsing_webhook_test.go
file event_systemhook_types.go
file event_webhook_types.go
file event_webhook_types_test.go
file events.go
file events_test.go
file external_status_checks.go
file external_status_checks_test.go
file feature_flags.go
file feature_flags_test.go
file fixtures_test.go
file freeze_periods.go
file freeze_periods_test.go
file generic_packages.go
file generic_packages_test.go
file geo_nodes.go
file geo_nodes_test.go
file gitignore_templates.go
file gitignore_templates_test.go
file gitlab.go
file gitlab_test.go
file go.mod
file go.sum
file group_access_tokens.go
file group_access_tokens_test.go
file group_badges.go
file group_badges_test.go
file group_boards.go
file group_boards_test.go
file group_clusters.go
file group_clusters_test.go
file group_epic_boards.go
file group_epic_boards_test.go
file group_hooks.go
file group_hooks_test.go
file group_import_export.go
file group_import_export_test.go
file group_iterations.go
file group_iterations_test.go
file group_labels.go
file group_labels_test.go
file group_members.go
file group_members_test.go
file group_milestones.go
file group_milestones_test.go
file group_protected_environments.go
file group_protected_environments_test.go
file group_repository_storage_move.go
file group_repository_storage_move_test.go
file group_serviceaccounts.go
file group_serviceaccounts_test.go
file group_ssh_certificates.go
file group_ssh_certificates_test.go
file group_variables.go
file group_variables_test.go
file group_wikis.go
file group_wikis_test.go
file groups.go
file groups_test.go
file import.go
file import_test.go
file instance_clusters.go
file instance_clusters_test.go
file instance_variables.go
file instance_variables_test.go
file invites.go
file invites_test.go
file issue_links.go
file issue_links_test.go
file issues.go
file issues_statistics.go
file issues_statistics_test.go
file issues_test.go
file job_token_scope.go
file job_token_scope_test.go
file jobs.go
file jobs_test.go
file keys.go
file keys_test.go
file labels.go
file labels_test.go
file license.go
file license_templates.go
file license_templates_test.go
file license_test.go
file markdown.go
file markdown_test.go
file member_roles.go
file member_roles_test.go
file merge_request_approvals.go
file merge_request_approvals_test.go
file merge_requests.go
file merge_requests_test.go
file merge_trains.go
file merge_trains_test.go
file metadata.go
file metadata_test.go
file milestones.go
file milestones_test.go
file namespaces.go
file namespaces_test.go
file notes.go
file notes_test.go
file notifications.go
file notifications_test.go
file packages.go
file packages_test.go
file pages.go
file pages_domains.go
file pages_domains_test.go
file pages_test.go
file personal_access_tokens.go
file personal_access_tokens_test.go
file pipeline_schedules.go
file pipeline_schedules_test.go
file pipeline_triggers.go
file pipeline_triggers_test.go
file pipelines.go
file pipelines_test.go
file plan_limits.go
file plan_limits_test.go
file project_access_tokens.go
file project_access_tokens_test.go
file project_badges.go
file project_badges_test.go
file project_clusters.go
file project_clusters_test.go
file project_feature_flags.go
file project_feature_flags_test.go
file project_import_export.go
file project_import_export_test.go
file project_iterations.go
file project_iterations_test.go
file project_managed_licenses.go
file project_managed_licenses_test.go
file project_members.go
file project_members_test.go
file project_mirror.go
file project_mirror_test.go
file project_repository_storage_move.go
file project_repository_storage_move_test.go
file project_snippets.go
file project_snippets_test.go
file project_templates.go
file project_templates_test.go
file project_variables.go
file project_variables_test.go
file project_vulnerabilities.go
file project_vulnerabilities_test.go
file projects.go
file projects_test.go
file protected_branches.go
file protected_branches_test.go
file protected_environments.go
file protected_environments_test.go
file protected_tags.go
file protected_tags_test.go
file releaselinks.go
file releaselinks_test.go
file releases.go
file releases_test.go
file repositories.go
file repositories_test.go
file repository_files.go
file repository_files_test.go
file repository_submodules.go
file repository_submodules_test.go
file request_options.go
file request_options_test.go
file resource_group.go
file resource_group_test.go
file resource_iteration_events.go
file resource_iteration_events_test.go
file resource_label_events.go
file resource_label_events_test.go
file resource_milestone_events.go
file resource_milestone_events_test.go
file resource_state_events.go
file resource_state_events_test.go
file resource_weight_events.go
file resource_weight_events_test.go
file runners.go
file runners_test.go
file search.go
file search_test.go
file services.go
file services_test.go
file settings.go
file settings_test.go
file sidekiq_metrics.go
file sidekiq_metrics_test.go
file snippet_repository_storage_move.go
file snippet_repository_storage_move_test.go
file snippets.go
file snippets_test.go
file strings.go
file strings_test.go
file system_hooks.go
file system_hooks_test.go
file tags.go
file tags_test.go
file time_stats.go
file todos.go
file todos_test.go
file topics.go
file topics_test.go
file types.go
file types_test.go
file users.go
file users_test.go
file validate.go
file validate_test.go
file version.go
file version_test.go
file wikis.go
file wikis_test.go