How to get License feature usage using REST API of AutoPass License Server (APLS)?

  • KM03807635
  • 27-Apr-2021
  • 27-Apr-2021

Summary

APLS REST API Get License feature usage

Question

How to get License feature usage using REST API of AutoPass License Server (APLS)?

Answer

Below is a VBScript code version of a Java code example included on API documentation.

Note: The following script is provided for example purposes only. It is not supported by Micro Focus International plc.

Highlights:

  • Searches for Unified Functional Testing Concurrent, with license feature ID 10594
  • Search range is from 1year ago to today
  • It request the response in JSON format
  •  

DISCLAIMER OF WARRANTY
The example software is experimental and is provided as a courtesy, free of charge, "AS-IS" by Micro Focus International plc. Micro Focus shall have no obligation to maintain or support this software. MICRO FOCUS MAKES NO EXPRESS OR IMPLIED WARRANTY OF ANY KIND REGARDING THIS SOFTWARE. MICRO FOCUSSHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON CONTRACT, TORT OR ANY OTHER LEGAL THEORY, IN CONNECTION WITH OR ARISING OUT OF THE FURNISHING, PERFORMANCE OR USE OF THIS SOFTWARE

dim featureId, featureVersion, startTime, endTime, username, password, URL, restReq:
featureId = "10594" ' UFT Concurrent license feature
featureVersion = "1"

'The Start limit/boundary seaching range, using Epoch time, for 1 year ago from today/now
startTime = DateDiff("s", "01/01/1970 00:00:00", DateAdd("yyyy", -1, Now()))

'The End limit/boundary searching range, which is today/now

endTime = DateDiff("s", "01/01/1970 00:00:00", Now()) 'Epock time of today/now

username = "APLS_Username"
password = "APLS_Password"
URL = "
https://localhost:5814/autopass/wsservices/v9.3/usage/feature?featureId="&featureId&"&featureVersion="&featureVersion&"&startTime="&startTime&"&endTime="&endTime
'wscript.echo URL
Set restReq = CreateObject("MSXML2.ServerXMLHTTP")
restReq.setOption 2, 13056
restReq.open "GET", URL, false
restReq.setRequestHeader "Accept", "application/json"
restReq.setRequestHeader "Authorization", "Basic " & Base64Encode(username & ":" & password)
restReq.send
WScript.echo restReq.responseText

Function Base64Encode(inData)
'rfc1521
'2001 Antonin Foller, Motobit Software, 
http://Motobit.cz
 
Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim cOut, sOut, I
 
'For each group of 3 bytes
 
For I = 1 To Len(inData) Step 3
Dim nGroup, pOut, sGroup
 
'Create one long from this 3 bytes.
 
nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _
&H100 * MyASC(Mid(inData, I + 1, 1)) + MyASC(Mid(inData, I + 2, 1))
 
'Oct splits the long To 8 groups with 3 bits
 
nGroup = Oct(nGroup)
 
'Add leading zeros
 
nGroup = String(8 - Len(nGroup), "0") & nGroup
 
'Convert To base64
 
pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)
 
'Add the part To OutPut string
 
sOut = sOut + pOut
 
'Add a new line For Each 76 chars In dest (76*3/4 = 57)
'If (I + 2) Mod 57 = 0 Then sOut = sOut + vbCrLf
 
Next
Select Case Len(inData) Mod 3
Case 1: '8 bit final
 
sOut = Left(sOut, Len(sOut) - 2) + "=="
Case 2: '16 bit final
 
sOut = Left(sOut, Len(sOut) - 1) + "="
End Select
Base64Encode = sOut
End Function
 
Function MyASC(OneChar)
If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)
End Function