Skip to content

Commit 8460632

Browse files
authored
Merge pull request #4 from Akaizoku/develop
1.1.1
2 parents 4058c97 + 36ced64 commit 8460632

File tree

3 files changed

+61
-31
lines changed

3 files changed

+61
-31
lines changed

PSAYX.psd1

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Florian Carrier
55
#
6-
# Generated on: 07/10/2024
6+
# Generated on: 08/10/2024
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'PSAYX.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.1.0'
15+
ModuleVersion = '1.1.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

Public/API/License/Get-LatestRelease.ps1

+57-27
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function Get-LatestRelease {
1010
File name: Get-LatestRelease.ps1
1111
Author: Florian Carrier
1212
Creation date: 2024-09-03
13-
Last modified: 2024-09-04
13+
Last modified: 2024-10-08
1414
1515
.LINK
1616
https://us1.alteryxcloud.com/license-portal/api/swagger-ui/index.html
@@ -81,38 +81,68 @@ function Get-LatestRelease {
8181
# Parse release date
8282
$Response.Add("Date", $Release.releaseDate)
8383
# Fetch corresponding product installer download URL
84-
if ($Patch) {
85-
$Product = "$ProductID Patch"
86-
} else {
87-
$Product = $ProductID
84+
switch ($ProductID) {
85+
"Alteryx Designer" {
86+
if ($Patch) {
87+
$Product = "$ProductID (Admin version) Patch"
88+
} else {
89+
$Product = "$ProductID (Admin version)"
90+
}
91+
}
92+
"Alteryx Server" {
93+
if ($Patch) {
94+
$Product = "$ProductID Patch"
95+
} else {
96+
$Product = $ProductID
97+
}
98+
}
99+
"Alteryx Intelligence Suite" {
100+
$Product = "$ProductID (Admin)"
101+
}
102+
"Data Packages" {
103+
# TODO handle asynchronous release cycle & demographic packages
104+
$Product = $ProductID.Replace("Spatial", "Location Insights")
105+
}
106+
default {
107+
Write-Log -Type "WARN" -Message "$ProductID is not (yet) supported"
108+
$Product = $ProductID
109+
}
88110
}
89111
$Installer = Get-AlteryxProductEditions -AccountID $AccountID -Token $Token -ReleaseID $Release.id | Where-Object -Property "description" -EQ -Value $Product
90112
# Parse file name
91-
if ((Split-Path -Path $Installer.downloadLink -Leaf) -match '(.+?\.exe)') {
92-
$FileName = $matches[1]
93-
} else {
94-
Write-Log -Type "WARN" -Message "Unable to parse file name"
95-
$FileName = $Null
96-
}
97-
$Response.Add("FileName", $FileName)
98-
# Parse complete version number
99-
if ($Installer.downloadLink -match '_(\d+\.\d+(\.\d+)?(\.\d+)?(\.\d+)?)\.exe') {
100-
$ParsedVersion = $matches[1]
101-
# Hotfix for messed up patch version formatting
102-
if ($Patch) {
103-
$PatchVersion = Select-String -InputObject $ParsedVersion -Pattern '(\d+\.\d+\.\d+)(?:\.\d+)(\.\d+)' -AllMatches
104-
$Version = [System.String]::Concat($PatchVersion.Matches.Groups[1].Value, $PatchVersion.Matches.Groups[2].Value)
113+
try {
114+
if ((Split-Path -Path $Installer.downloadLink -Leaf) -match '(.+?\.exe)') {
115+
$FileName = $matches[1]
105116
} else {
106-
$Version = $ParsedVersion
117+
Write-Log -Type "WARN" -Message "Unable to parse file name"
118+
$FileName = $Null
107119
}
108-
} else {
109-
$Version = $Release.version
120+
$Response.Add("FileName", $FileName)
121+
# Parse complete version number
122+
if ($Installer.downloadLink -match '_(\d+\.\d+(\.\d+)?(\.\d+)?(\.\d+)?)\.exe') {
123+
$ParsedVersion = $matches[1]
124+
# Hotfix for messed up patch version formatting
125+
if ($Patch) {
126+
$PatchVersion = Select-String -InputObject $ParsedVersion -Pattern '(\d+\.\d+\.\d+)(?:\.\d+)(\.\d+)' -AllMatches
127+
$Version = [System.String]::Concat($PatchVersion.Matches.Groups[1].Value, $PatchVersion.Matches.Groups[2].Value)
128+
} else {
129+
$Version = $ParsedVersion
130+
}
131+
} else {
132+
$Version = $Release.version
133+
}
134+
$Response.Add("Version", $Version)
135+
# Expose direct download link
136+
$Response.Add("URL", $Installer.downloadLink)
137+
# Return formatted response object
138+
Write-Log -Type "DEBUG" -Message $Response
139+
}
140+
catch {
141+
Write-Log -Type "ERROR" -Message "Failed to fetch latest release of $ProductID"
142+
$Response = $null
110143
}
111-
$Response.Add("Version", $Version)
112-
# Expose direct download link
113-
$Response.Add("URL", $Installer.downloadLink)
114-
# Return formatted response object
115-
Write-Log -Type "DEBUG" -Message $Response
144+
}
145+
End {
116146
return $Response
117147
}
118148
}

Public/API/License/Get-LicensedProducts.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function Get-LicensedProducts {
1010
File name: Get-LicensedProducts.ps1
1111
Author: Florian Carrier
1212
Creation date: 2024-08-22
13-
Last modified: 2024-08-22
13+
Last modified: 2024-10-08
1414
1515
.LINK
1616
https://us1.alteryxcloud.com/license-portal/api/swagger-ui/index.html
@@ -43,7 +43,7 @@ function Get-LicensedProducts {
4343
Write-Log -Type "DEBUG" -Message $MyInvocation.MyCommand.Name
4444
}
4545
Process {
46-
$Products = Invoke-AlteryxLicenseAPI -Token $AccessToken -Endpoint "v1/products" -AccountID $AccountID
46+
$Products = Invoke-AlteryxLicenseAPI -Token $Token -Endpoint "v1/products" -AccountID $AccountID
4747
return ($Products | ConvertFrom-Json)
4848
}
4949
}

0 commit comments

Comments
 (0)