mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-10 11:41:23 +00:00
Move retry logic to the AzureDevOpsApi class
This commit is contained in:
@@ -3,14 +3,25 @@ class AzureDevOpsApi
|
||||
[string] $BaseUrl
|
||||
[string] $RepoOwner
|
||||
[object] $AuthHeader
|
||||
[UInt32] $RetryCount = 0
|
||||
[UInt32] $RetryIntervalSec = 30
|
||||
|
||||
AzureDevOpsApi(
|
||||
[string] $TeamFoundationCollectionUri,
|
||||
[string] $ProjectName,
|
||||
[string] $AccessToken
|
||||
[string] $AccessToken,
|
||||
[UInt32] $RetryCount,
|
||||
[UInt32] $RetryIntervalSec
|
||||
) {
|
||||
$this.BaseUrl = $this.BuildBaseUrl($TeamFoundationCollectionUri, $ProjectName)
|
||||
$this.AuthHeader = $this.BuildAuth($AccessToken)
|
||||
|
||||
if ($RetryCount -gt 0) {
|
||||
$this.RetryCount = $RetryCount
|
||||
}
|
||||
if ($RetryIntervalSec -gt 0) {
|
||||
$this.RetryIntervalSec = $RetryIntervalSec
|
||||
}
|
||||
}
|
||||
|
||||
[object] hidden BuildAuth([string]$AccessToken) {
|
||||
@@ -73,17 +84,21 @@ class AzureDevOpsApi
|
||||
$params.Body = $Body
|
||||
}
|
||||
|
||||
$params.RetryIntervalSec = $this.RetryIntervalSec
|
||||
$params.MaximumRetryCount = $this.RetryCount
|
||||
|
||||
return Invoke-RestMethod @params
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Get-AzureDevOpsApi {
|
||||
param (
|
||||
[string] $TeamFoundationCollectionUri,
|
||||
[string] $ProjectName,
|
||||
[string] $AccessToken
|
||||
[string] $AccessToken,
|
||||
[UInt32] $RetryCount,
|
||||
[UInt32] $RetryIntervalSec
|
||||
)
|
||||
|
||||
return [AzureDevOpsApi]::New($TeamFoundationCollectionUri, $ProjectName, $AccessToken)
|
||||
return [AzureDevOpsApi]::New($TeamFoundationCollectionUri, $ProjectName, $AccessToken, $RetryCount, $RetryIntervalSec)
|
||||
}
|
||||
Reference in New Issue
Block a user