gitlab

package module
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 16 Imported by: 1

README

gitlab-go

Package for gitlab API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitlabClient added in v0.1.2

type GitlabClient interface {
	GetProperty(property string) string
	SetProperty(property string, value string) string
	Get(uri string) (string, error)
	Delete(uri string) (string, error)
	GetUsers(search string) (string, error)
	GetGroup(groupID int) (Group, error)
	GetGroups(search string) (GroupList, error)
	GetSubGroups(groupID int) (GroupList, error)
	GetDescendantGroups(groupID int) (GroupList, error)
	GetGroupProjects(groupID int) (ProjectList, error)
	GetGroupMembers(group int) (string, error)
	AddGroupMember(groupID, userID, accessLevel int) (string, error)
	GetForcePushSetting(projectID int, protectedBranch string) (bool, error)
	GetProjectID(projectPath string) (int, error)
	GetProject(projectID int) (Project, error)
	GetProjectMembers(project int) (string, error)
	AddProjectMember(projectID, userID, accessLevel int) (string, error)
	DeleteProject(projectID int) error
	GetProjectMirrors(projectID int) (ProjectMirrors, error)
	GetGroupID(groupPath string) (int, error)
	CreateProject(groupID int, projectPath string, visibility string) (Project, error)
	DeleteProtectedBranch(projectID int, protectedBranch string) (bool, error)
	ProtectBranch(projectID int, protectedBranch string) (bool, error)
	CreateProjectMirror(projectID int, mirrorURL string) (ProjectMirror, error)
	UpdateProjectMirror(projectID int, mirrorID int) (ProjectMirror, error)
	CreateMergeRequest(projectID int, title string, sourceBranch string, targetBranch string, description string, squashOnMerge bool, removeSourceBranch bool) (string, error)
	GetPipelines(projectID int, user string, limit int) (Pipelines, error)
	GetPipeline(projectID int, pipelineID int) (Pipeline, error)
	GetVariableFrom(id int, resource string, variable string) (string, error)
	GetCicdVariables(projectdID int) (Variables, error)
	GetCicdVariablesFromGroup(groupID int, includeProjects bool) (Variables, error)
	UpdateVariableFrom(id int, resource string, variable string, value string) (string, error)
	GetRepositoryFile(projectSlug string, fileSlug string, ref string) ([]byte, error)
}

func New

func New(baseUrl, apiPath, token string) GitlabClient

New generate a new gitlab client

func NewGitlabMock added in v0.1.2

func NewGitlabMock(baseUrl, apiPath, token string) GitlabClient

NewGitlabMock - Mocking the gitlab interactions

type Group added in v0.1.6

type Group struct {
	ID                             int         `json:"id"`
	WebURL                         string      `json:"web_url"`
	Name                           string      `json:"name"`
	Path                           string      `json:"path"`
	Description                    string      `json:"description"`
	Visibility                     string      `json:"visibility"`
	ShareWithGroupLock             bool        `json:"share_with_group_lock"`
	RequireTwoFactorAuthentication bool        `json:"require_two_factor_authentication"`
	TwoFactorGracePeriod           int         `json:"two_factor_grace_period"`
	ProjectCreationLevel           string      `json:"project_creation_level"`
	AutoDevopsEnabled              interface{} `json:"auto_devops_enabled"`
	SubgroupCreationLevel          string      `json:"subgroup_creation_level"`
	EmailsDisabled                 interface{} `json:"emails_disabled"`
	MentionsDisabled               interface{} `json:"mentions_disabled"`
	LfsEnabled                     bool        `json:"lfs_enabled"`
	DefaultBranchProtection        int         `json:"default_branch_protection"`
	AvatarURL                      interface{} `json:"avatar_url"`
	RequestAccessEnabled           bool        `json:"request_access_enabled"`
	FullName                       string      `json:"full_name"`
	FullPath                       string      `json:"full_path"`
	CreatedAt                      time.Time   `json:"created_at"`
	ParentID                       int         `json:"parent_id"`
	LdapCn                         interface{} `json:"ldap_cn"`
	LdapAccess                     interface{} `json:"ldap_access"`
	MarkedForDeletionOn            interface{} `json:"marked_for_deletion_on"`
}

func (*Group) ToGRON added in v0.1.6

func (gr *Group) ToGRON() string

func (*Group) ToJSON added in v0.1.6

func (gr *Group) ToJSON() string

ToJSON - Write the output as JSON

func (*Group) ToTEXT added in v0.1.6

func (gr *Group) ToTEXT(noHeaders bool, user string) string

func (*Group) ToYAML added in v0.1.6

func (gr *Group) ToYAML() string

type GroupList added in v0.1.6

type GroupList []Group

func (*GroupList) ToGRON added in v0.1.6

func (gr *GroupList) ToGRON() string

func (*GroupList) ToJSON added in v0.1.6

func (gr *GroupList) ToJSON() string

ToJSON - Write the output as JSON

func (*GroupList) ToTEXT added in v0.1.6

func (gr *GroupList) ToTEXT(noHeaders bool, user string) string

func (*GroupList) ToYAML added in v0.1.6

func (gr *GroupList) ToYAML() string

type Message added in v0.1.2

type Message struct {
	Message string `json:"message"`
}

type PaginationOptions

type PaginationOptions struct {
	Page    int `url:"page,omitempty"`
	PerPage int `url:"per_page,omitempty"`
}

type Pipeline added in v0.1.9

type Pipeline struct {
	ID        int       `json:"id"`
	ProjectID int       `json:"project_id"`
	Sha       string    `json:"sha"`
	Ref       string    `json:"ref"`
	Status    string    `json:"status"`
	Source    string    `json:"source"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	WebURL    string    `json:"web_url"`
}

type Pipelines added in v0.1.9

type Pipelines []Pipeline

func (*Pipelines) ToGRON added in v0.1.9

func (pl *Pipelines) ToGRON() string

func (*Pipelines) ToJSON added in v0.1.9

func (pl *Pipelines) ToJSON() string

ToJSON - Write the output as JSON

func (*Pipelines) ToTEXT added in v0.1.9

func (pl *Pipelines) ToTEXT(noHeaders bool) string

func (*Pipelines) ToYAML added in v0.1.9

func (pl *Pipelines) ToYAML() string

type Project added in v0.1.2

type Project struct {
	ID                int       `json:"id"`
	Name              string    `json:"name"`
	Description       string    `json:"description"`
	NameWithNamespace string    `json:"name_with_namespace"`
	Path              string    `json:"path"`
	PathWithNamespace string    `json:"path_with_namespace"`
	Archived          bool      `json:"archived"`
	SSHURL            string    `json:"ssh_url_to_repo"`
	HTTPURL           string    `json:"http_url_to_repo"`
	CreatedAt         time.Time `json:"created_at"`
	DefaultBranch     string    `json:"default_branch"`
	Namespace         struct {
		ID       int    `json:"id"`
		Name     string `json:"name"`
		Path     string `json:"path"`
		Kind     string `json:"kind"`
		FullPath string `json:"full_path"`
		ParentID int    `json:"parent_id"`
		WebURL   string `json:"web_url"`
	} `json:"namespace"`
	Visibility string `json:"visibility"`
	CreatorID  int    `json:"creator_id"`
	Mirror     bool   `json:"mirror"`
}

type ProjectInfo

type ProjectInfo struct {
	ID int `json:"id"`
}

type ProjectList added in v0.1.7

type ProjectList []Project

type ProjectMirror added in v0.1.2

type ProjectMirror struct {
	ID                     int         `json:"id"`
	Enabled                bool        `json:"enabled"`
	URL                    string      `json:"url"`
	UpdateStatus           string      `json:"update_status"`
	LastUpdateAt           time.Time   `json:"last_update_at"`
	LastUpdateStartedAt    time.Time   `json:"last_update_started_at"`
	LastSuccessfulUpdateAt time.Time   `json:"last_successful_update_at"`
	LastError              interface{} `json:"last_error"`
	OnlyProtectedBranches  bool        `json:"only_protected_branches"`
	KeepDivergentRefs      interface{} `json:"keep_divergent_refs"`
}

type ProjectMirrors added in v0.1.2

type ProjectMirrors []ProjectMirror

type ProtectedBranchSettings added in v0.1.2

type ProtectedBranchSettings struct {
	ID               int    `json:"id"`
	Name             string `json:"name"`
	PushAccessLevels []struct {
		AccessLevel            int         `json:"access_level"`
		AccessLevelDescription string      `json:"access_level_description"`
		UserID                 interface{} `json:"user_id"`
		GroupID                interface{} `json:"group_id"`
	} `json:"push_access_levels"`
	MergeAccessLevels []struct {
		AccessLevel            int         `json:"access_level"`
		AccessLevelDescription string      `json:"access_level_description"`
		UserID                 interface{} `json:"user_id"`
		GroupID                interface{} `json:"group_id"`
	} `json:"merge_access_levels"`
	AllowForcePush        bool `json:"allow_force_push"`
	UnprotectAccessLevels []struct {
		AccessLevel            int         `json:"access_level"`
		AccessLevelDescription string      `json:"access_level_description"`
		UserID                 interface{} `json:"user_id"`
		GroupID                interface{} `json:"group_id"`
	} `json:"unprotect_access_levels"`
	CodeOwnerApprovalRequired bool `json:"code_owner_approval_required"`
}

type RepositoryFile added in v0.1.20

type RepositoryFile struct {
	FileName        string `json:"file_name"`
	FilePath        string `json:"file_path"`
	Size            int    `json:"size"`
	Encoding        string `json:"encoding"`
	ContentSha256   string `json:"content_sha256"`
	Ref             string `json:"ref"`
	BlobID          string `json:"blob_id"`
	CommitID        string `json:"commit_id"`
	LastCommitID    string `json:"last_commit_id"`
	ExecuteFilemode bool   `json:"execute_filemode"`
	Content         string `json:"content"`
}

type RequestError added in v0.1.2

type RequestError struct {
	StatusCode int

	Err error
}

func (*RequestError) Error added in v0.1.2

func (r *RequestError) Error() string

type ResponseMeta

type ResponseMeta struct {
	Method     string
	Url        string
	StatusCode int
	RequestId  string
	Page       int
	PerPage    int
	PrevPage   int
	NextPage   int
	TotalPages int
	Total      int
	Runtime    float64
}

type ResponseWithMessage

type ResponseWithMessage struct {
	Message string `json:"message"`
}

type SortDirection

type SortDirection string
const (
	SortDirectionAsc  SortDirection = "asc"
	SortDirectionDesc SortDirection = "desc"
)

type SortOptions

type SortOptions struct {
	OrderBy string        `url:"order_by,omitempty"`
	Sort    SortDirection `url:"sort,omitempty"`
}

type Variable added in v0.1.10

type Variable struct {
	EnvironmentScope string `json:"environment_scope"`
	Key              string `json:"key"`
	Masked           bool   `json:"masked"`
	Protected        bool   `json:"protected"`
	Value            string `json:"value"`
	VariableType     string `json:"variable_type"`
	Source           string `json:"source"`
}

type Variables added in v0.1.10

type Variables []Variable

func (*Variables) ToGRON added in v0.1.10

func (v *Variables) ToGRON() string

func (*Variables) ToJSON added in v0.1.10

func (v *Variables) ToJSON() string

ToJSON - Write the output as JSON

func (*Variables) ToTEXT added in v0.1.10

func (v *Variables) ToTEXT(noHeaders bool) string

func (*Variables) ToYAML added in v0.1.10

func (v *Variables) ToYAML() string

Jump to

Keyboard shortcuts

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