UsersEndpointGroup
public class UsersEndpointGroup : EndpointGroup
This EndpointGroup communicates with Users API
-
Gets users
Declaration
Swift
public func getUsers(perPage: Int = RxGitLabAPIClient.defaultPerPage, parameters: QueryParameters? = nil) -> Paginator<User>Parameters
perPagenumber of users per page - default: 20
parametersQuery Parameters - See description Optinal Query Parameters:
Return Value
A Paginator of User
-
Get a single user.
- Query Parameters:
- Optional:
- password: String - Password
- reset_password: Bool - Send user password reset link - true or false(default)
- skype: String - Skype ID
- linkedin: String - LinkedIn
- twitter: String - Twitter account
- website_url: String - Website URL
- organization: String - Organization name
- projects_limit: Int - Number of projects user can create
- extern_uid: Int - External UID
- provider: String - External provider name
- bio: String - User’s biography
- location: String - User’s location
- public_email: String - The public email of the user
- admin: String - User is admin - true or false (default)
- can_create_group: Bool - User can create groups - true or false
- skip_confirmation: Bool - Skip confirmation - true or false (default)
- external: Bool - Flags the user as external - true or false(default)
- avatar: String - Image file for user’s avatar
- private_profile: Bool - User’s profile is private - true or false
Declaration
Swift
public func getUser(userID: Int, parameters: QueryParameters? = nil) -> Observable<User?>Parameters
parametersQuery Parameters - See description
Return Value
returns and observable of User?
- Query Parameters:
-
User creation
Creates a new user. Note only administrators can create new users. Either
passwordorreset_passwordshould be specified (reset_password takes priority). Ifreset_passwordisfalse, thenpasswordis required.Parameters
userThe user to be created
Return Value
An observable of created User
-
Modifies an existing user. Only administrators can change attributes of a user.
- Query Parameters:
- email: String - Email
- username: String - Username
- name: String - Name
- password: String - Password
- skype: String - Skype ID
- linkedin: String - LinkedIn
- twitter: String - Twitter account
- website_url: String - Website URL
- organization: String - Organization name
- projects_limit: String - Limit projects each user can create
- extern_uid: Int - External UID
- provider: String - External provider name
- bio: String - User’s biography
- location: String - User’s location
- public_email: String - The public email of the user
- admin: String - User is admin - true or false (default)
- can_create_group: Bool - User can create groups - true or false
- skip_reconfirmation: Bool - Skip reconfirmation - true or false (default)
- external: Bool - Flags the user as external - true or false(default)
- avatar: String - Image file for user’s avatar
- private_profile: String - User’s profile is private - true or false
Declaration
Swift
public func putUser(userID: Int, parameters: QueryParameters? = nil) -> Observable<User>Parameters
parametersQuery Parameters [String: Any]
Return Value
returns and observable of User?
- Query Parameters:
-
Deletes a user. Available only for administrators. This returns a
204 No Contentstatus code if the operation was successfully or404if the resource was not found.- Query Parameters:
- email: String - Email
- username: String - Username
Declaration
Swift
public func deleteUser(userID: Int, parameters: QueryParameters? = nil) -> Observable<Bool>Parameters
parametersQuery Parameters [String: Any]
Return Value
An Observable of boolean whether the deletion was successful
- Query Parameters:
-
User status
Get the status of the currently signed in user.
Declaration
Swift
public func getStatus() -> Observable<UserStatus>Return Value
An
Observableof aUserStatus -
Get the status of a user
Declaration
Swift
public func getUsersStatus(userID: Int) -> Observable<UserStatus>Parameters
userIDThe id of the user to get a status of
Return Value
An
Observableof aUserStatus -
Get the status of a user
Declaration
Swift
public func getUsersStatus(username: String) -> Observable<UserStatus>Parameters
usernameThe username of the user to get a status of
Return Value
An
Observableof aUserStatus -
Set user status
Set the status of the current user.
Declaration
Swift
public func putStatus(status: UserStatus) -> Observable<UserStatus>Parameters
statusUserStatus
Return Value
An
Observableof aUserStatus -
Delete SSH key for current user
Deletes key owned by currently authenticated user. This returns a
204 No Contentstatus code if the operation was successfully or404if the resource was not found.Declaration
Swift
public func deleteSSHKey(keyID: Int) -> Observable<Bool>Parameters
keyIDSSH key ID
Return Value
An
Observableof aBool-trueif the deletion was successful -
Delete SSH key for given user
Deletes key owned by a specified user. Available only for admin.
Declaration
Swift
public func deleteUsersSSHKey(userID: Int, keyID: Int, parameters: QueryParameters? = nil) -> Observable<Bool>Parameters
userIDid of specified user
keyIDSSH key ID
Return Value
An
Observableof aUserKey -
Delete a GPG key
Delete a GPG key owned by currently authenticated user.
Declaration
Swift
public func deleteGPGKey(keyID: Int) -> Observable<Bool>Parameters
keyIDThe ID of the GPG key
Return Value
An
Observableof aBool-trueif the deletion was successful -
Get a specific GPG key for a given user
Get a specific GPG key for a given user. Available only for admins.
Declaration
Swift
public func getGPGKeyForUser(userID: Int, keyID: Int) -> Observable<UserKey>Parameters
userIDThe ID of the user
keyIDThe ID of the GPG key
Return Value
An
Observableof aUserKey -
Add a GPG key for a given user
Create new GPG key owned by the specified user. Available only for admins.
Parameters
keyUserKey (
keyis required)userIDThe ID of the user
Return Value
An
Observableof aUserKey -
Delete a GPG key for a given user
Delete a GPG key owned by a specified user. Available only for admins.
Declaration
Swift
public func deleteUsersGPGKey(userID: Int, keyID: Int) -> Observable<Bool>Parameters
keyIDThe ID of the GPG key
userIDThe ID of the user
Return Value
An
Observableof aBool-trueif the deletion was successful -
Delete email for current user
Deletes email owned by currently authenticated user.
Declaration
Swift
public func deleteEmail(emailID: Int) -> Observable<Bool>Return Value
An
Observableof aBool-trueif the deletion was successful -
Delete email for given user
Deletes email owned by a specified user. Available only for admin.
Declaration
Swift
public func deleteUsersEmail(userID: Int, emailID: Int) -> Observable<Bool>Parameters
userIDThe ID of the user
emailIDThe ID of the email
Return Value
An
Observableof aBool-trueif the deletion was successful -
Block user
Blocks the specified user. Available only for admin.
Declaration
Swift
public func blockUser(userID: Int) -> Observable<Bool>Parameters
userIDThe ID of the user
Return Value
An
Observableof aBool-trueif blocking was successful -
Unblock user
Unlocks the specified user. Available only for admin.
Declaration
Swift
public func unBlockUser(userID: Int) -> Observable<Bool>Parameters
userIDThe ID of the user
Return Value
An
Observableof aBool-trueif unblocking was successful -
Get all impersonation tokens of a user
Requires admin permissions.
It retrieves every impersonation token of the user. Use the pagination parameters
pageandper_pageto restrict the list of impersonation tokens.Optinal Query Parameters:
state: String - filter tokens based on state (
all,active,inactive)
Declaration
Swift
public func getImpersonationTokens(userID: Int, parameters: QueryParameters?) -> Observable<[ImpersonationToken]>Parameters
userIDThe ID of the user
parametersQuery Parameters - See description
Return Value
An
Observableof a list ofImpersonationToken -
Get an impersonation token of a user
Requires admin permissions.
It shows a user’s impersonation token.
Declaration
Swift
public func getUsersImpersonationToken(userID: Int, tokenID: Int) -> Observable<[ImpersonationToken]>Parameters
userIDThe ID of the user
tokenIDThe ID of the impersonation token
Return Value
An
Observableof aUserKey -
Create an impersonation token
Requires admin permissions.
Token values are returned once. Make sure you save it - you won’t be able to access it again.
It creates a new impersonation token. Note that only administrators can do this. You are only able to create impersonation tokens to impersonate the user and perform both API calls and Git reads and writes. The user will not see these tokens in their profile settings page.
Declaration
Swift
public func postImpersonationToken(token: ImpersonationToken, userID: Int) -> Observable<ImpersonationToken>Parameters
userIDThe ID of the user
Return Value
An
Observableof aUserKey -
Revoke an impersonation token
Requires admin permissions.
It revokes an impersonation token.
Declaration
Swift
public func deleteImpersonationToken(userID: Int, tokenID: Int) -> Observable<Bool>Parameters
userIDThe ID of the user
tokenIDThe ID of the impersonation token
Return Value
An
Observableof aBool-trueif the deletion was successful -
Get user activities (admin only)
Note: This API endpoint is only available on 8.15 (EE) and 9.1 (CE) and above.
Get the last activity date for all users, sorted from oldest to newest.
The activities that update the timestamp are:
- Git HTTP/SSH activities (such as clone, push)
- User logging in into GitLab
By default, it shows the activity for all users in the last 6 months, but this can be amended by using the
fromparameter.Declaration
Swift
public func getUserActivities(from: Date? = nil) -> Observable<[Activity]>Parameters
userIDThe ID of the user
tokenIDThe ID of the impersonation token
Return Value
An
Observableof a list ofActivity
UsersEndpointGroup Class Reference