如何使用 Azure DevOps API 列出有权访问项目存储库的 groups/user?
How to list the groups/user who has permissions to the project repo with Azure DevOps API?
我想检查谁有权通过 REST API 访问项目中的某些存储库。我参考了文档,但什么也找不到。
使用 AzurePipelinesPS PowerShell module you can run the following commands to create a permission report and save the file locally. Where _yourSessionName_ is the name of your session. To learn more about session management with AzurePipelinesPS you can review the documentation here.
创建报告
为团队项目中的存储库创建报告,其中 _myTeamProjectName_ 是您的团队项目的名称,_myRepoName_ 是您的存储库的名称。可以修改此输入对象以创建各种权限报告。请参阅文档 here。
New-APPermissionReport -Session '_yourSessionName_' -InputObject @{
descriptors = @()
reportName = 'myFirstPermissionReport'
resources = @(
@{
resourceId = '_myTeamProjectName_/_myRepoName_'
resourceName = '_myRepoName_'
resourceType = 'repo'
}
)
}
Return 报告状态
Return列表中第一个报告的报告信息
$session = '_yourSessionName_'
$reports = Get-APPermissionReportList -Session $session
Get-APPermissionReport -Session $session -ReportId $reports[0].id
保存报告
将列表中的第一个报告保存到位于 c:\temp\myReport.json
的文件中
$session = '_yourSessionName_'
$reports = Get-APPermissionReportList -Session $session
Save-APPermissionReport -Session $session -ReportId $reports[0].id -OutputPath C:\temp\myReport.json
如果您对该模块有任何问题,请随时在 AzurePipelinesPS Github project
上提出问题
How to list the groups/user who has permissions to the project repo with Azure DevOps API?
目前,恐怕没有这样的 Rest API 可以为每个 User/Group 获得 git 回购权限。
虽然在preview版本REST API Permissions Report - List中列出了方法,但似乎还没有完全实现这样的RESTAPI:
希望此 REST API 很快发布。
您可以查看此 similar thread and 了解一些详细信息。
这是获取这些报告的 3 部分练习:
#请求报告:
$uri= -join("https://dev.azure.com/", $Account, "/_apis/permissionsreport?api-version=6.1-preview.1")
$Report=Invoke-RestMethod -Method Post -Uri $uri -Headers @{Authorization=("Basic {0}" -f $auth)} -ContentType "application/json" -Body $body
$fileUri=-join($Report[0]._Link.href, "?api-version=6.0-preview.1")
do{
#Now wait for it to complete:
sleep -Seconds 45
$ReportObj=Invoke-RestMethod -Method get -Uri $Fileuri -Headers @{Authorization=("Basic {0}" -f $auth)} -ContentType "application/json"
}while($ReportObj.reportStatus -ne "completedSuccessfully" -and $ReportObj.error -eq $null)
#Now get the report
$fileUri=-join($Report[0]._downloadLink.href, "?api-version=6.0-preview.1")
$ReportObj=Invoke-RestMethod -Method get -Uri $Fileuri -Headers @{Authorization=("Basic {0}" -f $auth)} -ContentType "application/json"
#because this isn't designed to be read directly like I've done, you have to clean it up:
$ReportObj=$ReportObj.Replace("", "") | ConvertFrom-Json
我发现它对我的目的来说太慢了。我有一个项目有 1300 个项目需要单独检查,到目前为止,它已经 运行 27 个小时,我预计它要到这个周末才能完成。
资源数据只能是一个。它不支持像 Descriptor 这样的倍数
描述符不能处理超过 70 个。
None 其中有记录。
我想检查谁有权通过 REST API 访问项目中的某些存储库。我参考了文档,但什么也找不到。
使用 AzurePipelinesPS PowerShell module you can run the following commands to create a permission report and save the file locally. Where _yourSessionName_ is the name of your session. To learn more about session management with AzurePipelinesPS you can review the documentation here.
创建报告
为团队项目中的存储库创建报告,其中 _myTeamProjectName_ 是您的团队项目的名称,_myRepoName_ 是您的存储库的名称。可以修改此输入对象以创建各种权限报告。请参阅文档 here。
New-APPermissionReport -Session '_yourSessionName_' -InputObject @{
descriptors = @()
reportName = 'myFirstPermissionReport'
resources = @(
@{
resourceId = '_myTeamProjectName_/_myRepoName_'
resourceName = '_myRepoName_'
resourceType = 'repo'
}
)
}
Return 报告状态
Return列表中第一个报告的报告信息
$session = '_yourSessionName_'
$reports = Get-APPermissionReportList -Session $session
Get-APPermissionReport -Session $session -ReportId $reports[0].id
保存报告
将列表中的第一个报告保存到位于 c:\temp\myReport.json
的文件中$session = '_yourSessionName_'
$reports = Get-APPermissionReportList -Session $session
Save-APPermissionReport -Session $session -ReportId $reports[0].id -OutputPath C:\temp\myReport.json
如果您对该模块有任何问题,请随时在 AzurePipelinesPS Github project
上提出问题How to list the groups/user who has permissions to the project repo with Azure DevOps API?
目前,恐怕没有这样的 Rest API 可以为每个 User/Group 获得 git 回购权限。
虽然在preview版本REST API Permissions Report - List中列出了方法,但似乎还没有完全实现这样的RESTAPI:
希望此 REST API 很快发布。
您可以查看此 similar thread and
这是获取这些报告的 3 部分练习: #请求报告:
$uri= -join("https://dev.azure.com/", $Account, "/_apis/permissionsreport?api-version=6.1-preview.1")
$Report=Invoke-RestMethod -Method Post -Uri $uri -Headers @{Authorization=("Basic {0}" -f $auth)} -ContentType "application/json" -Body $body
$fileUri=-join($Report[0]._Link.href, "?api-version=6.0-preview.1")
do{
#Now wait for it to complete:
sleep -Seconds 45
$ReportObj=Invoke-RestMethod -Method get -Uri $Fileuri -Headers @{Authorization=("Basic {0}" -f $auth)} -ContentType "application/json"
}while($ReportObj.reportStatus -ne "completedSuccessfully" -and $ReportObj.error -eq $null)
#Now get the report
$fileUri=-join($Report[0]._downloadLink.href, "?api-version=6.0-preview.1")
$ReportObj=Invoke-RestMethod -Method get -Uri $Fileuri -Headers @{Authorization=("Basic {0}" -f $auth)} -ContentType "application/json"
#because this isn't designed to be read directly like I've done, you have to clean it up:
$ReportObj=$ReportObj.Replace("", "") | ConvertFrom-Json
我发现它对我的目的来说太慢了。我有一个项目有 1300 个项目需要单独检查,到目前为止,它已经 运行 27 个小时,我预计它要到这个周末才能完成。 资源数据只能是一个。它不支持像 Descriptor 这样的倍数 描述符不能处理超过 70 个。 None 其中有记录。