- Authenticate to vCenter to get user credential.
# curl -k -X POST https://<FQDN or IP>/rest/com/vmware/cis/session -u <USERNAME>:<PASSWORD> | jq
{
"value": "SESSIONID"
}
- Save the session id to a variable
# ID=SESSIONID
- Access the end point with the session id
# curl -k -X GET -H "vmware-api-session-id: $ID" https:/ /<VCENTERIP or FQDN>/rest/vcenter/vm |jq
{
"value": [
{
"memory_size_MiB": 16384,
"vm": "vm-1",
"name": "VM01",
"power_state": "POWERED_ON",
"cpu_count": 4
},
{
"memory_size_MiB": 16384,
"vm": "vm-2",
"name": "VM02",
"power_state": "POWERED_ON",
"cpu_count": 4
}
]
}
# curl -k -X GET -H "vmware-api-session-id: $ID" https://<VCENTERIP or FQDN>/rest/vcenter/datastore |jq
{
"value": [
{
"datastore": "datastore-1",
"name": "DS1",
"type": "VMFS",
"free_space": 290276245504,
"capacity": 291789340672
},
{
"datastore": "datastore-2",
"name": "DS2",
"type": "VMFS",
"free_space": 3349917204480,
"capacity": 3599451029504
}
]
}
List of apis can be found below
- https://<vCenter IP>/apiexplorer
- https://code.vmware.com/apis/191/vsphere-automation
Thanks for the feedback! Some of the comments in the command were wrong so I fixed it up.
Hope it works on your end!