Show / Hide Table of Contents

Interface IRoleService

Roles data access interface.

Namespace: Microsoft.GNS.Roster.Service
Assembly: Microsoft.GNS.Roster.Service.dll
Syntax
public interface IRoleService

Methods

View Source

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.

View Source

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.

View Source

GetRoleByIdAsync(Guid, AccessLevel, bool)

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.

bool throwIfNotFound

If true throws an EntityNotFoundException if the role does not exist. If false will return Microsoft.GNS.Roster.Internal.RosterRole.Empty.

Returns
Type Description
Task<IRosterRole>

The role as an IRosterRole.

View Source

GetRoleByNameAsync(string, Scope, AccessLevel, bool)

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
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.

bool throwIfNotFound

If true throws an EntityNotFoundException if the role does not exist. If false will return Microsoft.GNS.Roster.Internal.RosterRole.Empty.

Returns
Type Description
Task<IRosterRole>

The role as an IRosterRole.

View Source

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.

View Source

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 IRosterRole in which to determine admin membership.

IRosterPrincipal principal

The principal in which to check membership.

Returns
Type Description
Task<bool>

True if the principal is an admin. Otherwise, false.

View Source

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 IRosterRole in which to determine membership.

IRosterPrincipal principal

The principal in which to check membership.

Returns
Type Description
Task<bool>

True if the principal is the role. Otherwise, false.

View Source

SearchRolesByNameAsync(string, Scope, bool, int)

Searches roles by name.

Declaration
IAsyncEnumerable<IRosterRole> SearchRolesByNameAsync(string name, Scope scope, bool caseSensitive = false, int take = 0)
Parameters
Type Name Description
string name

The name to search for.

Scope scope

The Roster scope.

bool caseSensitive

True for a case sensitive search. Otherwise, false.

int take

The number of items to take. Default of 0 returns all results.

Returns
Type Description
IAsyncEnumerable<IRosterRole>

An enumerable list of Roster roles.

View Source

SetRoleAdminsAsync(IRosterRole, IEnumerable<IRosterPrincipal>?, 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.

IEnumerable<IRosterPrincipal> principalsToAdd

An optional enumerable list of principals to add.

IEnumerable<IRosterPrincipal> principalsToRemove

An optional enumerable list of principals to remove.

Returns
Type Description
Task

A task representing the work to set role admins.

View Source

SetRoleMembersAsync(IRosterRole, IEnumerable<IRosterPrincipal>?, 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.

IEnumerable<IRosterPrincipal> principalsToAdd

An optional enumerable list of principals to add.

IEnumerable<IRosterPrincipal> principalsToRemove

An optional enumerable list of principals to remove.

Returns
Type Description
Task

A task representing the work to set role principals.

View Source

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.

  • View Source
In this article
Back to top Generated by DocFX