Code Samples

The code samples provided here are intended as standalone examples.  They can be downloaded, copied and/or modified in any way you see fit.

Please be aware that all code samples provided here are unofficial in nature, are provided as examples only, are unsupported and will need to be heavily modified before they can be used in a production environment.

Most code samples can be directly accessed from the NutanixDev GitHub code samples repo.  Larger samples will be published via dedicated repos when required.

Please see the License section of this page for information on how these code samples may be used.

Languages & Scripts

Python

These samples require Python 3.7 or later and demonstrate complete, standalone scripts for carrying out common API operations.

For easy sharing of parameters between scripts, most scripts accept their JSON payloads via an on-disk JSON-formatted text file.

Most scripts utilise requests, urllib3, getpass, argparse and json modules.

Repo directory: python

Bash Shell

These samples are written specifically for use with Bash Shell; please note that modification will be required before use with the sh shell.  All scripts are standalone and can be run without any other script dependencies.

All scripts utilise jq, a free sed-like JSON processor.  JQ can be downloaded from here.

Repo directory: shell

C#

These samples are intended for use with Visual Studio.  Visual Studio Community can be downloaded from here.

All C# code samples utilise Newtonsoft.Json, a popular high-performance JSON framework for .NET.  Please see here for instructions on installing Newtonsoft.Json into your Visual Studio environment.

Repo directory: csharp

PowerShell

A default installation of PowerShell, e.g. on Windows 10 or Windows 2016 (or later) should have all required packages available.

To run these scripts the PowerShell ExecutionPolicy will need to be set to RemoteSigned.  To do this, run the following command in an administrative PowerShell session:

SetExecutionPolicy RemoteSigned

Repo directory: powershell

Go

A collection of Go code samples, provided by Nutanix Community and staff members.

To run these scripts please download and install Go from the Go website.

Repo directory: go

JSON

A collection of JSON Payload samples, intended for use with Nutanix API requests.

To use these samples it is suggested than an application such as Postman be used.

Repo directory: json

Update Existing VM

Request Parameters The below parameters should be used with the sample payload. Please note you will need to alter {{placeholder}} values to match your environment,

Read More »

Create Detailed VM

Request Parameters The below parameters should be used with the sample payload. Please note you will need to alter {{placeholder}} values to match your environment,

Read More »

Terraform

A collection of Terraform code samples, provided by Nutanix Community and staff members.

Repo directory: terraform

License

All code samples are covered under the Open Source MIT license, as follows:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

SSH PUBLIC KEY

Copy the SSH public key below.  In BASH shell environments, for example, this file could be saved to ~/.ssh/nutanix_demo.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCm+7N2tjmJw5jhPmD8MS6urZQJB42ABh73ffGQSJ0XUHgdEDfjUDFkLK0wyJCe0sF5QJnh07UQn0F0BUnBi+VwehPGeODh6S43OP5YS/14L0fyntFI06B9lckx/ygRNu82sHxXCX+6VVUFPOPC+sz6j1DQswKY9d4cEYnaMBGSzqRxrqAIf6aWIKTJTYKPFY0zaUZ6ow2iwS0Nlh5EqaXsEBWkqMmr7/auP9GV/adUgzFrGLJklYBdfH575SIK6/PZL6wNT0jE9LmFlEm7dI01ZWPclBuV16FzRyrnzmWr/ebY62A04vYBtR0vyfEfsW2ZgxgD6aAE6+ytj0v19y0elRtOaeTySN/HlXh7owKWCHnlXNpTUiSDP8SQ8LRARkhQu3KEDL0ppGCrSF87oFkp1gPzf92U+UK3LaNMMjZXMOy0zLoLEdLtbQo6S8iHggDoX4NI4sWWxcX0mtadvjy/nIOvskk9IXasQh0u0MT9ARQY5VXPluKDtEVdeow9UbvgJ1xxNkphUgsWjCiy+sjgapsuZvWqKM6TPT1i24XYaau+/Fa0vhjLb8vCMWrrtkRwGt4re243NDYcYWTzVZUFuUK0w1wqt77KgjCCeyJdsZNwrh15v780Fjqpec3EGVA0xyNbF0jn/tsnYy9jPh/6Cv767EratI97JhUxoB4gXw== no-reply@acme.com