Actually i need get the number of licenses allocated in each tenant with pruporses of migration from onprem to Cloud, i work for a company wich have entrepise license and they dont want use the migration tool and actually i need to know the number licenses allocated in each of the tenants.
I try with the API orchestrator but only show folders,assets, robots, al most everything realtion with tenant level but no show in wich part i cand find this information.
Imports System.Net
Imports System.IO
Imports Newtonsoft.Json.Linq
Const orchestratorUrl As String = "https://<orchestrator_instance>/"
Const clientId As String = "<client_id>"
Const clientSecret As String = "<client_secret>"
Dim authUrl As String = orchestratorUrl & "identity/connect/token"
Dim authData As String = String.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=orchestrator", clientId, clientSecret)
Dim authRequest As HttpWebRequest = DirectCast(WebRequest.Create(authUrl), HttpWebRequest)
authRequest.Method = "POST"
authRequest.ContentType = "application/x-www-form-urlencoded"
Dim authStream As Stream = authRequest.GetRequestStream()
Dim authWriter As New StreamWriter(authStream)
authWriter.Write(authData)
authWriter.Flush()
authWriter.Close()
Dim authResponse As HttpWebResponse = DirectCast(authRequest.GetResponse(), HttpWebResponse)
Dim authResponseStream As Stream = authResponse.GetResponseStream()
Dim authStreamReader As New StreamReader(authResponseStream)
Dim authResponseJson As JObject = JObject.Parse(authStreamReader.ReadToEnd())
Dim accessToken As String = authResponseJson.GetValue("access_token").ToString()
Dim usageUrl As String = orchestratorUrl & "licensing/usage"
Dim usageRequest As HttpWebRequest = DirectCast(WebRequest.Create(usageUrl), HttpWebRequest)
usageRequest.Method = "GET"
usageRequest.Headers.Add("Authorization", "Bearer " & accessToken)
Dim usageResponse As HttpWebResponse = DirectCast(usageRequest.GetResponse(), HttpWebResponse)
Dim usageResponseStream As Stream = usageResponse.GetResponseStream()
Dim usageStreamReader As New StreamReader(usageResponseStream)
Dim usageResponseJson As JArray = JArray.Parse(usageStreamReader.ReadToEnd())
For Each tenant As JObject In usageResponseJson
Dim tenantName As String = tenant.GetValue("tenantName").ToString()
Dim allocated As Integer = tenant.GetValue("licensesAllocated").ToObject(Of Integer)()
Dim used As Integer = tenant.GetValue("licensesUsed").ToObject(Of Integer)()
Dim available As Integer = allocated - used
Console.WriteLine("Tenant: " & tenantName & ", Allocated: " & allocated & ", Used: " & used & ", Available: " & available)
Next
wow you are awesome, one question this code should I try it in the invoke code of Vb.net ?
Or where I could test it since I was currently using postmant for API consumption.