From 13514258255c2859845618d4db2f2edccb4fefe7 Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 8 Oct 2024 12:36:56 +0200 Subject: [PATCH 1/2] Fix Get-LicensedProducts Correct parameter name --- PSAYX.psd1 | 2 +- Public/API/License/Get-LicensedProducts.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PSAYX.psd1 b/PSAYX.psd1 index abf22f5..7c7492c 100644 --- a/PSAYX.psd1 +++ b/PSAYX.psd1 @@ -3,7 +3,7 @@ # # Generated by: Florian Carrier # -# Generated on: 07/10/2024 +# Generated on: 08/10/2024 # @{ diff --git a/Public/API/License/Get-LicensedProducts.ps1 b/Public/API/License/Get-LicensedProducts.ps1 index 1f080c1..77a8f6f 100644 --- a/Public/API/License/Get-LicensedProducts.ps1 +++ b/Public/API/License/Get-LicensedProducts.ps1 @@ -10,7 +10,7 @@ function Get-LicensedProducts { File name: Get-LicensedProducts.ps1 Author: Florian Carrier Creation date: 2024-08-22 - Last modified: 2024-08-22 + Last modified: 2024-10-08 .LINK https://us1.alteryxcloud.com/license-portal/api/swagger-ui/index.html @@ -43,7 +43,7 @@ function Get-LicensedProducts { Write-Log -Type "DEBUG" -Message $MyInvocation.MyCommand.Name } Process { - $Products = Invoke-AlteryxLicenseAPI -Token $AccessToken -Endpoint "v1/products" -AccountID $AccountID + $Products = Invoke-AlteryxLicenseAPI -Token $Token -Endpoint "v1/products" -AccountID $AccountID return ($Products | ConvertFrom-Json) } } \ No newline at end of file From 36ced64d25afbac8b477415e0135cd5ab951cc5c Mon Sep 17 00:00:00 2001 From: Florian Carrier Date: Tue, 8 Oct 2024 13:15:07 +0200 Subject: [PATCH 2/2] Add Designer and IS support --- PSAYX.psd1 | 2 +- Public/API/License/Get-LatestRelease.ps1 | 84 ++++++++++++++++-------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/PSAYX.psd1 b/PSAYX.psd1 index 7c7492c..878019d 100644 --- a/PSAYX.psd1 +++ b/PSAYX.psd1 @@ -12,7 +12,7 @@ RootModule = 'PSAYX.psm1' # Version number of this module. -ModuleVersion = '1.1.0' +ModuleVersion = '1.1.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/Public/API/License/Get-LatestRelease.ps1 b/Public/API/License/Get-LatestRelease.ps1 index adc782d..cab5ac2 100644 --- a/Public/API/License/Get-LatestRelease.ps1 +++ b/Public/API/License/Get-LatestRelease.ps1 @@ -10,7 +10,7 @@ function Get-LatestRelease { File name: Get-LatestRelease.ps1 Author: Florian Carrier Creation date: 2024-09-03 - Last modified: 2024-09-04 + Last modified: 2024-10-08 .LINK https://us1.alteryxcloud.com/license-portal/api/swagger-ui/index.html @@ -81,38 +81,68 @@ function Get-LatestRelease { # Parse release date $Response.Add("Date", $Release.releaseDate) # Fetch corresponding product installer download URL - if ($Patch) { - $Product = "$ProductID Patch" - } else { - $Product = $ProductID + switch ($ProductID) { + "Alteryx Designer" { + if ($Patch) { + $Product = "$ProductID (Admin version) Patch" + } else { + $Product = "$ProductID (Admin version)" + } + } + "Alteryx Server" { + if ($Patch) { + $Product = "$ProductID Patch" + } else { + $Product = $ProductID + } + } + "Alteryx Intelligence Suite" { + $Product = "$ProductID (Admin)" + } + "Data Packages" { + # TODO handle asynchronous release cycle & demographic packages + $Product = $ProductID.Replace("Spatial", "Location Insights") + } + default { + Write-Log -Type "WARN" -Message "$ProductID is not (yet) supported" + $Product = $ProductID + } } $Installer = Get-AlteryxProductEditions -AccountID $AccountID -Token $Token -ReleaseID $Release.id | Where-Object -Property "description" -EQ -Value $Product # Parse file name - if ((Split-Path -Path $Installer.downloadLink -Leaf) -match '(.+?\.exe)') { - $FileName = $matches[1] - } else { - Write-Log -Type "WARN" -Message "Unable to parse file name" - $FileName = $Null - } - $Response.Add("FileName", $FileName) - # Parse complete version number - if ($Installer.downloadLink -match '_(\d+\.\d+(\.\d+)?(\.\d+)?(\.\d+)?)\.exe') { - $ParsedVersion = $matches[1] - # Hotfix for messed up patch version formatting - if ($Patch) { - $PatchVersion = Select-String -InputObject $ParsedVersion -Pattern '(\d+\.\d+\.\d+)(?:\.\d+)(\.\d+)' -AllMatches - $Version = [System.String]::Concat($PatchVersion.Matches.Groups[1].Value, $PatchVersion.Matches.Groups[2].Value) + try { + if ((Split-Path -Path $Installer.downloadLink -Leaf) -match '(.+?\.exe)') { + $FileName = $matches[1] } else { - $Version = $ParsedVersion + Write-Log -Type "WARN" -Message "Unable to parse file name" + $FileName = $Null } - } else { - $Version = $Release.version + $Response.Add("FileName", $FileName) + # Parse complete version number + if ($Installer.downloadLink -match '_(\d+\.\d+(\.\d+)?(\.\d+)?(\.\d+)?)\.exe') { + $ParsedVersion = $matches[1] + # Hotfix for messed up patch version formatting + if ($Patch) { + $PatchVersion = Select-String -InputObject $ParsedVersion -Pattern '(\d+\.\d+\.\d+)(?:\.\d+)(\.\d+)' -AllMatches + $Version = [System.String]::Concat($PatchVersion.Matches.Groups[1].Value, $PatchVersion.Matches.Groups[2].Value) + } else { + $Version = $ParsedVersion + } + } else { + $Version = $Release.version + } + $Response.Add("Version", $Version) + # Expose direct download link + $Response.Add("URL", $Installer.downloadLink) + # Return formatted response object + Write-Log -Type "DEBUG" -Message $Response + } + catch { + Write-Log -Type "ERROR" -Message "Failed to fetch latest release of $ProductID" + $Response = $null } - $Response.Add("Version", $Version) - # Expose direct download link - $Response.Add("URL", $Installer.downloadLink) - # Return formatted response object - Write-Log -Type "DEBUG" -Message $Response + } + End { return $Response } } \ No newline at end of file