Skip to main content

Creating resources with The Python SDK

You can use the SDK to create new resources.

For example, you can run a script to create a work group, also known as a governance group.

Copy this 'create WorkGroup' script from the beta APIs into your Python project to try it out:

import sailpoint
import sailpoint.v3
import sailpoint.beta
from sailpoint.beta.models.workgroup_dto import WorkgroupDto
from sailpoint.beta.models.owner_dto import OwnerDto
from sailpoint.configuration import Configuration

configuration = Configuration()

api_client = sailpoint.v3.ApiClient(configuration)
api_client_beta = sailpoint.beta.ApiClient(configuration)

identities_api_instance = sailpoint.v3.PublicIdentitiesApi(api_client)
workgroups_api_instance = sailpoint.beta.GovernanceGroupsApi(api_client_beta)

identity = identities_api_instance.get_public_identities(limit=1)[0]

workgroup = WorkgroupDto(name='DB Access Governance Group',
description='Description of the Governance Group',
owner=OwnerDto(id=identity.id,
name=identity.name,
type='IDENTITY'))


try:
workgroupResponse = workgroups_api_instance.create_workgroup(workgroup)
print("The response of GovernanceGroupsApi->create_workgroup:\n")
print(workgroupResponse)
except Exception as e:
print("Exception when calling GovernanceGroupsApi->create_workgroup: %s\n" % e)

Run this command to run the code:

python sdk.py

The example uses the getPublicIdentities method from the PublicIdentitiesApi to pull an identity needed to be the owner of the work group.

The create_workgroup request is initialized on lines 18-22, using the identity's name and id in the owner object.

The SDK will return the created work group:

id='d287a1e2-81fc-474e-bc0c-155bd8ab0899' 
name='DB Access Governance Group'
description='Description of the Governance Group'
member_count=0
connection_count=0
owner=OwnerDto(type='IDENTITY',
id='0003c25c365e492381d4e557b6159f9b',
name='Brian Mendoza')