Search with The Python SDK
One of the most useful functionalities you can access with the Python SDK is Identity Security Cloud's search functionality.
Here is an example of how you can implement Search, along with pagination. Copy this code into your "sdk.py" file to try it out:
import sailpoint
import sailpoint.v3
from sailpoint.configuration import Configuration
from sailpoint.paginator import Paginator
configuration = Configuration()
api_client = sailpoint.v3.ApiClient(configuration)
search = sailpoint.v3.Search(
indices=['identities'],
query=sailpoint.v3.Query(query='*'),
sort=['-name'])
identities = Paginator.paginate_search(sailpoint.v3.SearchApi(api_client), search, increment=100, limit=1000)
print(identities.count)
Run this command to run the code:
python sdk.py
This example returns 1000 identities, 100 per page, and sorts them in descending order by name ('-name'
). You can also change the search pagination by changing "100" and "1000", respectively.
There are two main ways you can manipulate this example to search for the results you want:
The first way is to change the indices
, the document types you want to limit your search to. For example, if you add "access profiles"
to the indices, the SDK will search access profiles too. To see all the indices you can search, refer to the Search endpoint specification.
The second way is to change the query
, the value you're searching for. For example, if you change the query to "a*", the search will return all records starting with the letter "a". To learn more about how to build search queries, refer to Building a Search Query.
You can also change the sorting logic in the brackets next to sort
. For more information about sorting results, refer to Sorting Results.