Product: Stratusphere
Product Version: 6.6.2.x
Expires on: 365 days from publish date.
Updated: Nov. 08, 2023
Files: BatchReportVWNew2.ps1.txt & UXTestURLsv2New2.txt
Problem:
Run multiple API queries against HUB deployment.
Summary:
Stratusphere allow access to build custom API queries through our API Builder functionality. These API's later can be extrapolated and used within a variety of tools for automation.
How to access API Builder:
- Building Stratusphere API Queries Graphically (liquidware.com)
- Locating Stratusphere API Builder 1.0 (liquidware.com)
Legacy Article: How to use the Liquidware Stratusphere UX API with PowerShell - Workspace Guru (workspace-guru.com)
Instruction:
Liquidware Stratusphere UX makes it simple to use out API. Our product come with a built-in API Builder. To start you will need to provide access to Stratusphere API.
- Sign in to the Stratusphere UX Administration console (FQDN of the HUB)
- Click on Hub Administration Configuration. Select Other Settings.
- Find API Client IPs and enter the IP address from which you want to run your script.
*Beware that this IP address can now access the data and API without a password. Preferred Method:: Configure a user account to access the API and use authentication.
Navigate to the web browser and enter the following url "https://YOURHUBADDRESS/apibuilder/#/" or choose API Builder from the drop down and access the builder through the webui.
This is your landing page where you will build and construct you json API queries:
On the right hand side you can see the query taking shape in real time in JSON. And you see the API URL this is the complete URL you can use to get this data. Lets make a note of the "json=" part of this url.
While this is great, it can become cumbersome having to copy and paste the url individually to run multiple API queries you might desire. Below is a script that helps you automate this process with the help of an input file and a for loop script. It is available as an attachment along with a sample input file below.
Sample Script:
You will need to change the script from: BatchReportVWNew2.ps1.txt to BatchReportVWNew2.ps1
Requirements:
1. Set you $hub variable to the FQDN of your HUB with the JSON tail string appended to the end.
2. Set your $Reportlistpath variable to the location of where the input file may reside.
3. Set your $ReportOutputFolder variable to the out file and its location.
### Set Cert Trust ###
if ("TrustAllCertsPolicy" -as [type]) {} else {
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12,Tls13'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
}
###
## Prompt the user to input the URL before the loop
#$add = Read-Host "Enter the URL for all iterations"
$hub = "https://ux-demo.liquidware.com/lwl/api?json="
$Reportlistpath = "C:\Liquidware_SQL\Published App REST API\UXTestURLsv2New2.txt"
$Reports = Get-Content -Path $Reportlistpath
$ReportOutputFolder = "C:\Liquidware_SQL\Published App REST API\Results Files"
# Loop through each URL in the list
for ($index = 0; $index -lt $Reports.Count; $index++) {
$json = $Reports[$index]
# Write-Host "URL: $url"
# Generate a unique filename for each iteration
$outputPath = Join-Path -Path $ReportOutputFolder -ChildPath ("Report_$index.csv")
# Construct the URL
$add = $hub + $json
# $add = "https://ux-demo.liquidware.com/lwl/api?json=" + $json
try {
# Download the CSV file from the URL
Invoke-WebRequest -URI $add -OutFile $outputPath
# Invoke-WebRequest -URI $url -OutFile $outputPath
Write-Host "File downloaded: $outputPath"
} catch {
Write-Host "Error downloading file: $_"
}
}
Sample Input File:
Requirements:
1. The input file will only require you to copy and paste only the curly bracket component of the json string from the API Builder in the format below.
2. Make sure each line does not have return characters and is set as an line items for the script to properly run.
{"inspector":"2","basis":"date","date":"today","columns":"user_count,session_count,sent_packet_loss_percent,node_count,record_count,up_time_percent,sum_cid_seconds,avg_cid_seconds,receive_packet_loss_percent,session_idle_min","percents":"1","units":"1","output":"1","stats_as_cols":"0","output_name":"Test_Published_APP.csv","delimeter":"","header":"0","csv_eof":"","escape_dbq":""}
{"inspector":"2","basis":"date,published_app","date":"last 30 days","columns":"user_count,node_count,stat_avg_round_trip_latency_avg_ms,session_count,sent_packet_loss_percent,receive_packet_loss_percent,record_count,session_idle_min,avg_cid_seconds,sum_cid_seconds,up_time_percent,stat_avg_session_duration,stat_min_session_duration,stat_max_session_duration,stat_avg_session_disconnect_percent,stat_min_session_disconnect_percent,stat_max_session_disconnect_percent,stat_stddev_session_disconnect_percent,stat_avg_avg_connected_time_percent,stat_min_avg_connected_time_percent,stat_max_avg_connected_time_percent,stat_stddev_avg_connected_time_percent,avg_connected_time_percent,stat_avg_avg_connected_active_percent,stat_min_avg_connected_active_percent,stat_max_avg_connected_active_percent,stat_stddev_avg_connected_active_percent,stat_avg_avg_idle_time_percent,stat_max_avg_idle_time_percent,stat_stddev_avg_idle_time_percent,stat_avg_avg_io_total_kbps,stat_min_avg_io_total_kbps,stat_max_avg_io_total_kbps,stat_stddev_avg_io_total_kbps,avg_img_total_kbps,stat_avg_avg_img_total_kbps,stat_min_avg_img_total_kbps,stat_stddev_avg_img_total_kbps,stat_avg_avg_audio_total_kbps,stat_min_avg_audio_total_kbps,stat_max_avg_audio_total_kbps,stat_stddev_avg_audio_total_kbps,stat_avg_avg_usb_total_kbps,stat_min_avg_usb_total_kbps,stat_max_avg_usb_total_kbps,stat_stddev_avg_usb_total_kbps,stat_avg_sum_io_total_kbyte,stat_min_sum_io_total_kbyte,stat_max_sum_io_total_kbyte,stat_stddev_sum_io_total_kbyte,stat_avg_sum_img_total_kbyte,stat_min_sum_img_total_kbyte,stat_max_sum_img_total_kbyte,stat_stddev_sum_img_total_kbyte,stat_avg_sum_audio_total_kbyte,stat_min_sum_audio_total_kbyte,stat_max_sum_audio_total_kbyte,stat_stddev_sum_audio_total_kbyte,stat_avg_sum_usb_total_kbyte,stat_min_sum_usb_total_kbyte,stat_max_sum_usb_total_kbyte,stat_stddev_sum_usb_total_kbyte,round_trip_latency_avg_ms,stat_min_round_trip_latency_avg_ms,stat_max_round_trip_latency_avg_ms,stat_stddev_round_trip_latency_avg_ms,stat_avg_min_img_quality_avg_percent,stat_min_min_img_quality_avg_percent,stat_max_min_img_quality_avg_percent,stat_stddev_min_img_quality_avg_percent,stat_avg_sent_packet_loss_percent,stat_min_sent_packet_loss_percent,stat_max_sent_packet_loss_percent,stat_stddev_sent_packet_loss_percent,stat_avg_receive_packet_loss_percent,stat_min_receive_packet_loss_percent,stat_max_receive_packet_loss_percent,stat_stddev_receive_packet_loss_percent,stat_avg_total_fps,stat_min_total_fps,stat_max_total_fps,stat_stddev_total_fps,stat_avg_graphic_info_graphic_fps_avg,stat_min_graphic_info_graphic_fps_avg,stat_max_graphic_info_graphic_fps_avg,stat_stddev_graphic_info_graphic_fps_avg,stat_avg_d3d_info_d3d_fps_avg,stat_min_d3d_info_d3d_fps_avg,stat_max_d3d_info_d3d_fps_avg,stat_stddev_d3d_info_d3d_fps_avg,stat_avg_thinwire_info_thinware_fps_avg,stat_min_thinwire_info_thinware_fps_avg,stat_max_thinwire_info_thinware_fps_avg,stat_stddev_thinwire_info_thinware_fps_avg,stat_avg_rfx_compression,stat_min_rfx_compression,stat_max_rfx_compression,stat_stddev_rfx_compression,stat_avg_total_errors,stat_min_total_errors,stat_max_total_errors,stat_stddev_total_errors,stat_avg_node_count,stat_min_node_count,stat_max_node_count,stat_stddev_node_count,stat_avg_user_count,stat_min_user_count,stat_max_user_count,stat_stddev_user_count,stat_min_session_count,stat_max_session_count,stat_stddev_session_count","output":"1","stats_as_cols":"0","output_name":"Published_app_Sept.csv","delimeter":"0"}
Execution
Proceed to launch the script via PowerShell on your desktop.