Interface IRoleService
Roles data access interface.
Namespace: Microsoft.GNS.Roster.Service
Assembly: Microsoft.GNS.Roster.Service.dll
Syntax
public interface IRoleService
Methods
View SourceCreateRoleAsync(String, String, Scope, IEnumerable<IRosterPrincipal>, Nullable<IEnumerable<IRosterPrincipal>>)
Creates a security role.
Declaration
Task<IRosterRole> CreateRoleAsync(string name, string description, Scope scope, IEnumerable<IRosterPrincipal> admins, IEnumerable<IRosterPrincipal>? members = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the role. |
System.String | description | The description of the role. |
Scope | scope | The role's scope. |
IEnumerable<IRosterPrincipal> | admins | An enumerable list of users who will be administrators of the role. |
System.Nullable<IEnumerable<IRosterPrincipal>> | members | An enumerable list of users who will be members of the role. |
Returns
Type | Description |
---|---|
Task<IRosterRole> | An object representing the Roster role. |
DeleteRoleAsync(IRosterRole)
Deletes a role.
Declaration
Task DeleteRoleAsync(IRosterRole role)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | The role to delete. |
Returns
Type | Description |
---|---|
Task | A task representing the work to delete the role. |
GetAllRolesAsync(Scope)
Gets all roles the current user has access to.
Declaration
IAsyncEnumerable<IRosterRole> GetAllRolesAsync(Scope scope)
Parameters
Type | Name | Description |
---|---|---|
Scope | scope | The scope in which to get all roles. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IRosterRole> | An enumeration of Roster roles. |
GetRoleByIdAsync(Guid, AccessLevel, Boolean)
Gets a specific Roster role by Id.
Declaration
Task<IRosterRole> GetRoleByIdAsync(Guid id, AccessLevel accessLevel = AccessLevel.Admin, bool throwIfNotFound = false)
Parameters
Type | Name | Description |
---|---|---|
Guid | id | The Id of the role to get. |
AccessLevel | accessLevel | The level of access for the current user in which to check for. |
System.Boolean | throwIfNotFound | If true throws an EntityNotFoundException if the role does not exist. If false will return |
Returns
Type | Description |
---|---|
Task<IRosterRole> | The role as an |
GetRoleByNameAsync(String, Scope, AccessLevel, Boolean)
Gets a specific Roster role by name.
Declaration
Task<IRosterRole> GetRoleByNameAsync(string name, Scope scope, AccessLevel accessLevel = AccessLevel.Admin, bool throwIfNotFound = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the role to get. |
Scope | scope | The role's scope. |
AccessLevel | accessLevel | The level of access for the current user in which to check for. |
System.Boolean | throwIfNotFound | If true throws an EntityNotFoundException if the role does not exist. If false will return |
Returns
Type | Description |
---|---|
Task<IRosterRole> | The role as an |
GetRoleMembershipsAsync(IRosterRole)
Enumerates all roles that the provided role is in.
Declaration
IAsyncEnumerable<IRosterRole> GetRoleMembershipsAsync(IRosterRole role)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | The role in which to look for memberships. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IRosterRole> | An enumerable list of roles. |
IsRoleAdminAsync(IRosterRole, IRosterPrincipal)
Checks if a principal is an admin of the role.
Declaration
Task<bool> IsRoleAdminAsync(IRosterRole role, IRosterPrincipal principal)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | The |
IRosterPrincipal | principal | The principal in which to check membership. |
Returns
Type | Description |
---|---|
Task<System.Boolean> | True if the principal is an admin. Otherwise, false. |
IsRoleMemberAsync(IRosterRole, IRosterPrincipal)
Checks if a principal can be found in this role.
Declaration
Task<bool> IsRoleMemberAsync(IRosterRole role, IRosterPrincipal principal)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | The |
IRosterPrincipal | principal | The principal in which to check membership. |
Returns
Type | Description |
---|---|
Task<System.Boolean> | True if the principal is the role. Otherwise, false. |
SearchRolesByNameAsync(String, Scope, Boolean, Int32)
Searches roles by name.
Declaration
IAsyncEnumerable<IRosterRole> SearchRolesByNameAsync(string name, Scope scope, bool caseSensitive = false, int take = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name to search for. |
Scope | scope | The Roster scope. |
System.Boolean | caseSensitive | True for a case sensitive search. Otherwise, false. |
System.Int32 | take | The number of items to take. Default of 0 returns all results. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IRosterRole> | An enumerable list of Roster roles. |
SetRoleAdminsAsync(IRosterRole, Nullable<IEnumerable<IRosterPrincipal>>, Nullable<IEnumerable<IRosterPrincipal>>)
Adds and/or removes principals as admins in a role.
Declaration
Task SetRoleAdminsAsync(IRosterRole role, IEnumerable<IRosterPrincipal>? principalsToAdd = null, IEnumerable<IRosterPrincipal>? principalsToRemove = null)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | The role in which to modify principals. |
System.Nullable<IEnumerable<IRosterPrincipal>> | principalsToAdd | An optional enumerable list of principals to add. |
System.Nullable<IEnumerable<IRosterPrincipal>> | principalsToRemove | An optional enumerable list of principals to remove. |
Returns
Type | Description |
---|---|
Task | A task representing the work to set role admins. |
SetRoleMembersAsync(IRosterRole, Nullable<IEnumerable<IRosterPrincipal>>, Nullable<IEnumerable<IRosterPrincipal>>)
Adds and/or removes principals as members in a role.
Declaration
Task SetRoleMembersAsync(IRosterRole role, IEnumerable<IRosterPrincipal>? principalsToAdd = null, IEnumerable<IRosterPrincipal>? principalsToRemove = null)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | The role in which to modify principals. |
System.Nullable<IEnumerable<IRosterPrincipal>> | principalsToAdd | An optional enumerable list of principals to add. |
System.Nullable<IEnumerable<IRosterPrincipal>> | principalsToRemove | An optional enumerable list of principals to remove. |
Returns
Type | Description |
---|---|
Task | A task representing the work to set role principals. |
UpdateRoleAsync(IRosterRole)
Updates a security role.
Declaration
Task<IRosterRole> UpdateRoleAsync(IRosterRole role)
Parameters
Type | Name | Description |
---|---|---|
IRosterRole | role | Role's original name used to lookup role to update. |
Returns
Type | Description |
---|---|
Task<IRosterRole> | An object representing the Roster role. |