Last week I posted about getting started with the Python toolkit, now I wanted to go a little deeper today on using the toolkit beyond connecting/creating a volume. A question I have seen more than once is:

“okay, I understand connecting and getting basic information, but what if I want to pull statistics or more advanced information from the array besides what the default commands? The API glossary for the toolkit doesn’t say explicitly how I can get the information I want”

In short, just because the Python glossary doesn’t explicitly say how to do something or even if you can, it does not mean you can’t. It really depends on what the REST API can do.

Let me explain.

 

If you go to our API glossary you can see the list of commands supported in our Python toolkit. As you might notice, it is a bit different than our PowerShell SDK for instance. While they both use our REST API to communicate with the array, the Python toolkit has less abstraction of the specific REST calls, meaning the syntax looks and follows exactly how our REST needs it. For the most part, there is one Python command for each specific GET, PUT, POST etc REST high-level command. PowerShell has switches etc to change it’s command structure. If we run the get_volume command with just the volume name will get you the basic information:

But that is not the only option for that command. If you look at the REST API guide you can see what else the GET volume REST call supports. The guide is built into your FlashArray GUI (click on the help button in the upper-right).resthelp

So if you go to the volume call you can see what it supports. Additional options like snapshots, space information, performance, etc.restvolumesinfo

So how do they get passed? The default call does not include any parameters. How can I add them? Well if you look at the Python guide, you will see a second parameter entry for putting in additional parameters:

Return a dictionary describing a volume or snapshot.

Parameters:
  • volume (str) – Name of the volume to get information about.
  • **kwargs (optional) – See the REST API Guide on your array for the documentation on the request: GET volume/:volume
Returns:

A list describing snapshots of the volume if the paramater snap is passed as True, else a dictionary describing the volume.

Return type:

dict or list

You will also notice the API glossary also tells you which API call to look at in the REST guide. So figure out which parameter you want to add and put it in the call. So if I want additional space detail, I would add space=true. Though, I cannot type it exactly like that, you need to enter the value in quotes like: space=”true. My volume name is just “myvolume”.

Python Command:

JSON Response:

What if you want more than one parameter? Well just add them comma separated. So if I want historical space/capacity information from the last hour, I would run this:

Python Command:


JSON Response (excerpt):

So just because the API glossary doesn’t explicitly list a feature of the command, it does not mean you cannot do it. This architecture of the toolkit allows you to leverage new REST features that might be introduced after the toolkit.