-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Map Search Results to Python Types #12
Comments
looks like it may take some work to put in type determination. I took out the change to object type. seems the generated code defaults to a type attribute which probably isn't there and it didn't know what type it was. I may have a closer look at this to see if some soft of 'hints' can be put in. Exception has occurred: ValueError |
The plot thickens... there is a _type on events anyway.
|
ProgressSome progress as the following shows SearchDocuments are typed and the EventDocument attributes can be reference using .actor.name notation instead of subscript ["actor"]["name"] As the api has a SearchDocument with oneOf result types, the search returns an array of SearchDocuments and the actual mapped object is the attribute actual_instance. paginate search could iterate through the search results and return a list of the actual_result items so API users wouldn't have to. This is a decision point. If I were to proceed be good to know which way to go. My initial preference would be to return the actual items rather than force the API user to do so. what is the direction dev rel is going on this? types had to be added for event actor and target as these were defined as strings and the json result is objects. In order to implement fully the definition of all search results has to be reviewed, possibly defined, and tested. Access to data is 'lazy' and errors don't show up until they are accessed. Is there a plan to validate the yaml for all search results? working codeInstead of dicts being return, the actual types are. As stated above the SearchDocument has to be examined for what type of document this is. so it's now event.actor.name instead of event["actor"]["name"]
changes madeapi yaml
paginate_search.pyas values are attributes and can't be subscripted the paginate_search.py needed this change. generator command lineNote: --additional-properties=useOneOfDiscriminatorLookup=true Without this, the generated code tries to map the objects based on attributes. Based on current yaml that results is ambiguous. Unknown if this would be required after evaluating all the search results.
Next steps, assuming this would be incorporated into the api spec and python sdk would be validate the remainder of the yaml definitions for all search results. assumptions
@tyler-mairose-sp , your thoughts? |
v3 Search API results are changed from defined types to an object.
This makes working with search results more difficult in some ways. The results have to be treated as a list of dicts.
Predominantly, the APIs use defined types.
So looping through search results:
Note in the last printf how it's event["created"] rather than event.created
I see a build step in https://github.com/sailpoint-oss/python-sdk/blob/main/sdk-resources/prescript.js that changes the type.
might be an advantage to being able to request how they are returned or have a different api.
feature ask is to be able to get typed return data.
The text was updated successfully, but these errors were encountered: