diff --git a/VSTeam.psd1 b/VSTeam.psd1
index 26fc8f00a..a831f7cf9 100644
--- a/VSTeam.psd1
+++ b/VSTeam.psd1
@@ -66,7 +66,6 @@
'types\cloudSubscriptions.ps1xml',
'types\repositories.ps1xml',
'types\policies.ps1xml',
- 'types\queues.ps1xml',
'types\releaseDefinitions.ps1xml',
'types\releases.ps1xml',
'types\serviceendpoints.ps1xml',
@@ -82,7 +81,6 @@
'formats\builds.format.ps1xml',
'formats\policyTypes.format.ps1xml',
'formats\profile.format.ps1xml',
- 'formats\queues.format.ps1xml',
'formats\serviceendpoints.format.ps1xml',
'formats\serviceendpointTypes.format.ps1xml',
'formats\team.format.ps1xml',
diff --git a/formats/queues.format.ps1xml b/formats/queues.format.ps1xml
deleted file mode 100644
index fde42eec1..000000000
--- a/formats/queues.format.ps1xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
- Team.Queue.TableView
-
- Team.Queue
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- id
-
-
- name
-
-
- poolName
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/formats/vsteamPSDrive.format.ps1xml b/formats/vsteamPSDrive.format.ps1xml
index cf64e8a54..5e5f928f2 100644
--- a/formats/vsteamPSDrive.format.ps1xml
+++ b/formats/vsteamPSDrive.format.ps1xml
@@ -1220,6 +1220,38 @@
+
+
+ Team.Provider.Queue.Table
+
+ Team.Provider.Queue
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DisplayMode
+
+
+ Name
+
+
+
+
+
+
+
Team.Provider.Pool.Table
@@ -1265,6 +1297,7 @@
Microsoft.PowerShell.SHiPS.SHiPSDirectory
Team.Account
Team.Pool
+ Team.Queues
Team.Pools
Team.Provider.Pools
Team.Builds
@@ -1306,6 +1339,7 @@
Microsoft.PowerShell.SHiPS.SHiPSDirectory
Team.Account
Team.Pool
+ Team.Queues
Team.Pools
Team.Builds
Team.BuildDefinitions
diff --git a/src/queues.psm1 b/src/queues.psm1
index eb3a9682e..5f5cdf5c5 100644
--- a/src/queues.psm1
+++ b/src/queues.psm1
@@ -4,15 +4,6 @@ Set-StrictMode -Version Latest
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$here\common.ps1"
-# Apply types to the returned objects so format and type files can
-# identify the object and act on it.
-function _applyTypesToQueue {
- param($item)
-
- $item.PSObject.TypeNames.Insert(0, 'Team.Queue')
- $item.pool.PSObject.TypeNames.Insert(0, 'Team.Pool')
-}
-
function Get-VSTeamQueue {
[CmdletBinding(DefaultParameterSetName = 'List')]
param(
@@ -38,20 +29,21 @@ function Get-VSTeamQueue {
$resp = _callAPI -ProjectName $ProjectName -Id $id -Area distributedtask -Resource queues `
-Version $([VSTeamVersions]::DistributedTask)
- _applyTypesToQueue -item $resp
+ $item = [VSTeamQueue]::new($resp, $ProjectName)
- Write-Output $resp
+ Write-Output $item
}
else {
$resp = _callAPI -ProjectName $projectName -Area distributedtask -Resource queues `
-QueryString @{ queueName = $queueName; actionFilter = $actionFilter } -Version $([VSTeamVersions]::DistributedTask)
- # Apply a Type Name so we can use custom format view and custom type extensions
+ $objs = @()
+
foreach ($item in $resp.value) {
- _applyTypesToQueue -item $item
+ $objs += [VSTeamQueue]::new($item, $ProjectName)
}
-
- Write-Output $resp.value
+
+ Write-Output $objs
}
}
}
diff --git a/src/teamspsdrive.ps1 b/src/teamspsdrive.ps1
index 85bb82abe..d0b22b4ce 100644
--- a/src/teamspsdrive.ps1
+++ b/src/teamspsdrive.ps1
@@ -274,6 +274,7 @@ class VSTeamProject : VSTeamDirectory {
return @(
[VSTeamBuildDefinitions]::new('Build Definitions', $this.Name),
[VSTeamBuilds]::new('Builds', $this.Name),
+ [VSTeamQueues]::new('Queues', $this.Name),
[VSTeamReleases]::new('Releases', $this.Name),
[VSTeamRepositories]::new('Repositories', $this.Name),
[VSTeamTeams]::new('Teams', $this.Name)
@@ -334,6 +335,58 @@ class VSTeamFeed : VSTeamLeaf {
}
}
+[SHiPSProvider(UseCache = $true)]
+[SHiPSProvider(BuiltinProgress = $false)]
+class VSTeamQueues : VSTeamDirectory {
+
+ # Default constructor
+ VSTeamQueues(
+ [string]$Name,
+ [string]$ProjectName
+ ) : base($Name, $ProjectName) {
+ $this.AddTypeName('Team.Queues')
+ }
+
+ [object[]] GetChildItem() {
+ $items = Get-VSTeamQueue -ProjectName $this.ProjectName -ErrorAction SilentlyContinue
+
+ foreach ($item in $items) {
+ $item.AddTypeName('Team.Provider.Queue')
+ }
+
+ return $items
+ }
+}
+
+[SHiPSProvider(UseCache = $true)]
+[SHiPSProvider(BuiltinProgress = $false)]
+class VSTeamQueue : VSTeamLeaf {
+
+ [string]$poolName
+ [VSTeamPool]$pool
+
+ # Default constructor
+ VSTeamQueue(
+ [object]$obj,
+ [string]$Projectname
+ ) : base($obj.name, $obj.id, $Projectname) {
+
+ # pool values are not returned always
+ if ($obj.PSObject.Properties.Match('poolName').count -gt 0) {
+ $this.poolName = $obj.poolName
+ }
+
+ if ($obj.PSObject.Properties.Match('pool').count -gt 0) {
+ $this.pool = [VSTeamPool]::new($obj.pool)
+ $this.poolName = $obj.pool.name
+ }
+
+ $this.AddTypeName('Team.Queue')
+
+ $this._internalObj = $obj
+ }
+}
+
[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamPools : VSTeamDirectory {
@@ -380,11 +433,19 @@ class VSTeamPool : VSTeamDirectory {
) : base($obj.Name, $null) {
$this.id = $obj.id
- $this.count = $obj.size
- $this.isHosted = $obj.isHosted
- # On some accounts teh CreatedBy is null for hosted pools
- if ($null -ne $obj.createdBy) {
+ # values are not returned always
+ if ($obj.PSObject.Properties.Match('isHosted').count -gt 0) {
+ $this.isHosted = $obj.isHosted
+ }
+
+ if ($obj.PSObject.Properties.Match('size').count -gt 0) {
+ $this.count = $obj.size
+ }
+
+ # On some accounts the CreatedBy is null for hosted pools
+ if ($obj.PSObject.Properties.Match('createdBy').count -gt 0 -and
+ $null -ne $obj.createdBy) {
$this.createdBy = [VSTeamUser]::new($obj.createdBy, $null)
}
@@ -566,16 +627,16 @@ class VSTeamBuildDefinition : VSTeamDirectory {
[int]$Revision = -1
[string]$Path = $null
[object]$Tags = $null
- [object]$Queue = $null
[object]$Options = $null
[object]$Triggers = $null
[object]$Variables = $null
[object]$Repository = $null
- [VSTeamGitRepository]$GitRepository = $null
+ [VSTeamQueue]$Queue = $null
[object]$RetentionRules = $null
[VSTeamUser]$AuthoredBy = $null
[string]$BuildNumberFormat = $null
[string]$JobAuthorizationScope = $null
+ [VSTeamGitRepository]$GitRepository = $null
[datetime]$CreatedOn = [datetime]::MinValue
[VSTeamBuildDefinitionProcess]$Process = $null
[VSTeamBuildDefinitionProcessPhaseStep[]]$Steps = $null
@@ -587,7 +648,6 @@ class VSTeamBuildDefinition : VSTeamDirectory {
$this.id = $obj.id
$this.Path = $obj.path
- $this.Queue = $obj.queue
$this.Revision = $obj.revision
$this.Variables = $obj.variables
$this.CreatedOn = $obj.createdDate
@@ -595,6 +655,9 @@ class VSTeamBuildDefinition : VSTeamDirectory {
$this.AuthoredBy = [VSTeamUser]::new($obj.authoredBy, $Projectname)
# These might not be returned
+ if ($obj.PSObject.Properties.Match('queue').count -gt 0) {
+ $this.Queue = [VSTeamQueue]::new($obj.queue, $Projectname)
+ }
if ($obj.PSObject.Properties.Match('triggers').count -gt 0) {
$this.Triggers = $obj.triggers
}
diff --git a/types/queues.ps1xml b/types/queues.ps1xml
deleted file mode 100644
index c71d66bb9..000000000
--- a/types/queues.ps1xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- Team.Queue
-
-
- poolName
- $this.pool.name
-
-
-
-
\ No newline at end of file
diff --git a/unit/test/queues.Tests.ps1 b/unit/test/queues.Tests.ps1
index 37e321f77..ecd47cf65 100644
--- a/unit/test/queues.Tests.ps1
+++ b/unit/test/queues.Tests.ps1
@@ -14,6 +14,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue with no parameters' {
Mock Invoke-RestMethod { return @{
value = @{
+ id = 3
+ name = 'Hosted'
pool = @{}
}
}}
@@ -30,6 +32,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue with queueName parameter' {
Mock Invoke-RestMethod { return @{
value = @{
+ id = 3
+ name = 'Hosted'
pool = @{}
}
}}
@@ -46,6 +50,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue with actionFilter parameter' {
Mock Invoke-RestMethod { return @{
value = @{
+ id = 3
+ name = 'Hosted'
pool = @{}
}
}}
@@ -66,6 +72,8 @@ InModuleScope queues {
return @{
value = @{
+ id = 3
+ name = 'Hosted'
pool = @{}
}
}}
@@ -91,6 +99,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue' {
Mock Invoke-RestMethod { return @{
+ id = 3
+ name = 'Hosted'
pool = @{}
}}
diff --git a/unit/test/teamspsdrive.Tests.ps1 b/unit/test/teamspsdrive.Tests.ps1
index e4945dae1..32d70ae1c 100644
--- a/unit/test/teamspsdrive.Tests.ps1
+++ b/unit/test/teamspsdrive.Tests.ps1
@@ -177,12 +177,14 @@ Describe 'TeamsPSDrive' {
$actual[0].ProjectName | Should Be 'TestProject'
$actual[1].Name | Should Be 'Builds'
$actual[1].ProjectName | Should Be 'TestProject'
- $actual[2].Name | Should Be 'Releases'
+ $actual[2].Name | Should Be 'Queues'
$actual[2].ProjectName | Should Be 'TestProject'
- $actual[3].Name | Should Be 'Repositories'
+ $actual[3].Name | Should Be 'Releases'
$actual[3].ProjectName | Should Be 'TestProject'
- $actual[4].Name | Should Be 'Teams'
+ $actual[4].Name | Should Be 'Repositories'
$actual[4].ProjectName | Should Be 'TestProject'
+ $actual[5].Name | Should Be 'Teams'
+ $actual[5].ProjectName | Should Be 'TestProject'
}
}