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
perPage
number of users per page - default: 20
parameters
Query 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
parameters
Query 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
password
orreset_password
should be specified (reset_password takes priority). Ifreset_password
isfalse
, thenpassword
is required.Parameters
user
The 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
parameters
Query Parameters [String: Any]
Return Value
returns and observable of User?
- Query Parameters:
-
Deletes a user. Available only for administrators. This returns a
204 No Content
status code if the operation was successfully or404
if 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
parameters
Query 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
Observable
of aUserStatus
-
Get the status of a user
Declaration
Swift
public func getUsersStatus(userID: Int) -> Observable<UserStatus>
Parameters
userID
The id of the user to get a status of
Return Value
An
Observable
of aUserStatus
-
Get the status of a user
Declaration
Swift
public func getUsersStatus(username: String) -> Observable<UserStatus>
Parameters
username
The username of the user to get a status of
Return Value
An
Observable
of aUserStatus
-
Set user status
Set the status of the current user.
Declaration
Swift
public func putStatus(status: UserStatus) -> Observable<UserStatus>
Parameters
status
UserStatus
Return Value
An
Observable
of aUserStatus
-
Delete SSH key for current user
Deletes key owned by currently authenticated user. This returns a
204 No Content
status code if the operation was successfully or404
if the resource was not found.Declaration
Swift
public func deleteSSHKey(keyID: Int) -> Observable<Bool>
Parameters
keyID
SSH key ID
Return Value
An
Observable
of aBool
-true
if 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
userID
id of specified user
keyID
SSH key ID
Return Value
An
Observable
of aUserKey
-
Delete a GPG key
Delete a GPG key owned by currently authenticated user.
Declaration
Swift
public func deleteGPGKey(keyID: Int) -> Observable<Bool>
Parameters
keyID
The ID of the GPG key
Return Value
An
Observable
of aBool
-true
if 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
userID
The ID of the user
keyID
The ID of the GPG key
Return Value
An
Observable
of aUserKey
-
Add a GPG key for a given user
Create new GPG key owned by the specified user. Available only for admins.
Parameters
key
UserKey (
key
is required)userID
The ID of the user
Return Value
An
Observable
of 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
keyID
The ID of the GPG key
userID
The ID of the user
Return Value
An
Observable
of aBool
-true
if 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
Observable
of aBool
-true
if 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
userID
The ID of the user
emailID
The ID of the email
Return Value
An
Observable
of aBool
-true
if the deletion was successful -
Block user
Blocks the specified user. Available only for admin.
Declaration
Swift
public func blockUser(userID: Int) -> Observable<Bool>
Parameters
userID
The ID of the user
Return Value
An
Observable
of aBool
-true
if blocking was successful -
Unblock user
Unlocks the specified user. Available only for admin.
Declaration
Swift
public func unBlockUser(userID: Int) -> Observable<Bool>
Parameters
userID
The ID of the user
Return Value
An
Observable
of aBool
-true
if 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
page
andper_page
to 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
userID
The ID of the user
parameters
Query Parameters - See description
Return Value
An
Observable
of 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
userID
The ID of the user
tokenID
The ID of the impersonation token
Return Value
An
Observable
of 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
userID
The ID of the user
Return Value
An
Observable
of 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
userID
The ID of the user
tokenID
The ID of the impersonation token
Return Value
An
Observable
of aBool
-true
if 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
from
parameter.Declaration
Swift
public func getUserActivities(from: Date? = nil) -> Observable<[Activity]>
Parameters
userID
The ID of the user
tokenID
The ID of the impersonation token
Return Value
An
Observable
of a list ofActivity