BuiltRole Class Reference

Inherits from BuiltObject : NSObject
Declared in BuiltRole.h

Other Methods

  roleName

Get the name of the role.

@property (nonatomic, copy, readonly) NSString *roleName

Discussion

 //'blt5d4sample2633b' is a dummy Application API key
 //'blt8h2sample1463j' is a dummy role uid

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithUID:@"blt8h2sample1463j"];
 NSString *roleName = role.roleName;

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithUID("blt8h2sample1463j")
 var roleName:String = role.roleName

Declared In

BuiltRole.h

  users

Array of users that are included in a BuiltRole.

@property (nonatomic, strong) NSMutableArray *users

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 NSMutableArray *usersArray = role.users;

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 var userArray = role.users

Declared In

BuiltRole.h

  roles

Array of other roles that are included in a BuiltRole. A role may have other roles included in it.

@property (nonatomic, strong) NSMutableArray *roles

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 NSMutableArray *rolesArray = role.roles;

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 var roleArray = role.roles

Declared In

BuiltRole.h

Check for Users / Roles

– hasRole:

Checks whether a role exists inside this role.

 //'blt5d4sample2633b' is a dummy Application API key
 //'blt8h2sample1463j' is a dummy role uid

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 if ([role hasRole:@"blt8h2sample1463j"]) {
    //Role exist"
 } else {
    //Role not exist"
 }

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 if (role.hasRole("blt8h2sample1463j")) {
    //Role exist
 } else {
    //Role not exist
 }
- (BOOL)hasRole:(NSString *)roleUID

Parameters

roleUID

The uid of the role.

Return Value

Returns whether the role exists or not.

Declared In

BuiltRole.h

– hasUser:

Checks whether a user exists inside this role.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];

 //'bltba9userdd9e741' is a uid of an object of inbuilt Application User class
 if ([role hasUser:@"bltba9userdd9e741"]) {
    //User exist
 } else {
    //User not exist
 }

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")

 //'bltba9userdd9e741' is a uid of an object of inbuilt Application User class
 if (role.hasUser("bltba9userdd9e741")) {
    //User exist
 } else {
    //User not exist
 }
- (BOOL)hasUser:(NSString *)userUid

Parameters

userUid

The uid of the user.

Return Value

Returns whether the user exists or not.

Declared In

BuiltRole.h

Set Name

– setName:

Set the name for the role. This value must be set before the role has been saved, and cannot be set once the role has been saved. A role’s name can only contain alphanumeric characters, _, -, and spaces.

 //'blt5d4sample2633b' is a dummy Application API key
 //'blt8h2sample1463j' is a dummy role uid

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithUID:@"role_uid"];
 [role setName:@"Manager"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithUID("role_uid")
 role.setName("Manager")
- (void)setName:(NSString *)name

Parameters

name

name of the role.

Declared In

BuiltRole.h

Add Users

– addUser:

Adds a user to a role

 //'blt5d4sample2633b' is a dummy Application API key
 //'bltba9a44506dd9e741' is a uid of an object of inbuilt Application User class

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 [role addUser:@"bltba9a44506dd9e741"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 role.addUser("bltba9a44506dd9e741")
- (void)addUser:(NSString *)userUid

Parameters

userUid

User’s uid that needs to be added to the role.

Declared In

BuiltRole.h

– addUsers:

Adds a user’s to a role

 //'blt5d4sample2633b' is a dummy Application API key
 //'bltba9a44506dd9e741', 'bltfn5e54207ab7r451' is a uid of an object of inbuilt Application User class

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 [role addUsers:@[@"bltba9a44506dd9e741", @"bltfn5e54207ab7r451"]];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 role.addUsers(["bltba9a44506dd9e741", "bltfn5e54207ab7r451"])
- (void)addUsers:(NSArray *)userArray

Parameters

userArray

Array containing User’s uid or BuiltUser object that needs to be added to the role.

Declared In

BuiltRole.h

– setUsersWithQuery:

Adds users through query in given role.

//'blt5d4sample2633b' is a dummy Application API key

//Obj-C
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltRole *role = [builtApplication roleWithName:@"Manager"];
BuiltQuery *query = [builtApplication userQuery];
[query whereKey:@"email" matchesRegex:@".john" modifiers:@"i"];
[role setUsersWithQuery:query];

//Swift
var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
var role:BuiltRole = builtApplication.roleWithName("Manager")
var query:BuiltQuery = builtApplication.userQuery()
query.whereKey("email", matchesRegex: ".john", modifiers: "i")
role.setUsersWithQuery(query)
- (void)setUsersWithQuery:(BUILT_NONNULL BuiltQuery *)query

Parameters

query

BuiltQuery contains condition to select group of users to assign for current role.

Discussion

Note: BuiltQuery object must be created from ‘built_io_application_user’ class, which we can create using method ‘userQuery’ from BuiltApplication class.

Declared In

BuiltRole.h

Remove Users

– removeUser:

Removes a user from a role

 //'blt5d4sample2633b' is a dummy Application API key
 //'bltba9a44506dd9e741' is a uid of an object of inbuilt Application User class

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 [role removeUser:@"bltba9a44506dd9e741"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 role.removeUser("bltba9a44506dd9e741")
- (void)removeUser:(NSString *)userUid

Parameters

userUid

User’s uid that needs to be removed from the role.

Declared In

BuiltRole.h

– removeUsers:

Removes users from a role

 //'blt5d4sample2633b' is a dummy Application API key
 //'bltba9a44506dd9e741', 'bltfn5e54207ab7r451' is a uid of an object of inbuilt Application User class

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 [role removeUsers:@[@"bltba9a44506dd9e741", @"bltfn5e54207ab7r451"]];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 role.removeUsers(["bltba9a44506dd9e741", "bltfn5e54207ab7r451"])
- (void)removeUsers:(NSArray *)userArray

Parameters

userArray

Array containing User’s uid or BuiltUser object that needs to be removed from the role.

Declared In

BuiltRole.h

Add Roles

– addRole:

Adds a role to this role.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 [role addRole:@"blt4d5sample1962c"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 role.addRole("blt4d5sample1962c")
- (void)addRole:(NSString *)roleUid

Parameters

roleUid

uid of the role that has to be added to this role.

Declared In

BuiltRole.h

– addRoles:

Adds role’s to this role.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 [role addRoles:@[@"blt4d5sample1962c", @"blt4d5sample1854a"]];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 role.addRoles(["blt4d5sample1962c", "blt4d5sample1854a"])
- (void)addRoles:(NSArray *)roleArray

Parameters

roleArray

Array of role uid or role object that has to be added to this role.

Declared In

BuiltRole.h

Remove Roles

– removeRole:

Removes a role from this role if it exists.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 [role removeRole:@"blt4d5sample1962c"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 role.removeRole("blt4d5sample1962c")
- (void)removeRole:(NSString *)roleUid

Parameters

roleUid

uid of the role that has to be removed from this role.

Declared In

BuiltRole.h

– removeRoles:

Removes roles from this role if it exists.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltRole *role = [builtApplication roleWithName:@"Manager"];
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 [role removeRoles:@[@"blt4d5sample1962c", @"blt4d5sample1854a"]];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var role:BuiltRole = builtApplication.roleWithName("Manager")
 //'blt4d5sample1962c' is a dummy role uid which we want to remove
 role.removeRoles(["blt4d5sample1962c", "blt4d5sample1854a"])
- (void)removeRoles:(NSArray *)roleArray

Parameters

roleArray

Array of role uid or role object that has to be removed from this role.

Declared In

BuiltRole.h