Skip to main content
Version: Current

Users.GetRolesAsync

Description​

The API gets the assigned list of roles for the specified user Id from the connected AI Command Center.

Signature [C#]​

Task<List<RoleInfo>> GetRolesAsync(int userId);

Properties​

Input​

ParameterTypeRequired / defaultDescription
userIdintRequiredSpecify the user Id to retrieve the role information.

Output​

PropertyDescription
Task<List<RoleInfo>>Returns assigned roles information of a specified user.

Remarks​

Use GetRolesAsync API to get the list of all assigned roles for specified user Id from the connected AI Command Center.

Example​

C#
public async Task GetRoles()
{
IControlRoomContext context = LoginControlRoom();
try
{
int userId = 1;
var roles = await context.Users.GetRolesAsync(userId);
foreach (RoleInfo roleInfo in roles)
Console.WriteLine("Role Name: " + roleInfo.RoleName);
}
finally
{
context.Close();
}
}
Connection helper
public IControlRoomContext LoginControlRoom()
{
string RequiredSetting(string name) => Environment.GetEnvironmentVariable(name) ?? throw new InvalidOperationException($"Set {name} before running this example.");
string serverUrl = RequiredSetting("INTELLIBUDDIES_SERVER_URL");
string userName = RequiredSetting("INTELLIBUDDIES_USERNAME");
string password = RequiredSetting("INTELLIBUDDIES_PASSWORD");
string connectionString = $"ServerUrl={serverUrl};UserName={userName};Password={password}";
IControlRoomContext context = new ControlRoomContext(connectionString);
context.Open();
return context;
}

See Get started for namespaces, configuration, and context cleanup, and SDK usage for error handling.