diff --git a/eng/common/scripts/Invoke-GitHubAPI.ps1 b/eng/common/scripts/Invoke-GitHubAPI.ps1 index 0f0469b8fe..90c1ff6389 100644 --- a/eng/common/scripts/Invoke-GitHubAPI.ps1 +++ b/eng/common/scripts/Invoke-GitHubAPI.ps1 @@ -187,6 +187,33 @@ function New-GitHubIssue { -MaximumRetryCount 3 } +function Get-GitHubIssues { + param ( + [Parameter(Mandatory = $true)] + $RepoOwner, + [Parameter(Mandatory = $true)] + $RepoName, + $CreatedBy, + [Parameter(Mandatory = $true)] + $Labels, + [ValidateNotNullOrEmpty()] + [Parameter(Mandatory = $true)] + $AuthToken + ) + + $uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/issues?labels=$Labels" + + if ($CreatedBy) { + $uri += "&creator=$CreatedBy" + } + + return Invoke-RestMethod ` + -Method GET ` + -Uri $uri ` + -Headers (Get-GitHubApiHeaders -token $AuthToken) ` + -MaximumRetryCount 3 +} + function Add-GitHubIssueComment { param ( [Parameter(Mandatory = $true)]