client

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("404 Not Found")

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

func PathEscape

func PathEscape(s string) string

func WithOffsetPagination

func WithOffsetPagination(url *url.URL, nextPageToken string)

func WithSearch

func WithSearch(url *url.URL, search string)

Types

type AccessLevelValue

type AccessLevelValue int
const (
	NoPermissions            AccessLevelValue = 0
	MinimalAccessPermissions AccessLevelValue = 5
	GuestPermissions         AccessLevelValue = 10
	ReporterPermissions      AccessLevelValue = 20
	DeveloperPermissions     AccessLevelValue = 30
	MaintainerPermissions    AccessLevelValue = 40
	OwnerPermissions         AccessLevelValue = 50
	AdminPermissions         AccessLevelValue = 60
)

func GetAccessLevelByName

func GetAccessLevelByName(name string) (AccessLevelValue, bool)

func (AccessLevelValue) String

func (a AccessLevelValue) String() string

type AddGroupMemberRequest

type AddGroupMemberRequest struct {
	UserID      int              `json:"user_id"`
	AccessLevel AccessLevelValue `json:"access_level"`
}

type AddProjectMemberRequest

type AddProjectMemberRequest struct {
	UserID      int              `json:"user_id"`
	AccessLevel AccessLevelValue `json:"access_level"`
}

type CreateUserOptions

type CreateUserOptions struct {
	Email               *string `url:"email,omitempty" json:"email,omitempty"`
	ForceRandomPassword *bool   `url:"force_random_password,omitempty" json:"force_random_password,omitempty"`
	GroupIDForSAML      *string `url:"group_id_for_saml,omitempty" json:"group_id_for_saml,omitempty"`
	Name                *string `url:"name,omitempty" json:"name,omitempty"`
	Password            *string `url:"password,omitempty" json:"password,omitempty"`
	Username            *string `url:"username,omitempty" json:"username,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Body     []byte
	Response *http.Response
	Message  string
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type GitlabClient

type GitlabClient struct {
	AccountCreationGroup string
	IsOnPremise          bool
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, accessToken, baseURL, accountCreationGroup string) (*GitlabClient, error)

func (*GitlabClient) AddGroupMember

func (c *GitlabClient) AddGroupMember(ctx context.Context, groupID string, memberRequest *AddGroupMemberRequest) (*GroupMember, *v2.RateLimitDescription, error)

AddGroupMember adds a member to a group.

func (*GitlabClient) AddProjectMember

func (c *GitlabClient) AddProjectMember(ctx context.Context, projectID string, memberRequest *AddProjectMemberRequest) (*ProjectMember, *v2.RateLimitDescription, error)

AddProjectMember adds a member to a project.

func (*GitlabClient) CreateUser

func (c *GitlabClient) CreateUser(ctx context.Context, userRequest *CreateUserOptions) (*User, *v2.RateLimitDescription, error)

CreateUser creates a new user in GitLab.

func (*GitlabClient) DeleteUser

func (c *GitlabClient) DeleteUser(ctx context.Context, userID string) (*v2.RateLimitDescription, error)

DeleteUser deletes a user from GitLab.

func (*GitlabClient) FindGroupByName

func (c *GitlabClient) FindGroupByName(ctx context.Context, groupName string) (*Group, *v2.RateLimitDescription, error)

FindGroupByName searches for groups across all pages and then filters for an exact match.

func (*GitlabClient) GetGroup

func (c *GitlabClient) GetGroup(ctx context.Context, groupID string) (*Group, *v2.RateLimitDescription, error)

GetGroup retrieves a specific group by ID.

func (*GitlabClient) GetProject

func (c *GitlabClient) GetProject(ctx context.Context, projectID string) (*Project, *v2.RateLimitDescription, error)

GetProject retrieves a specific project by ID.

func (*GitlabClient) InviteGroupMember

func (c *GitlabClient) InviteGroupMember(ctx context.Context, groupID string, userEmail string, accessLevel AccessLevelValue) (*v2.RateLimitDescription, error)

InviteGroupMember invites a member to a group.

func (*GitlabClient) ListGroupMembers

func (c *GitlabClient) ListGroupMembers(ctx context.Context, groupID string, nextPageToken string) ([]*GroupMember, string, *v2.RateLimitDescription, error)

ListGroupMembers retrieves members of a specific group.

func (*GitlabClient) ListGroups

func (c *GitlabClient) ListGroups(ctx context.Context, nextPageToken string) ([]*Group, string, *v2.RateLimitDescription, error)

ListGroups retrieves all groups from GitLab API.

func (*GitlabClient) ListPendingGroupInvitations

func (c *GitlabClient) ListPendingGroupInvitations(ctx context.Context, groupID string, nextPageToken string) ([]*PendingInviteUser, string, *v2.RateLimitDescription, error)

ListPendingGroupInvitations lists pending invitations for a group.

func (*GitlabClient) ListProjectMembers

func (c *GitlabClient) ListProjectMembers(ctx context.Context, projectID string, nextPageToken string) ([]*ProjectMember, string, *v2.RateLimitDescription, error)

ListProjectMembers retrieves members of a specific project.

func (*GitlabClient) ListProjects

func (c *GitlabClient) ListProjects(ctx context.Context, groupID string, nextPageToken string) ([]*Project, string, *v2.RateLimitDescription, error)

ListProjects retrieves all projects from GitLab API.

func (*GitlabClient) ListUsers

func (c *GitlabClient) ListUsers(ctx context.Context, nextPageToken string) ([]*User, string, *v2.RateLimitDescription, error)

ListUsers retrieves all users from GitLab API.

func (*GitlabClient) RemoveGroupMember

func (c *GitlabClient) RemoveGroupMember(ctx context.Context, groupID, userID string) (*v2.RateLimitDescription, error)

RemoveGroupMember removes a member from a group.

func (*GitlabClient) RemoveProjectMember

func (c *GitlabClient) RemoveProjectMember(ctx context.Context, projectID, userID string) (*v2.RateLimitDescription, error)

RemoveProjectMember removes a member from a project.

func (*GitlabClient) SearchGroups

func (c *GitlabClient) SearchGroups(ctx context.Context, search string, nextPageToken string) ([]*Group, string, *v2.RateLimitDescription, error)

SearchGroups searches for groups by name.

type Group

type Group struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	FullName    string `json:"full_name"`
	ParentID    int    `json:"parent_id"`
}

type GroupMember

type GroupMember struct {
	ID                int           `json:"id"`
	Email             string        `json:"email"`
	Username          string        `json:"username"`
	Name              string        `json:"name"`
	State             string        `json:"state"`
	AccessLevel       int           `json:"access_level"`
	GroupSAMLIdentity *SAMLIdentity `json:"group_saml_identity"`
}

type ISOTime

type ISOTime time.Time

func (*ISOTime) EncodeValues

func (t *ISOTime) EncodeValues(key string, v *url.Values) error

func (*ISOTime) MarshalJSON

func (t *ISOTime) MarshalJSON() ([]byte, error)

func (*ISOTime) String

func (t *ISOTime) String() string

func (*ISOTime) UnmarshalJSON

func (t *ISOTime) UnmarshalJSON(data []byte) error

type InviteGroupMemberRequest

type InviteGroupMemberRequest struct {
	Email       string           `json:"email"`
	AccessLevel AccessLevelValue `json:"access_level"`
}

type PendingInviteUser

type PendingInviteUser struct {
	InviteEmail string `json:"invite_email"`
}

type Project

type Project struct {
	ID                int    `json:"id"`
	Name              string `json:"name"`
	Description       string `json:"description"`
	NameWithNamespace string `json:"name_with_namespace"`
}

type ProjectMember

type ProjectMember struct {
	ID                int           `json:"id"`
	Username          string        `json:"username"`
	Name              string        `json:"name"`
	State             string        `json:"state"`
	AvatarURL         string        `json:"avatar_url"`
	WebURL            string        `json:"web_url"`
	AccessLevel       int           `json:"access_level"`
	ExpiresAt         *ISOTime      `json:"expires_at"`
	GroupSAMLIdentity *SAMLIdentity `json:"group_saml_identity"`
	Email             string        `json:"email"`
}

type SAMLIdentity

type SAMLIdentity struct {
	ExternUID      string `json:"extern_uid"`
	Provider       string `json:"provider"`
	SAMLProviderID int    `json:"saml_provider_id"`
}

SAMLIdentity represents SAML identity information.

type User

type User struct {
	ID             int      `json:"id"`
	Email          string   `json:"email"`
	Username       string   `json:"username"`
	Name           string   `json:"name"`
	State          string   `json:"state"`
	LastActivityOn *ISOTime `json:"last_activity_on"`
}

Jump to

Keyboard shortcuts

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