Like users, groups also exist within the scope of an organization within Control Hub. Groups encompass 1 or more users, and help further filter and categorize users within an organization.

Creating a new Group

You can create a new streamsets.sdk.sch_models.Group instance within a Control Hub organization via the streamsets.sdk.sch_models.GroupBuilder class. Use the streamsets.sdk.ControlHub.get_group_builder() method to instantiate the builder object:

group_builder = sch.get_group_builder()
group ='test@admin', display_name='Test Group')
group.users = ['admin@admin']

Retrieving existing groups

Retrieving existing groups from a Control Hub instance is as simple as asking for the groups attribute from the streamsets.sdk.ControlHub instance. You can further filter the available groups by specifying items like id and display_name:

# Get all groups belonging to current organization

# Get a particular group
group = sch.groups.get(id='test@admin')

# Validate the users that are members of this group


# sch.groups
[<Group (id=all@admin, display_name=all)>,
 <Group (id=test@admin, display_name=Test Group)>]

# group
<Group (id=test@admin, display_name=Test Group)>

# group.users
['test@admin', 'johnsmith@admin', 'janedoe@admin']

Updating an existing Group

The SDK also allows for updating existing groups within an organization. Simply retrieve the group to be modified from Control Hub, make the desired changes (such as adding a new user, or removing a role from the group), and then pass the streamsets.sdk.sch_models.Group instance to the streamsets.sdk.ControlHub.update_group() method:

group = sch.groups.get(display_name='Test Group')
group.roles.append('Data SLA User')
group.roles.remove('Data SLA Editor')

Deleting existing Groups

Deleting existing groups from an organization is also done in a similar fashion. Simply retrieve the group(s) to be deleted from Control Hub, and then pass the streamsets.sdk.sch_models.Group instance(s) to the streamsets.sdk.ControlHub.delete_group() method:

# Delete a single group
group = sch.groups.get(display_name='Test Group')

# Delete multiple groups
groups = sch.groups.get_all(display_name='Test Group')