diff --git a/d365fo.tools/functions/get-d365lcssharedassetfile.ps1 b/d365fo.tools/functions/get-d365lcssharedassetfile.ps1 index de207a75..ac8ff290 100644 --- a/d365fo.tools/functions/get-d365lcssharedassetfile.ps1 +++ b/d365fo.tools/functions/get-d365lcssharedassetfile.ps1 @@ -93,6 +93,11 @@ .PARAMETER Latest Instruct the cmdlet to only fetch the latest file from the Asset Library from LCS + .PARAMETER SkipSasGeneration + Instruct the cmdlet to only fetch the meta data from the asset file (entry) + + This is to speed up the listing of entries, in some of the larger areas in the Shared Asset Library + .PARAMETER RetryTimeout The retry timeout, before the cmdlet should quit retrying based on the 429 status code @@ -200,6 +205,18 @@ The default values can be configured using Set-D365LcsApiConfig. + .EXAMPLE + PS C:\> Get-D365LcsSharedAssetFile -FileType SoftwareDeployablePackage -SkipSasGeneration + + This will list all Software Deployable Packages in the shared asset library, but skip the SAS / Download generation + It will search for SoftwareDeployablePackage by using the FileType parameter. + + This will increase the speed getting the list of assets - but you will not get a downloadable link. + + All default values will come from the configuration available from Get-D365LcsApiConfig. + + The default values can be configured using Set-D365LcsApiConfig. + .LINK Get-D365LcsApiConfig @@ -246,6 +263,8 @@ function Get-D365LcsSharedAssetFile { [Alias('GetLatest')] [switch] $Latest, + [switch] $SkipSasGeneration, + [Timespan] $RetryTimeout = "00:00:00", [switch] $EnableException @@ -257,14 +276,26 @@ function Get-D365LcsSharedAssetFile { $BearerToken = "Bearer $BearerToken" } - $assets = Get-LcsSharedAssetFile -BearerToken $BearerToken -LcsApiUri $LcsApiUri -FileType $([int]$FileType) -RetryTimeout $RetryTimeout + $colTemp = Get-LcsSharedAssetFile -BearerToken $BearerToken -LcsApiUri $LcsApiUri -FileType $([int]$FileType) -RetryTimeout $RetryTimeout + + $assets = $colTemp | Select-PSFObject -TypeName "D365FO.TOOLS.Lcs.Asset.File" -Property "*", "Id as AssetId", ` + @{Name = "ProductVersion"; Expression = { [System.Version]$($_.Name.Split(" ") | Select-Object -Last 1 ) } }, ` + @{Name = "ProductBuild"; Expression = { [System.Version]$($_.FileName.Split("_") | Select-Object -First 1 -Skip 1) } } if (Test-PSFFunctionInterrupt) { return } if ($Latest) { $latestSharedAsset = $assets | Sort-Object -Property "ModifiedDate" -Descending | Select-Object -First 1 - $latestSharedAsset = Get-LcsFileAsset -BearerToken $BearerToken -ProjectId $ProjectId -LcsApiUri $LcsApiUri -AssetId $latestSharedAsset.Id -RetryTimeout $RetryTimeout - $latestSharedAsset | Select-PSFObject -TypeName "D365FO.TOOLS.Lcs.Asset.File" "*", "Id as AssetId" + + if ($SkipSasGeneration -eq $false) { + $latestSharedAsset = Get-LcsFileAsset -BearerToken $BearerToken -ProjectId $ProjectId -LcsApiUri $LcsApiUri -AssetId $latestSharedAsset.Id -RetryTimeout $RetryTimeout + $latestSharedAsset | Select-PSFObject -TypeName "D365FO.TOOLS.Lcs.Asset.File" -Property "*", "Id as AssetId", ` + @{Name = "ProductVersion"; Expression = { [System.Version]$($_.Name.Split(" ") | Select-Object -Last 1 ) } }, ` + @{Name = "ProductBuild"; Expression = { [System.Version]$($_.FileName.Split("_") | Select-Object -First 1 -Skip 1) } } + } + else { + $latestSharedAsset + } } else { foreach ($obj in $assets) { @@ -274,8 +305,15 @@ function Get-D365LcsSharedAssetFile { if ($obj.FileDescription -NotLike $AssetDescription) { continue } if ($obj.Id -NotLike $AssetId) { continue } - $obj = Get-LcsFileAsset -BearerToken $BearerToken -ProjectId $ProjectId -LcsApiUri $LcsApiUri -AssetId $obj.Id -RetryTimeout $RetryTimeout - $obj | Select-PSFObject -TypeName "D365FO.TOOLS.Lcs.Asset.File" "*", "Id as AssetId" + if ($SkipSasGeneration -eq $false) { + $obj = Get-LcsFileAsset -BearerToken $BearerToken -ProjectId $ProjectId -LcsApiUri $LcsApiUri -AssetId $obj.Id -RetryTimeout $RetryTimeout + $obj | Select-PSFObject -TypeName "D365FO.TOOLS.Lcs.Asset.File" -Property "*", "Id as AssetId", ` + @{Name = "ProductVersion"; Expression = { [System.Version]$($_.Name.Split(" ") | Select-Object -Last 1 ) } }, ` + @{Name = "ProductBuild"; Expression = { [System.Version]$($_.FileName.Split("_") | Select-Object -First 1 -Skip 1) } } + } + else { + $obj + } } } diff --git a/d365fo.tools/internal/tepp/assignment.ps1 b/d365fo.tools/internal/tepp/assignment.ps1 index 9b7e532a..6b7f4237 100644 --- a/d365fo.tools/internal/tepp/assignment.ps1 +++ b/d365fo.tools/internal/tepp/assignment.ps1 @@ -14,7 +14,9 @@ Register-PSFTeppArgumentCompleter -Command Get-D365LcsAssetValidationStatus -Par Register-PSFTeppArgumentCompleter -Command Get-D365LcsDatabaseBackups -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls Register-PSFTeppArgumentCompleter -Command Get-D365LcsDatabaseOperationStatus -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls Register-PSFTeppArgumentCompleter -Command Get-D365LcsDeploymentStatus -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls - +Register-PSFTeppArgumentCompleter -Command Get-D365LcsEnvironmentHistory -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls +Register-PSFTeppArgumentCompleter -Command Get-D365LcsEnvironmentMetadata -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls +Register-PSFTeppArgumentCompleter -Command Get-D365LcsSharedAssetFile -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls Register-PSFTeppArgumentCompleter -Command Invoke-D365LcsDatabaseExport -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls Register-PSFTeppArgumentCompleter -Command Invoke-D365LcsDatabaseRefresh -Parameter LcsApiUri -Name d365fo.tools.lcs.api.urls diff --git a/d365fo.tools/tests/functions/Get-D365LcsSharedAssetFile.Tests.ps1 b/d365fo.tools/tests/functions/Get-D365LcsSharedAssetFile.Tests.ps1 index 1ef9a51a..d1ee08a8 100644 --- a/d365fo.tools/tests/functions/Get-D365LcsSharedAssetFile.Tests.ps1 +++ b/d365fo.tools/tests/functions/Get-D365LcsSharedAssetFile.Tests.ps1 @@ -141,6 +141,19 @@ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } + It 'Should have the expected parameter SkipSasGeneration' { + $parameter = (Get-Command Get-D365LcsSharedAssetFile).Parameters['SkipSasGeneration'] + $parameter.Name | Should -Be 'SkipSasGeneration' + $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter + $parameter.IsDynamic | Should -Be $False + $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' + $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' + $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False + $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 + $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False + $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False + $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False + } It 'Should have the expected parameter RetryTimeout' { $parameter = (Get-Command Get-D365LcsSharedAssetFile).Parameters['RetryTimeout'] $parameter.Name | Should -Be 'RetryTimeout' @@ -172,7 +185,7 @@ Describe "Testing parameterset __AllParameterSets" { <# __AllParameterSets - - __AllParameterSets -ProjectId -FileType -AssetName -AssetVersion -AssetFilename -AssetDescription -AssetId -BearerToken -LcsApiUri -Latest -RetryTimeout -EnableException + __AllParameterSets -ProjectId -FileType -AssetName -AssetVersion -AssetFilename -AssetDescription -AssetId -BearerToken -LcsApiUri -Latest -SkipSasGeneration -RetryTimeout -EnableException #> } diff --git a/docs/Get-D365LcsSharedAssetFile.md b/docs/Get-D365LcsSharedAssetFile.md index bc3746ba..085e3c69 100644 --- a/docs/Get-D365LcsSharedAssetFile.md +++ b/docs/Get-D365LcsSharedAssetFile.md @@ -15,8 +15,8 @@ Get information for assets from the shared asset library of LCS ``` Get-D365LcsSharedAssetFile [[-ProjectId] ] [[-FileType] ] [[-AssetName] ] [[-AssetVersion] ] [[-AssetFilename] ] [[-AssetDescription] ] [[-AssetId] ] - [[-BearerToken] ] [[-LcsApiUri] ] [-Latest] [[-RetryTimeout] ] [-EnableException] - [] + [[-BearerToken] ] [[-LcsApiUri] ] [-Latest] [-SkipSasGeneration] [[-RetryTimeout] ] + [-EnableException] [] ``` ## DESCRIPTION @@ -125,6 +125,20 @@ All default values will come from the configuration available from Get-D365LcsAp The default values can be configured using Set-D365LcsApiConfig. +### EXAMPLE 9 +``` +Get-D365LcsSharedAssetFile -FileType SoftwareDeployablePackage -SkipSasGeneration +``` + +This will list all Software Deployable Packages in the shared asset library, but skip the SAS / Download generation +It will search for SoftwareDeployablePackage by using the FileType parameter. + +This will increase the speed getting the list of assets - but you will not get a downloadable link. + +All default values will come from the configuration available from Get-D365LcsApiConfig. + +The default values can be configured using Set-D365LcsApiConfig. + ## PARAMETERS ### -ProjectId @@ -346,6 +360,23 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -SkipSasGeneration +Instruct the cmdlet to only fetch the meta data from the asset file (entry) + +This is to speed up the listing of entries, in some of the larger areas in the Shared Asset Library + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -RetryTimeout The retry timeout, before the cmdlet should quit retrying based on the 429 status code