If you missed the pre-registration for NetApp MS Azure AD B2C, the new login prompt will offer the option to register. Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Software Development Kit (SDK) and API Discussions

How to build a request query with Python OntapAPI


Hi, I'm trying to specify a results-limiting query while listing volumes by OntapAPI 5.2.


I wonder if there's some easy way to build the query, similar to?:

my_vserver_connection.invoke("volume-get-iter", "max-records", 10000, "query", ("volume-attributes", ("volume-state-attributes", ("state", "restricted"))))


I can build the query using series of NaElement objects - that's a lot of lines of code, however.







Lukas -

Have you tried using the Zexplore tool ?

I did a drag and drop of volume-get-iter with the language set to Python.

It is a lot of lines of code that resulted - 563.

A lot of them are for setting all of the optional attribute elements, and could be deleted.

But it only took about 10 seconds to drag and drop and get the code ...

- Eugene


Thanks for answer Eugene. Zexplore doesn't seem to help me, however.

I wish to avoid spending several lines by building a hierarchy of NaElement objects to get a simple "state = restricted" filtering query, which is what Zexplore does. Instead, I look for an elegant way to directly pass query or desired-attributes arguments to invoke method, not to invoke_elem one. Something in the way of the example I've provided in original post.

Instead of quite chaotic this:

api = NaElement("volume-get-iter")

xi = NaElement("desired-attributes")


xi1 = NaElement("volume-attributes")



xi2 = NaElement("query")


xi3 = NaElement("volume-attributes")


xi4 = NaElement("volume-state-attributes")



xo = s.invoke_elem(api)

I wish to write something like this:

xo = s.invoke("volume-get-iter", "desired-attributes", ("volume-attributes", ("volume-id-attributes",)), "query", ("volume-attributes", ("volume-state-attributes", ("state", "restricted")))) 

I just wonder if the Python Ontapi implements similar syntax. I have tried to use that without success.


NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner