Documentation
¶
Index ¶
- Variables
- func CheckResponse(r *http.Response) error
- func IsEmailTakenConflict(err error) bool
- func PathEscape(s string) string
- func WithOffsetPagination(url *url.URL, nextPageToken string)
- func WithSearch(url *url.URL, search string)
- type APIError
- type AccessLevelValue
- type AddGroupMemberRequest
- type AddProjectMemberRequest
- type CreateUserOptions
- type ErrorResponse
- type GitlabClient
- func (c *GitlabClient) AddGroupMember(ctx context.Context, groupID string, memberRequest *AddGroupMemberRequest) (*GroupMember, *v2.RateLimitDescription, error)
- func (c *GitlabClient) AddProjectMember(ctx context.Context, projectID string, memberRequest *AddProjectMemberRequest) (*ProjectMember, *v2.RateLimitDescription, error)
- func (c *GitlabClient) CreateUser(ctx context.Context, userRequest *CreateUserOptions) (*User, *v2.RateLimitDescription, error)
- func (c *GitlabClient) DeleteUser(ctx context.Context, userID string) (*v2.RateLimitDescription, error)
- func (c *GitlabClient) FindGroupByName(ctx context.Context, groupName string) (*Group, *v2.RateLimitDescription, error)
- func (c *GitlabClient) GetCurrentlyAuthenticatedUser(ctx context.Context) (*User, *v2.RateLimitDescription, error)
- func (c *GitlabClient) GetGroup(ctx context.Context, groupID string) (*Group, *v2.RateLimitDescription, error)
- func (c *GitlabClient) GetGroupMemberAll(ctx context.Context, groupID, userID string) (*GroupMember, *v2.RateLimitDescription, error)
- func (c *GitlabClient) GetProject(ctx context.Context, projectID string) (*Project, *v2.RateLimitDescription, error)
- func (c *GitlabClient) GetProjectMemberAll(ctx context.Context, projectID, userID string) (*ProjectMember, *v2.RateLimitDescription, error)
- func (c *GitlabClient) InviteGroupMember(ctx context.Context, groupID string, userEmail string, ...) (*v2.RateLimitDescription, error)
- func (c *GitlabClient) ListAllGroupMembers(ctx context.Context, groupID string, nextPageToken string) ([]*GroupMember, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListAllProjectMembers(ctx context.Context, projectID string, nextPageToken string) ([]*ProjectMember, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListGroupMembers(ctx context.Context, groupID string, nextPageToken string) ([]*GroupMember, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListGroups(ctx context.Context, nextLink string) ([]*Group, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListPendingGroupInvitations(ctx context.Context, groupID string, nextPageToken string) ([]*PendingInviteUser, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListProjectMembers(ctx context.Context, projectID string, nextPageToken string) ([]*ProjectMember, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListProjects(ctx context.Context, groupID string, nextLink string) ([]*Project, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) ListUsers(ctx context.Context, nextLink string) ([]*User, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) RemoveGroupMember(ctx context.Context, groupID, userID string) (*v2.RateLimitDescription, error)
- func (c *GitlabClient) RemoveProjectMember(ctx context.Context, projectID, userID string) (*v2.RateLimitDescription, error)
- func (c *GitlabClient) SearchGroups(ctx context.Context, search string, nextPageToken string) ([]*Group, string, *v2.RateLimitDescription, error)
- func (c *GitlabClient) SearchUsers(ctx context.Context, search string, nextPageToken string) ([]*User, string, *v2.RateLimitDescription, error)
- type GitlabError
- type Group
- type GroupMember
- type ISOTime
- type InviteGroupMemberRequest
- type KeysetPaginationOpts
- type Namespace
- type PendingInviteUser
- type Project
- type ProjectMember
- type ReqOpt
- type SAMLIdentity
- type SharedGroup
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = errors.New("403 Forbidden")
var ErrNotFound = errors.New("404 Not Found")
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present.
func IsEmailTakenConflict ¶ added in v0.3.1
IsEmailTakenConflict reports whether err is GitLab's 409 response for a create-user request whose email already belongs to an existing user.
func PathEscape ¶
func WithOffsetPagination ¶
func WithSearch ¶
Types ¶
type APIError ¶ added in v0.3.1
type APIError struct {
StatusCode int
// contains filtered or unexported fields
}
APIError is returned for a request that got an HTTP error response. It keeps the status and the GitLab error body so callers can classify specific provider errors without parsing the formatted error text. Error and Unwrap are unchanged from the plain wrapped error, so status.Code still works.
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 ¶
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type GitlabClient ¶
type GitlabClient struct {
AccountCreationGroup string
IsOnPremise bool
SyncDirectMembersOnly bool
SyncAccessPaths bool
// contains filtered or unexported fields
}
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) GetGroupMemberAll ¶ added in v0.0.33
func (c *GitlabClient) GetGroupMemberAll(ctx context.Context, groupID, userID string) (*GroupMember, *v2.RateLimitDescription, error)
GetGroupMemberAll retrieves a single member of a group including inherited and invited (shared) members (GET /groups/:id/members/all/:user_id). Returns a gRPC NotFound status (not the ErrNotFound sentinel — doRequest surfaces uhttp's 4xx error before CheckResponse runs) when the user has no effective access to the group. Used to tell a direct membership apart from inherited/invited access on revoke.
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) GetProjectMemberAll ¶ added in v0.0.33
func (c *GitlabClient) GetProjectMemberAll(ctx context.Context, projectID, userID string) (*ProjectMember, *v2.RateLimitDescription, error)
GetProjectMemberAll retrieves a single member of a project including inherited and invited (shared) members (GET /projects/:id/members/all/:user_id). Returns a gRPC NotFound status (not the ErrNotFound sentinel — doRequest surfaces uhttp's 4xx error before CheckResponse runs) when the user has no effective access to the project. Used to tell a direct membership apart from inherited/invited access on revoke.
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.
func (*GitlabClient) SearchUsers ¶ added in v0.3.1
func (c *GitlabClient) SearchUsers(ctx context.Context, search string, nextPageToken string) ([]*User, string, *v2.RateLimitDescription, error)
SearchUsers lists users matching search (GET /users?search=), one page at a time. For administrators GitLab also matches exact primary and secondary emails, so callers must verify the returned email themselves.
type GitlabError ¶ added in v0.0.25
type GitlabError struct {
Detail json.RawMessage `json:"message"`
}
GitlabError is the body of a GitLab error response. Its "message" is a string for most errors and an object of field errors for validation failures, such as {"access_level":["should be greater than or equal to ..."]}.
func (*GitlabError) Message ¶ added in v0.0.25
func (e *GitlabError) Message() string
Message implements the uhttp.ErrorResponse interface.
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 InviteGroupMemberRequest ¶
type InviteGroupMemberRequest struct {
Email string `json:"email"`
AccessLevel AccessLevelValue `json:"access_level"`
}
type KeysetPaginationOpts ¶ added in v0.0.28
type PendingInviteUser ¶
type PendingInviteUser struct {
InviteEmail string `json:"invite_email"`
}
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
func WithQueryParam ¶ added in v0.0.29
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 SharedGroup ¶ added in v0.0.33
type SharedGroup struct {
}
SharedGroup is a group invited (shared) into another group or project. GitLab reports it under shared_with_groups on the group/project object. GroupAccessLevel is the ceiling access the invited group's members receive on the target.
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"`
Bot bool `json:"bot"`
}