diff --git a/Evergreen/Shared/Get-VMwareAPIPath.ps1 b/Evergreen/Shared/Get-VMwareAPIPath.ps1 new file mode 100644 index 00000000..1c09df3d --- /dev/null +++ b/Evergreen/Shared/Get-VMwareAPIPath.ps1 @@ -0,0 +1,12 @@ +function Get-VMwareAPIPath { + [CmdletBinding(SupportsShouldProcess = $false)] + [OutputType("System.String")] + param ( + [Parameter(Mandatory = $false)] + [ValidateSet('products', 'dlg')] + [System.String] $Endpoint = "products" + ) + $ApiPath = "https://customerconnect.vmware.com/channel/public/api/v1.0/${Endpoint}" + Write-Verbose -Message "$($MyInvocation.MyCommand): Return $ApiPath" + return $ApiPath +} \ No newline at end of file diff --git a/Evergreen/Shared/Get-VMwareDLGDetailsQuery.ps1 b/Evergreen/Shared/Get-VMwareDLGDetailsQuery.ps1 new file mode 100644 index 00000000..45f41b0e --- /dev/null +++ b/Evergreen/Shared/Get-VMwareDLGDetailsQuery.ps1 @@ -0,0 +1,20 @@ +function Get-VMwareDLGDetailsQuery { + [OutputType("System.String")] + param ( + [Parameter(Mandatory = $true)] + [System.String] $DownloadGroup, + + [Parameter(Mandatory = $false)] + [System.String] $Locale = 'en_US' + ) + + $APIResource = 'details' + $queryParameters = @{ + locale = $Locale + downloadGroup = $DownloadGroup + } + $queryString = ($queryParameters.GetEnumerator() | ForEach-Object { "&$($_.Key)=$($_.Value)" }) -join '' + $DlgQuery = "$(Get-VMwareAPIPath -Endpoint 'dlg')/$($APIResource)?$($queryString.TrimStart('&'))" + Write-Verbose -Message "$($MyInvocation.MyCommand): $DlgQuery" + return $DlgQuery +} diff --git a/Evergreen/Shared/Get-VMwareProductDownload.ps1 b/Evergreen/Shared/Get-VMwareProductDownload.ps1 new file mode 100644 index 00000000..cc8227d3 --- /dev/null +++ b/Evergreen/Shared/Get-VMwareProductDownload.ps1 @@ -0,0 +1,41 @@ +function Get-VMwareProductDownload { + <# + .EXTERNALHELP Evergreen.VMware-help.xml + #> + param ( + [Parameter(Mandatory = $true, + Position = 0, + ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String[]] $Name + ) + + process { + foreach ($Product in $Name) { + $VMwareProduct = Get-VMwareProductList -Name $Product + $VMwareDLG = $VMwareProduct | Get-VMwareRelatedDLGList + + foreach ($Dlg in $VMwareDLG) { + $params = @{ + Uri = $(Get-VMwareDLGDetailsQuery -DownloadGroup $Dlg.code) + } + $DownloadFiles = $(Invoke-RestMethodWrapper @params).downloadFiles + + foreach ($File in $DownloadFiles) { + if ([System.String]::IsNullOrEmpty($File.title)) { + } + else { + $Result = [PSCustomObject]@{ + Version = $File.version + ReleaseDate = $([System.DateTime]::ParseExact($File.releaseDate, "yyyy-MM-dd", [System.Globalization.CultureInfo]::CurrentUICulture.DateTimeFormat)) + Md5 = $File.md5checksum + Type = Get-FileType -File $File.fileName + URI = "https://download3.vmware.com/software/$($Dlg.code)/$($File.fileName)" + } + Write-Output -InputObject $Result + } + } + } + } + } +} diff --git a/Evergreen/Shared/Get-VMwareProductList.ps1 b/Evergreen/Shared/Get-VMwareProductList.ps1 new file mode 100644 index 00000000..9a3c297e --- /dev/null +++ b/Evergreen/Shared/Get-VMwareProductList.ps1 @@ -0,0 +1,32 @@ +function Get-VMwareProductList { + <# + .EXTERNALHELP Evergreen.VMware-help.xml + #> + [CmdletBinding(SupportsShouldProcess = $false)] + param ( + [Parameter(Mandatory = $false)] + [System.String] $Name + ) + + $APIResource = 'getProductsAtoZ' + $params = @{ + Uri = "$(Get-VMwareAPIPath)/${APIResource}" + } + $WebResult = Invoke-RestMethodWrapper @params + + $FilteredProductList = $WebResult.productCategoryList.ProductList + if ($PSBoundParameters.ContainsKey('Name')) { + $FilteredProductList = $FilteredProductList | Where-Object -FilterScript { $_.Name -eq $Name } + } + + $Result = $FilteredProductList | ForEach-Object -Process { + $Action = $_.actions | Where-Object -FilterScript { $_.linkname -eq "Download Product" } + [PSCustomObject]@{ + Name = $_.Name + CategoryMap = $($Action.target -split '/')[-3] + ProductMap = $($Action.target -split '/')[-2] + VersionMap = $($Action.target -split '/')[-1] + } + } + Write-Output -InputObject $Result +} diff --git a/Evergreen/Shared/Get-VMwareRelatedDLGList.ps1 b/Evergreen/Shared/Get-VMwareRelatedDLGList.ps1 new file mode 100644 index 00000000..683a1718 --- /dev/null +++ b/Evergreen/Shared/Get-VMwareRelatedDLGList.ps1 @@ -0,0 +1,42 @@ +function Get-VMwareRelatedDLGList { + [CmdletBinding(SupportsShouldProcess = $false)] + param ( + [Parameter(Mandatory = $true, + Position = 0, + ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $CategoryMap, + + [Parameter(Mandatory = $true, + Position = 1, + ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $ProductMap, + + [Parameter(Mandatory = $true, + Position = 2, + ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [System.String] $VersionMap, + + [Parameter(Mandatory = $false)] + [ValidateSet('PRODUCT_BINARY', 'DRIVERS_TOOLS', 'OPEN_SOURCE', 'CUSTOM_ISO', 'ADDONS')] + [System.String] $DLGType = 'PRODUCT_BINARY' + ) + + process { + $APIResource = 'getRelatedDLGList' + $queryParameters = @{ + category = $CategoryMap + product = $ProductMap + version = $VersionMap + dlgType = $DLGType + } + $queryString = ( $queryParameters.GetEnumerator() | ForEach-Object { "&$($_.Key)=$($_.Value)" }) -join '' + $params = @{ + Uri = "$(Get-VMwareAPIPath)/$($APIResource)?$($queryString.TrimStart('&'))" + } + $WebResult = Invoke-RestMethodWrapper @params + Write-Output -InputObject $WebResult.dlgEditionsLists.dlgList + } +}