I was able to retrieve VMs CPU, Ram and name via Power CLi,
How you do retrieve the same hardware using API instead?
import requests
vm_id = "<YOUR_VM_ID>"
url = f"https://clouddirector.example.com/vdc/vm/{vm_id}"
response = requests.get(url, headers={"Authorization": "Bearer YOUR_API_TOKEN"})
vm_data = response.json()
cpu_count = vm_data["VirtualHardwareSection"]["virtualCpu"]
ram_mb = vm_data["VirtualHardwareSection"]["memorySizeMB"]
vm_name = vm_data["name"]
vSphere API
Get-VM -Name "<VM_NAME>" | Select-Object NumCpu, MemorySize, Name
# Output formatted for readability
$vm = Get-VM -Name "<VM_NAME>"
$cpu_count = $vm.NumCpu
$ram_mb = $vm.MemorySize / 1MB
$vm_name = $vm.Name
Write-Host "VM Name: $vm_name, CPU: $cpu_count, RAM: $ram_mb MB"
print(f"VM Name: {vm_name}, CPU: {cpu_count}, RAM: {ram_mb} MB")
I am using this API
https://xxx.com/cloudapi/1.0.0/
vm_id = "<YOUR_VM_ID>"
What is the VM_ ID meaning here? Virtual machine ID or Org ID?