Skip to content
Merged
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
27 changes: 27 additions & 0 deletions eng/common/scripts/Invoke-GitHubAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,33 @@ function New-GitHubIssue {
-MaximumRetryCount 3
}

function Get-GitHubIssues {
Copy link
Contributor

@sima-zhu sima-zhu Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use this API to get all issues with particular labels?

If so, can we have the right API name to indicate it is about labels as it is required parameters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add comments on what is the format for multi-labels?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually prefer to have this as a single API that can support different level of filtering. Adding label to name will make it more specific than a general API. Currently implementation is based on label and creator but this can be enhanced to make them optional and support more query options.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If support multi filters in this API, can we make labels as optional as well? Otherwise, people has no way to use this for authors only or for assignees only. It is currently working so specific for particular purpose.

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)]
Expand Down