Reading Roles

Reading Roles

As with data operations, you can retrieve information about a single role as well as several or all roles using a single call. Requesting all roles returns an array of role objects.

Reading a Single Role

You need the role ID to read information about a role:

public async Task<Role> GetRoleByIdAsync(Guid applicationId, Guid roleId, string masterKey)
{
    var metadata = new EverliveAccount(new EverliveAccountSettings(AuthorizationStrategy.MasterKey, masterKey));
    var role = await metadata.WorkWith().Application(applicationId).Roles().GetById(roleId).ExecuteAsync();
    return role;
}

This request returns a single role object:

{
    "Result": {
        "Name": "Premium",
        "CreatedAt": "2015-07-06T11:19:04.385Z",
        "ModifiedAt": "2015-07-06T11:19:04.385Z",
        "Id": "cf5d8310-23d0-11e5-9c49-2740f827794e"
    }
}

Reading All Roles

The following request returns information about all roles in the application. Any filtering, sorting, or paging parameters can be passed to the request. See Introduction to Querying for details.

public async Task<IEnumerable<Role>> GetRolesAsync(Guid applicationId, string masterKey)
{
    var metadata = new EverliveAccount(new EverliveAccountSettings(AuthorizationStrategy.MasterKey, masterKey));
    var roles = await metadata.WorkWith().Application(applicationId).Roles().GetAll().ExecuteAsync();
    return roles;
}

This request returns an array of role objects:

{
    "Count": 2,
    "Result": [
        {
            "Name": "Registered",
            "CreatedAt": "2015-05-11T09:33:22.776Z",
            "ModifiedAt": "2015-05-11T09:33:22.776Z",
            "Id": "c42a8560-f7c0-11e4-87db-713680c9d2da"
        },
        {
            "Name": "Premium",
            "CreatedAt": "2015-07-06T11:19:04.385Z",
            "ModifiedAt": "2015-07-06T11:19:04.385Z",
            "Id": "cf5d8310-23d0-11e5-9c49-2740f827794e"
        }
    ]
}

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.