Roles.GetRoleByIdAsync
Description
Gets a role as Role with specified Role ID from the connected AI Command Center.
Signature [C#]
Task<Role> GetRoleByIdAsync(int roleId);
Properties
Input
| Parameter | Type | Required / default | Description |
|---|---|---|---|
roleId | int | Required | Specify the Role ID for which the Role information has to be retrieved. |
Output
| Type | Description |
|---|---|
| Task<Role> | Returns the information of a role using its Id. |
Remarks
Use GetRoleByIdAsync API to get the Role with specified role Id from the connected AI Command Center.
Example
C#
public async Task GetRoleById()
{
IControlRoomContext context = LoginControlRoom();
try
{
int roleId = 5;
Role role = await context.Roles.GetRoleByIdAsync(roleId);
Console.WriteLine("RoleName is " + role.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.