I'm trying to convert a search in vRNI to a search in the API with the same results.
But I'm experiencing some difficulties to get the same response results from the API in understandable human format.
I need to measure all the Edge's internet traffic and i came up with this search:
This example gives me the information i need but i cant get it converted to Powershell to get the same request.
The API documentation doesn't explain how you can convert a search in vRNI to an API search.
# Set the correct TLS protocol
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Address and login info
$baseurl = "https://vRNI.someserver.com"
$user = "admin@yourdomain.local"
$pass = 'ReallyDifficultPassword'
# Json format for aquiring token
$body = '{
"username": "'+$user+'",
"password": "'+$pass+'",
"domain": {
"domain_type" : "LDAP",
"value" : "yourdomain.local"
}
}'
# Getting token for api queries
$url = $baseurl + "/api/ni/auth/token"
$auth = Invoke-RestMethod -Method POST -Uri $url -Body $body -ContentType "application/json"
#converting the token
$token = $auth.token
$headers = @{"Authorization"="NetworkInsight $token"}
# First run to get VMs
$url = $baseurl + "/api/ni/entities/vms"
$entities = Invoke-RestMethod -Method GET -Uri $url -ContentType "application/json" -Headers $headers
$entities.results
# Testing search functionality
$body = @{
"entity_type"= "VirtualMachine"
"filter"= "default_gateway is set"
}
$url = $baseurl + "/api/ni/search"
$entities = Invoke-RestMethod -Method POST -Uri $url -Body ($body | ConvertTo-Json) -ContentType "application/json" -Headers $headers
$entities.results
# Find VMs with name starting with 'vse'
$body = @{
"entity_type"= "VirtualMachine"
"filter"= "host.name like vse*"
}
$url = $baseurl + "/api/ni/search"
$filter = Invoke-RestMethod -Method POST -Uri $url -Body ($body | ConvertTo-Json) -ContentType "application/json" -Headers $headers
$filter.results
Does anybody knows how to convert a search or know where to find that kind of information?