Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Not sure if this should be in here, or in the Python section?
I've been doing some work with the Python bindings for the rest API and so far so good, until I came up against Qtrees. In most cases, when looking for object I can do a .find(uuid=<uuid>). Qtrees don't have a uuid, so to query we need (for example) the volume uuid and the qtree id within the volume. Now the REST syntax for that is easy, but what does the python syntax to 'find' look like?
I've tried the obvious things - find (volume.uuid=<uuid>,id=<id>) but python doesn't like that...
I've tried creating Qtree/Volume objects and passing that in, no go....
What am I missing?
thx,
--rdp
Solved! See The Solution
1 ACCEPTED SOLUTION
richard_payne has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Richard,
Sorry this question went unanswered here for so long. Python (as a language) doesn't allow identifiers to contain the "." character. So here's how you can get around that limitation when using keyword arguments (which turn into query parameters to the API) with netapp_ontap functions:
qtree = Qtree.find(**{"id": "qtree_id", "volume.uuid": "volume_uuid"})
That is, you can use the ** syntax to expand a dictionary into a list of key/value pairs. In this example, I didn't have to put id in the dictionary. I could have passed it as a normal keyword argument, but I did so for the sake of illustrating how this works with multiple values.
2 REPLIES 2
richard_payne has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Richard,
Sorry this question went unanswered here for so long. Python (as a language) doesn't allow identifiers to contain the "." character. So here's how you can get around that limitation when using keyword arguments (which turn into query parameters to the API) with netapp_ontap functions:
qtree = Qtree.find(**{"id": "qtree_id", "volume.uuid": "volume_uuid"})
That is, you can use the ** syntax to expand a dictionary into a list of key/value pairs. In this example, I didn't have to put id in the dictionary. I could have passed it as a normal keyword argument, but I did so for the sake of illustrating how this works with multiple values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brilliant - thank you - I don't think I ever would have come up with that syntax!
--rdp
