AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
322 stars 131 forks source link

Add Get-JiraIssueWorklog #402

Closed asherber closed 1 year ago

asherber commented 4 years ago

Context

I'd like to be able to get a full list of issue worklogs. Get-JiraIssue only returns the first 20.

Description

I'd like a function Get-JiraIssueWorklog, modeled after Get-JiraIssueComment that returns a full list of all worklog items for an issue.

Additional Information

Testing locally, I was able to accomplish this by copying the body of Get-JiraIssueComment to a new function Get-JiraIssueWorklog, changing only the URI (comment -> worklog) and the OutputType (JiraComment -> JiraWorklogItem). I also had to add JiraWorklogItem to the ValidateSet for OutputType on Invoke-JiraMethod.

I could submit a PR for this, but I'm not sure I'm able to write the appropriate unit tests.

nvarscar commented 4 years ago

Just ran into this and I would appreciate this being supported out of the box. And thanks for the workaround idea!

asherber commented 4 years ago

@nvarscar Also add Get-JiraIssueWorklog to the FunctionsToExport array in JiraPS.psd1 if you're making mods locally.

nvarscar commented 4 years ago

I ended up just reusing Invoke-JiraMethod from the source, as I didn't need to interface with the worklog object:

        $parameter = @{
                URI          = "{0}/worklog" -f $issue.RestURL
                Method       = "GET"
                GetParameter = @{
                    maxResults = 1000
                }
                Paging       = $true
                Credential   = $Credential
            }
            $workLogs = Invoke-JiraMethod @parameter