Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions Invoke-ADORestAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -157,33 +157,28 @@ Specifies the method used for the web request. The acceptable values for this pa
)

begin {
# From [Irregular](https://github.com/StartAutomating/Irregular):
# ?<REST_Variable> -VariableFormat Braces
$RestVariable = [Regex]::new(@'
# Matches URL segments and query strings containing variables.
# Variables can be enclosed in brackets or curly braces, or preceeded by a $ or :
(?> # A variable can be in a URL segment or subdomain
(?<Start>[/\.]) # Match the <Start>ing slash|dot ...
(?<IsOptional>\?)? # ... an optional ? (to indicate optional) ...
(?:
\{(?<Variable>\w+)\}| # ... A <Variable> name in {} OR
\[(?<Variable>\w+)\]| # A <Variable> name in [] OR
`\$(?<Variable>\w+) | # A `$ followed by a <Variable> OR
\:(?<Variable>\w+) # A : followed by a <Variable>
\{(?<Variable>\w+)\} # ... A <Variable> name in {} OR
)
|
(?<IsOptional> # If it's optional it can also be
(?<IsOptional> # If it's optional it can also be
[{\[](?<Start>/) # a bracket or brace, followed by a slash
)
(?<Variable>\w+)[}\]] # then a <Variable> name followed by } or ]

| # OR it can be in a query parameter:
(?<Start>[?&]) # Match The <Start>ing ? or & ...
(?<Query>[\w\-]+) # ... the <Query> parameter name ...
(?<Start>[\?\&]) # Match The <Start>ing ? or & ...
(?<Query>[\$\w\-]+) # ... the <Query> parameter name ...
= # ... an equals ...
(?<IsOptional>\?)? # ... an optional ? (to indicate optional) ...
(?:
\{(?<Variable>\w+)\}| # ... A <Variable> name in {} OR
\[(?<Variable>\w+)\]| # A <Variable> name in [] OR
\`$(?<Variable>\w+) | # A $ followed by a <Variable> OR
\:(?<Variable>\w+) # A : followed by a <Variable>
\{(?<Variable>\w+)\} # ... A <Variable> name in {} OR
)
)
'@, 'IgnoreCase,IgnorePatternWhitespace')
Expand Down Expand Up @@ -377,7 +372,7 @@ $($MyInvocation.MyCommand.Name) @parameter
$streamIn.Dispose()
$PSCmdlet.WriteError(
[Management.Automation.ErrorRecord]::new(
[Exception]::new($strResponse, $ex.Exception.InnerException
[Exception]::new("$($ex.Exception.InnerException.Response.StatusCode, $ex.Exception.InnerException.Response.StatusDescription)$strResponse ", $ex.Exception.InnerException
), $ex.Exception.HResult, 'NotSpecified', $webRequest)
)
return
Expand All @@ -402,7 +397,7 @@ $($MyInvocation.MyCommand.Name) @parameter
if ($AsByte) {
$ms = [IO.MemoryStream]::new()
$rs.CopyTo($ms)
$ms.ToArray()
,$ms.ToArray()
$ms.Dispose()
return
}
Expand All @@ -424,6 +419,9 @@ $($MyInvocation.MyCommand.Name) @parameter
$null = $null
# We call Invoke-RestMethod with the parameters we've passed in.
# It will take care of converting the results from JSON.
if ($response -is [byte[]]) {
return $response
}

$apiOutput =
$response |
Expand All @@ -434,7 +432,7 @@ $($MyInvocation.MyCommand.Name) @parameter
# A lot of things in the Azure DevOps REST apis come back as a count/value pair
if ($in -eq 'null') {
return
}
}
if ($ExpandProperty) {
if ($in.$ExpandProperty) {
return $in.$ExpandProperty
Expand All @@ -456,7 +454,7 @@ $($MyInvocation.MyCommand.Name) @parameter


$in = $_
if ($in -is [string]) { return $in }
if ($in -is [string]) { return $in }
if ($null -ne $in.Count -and $in.Count -eq 0) {
return
}
Expand Down
15 changes: 6 additions & 9 deletions PSDevOps.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.5.4'
ModuleVersion = '0.5.4.1'
RootModule = 'PSDevOps.psm1'
Description = 'PowerShell Tools for DevOps'
Guid = 'e6b56c5f-41ac-4ba4-8b88-2c063f683176'
Expand All @@ -9,6 +9,11 @@
ProjectURI = 'https://github.com/StartAutomating/PSDevOps'
LicenseURI = 'https://github.com/StartAutomating/PSDevOps/blob/master/LICENSE'
ReleaseNotes = @'
0.5.4.1:
---
* Fixing Invoke-ADORestApi issues: #111,#114,#115
* Attaching .BuildID and .DefinitionID properties to Get-ADOBuild where appropriate.

0.5.4:
---
* Formatting Improvments:
Expand Down Expand Up @@ -96,14 +101,6 @@
** Get-ADOProject now has -TestRun, -TestPlan, -Release, and -PendingApproval (and better progress bars)
** Get-ADOWorkItemType now has -Field
** Commands for Picklists: Add/Get/Remove/Update-ADOPicklist
0.4.7
----
* New Commands:
** Add/Get/Remove-ADOWiki
** Get-ADOPermission
* Bugfixes:
** Honoring Get-ADOBuild -DefinitionName
* Disconnect-ADO is now run prior at the start of Connect-ADO, and on module unload.
'@
}
Colors = @{
Expand Down