client

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = errors.New("403 Forbidden")
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

	SyncDirectMembersOnly bool
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, accessToken, baseURL, accountCreationGroup string, syncDirectMembersOnly bool) (*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) GetCurrentlyAuthenticatedUser added in v0.0.26

func (c *GitlabClient) GetCurrentlyAuthenticatedUser(ctx context.Context) (*User, *v2.RateLimitDescription, error)

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) ListAllGroupMembers added in v0.0.26

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

ListAllGroupMembers retrieves members and pending invites of a specific group including inherited members through ancestor groups.

func (*GitlabClient) ListAllProjectMembers added in v0.0.29

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

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, nextLink string) ([]*Group, string, *v2.RateLimitDescription, error)

ListGroups retrieves all groups from GitLab API using keyset pagination.

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, nextLink string) ([]*Project, string, *v2.RateLimitDescription, error)

ListProjects retrieves all projects from GitLab API.

func (*GitlabClient) ListUsers

func (c *GitlabClient) ListUsers(ctx context.Context, nextLink 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 GitlabError added in v0.0.25

type GitlabError struct {
	Detail string `json:"message"`
}

func (*GitlabError) Message added in v0.0.25

func (e *GitlabError) Message() string

Message implements the uhttp.ErrorResponse interface.

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"`
	Archived          bool     `json:"archived"`
	Visibility        string   `json:"visibility"`
	MarkedForDeletion *ISOTime `json:"marked_for_deletion"`
}

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"`
	MembershipState   string        `json:"membership_state"`
	Locked            bool          `json:"locked"`
}

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 KeysetPaginationOpts added in v0.0.28

type KeysetPaginationOpts struct {
	OrderBy string
	Sort    string
}

type Namespace added in v0.0.29

type 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"`
}

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"`
	Namespace         *Namespace `json:"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 ReqOpt added in v0.0.29

type ReqOpt func(reqURL *url.URL)

func WithQueryParam added in v0.0.29

func WithQueryParam(key string, value string) ReqOpt

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"`
	MembershipState string   `json:"membership_state"`
	Locked          bool     `json:"locked"`
}

Jump to

Keyboard shortcuts

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