To help customers start using and adopting the ONTAP REST API, we are happy to announce the availability of sample Python scripts that are now on GitHub. These scripts demonstrate how administrators can use APIs to automate their NetApp® ONTAP® storage.
ONTAP 9.6 and later versions include support for an expansive RESTful web services API. In comparison to a NetApp ONTAPI™, the REST API offers a vastly simplified and workflow-driven user experience, allowing you to perform multiple operations on the storage objects with a single API. REST is the industry standard for API development, and the ONTAP REST API provides a great opportunity to automate your storage deployments.
ontap-rest-python repository includes Python samples for the ONTAP REST API and the Python client library. You can access the API through the Python client library, which is preferable in most situations. If needed, you can also connect directly to the API by using the native capabilities provided with Python. See the
examples repository folder, which has two sub-folders containing sample code by usage type. The sample script should be used only for reference purposes.
Using the Python Client Library
The Python client library is a package you can use when writing scripts to access the ONTAP REST API. It provides support for several underlying services, including connection management, asynchronous request processing, and exception handling. By using the Python client library, you can quickly develop robust code to support the automation of your ONTAP deployments.
Before beginning, you need to install the package containing the library. For example:
pip install netapp-ontap
You should also review the PyPI netapp-ontap package webpage for detailed system requirements and further instructions, as well as reference documentation for the library.
The repository folder
examples/python_client_library contains sample scripts to access the ONTAP REST API through the Python client library and the instructions on how to use them.
Directly Accessing the ONTAP REST API
The repository folder
examples/rest_api contains sample scripts for directly accessing the ONTAP REST API by using the requests library.
Running the Sample Scripts in the Lab on Demand
You can run the sample scripts in the NetApp lab on demand (LOD). The repository folder
lod contains instructions and the initialization script needed to configure the LOD environment.
If you would like to contribute scripts to this repository, make sure to read the CONTRIBUTING.md document in the repository and follow the procedures given in the document.
We know you will have more questions about things that concern you. We haven’t covered every possible scenario, so please contact us by mail at email@example.com or connect with us through Slack. To report any issues, file them on the GitHub Issues page.