Table of Contents

Class OpenBiApiClientUserExtensions

Namespace
BiExcellence.OpenBi.Api.Users
Assembly
BiExcellence.OpenBi.Api.Client.dll

Extension methods for the /users REST API.

public static class OpenBiApiClientUserExtensions
Inheritance
object
OpenBiApiClientUserExtensions

Methods

AssignUserOrganisationAsync(IOpenBiApiClient, string, string, CancellationToken)

Adds this user to an organisation. Idempotent. Throws OpenBiApiException (404) when the user or the organisation does not exist. RemoveUserOrganisationAsync(IOpenBiApiClient, string, string, CancellationToken) undoes it.

public static Task AssignUserOrganisationAsync(this IOpenBiApiClient client, string userId, string organisationId, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
organisationId string
cancellationToken CancellationToken

Returns

Task

AssignUserRoleAsync(IOpenBiApiClient, string, string, RoleAssignmentRequest?, CancellationToken)

Assigns a role to this user. The optional assignment sets the link's validity and edit/delete rights; without one, or for a date it leaves unset, the link is valid from now for 30 days and allows neither editing nor deleting. Assigning again replaces those fields. Throws OpenBiApiException (404) when the user or the role does not exist. RemoveUserRoleAsync(IOpenBiApiClient, string, string, CancellationToken) undoes it.

public static Task AssignUserRoleAsync(this IOpenBiApiClient client, string userId, string roleId, RoleAssignmentRequest? assignment = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
roleId string
assignment RoleAssignmentRequest
cancellationToken CancellationToken

Returns

Task

AssignUserUsergroupAsync(IOpenBiApiClient, string, string, CancellationToken)

Adds this user to a usergroup. Idempotent. Throws OpenBiApiException (404) when the user or the usergroup does not exist. RemoveUserUsergroupAsync(IOpenBiApiClient, string, string, CancellationToken) undoes it.

public static Task AssignUserUsergroupAsync(this IOpenBiApiClient client, string userId, string usergroupId, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
usergroupId string
cancellationToken CancellationToken

Returns

Task

ChangeUserPasswordAsync(IOpenBiApiClient, string, string?, string, CancellationToken)

Self-service operation: changes a user's own password, authorized by presenting their current password rather than requiring an authenticated client (so this also serves a "forgot password" recovery flow). Clears InitialPassword. The new password has to meet the server's password policy. Throws OpenBiApiException (400) when either password is empty or the new one breaks the policy - the message then names the rule - and (401) when the current one does not match.

public static Task ChangeUserPasswordAsync(this IOpenBiApiClient client, string id, string? oldPassword, string newPassword, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
id string
oldPassword string
newPassword string
cancellationToken CancellationToken

Returns

Task

CreateUserAsync(IOpenBiApiClient, User, CancellationToken)

Creates a user. Id - the username - is required; an empty one is refused with a 400. A new user has no password until SetUserPasswordAsync(IOpenBiApiClient, string, string, CancellationToken) sets one, and no usergroup, organisation or role until one is assigned - so once logged in it sees nothing.

public static Task<User?> CreateUserAsync(this IOpenBiApiClient client, User user, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
user User
cancellationToken CancellationToken

Returns

Task<User>

DeleteUserAsync(IOpenBiApiClient, string, CancellationToken)

Deletes a user together with its usergroup, organisation and role assignments, its auth values, its API keys and its access tokens; other users that name it as Superior lose that reference.

public static Task DeleteUserAsync(this IOpenBiApiClient client, string id, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
id string
cancellationToken CancellationToken

Returns

Task

GetUserAsync(IOpenBiApiClient, string, CancellationToken)

Reads one user by username. Throws OpenBiApiException (404) when there is no user with this id. Needs openbi.user.read; a caller that only wants to know about itself uses GetCurrentUserInfoAsync(IOpenBiApiClient, CancellationToken) instead.

public static Task<User> GetUserAsync(this IOpenBiApiClient client, string id, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
id string
cancellationToken CancellationToken

Returns

Task<User>

GetUserOrganisationsAsync(IOpenBiApiClient, string, OpenBiListRequest?, CancellationToken)

Lists the organisations this user belongs to, which scope what data it sees.

public static Task<OpenBiListResult<Organisation>> GetUserOrganisationsAsync(this IOpenBiApiClient client, string userId, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
request OpenBiListRequest
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<Organisation>>

GetUserRolesAsync(IOpenBiApiClient, string, OpenBiListRequest?, CancellationToken)

Lists the roles assigned to this user directly - not those it gets through a usergroup or an organisation.

public static Task<OpenBiListResult<Role>> GetUserRolesAsync(this IOpenBiApiClient client, string userId, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
request OpenBiListRequest
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<Role>>

GetUserUsergroupsAsync(IOpenBiApiClient, string, OpenBiListRequest?, CancellationToken)

Lists the usergroups this user belongs to - the same link that GetUsergroupUsersAsync(IOpenBiApiClient, string, OpenBiListRequest?, CancellationToken) reads from the other side. Only the direct assignments - the ones RemoveUserUsergroupAsync(IOpenBiApiClient, string, string, CancellationToken) can take away.

public static Task<OpenBiListResult<Usergroup>> GetUserUsergroupsAsync(this IOpenBiApiClient client, string userId, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
request OpenBiListRequest
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<Usergroup>>

GetUserUsergroupsAsync(IOpenBiApiClient, string, bool, OpenBiListRequest?, CancellationToken)

Lists the usergroups this user belongs to, with inherited also those it is in through one of its organisations, each marked with Inherited - the ones RemoveUserUsergroupAsync(IOpenBiApiClient, string, string, CancellationToken) cannot take away.

public static Task<OpenBiListResult<Usergroup>> GetUserUsergroupsAsync(this IOpenBiApiClient client, string userId, bool inherited, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
inherited bool
request OpenBiListRequest
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<Usergroup>>

GetUsersAsync(IOpenBiApiClient, OpenBiListRequest?, CancellationToken)

Lists users, with the shared list options of request. A user's rights come from the usergroups it belongs to, the data it sees from its organisations and the content it may open from its roles.

public static Task<OpenBiListResult<User>> GetUsersAsync(this IOpenBiApiClient client, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
request OpenBiListRequest
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<User>>

QueryUsersAsync(IOpenBiApiClient, OpenBiListRequest?, CancellationToken)

Lists users with the options in the request body instead of in the query string - the QUERY-method form of the list route, for filters that do not fit in a URL.

public static Task<OpenBiListResult<User>> QueryUsersAsync(this IOpenBiApiClient client, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
request OpenBiListRequest
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<User>>

RemoveUserOrganisationAsync(IOpenBiApiClient, string, string, CancellationToken)

Removes this user from an organisation. Removes the link only; neither the user nor the organisation is deleted. Removing a link that is not there is not an error.

public static Task RemoveUserOrganisationAsync(this IOpenBiApiClient client, string userId, string organisationId, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
organisationId string
cancellationToken CancellationToken

Returns

Task

RemoveUserRoleAsync(IOpenBiApiClient, string, string, CancellationToken)

Removes a role from this user. Removes the link only; neither the user nor the role is deleted. Removing a link that is not there is not an error.

public static Task RemoveUserRoleAsync(this IOpenBiApiClient client, string userId, string roleId, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
roleId string
cancellationToken CancellationToken

Returns

Task

RemoveUserUsergroupAsync(IOpenBiApiClient, string, string, CancellationToken)

Removes this user from a usergroup. Removes the link only; neither the user nor the usergroup is deleted. Removing a link that is not there is not an error.

public static Task RemoveUserUsergroupAsync(this IOpenBiApiClient client, string userId, string usergroupId, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
userId string
usergroupId string
cancellationToken CancellationToken

Returns

Task

SetUserPasswordAsync(IOpenBiApiClient, string, string, CancellationToken)

Admin operation: sets (or resets) a user's password and marks it as requiring change at next login (InitialPassword). Needs openbi.user.write. The password has to meet the server's password policy. Throws OpenBiApiException (400) when the password is empty or breaks the policy - the message then names the rule - and (404) when there is no such user. A user changing its own password uses ChangeUserPasswordAsync(IOpenBiApiClient, string, string?, string, CancellationToken).

public static Task SetUserPasswordAsync(this IOpenBiApiClient client, string id, string password, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
id string
password string
cancellationToken CancellationToken

Returns

Task

UpdateUserAsync(IOpenBiApiClient, string, User, CancellationToken)

Creates or updates the user with this username: an id that is not there yet is inserted rather than answered with a 404. The password is not touched.

public static Task<User?> UpdateUserAsync(this IOpenBiApiClient client, string id, User user, CancellationToken cancellationToken = default)

Parameters

client IOpenBiApiClient
id string
user User
cancellationToken CancellationToken

Returns

Task<User>