|
15 | 15 | [OutputType('PSDevOps.WorkItem')] |
16 | 16 | param( |
17 | 17 | # The InputObject |
18 | | - [Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName,ParameterSetName='WorkItem')] |
| 18 | + [Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName,ParameterSetName='WorkItem')] |
19 | 19 | [PSObject] |
20 | 20 | $InputObject, |
21 | 21 |
|
|
51 | 51 | [Parameter(ParameterSetName='SharedQuery',ValueFromPipelineByPropertyName)] |
52 | 52 | [ValidateSet('childFirst','parentFirst')] |
53 | 53 | [string] |
54 | | - $QueryRecursiveOption, |
| 54 | + $QueryRecursiveOption, |
55 | 55 |
|
56 | 56 | # If provided, create a shared query folder. |
57 | 57 | [Parameter(Mandatory, ParameterSetName='SharedQueryFolder',ValueFromPipelineByPropertyName)] |
|
97 | 97 | $BypassRule, |
98 | 98 |
|
99 | 99 | # If set, will only validate rules, but will not update the work item. |
100 | | - [Parameter(ValueFromPipelineByPropertyName,ParameterSetName='WorkItem')] |
| 100 | + [Parameter(ValueFromPipelineByPropertyName)] |
101 | 101 | [Alias('ValidateRules','ValidateRule','CheckRule','CheckRules')] |
102 | 102 | [switch] |
103 | 103 | $ValidateOnly, |
|
194 | 194 | } |
195 | 195 | #endregion Output Work Item |
196 | 196 |
|
197 | | - |
| 197 | + |
198 | 198 |
|
199 | 199 | $q = [Collections.Queue]::new() |
200 | 200 | } |
|
228 | 228 | } |
229 | 229 |
|
230 | 230 | $queryPathParts = @($QueryPath -split '/') |
231 | | - $sharedQueries = $null |
232 | | - foreach ($qp in $queryPathParts) { |
| 231 | + $sharedQueries = $null |
| 232 | + foreach ($qp in $queryPathParts) { |
233 | 233 | if (-not ($qp -as [guid])) { |
234 | 234 | $sharedQueries = Get-ADOWorkItem -SharedQuery @orgAndProject -Depth 2 |
235 | 235 | break |
236 | 236 | } |
237 | 237 | } |
238 | 238 |
|
239 | 239 | if ($sharedQueries) { |
240 | | - $queryPathId = $sharedQueries | |
| 240 | + $queryPathId = $sharedQueries | |
241 | 241 | Where-Object Path -eq $QueryPath | |
242 | 242 | Select-Object -ExpandProperty ID |
243 | 243 | if (-not $queryPathId) { |
|
246 | 246 | } else { |
247 | 247 | $QueryPath = $queryPathId |
248 | 248 | } |
249 | | - } |
| 249 | + } |
250 | 250 |
|
251 | 251 | $uri = $uriBase, "_apis/wit/queries", $(if ($QueryPath) { $QueryPath }) -ne '' -join '/' |
252 | 252 | $uri = $uri.ToString().TrimEnd('/') |
253 | | - $uri += '?' + |
254 | | - @( |
255 | | - if ($ApiVersion) {"api-version=$ApiVersion" } |
256 | | - ) -join '&' |
| 253 | + $uri += '?' + |
| 254 | + (@( |
| 255 | + if ($ApiVersion) { "api-version=$ApiVersion" } |
| 256 | + if ($validateOnly) { "validateWiqlOnly=true" } |
| 257 | + ) -join '&') |
257 | 258 | $invokeParams.uri = $uri |
258 | | - |
| 259 | + |
259 | 260 | $queryObject = @{} |
260 | 261 | if ($psParameterSet -eq 'SharedQueryFolder') { |
261 | 262 | $queryObject['name'] = $FolderName |
|
266 | 267 | if ($queryRecursionOption) { |
267 | 268 | $queryObject['queryRecursionOption'] = $queryRecursionOption |
268 | 269 | } |
| 270 | + |
269 | 271 | } else { |
270 | 272 | $queryObject['name'] = $QueryName |
271 | 273 | $queryObject['wiql'] = $WIQL |
| 274 | + |
272 | 275 | } |
273 | 276 |
|
274 | 277 | $invokeParams.Body = ConvertTo-Json $queryObject -Depth 100 |
|
284 | 287 | $invokeParams |
285 | 288 | continue |
286 | 289 | } |
287 | | - |
| 290 | + |
288 | 291 | if (-not $PSCmdlet.ShouldProcess("POST $uri with $($invokeParams.body)")) { continue } |
289 | 292 | $restResponse = Invoke-ADORestAPI @invokeParams 2>&1 |
290 | 293 | $restResponse |
|
0 commit comments