Skip to content
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

Add Support to Export to CSV #131

Open
mitchos opened this issue Jul 21, 2022 · 0 comments
Open

Add Support to Export to CSV #131

mitchos opened this issue Jul 21, 2022 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mitchos
Copy link
Owner

mitchos commented Jul 21, 2022

Context

pyZscaler displays data pulled from Zscaler via the native format in the API - JSON. While JSON is optimal for programmatic purposes, our users may want to export data into a format where it's easier to manipulate or display the data. pyZscaler should be able to support the ability to export to different data formats.

Challenges

Many of Zscaler's API calls return nested data structures that can't be easily flattened without creating a potentially unpredictable number of columns. When Zscaler has a nested data structure, most times it's going to be another object that may separately exist with it's own id. e.g. a user resource record often has a nested object for department and a nested object for the groups they belong to. Now we know that users can only belong to one department, but they can belong to multiple groups. Compounding this further is that Zscaler doesn't return all possible fields for every resource record (i.e. if a user isn't assigned to a department, a null department field isn't returned).

Ultimately this means there can be quite a few edge cases and a lot of work to create a reliable CSV export that works flawlessly for every API call. Gut feel is to go for a balanced approach unless there is consensus otherwise.

There is a design decision that needs to be made:

  • Create an export method that can generally flatten any JSON to a CSV, regardless of the number of columns.
  • Create an export method that detects whether the id key is present and then only return that, ignoring nested objects that don't match this format (then creating edge cases as our users require)
  • Create an export method that returns an immaculately usable data structure at the expense of a lot of coding effort and not being able to cover the entire library

After writing out this issue

Leaning towards an export method that looks for an id and only returns the id for each nested object. Reasons for this:

  • As stated above, most (if not all) nested objects have an id
  • This id means that the object should exist in its own right
  • If the object exists somewhere in Zscaler, we should be able to make an API call to retrieve further details if required
  • Users are likely to use another tool to join data after importing via CSV

Feedback

Open to any feedback on this from anyone using pyZscaler, thanks!

@mitchos mitchos added enhancement New feature or request help wanted Extra attention is needed labels Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant