Public/Get-PSGitLabProjectIssue.ps1
function Get-PSGitLabProjectIssue { <# .SYNOPSIS A PowerShell cmdlet to retrieve GitLab issues (Project Scope) .DESCRIPTION A PowerShell cmdlet to retrieve GitLab issues (Project Scope) .NOTES Author : Chendrayan Venkatesan Email : Chendrayan.Exchange@hotmail.com .LINK https://docs.gitlab.com/ee/api/graphql/reference/#projectissue .EXAMPLE Get-PSGitLabProjectIssue -OrganizationName 'gitlab.com' -PrivateToken 'XXXXX' -ProjectFullPath 'group/projectfullpath' #> [CmdletBinding()] param ( [string] $OrganizationName, [string] $PrivateToken, [string] $ProjectFullPath ) $query = @{ query = @" query { project(fullPath: "$($ProjectFullPath)") { issues (first: 20, after: null) { pageInfo { hasNextPage endCursor } nodes { id iid createdAt closedAt weight confidential state severity title labels { nodes { title } } } } } } "@ } | ConvertTo-Json $collection = @() while ($true) { $response = Invoke-RestMethod -Uri "https://$($OrganizationName)/api/graphql" -Headers @{Authorization = "Bearer $($PrivateToken)" } -Method Post -Body $query -ContentType 'application/json' $query = @{ query = @" query { project(fullPath: "$($ProjectFullPath)") { issues (first: 20, after: "$($response.data.project.issues.pageInfo.endCursor)") { pageInfo { hasNextPage endCursor } nodes { id iid createdAt closedAt weight confidential state severity title labels { nodes { title } } } } } } "@ } | ConvertTo-Json $collection += $response if ($response.data.project.issues.pageInfo.hasNextPage -eq $false) { break } } $collection.data.project.issues.nodes } |