### Add SNMP User - Wget Request Example Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Example of using Wget to add an SNMP user. This command shows how to send a POST request with a JSON payload to the user creation endpoint. ```bash # Wget command for adding an SNMP user would go here. # Wget is primarily for downloading files, so using curl or other HTTP clients is more common for API interactions. ``` -------------------------------- ### Add SNMP User - cURL Request Example Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Example using cURL to add an SNMP user. This command demonstrates sending a POST request with a JSON payload to the user creation endpoint, including necessary headers. ```bash curl -X POST https://{pc-ip}:9440/api/clustermgmt/v4.2/config/clusters/{clusterExtId}/snmp/$actions/add-user \ -H "Content-Type: application/json" \ -d '{ "//": "Example payload structure for adding an SNMP user.", "userName": "snmpUser", "authProtocol": "SHA", "privProtocol": "AES", "authKey": "yourAuthKey", "privKey": "yourPrivKey" }' ``` -------------------------------- ### Check Hypervisor ISO Upload Requirements (Wget) Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Example Wget command to check hypervisor ISO upload requirements. This shows how to make the API call using Wget, including the POST method and JSON data. ```bash wget --method POST \ --header "Content-Type: application/json" \ --body-content '{ "nodeList": [ { "nodeUuid": "f0637d2d-e61f-4469-88ee-b9487beea917", "hypervisorVersion": "Nutanix 20220304.480", "nosVersion": "7.0", "model": "NX-8155-G", "blockId": "8F3K144", "isLightCompute": true, "hypervisorType": "AHV", "isRoboMixedHypervisor": false, "isMinimumComputeNode": true, "luksStatus": "NON_LUKS" } ] }' \ 'https://{pc-ip}:9440/api/clustermgmt/v4.2/config/clusters/{clusterExtId}/$actions/check-hypervisor-requirements' ``` -------------------------------- ### Get Storage Container Configuration - cURL Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Provides a cURL command to retrieve storage container configuration details from the Nutanix API. This example demonstrates how to make a GET request to the specified endpoint, including the necessary path parameter for the container's external ID. ```bash curl -k -u "username:password" -X GET https://{pc-ip}:9440/api/clustermgmt/v4.2/config/storage-containers/a8FCe3BB-5cEF-Ab25-7bbF-1dBE1dDd6B8d ``` -------------------------------- ### Get Host Details using cURL Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This example shows how to fetch the details of a host associated with a cluster using cURL. It requires the cluster's external ID and the host's external ID, and it makes a GET request to the Nutanix API endpoint. Authentication is typically handled via basic authentication. ```bash curl -k -u "username:password" https://{pc-ip}:9440/api/clustermgmt/v4.2/config/clusters/{clusterExtId}/hosts/{extId} ``` -------------------------------- ### List Disks using Wget Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Demonstrates how to fetch a paginated list of Disks using Wget. This example includes basic authentication and specifies the target API endpoint for disk retrieval. ```wget wget --no-check-certificate --user= --password= "https://{pc-ip}:9440/api/clustermgmt/v4.2/config/disks?page=&limit=" ``` -------------------------------- ### Java SDK Sample - List Hosts Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This sample demonstrates how to use the Java SDK to list hosts within a Nutanix cluster. It includes client configuration, authentication, and calling the `listHosts` API. ```APIDOC ## GET /api/v4/clustermgmt/hosts ### Description Retrieves a list of hosts within the Nutanix cluster. Supports pagination and filtering. ### Method GET ### Endpoint /api/v4/clustermgmt/hosts ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The maximum number of hosts to return per page. - **filter** (string) - Optional - A filter expression to apply to the list of hosts. - **sort_order** (string) - Optional - The order in which to sort the results (e.g., 'ASC', 'DESC'). - **sort_attribute** (string) - Optional - The attribute by which to sort the results. - **async** (boolean) - Optional - Whether the request should be processed asynchronously. ### Request Example ```java // Java SDK Configuration ApiClient apiClient = new ApiClient(); apiClient.setHost("localhost"); apiClient.setPort(9440); apiClient.setRetryInterval(5000); apiClient.setMaxRetryAttempts(5); apiClient.setUsername("username"); apiClient.setPassword("password"); ClustersApi clustersApi = new ClustersApi(apiClient); int page = 0; int limit = 50; ListHostsApiResponse listHostsApiResponse = clustersApi.listHosts(page, limit, null, null, null, null); System.out.println(listHostsApiResponse.toString()); ``` ### Response #### Success Response (200) - **host_list** (array) - A list of host objects. - **host_id** (string) - The unique identifier for the host. - **name** (string) - The name of the host. - **ip_address** (string) - The IP address of the host. - **availability_zone** (string) - The availability zone the host belongs to. #### Response Example ```json { "host_list": [ { "host_id": "host-123", "name": "host-01", "ip_address": "192.168.1.10", "availability_zone": "AZ1" } ] } ``` ``` -------------------------------- ### GET /clustermgmt/v4.2/config/clusters/{clusterExtId}/rsyslog-servers Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Retrieves the RSYSLOG server configurations for a specified cluster. Supports Java SDK examples and provides response samples for success and error scenarios. ```APIDOC ## GET /clustermgmt/v4.2/config/clusters/{clusterExtId}/rsyslog-servers ### Description Retrieves the RSYSLOG server configurations for a specified cluster. ### Method GET ### Endpoint /api/clustermgmt/v4.2/config/clusters/{clusterExtId}/rsyslog-servers ### Parameters #### Path Parameters - **clusterExtId** (string) - Required - The UUID of the cluster. ### Request Example ```java // Java SDK example for retrieving RSYSLOG servers import com.nutanix.clu.java.client.ApiClient; import com.nutanix.clu.java.client.api.ClustersApi; import com.nutanix.dp1.clu.clustermgmt.v4.config.ListRsyslogServersByClusterIdApiResponse; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { ApiClient apiClient = new ApiClient(); apiClient.setHost("localhost"); apiClient.setPort(9440); apiClient.setRetryInterval(5000); apiClient.setMaxRetryAttempts(5); String username = "username"; String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); ClustersApi clustersApi = new ClustersApi(apiClient); String clusterExtId = "fefDfcBe-EfCD-cAA1-E8fb-DdAEBbeAB7f2"; try { ListRsyslogServersByClusterIdApiResponse listRsyslogServersByClusterIdApiResponse = clustersApi.listRsyslogServersByClusterId(clusterExtId); System.out.println(listRsyslogServersByClusterIdApiResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ``` ### Response #### Success Response (200) - **metadata** (object) - Contains metadata about the response, including flags, links, total results, and messages. - **data** (array) - An array of RSYSLOG server configuration objects. - **tenantId** (string) - The ID of the tenant. - **extId** (string) - The unique ID of the RSYSLOG server. - **links** (array) - Links related to the RSYSLOG server. - **serverName** (string) - The name of the RSYSLOG server. - **ipAddress** (object) - The IP address of the RSYSLOG server (IPv4 or IPv6). - **port** (integer) - The port number for the RSYSLOG server. - **networkProtocol** (string) - The network protocol used (UDP, TCP, RELP). - **modules** (array) - A list of modules configured for the RSYSLOG server. #### Response Example ```json { "metadata": { "flags": [ { "name": "string", "value": false } ], "links": [ { "href": "string", "rel": "string" } ], "totalAvailableResults": 72, "messages": [ { "code": "string", "message": "string", "locale": "en_US", "severity": "INFO" } ], "extraInfo": [ { "name": "string", "value": "string" } ] }, "data": [ { "tenantId": "12bdbaa1-6683-4f52-943d-2fbf80489ab1", "extId": "dc9491a5-a279-4bbb-a7b7-0bad42715963", "links": [ { "href": "string", "rel": "string" } ], "serverName": "testServer1", "ipAddress": { "ipv4": { "value": "83.92.41.252", "prefixLength": 32 }, "ipv6": { "value": "6004:7361:1a7d:9a64:df8d:dfd8:39c6:c4ea", "prefixLength": 128 } }, "port": 13, "networkProtocol": "UDP", "modules": [ { "name": "CASSANDRA", "logSeverityLevel": "EMERGENCY", "shouldLogMonitorFiles": true } ] } ] } ``` ``` -------------------------------- ### Get Disk by External Identifier Request (cURL) Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Example cURL command to retrieve details of a specific disk using its external identifier. This request requires the `extId` path parameter and is sent to the cluster management API. ```shell curl -k -u "${USER}":"${PASSWORD}" -X GET "https://$(hostname):9440/api/clustermgmt/v4.2/config/disks/{extId}" ``` -------------------------------- ### Get SNMP User by ID - Java SDK Example Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Demonstrates how to retrieve SNMP user configuration details using the Nutanix Java SDK. It shows client configuration, API client instantiation, and calling the getSnmpUserById method. ```java package sample; import com.nutanix.clu.java.client.ApiClient; import com.nutanix.clu.java.client.api.ClustersApi; import com.nutanix.dp1.clu.clustermgmt.v4.config.GetSnmpUserApiResponse; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { // Configure the client ApiClient apiClient = new ApiClient(); // IPv4/IPv6 address or FQDN of the cluster apiClient.setHost("localhost"); // Port to which to connect to apiClient.setPort(9440); // Interval in ms to use during retry attempts apiClient.setRetryInterval(5000); // Max retry attempts while reconnecting on a loss of connection apiClient.setMaxRetryAttempts(5); // UserName to connect to the cluster String username = "username"; // Password to connect to the cluster String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); // Please add authorization information here if needed. ClustersApi clustersApi = new ClustersApi(apiClient); String clusterExtId = "D4cae9c4-EDfa-afD8-AdDF-E9Ca2FaB5ead"; String extId = "F6ef1D5f-CF0b-bBeb-ffEd-B3B3cfDbC8CF"; try { GetSnmpUserApiResponse getSnmpUserApiResponse = clustersApi.getSnmpUserById(clusterExtId, extId); System.out.println(getSnmpUserApiResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ``` -------------------------------- ### Check Hypervisor ISO Upload Requirements (Go) Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Example Go code to check hypervisor ISO upload requirements using the Nutanix API. This snippet provides a Go implementation for the API request. ```go // Go code snippet for checking hypervisor ISO upload requirements would go here. ``` -------------------------------- ### Get Host Statistics (Example Data Structure) Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This snippet illustrates the structure of the data returned when fetching host statistics. It includes various metrics such as I/O bandwidth, storage usage, memory utilization, CPU capacity, and health check scores, each associated with a timestamp and a value. ```json { "controllerWriteIoBandwidthKbps": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "storageUsageBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "storageCapacityBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "freePhysicalStorageBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "logicalStorageUsageBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "overallMemoryUsageBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "healthCheckScore": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "recycleBinUsageBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "snapshotCapacityBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "overallSavingsBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "overallSavingsRatio": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "cpuCapacityHz": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "cpuUsageHz": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "memoryCapacityBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "powerConsumptionInstantWatt": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ], "overcommittedVmsReclaimableMemoryBytes": [ { "timestamp": "2009-09-23T14:30:00-07:00", "value": 83 } ] } ``` -------------------------------- ### Java SDK Sample for Listing Clusters Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This Java SDK sample demonstrates how to configure the ApiClient and use the ClustersApi to list clusters. It includes configuration for host, port, retry settings, and authentication, followed by a call to the listClusters method. ```APIDOC ## GET /api/v4/clustermgmt/clusters ### Description Retrieves a list of clusters with pagination and filtering options. ### Method GET ### Endpoint /api/v4/clustermgmt/clusters ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The maximum number of items to return per page. - **filter** (string) - Optional - A filter string to apply to the list. - **sort_order** (string) - Optional - The order in which to sort the results (e.g., ASC, DESC). - **sort_attribute** (string) - Optional - The attribute to sort the results by. - **kind_list** (string) - Optional - A comma-separated list of kinds to filter by. - **entity_filter** (string) - Optional - An entity filter string. ### Request Example ```java // Java SDK Configuration and Call import com.nutanix.clu.java.client.ApiClient; import com.nutanix.clu.java.client.api.ClustersApi; import com.nutanix.dp1.clu.clustermgmt.v4.config.ListClustersApiResponse; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { ApiClient apiClient = new ApiClient(); apiClient.setHost("localhost"); apiClient.setPort(9440); apiClient.setRetryInterval(5000); apiClient.setMaxRetryAttempts(5); String username = "username"; String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); ClustersApi clustersApi = new ClustersApi(apiClient); int page = 0; int limit = 50; try { ListClustersApiResponse listClustersApiResponse = clustersApi.listClusters(page, limit, null, null, null, null, null); System.out.println(listClustersApiResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ``` ### Response #### Success Response (200) - **entities** (array) - A list of cluster entities. - **metadata** (object) - Metadata about the response, including pagination information. #### Response Example ```json { "entities": [ { "uuid": "some-uuid-1", "name": "Cluster-1", "state": "ACTIVE" }, { "uuid": "some-uuid-2", "name": "Cluster-2", "state": "PROVISIONING" } ], "metadata": { "total_entities": 10, "next_page_token": null } } ``` ``` -------------------------------- ### Get BMC Details for a Host using Java SDK Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Retrieves the Baseboard Management Controller (BMC) details for a specific host within a Nutanix cluster. This Java SDK example demonstrates how to configure the API client, authenticate, and call the getBmcInfo method. It requires cluster and host external IDs as input and returns BMC information or a client error. ```java package sample; import com.nutanix.hw.java.client.ApiClient; import com.nutanix.hw.java.client.api.BmcApi; import com.nutanix.dp1.hw.clustermgmt.v4.config.GetBmcInfoResponse; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { // Configure the client ApiClient apiClient = new ApiClient(); // IPv4/IPv6 address or FQDN of the cluster apiClient.setHost("localhost"); // Port to which to connect to apiClient.setPort(9440); // Interval in ms to use during retry attempts apiClient.setRetryInterval(5000); // Max retry attempts while reconnecting on a loss of connection apiClient.setMaxRetryAttempts(5); // UserName to connect to the cluster String username = "username"; // Password to connect to the cluster String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); // Please add authorization information here if needed. BmcApi bmcApi = new BmcApi(apiClient); String clusterExtId = "faAd5Dfc-1C8a-Bf7b-fdE8-eDD5C8Dabbdc"; String extId = "dd47d01f-fDBc-A7f9-cf9f-fbf37fcE574C"; try { GetBmcInfoResponse getBmcInfoResponse = bmcApi.getBmcInfo(clusterExtId, extId); System.out.println(getBmcInfoResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ``` -------------------------------- ### Add SNMP User - Go Request Example Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 Example of how to make an API request to add an SNMP user using Go. This involves using the `net/http` package to construct and send a POST request with the JSON payload. ```go // Go code snippet for adding an SNMP user would go here. // This would involve using the 'net/http' package // to send a POST request to the SNMP user creation endpoint with the JSON payload. ``` -------------------------------- ### Get Disk Statistics using Java SDK Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This Java code snippet demonstrates how to retrieve disk statistics from a Nutanix cluster using the Nutanix Java SDK. It configures the API client with host, port, retry settings, and authentication credentials. It then calls the `getDiskStats` method with parameters like disk ID, start time, end time, sampling interval, and stat type. Error handling for `RestClientException` is included. ```java package sample; import com.nutanix.clu.java.client.ApiClient; import com.nutanix.clu.java.client.api.DisksApi; import com.nutanix.dp1.clu.clustermgmt.v4.stats.GetDiskStatsApiResponse; import java.time.OffsetDateTime; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { // Configure the client ApiClient apiClient = new ApiClient(); // IPv4/IPv6 address or FQDN of the cluster apiClient.setHost("localhost"); // Port to which to connect to apiClient.setPort(9440); // Interval in ms to use during retry attempts apiClient.setRetryInterval(5000); // Max retry attempts while reconnecting on a loss of connection apiClient.setMaxRetryAttempts(5); // UserName to connect to the cluster String username = "username"; // Password to connect to the cluster String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); // Please add authorization information here if needed. DisksApi disksApi = new DisksApi(apiClient); String extId = "87BfF126-fB86-fcDb-0DF9-BCfef7dbabC7"; // Datetime needs to be in RFC3339 format OffsetDateTime startTime = OffsetDateTime.now(); // Datetime needs to be in RFC3339 format OffsetDateTime endTime = OffsetDateTime.now(); int samplingInterval = 1; Object statType = SOME_RAW_DATA; try { GetDiskStatsApiResponse getDiskStatsApiResponse = disksApi.getDiskStats(extId, startTime, endTime, samplingInterval, statType); System.out.println(getDiskStatsApiResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ``` -------------------------------- ### List Virtual GPU Profiles using Java SDK Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This Java code snippet demonstrates how to configure the Nutanix API client and list virtual GPU profiles for a specified cluster. It includes setting host, port, retry configurations, and authentication credentials. The example shows how to instantiate the ClustersApi and call the listVirtualGpuProfiles method, handling potential RestClientExceptions. ```java package sample; import com.nutanix.clu.java.client.ApiClient; import com.nutanix.clu.java.client.api.ClustersApi; import com.nutanix.dp1.clu.clustermgmt.v4.config.ListVirtualGpuProfilesApiResponse; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { // Configure the client ApiClient apiClient = new ApiClient(); // IPv4/IPv6 address or FQDN of the cluster apiClient.setHost("localhost"); // Port to which to connect to apiClient.setPort(9440); // Interval in ms to use during retry attempts apiClient.setRetryInterval(5000); // Max retry attempts while reconnecting on a loss of connection apiClient.setMaxRetryAttempts(5); // UserName to connect to the cluster String username = "username"; // Password to connect to the cluster String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); // Please add authorization information here if needed. ClustersApi clustersApi = new ClustersApi(apiClient); String clusterExtId = "EdcfBFFB-5A7e-FFAb-DdEF-04Eba1C7BBf5"; int page = 0; int limit = 50; try { ListVirtualGpuProfilesApiResponse listVirtualGpuProfilesApiResponse = clustersApi.listVirtualGpuProfiles(clusterExtId, page, limit, null, null); System.out.println(listVirtualGpuProfilesApiResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ``` -------------------------------- ### List Vcenter Extensions using Java SDK Source: https://developers.nutanix.com/api-reference/index_namespace=clustermgmt&version=v4.2 This Java code snippet demonstrates how to configure the Nutanix API client and list vCenter extensions. It includes setting host, port, retry intervals, and authentication credentials. The response is printed to the console, and exceptions are caught. ```java package sample; import com.nutanix.vcnt.java.client.ApiClient; import com.nutanix.vcnt.java.client.api.VcenterExtensionsApi; import com.nutanix.dp1.vcnt.clustermgmt.v4.config.ListVcenterExtensionsApiResponse; import org.springframework.web.client.RestClientException; public class JavaSdkSample { public static void main(String[] args) { // Configure the client ApiClient apiClient = new ApiClient(); // IPv4/IPv6 address or FQDN of the cluster apiClient.setHost("localhost"); // Port to which to connect to apiClient.setPort(9440); // Interval in ms to use during retry attempts apiClient.setRetryInterval(5000); // Max retry attempts while reconnecting on a loss of connection apiClient.setMaxRetryAttempts(5); // UserName to connect to the cluster String username = "username"; // Password to connect to the cluster String password = "password"; apiClient.setUsername(username); apiClient.setPassword(password); // Please add authorization information here if needed. VcenterExtensionsApi vcenterExtensionsApi = new VcenterExtensionsApi(apiClient); int page = 0; int limit = 50; try { ListVcenterExtensionsApiResponse listVcenterExtensionsApiResponse = vcenterExtensionsApi.listVcenterExtensions(page, limit, null, null); System.out.println(listVcenterExtensionsApiResponse.toString()); } catch (RestClientException ex) { System.out.println(ex.getMessage()); } } } ```