Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github: [andygrunwald, benjivesterby]
custom: "https://paypal.me/andygrunwald"
github: [jplanckeel, benjivesterby]
custom: "https://paypal.me/jplanckeel"
2 changes: 1 addition & 1 deletion .github/workflows/label-pull-requests-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/labeler@v5
with:
sync-labels: false
# Output of gh pr list --repo andygrunwald/go-jira --state open --limit 100 --json number --jq ".[].number"
# Output of gh pr list --repo jplanckeel/go-jira --state open --limit 100 --json number --jq ".[].number"
pr-number: |
695
683
Expand Down
108 changes: 54 additions & 54 deletions CHANGELOG.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# go-jira

[![GoDoc](https://pkg.go.dev/badge/github.com/andygrunwald/go-jira?utm_source=godoc)](https://pkg.go.dev/github.com/andygrunwald/go-jira)
[![Build Status](https://github.com/andygrunwald/go-jira/actions/workflows/testing.yml/badge.svg)](https://github.com/andygrunwald/go-jira/actions/workflows/testing.yml)
[![Go Report Card](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/andygrunwald/go-jira)
[![GoDoc](https://pkg.go.dev/badge/github.com/jplanckeel/go-jira?utm_source=godoc)](https://pkg.go.dev/github.com/jplanckeel/go-jira)
[![Build Status](https://github.com/jplanckeel/go-jira/actions/workflows/testing.yml/badge.svg)](https://github.com/jplanckeel/go-jira/actions/workflows/testing.yml)
[![Go Report Card](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/jplanckeel/go-jira)

[Go](https://go.dev/) client library for [Atlassian Jira](https://www.atlassian.com/software/jira).

Expand All @@ -21,11 +21,11 @@ The goals of v2 are:
* being compliant with different kinds of Atlassian Jira products (on-premise vs. cloud)
* remove flaws introduced during the early times of this library

See our milestone [Road to v2](https://github.com/andygrunwald/go-jira/milestone/1) and provide feedback in [Development is kicking: Road to v2 🚀 #489](https://github.com/andygrunwald/go-jira/issues/489).
See our milestone [Road to v2](https://github.com/jplanckeel/go-jira/milestone/1) and provide feedback in [Development is kicking: Road to v2 🚀 #489](https://github.com/jplanckeel/go-jira/issues/489).
Attention: The current `main` branch represents the v2 development version - we treat this version as unstable and breaking changes are expected.

**If you want to stay more stable, please use v1.\*** - See our [releases](https://github.com/andygrunwald/go-jira/releases).
Latest stable release: [v1.16.0](https://github.com/andygrunwald/go-jira/releases/tag/v1.16.0)
**If you want to stay more stable, please use v1.\*** - See our [releases](https://github.com/jplanckeel/go-jira/releases).
Latest stable release: [v1.16.0](https://github.com/jplanckeel/go-jira/releases/tag/v1.16.0)

## Features

Expand All @@ -49,19 +49,19 @@ of Go are officially supported.
It is go gettable

```sh
go get github.com/andygrunwald/go-jira
go get github.com/jplanckeel/go-jira
```

## API

Please have a look at the [GoDoc documentation](https://pkg.go.dev/github.com/andygrunwald/go-jira) for a detailed API description.
Please have a look at the [GoDoc documentation](https://pkg.go.dev/github.com/jplanckeel/go-jira) for a detailed API description.

The [latest Jira REST API documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/) was the base document for this package.

## Examples

Further a few examples how the API can be used.
A few more examples are available in the [GoDoc examples section](https://pkg.go.dev/github.com/andygrunwald/go-jira#section-directories).
A few more examples are available in the [GoDoc examples section](https://pkg.go.dev/github.com/jplanckeel/go-jira#section-directories).

### Get a single issue

Expand All @@ -72,7 +72,7 @@ package main

import (
"fmt"
jira "github.com/andygrunwald/go-jira"
jira "github.com/jplanckeel/go-jira"
)

func main() {
Expand Down Expand Up @@ -137,7 +137,7 @@ Depending on your version of Jira, either of the above token authentication exam

If you want to connect via OAuth to your Jira Cloud instance checkout the [example of using OAuth authentication with Jira in Go](https://gist.github.com/Lupus/edafe9a7c5c6b13407293d795442fe67) by [@Lupus](https://github.com/Lupus).

For more details have a look at the [issue #56](https://github.com/andygrunwald/go-jira/issues/56).
For more details have a look at the [issue #56](https://github.com/jplanckeel/go-jira/issues/56).

### Create an issue

Expand All @@ -148,7 +148,7 @@ package main

import (
"fmt"
"github.com/andygrunwald/go-jira"
"github.com/jplanckeel/go-jira"
)

func main() {
Expand Down Expand Up @@ -199,7 +199,7 @@ package main

import (
"fmt"
"github.com/andygrunwald/go-jira"
"github.com/jplanckeel/go-jira"
)

func main() {
Expand Down Expand Up @@ -239,7 +239,7 @@ func main() {
Jira API has limit on maxResults it can return. You may have a usecase where you need to get all issues for given JQL.
This example shows reference implementation of GetAllIssues function which does pagination on Jira API to get all the issues for given JQL.

Please look at [Pagination Example](https://github.com/andygrunwald/go-jira/blob/main/cloud/examples/pagination/main.go)
Please look at [Pagination Example](https://github.com/jplanckeel/go-jira/blob/main/cloud/examples/pagination/main.go)

### Call a not implemented API endpoint

Expand All @@ -252,7 +252,7 @@ package main

import (
"fmt"
"github.com/andygrunwald/go-jira"
"github.com/jplanckeel/go-jira"
)

func main() {
Expand Down Expand Up @@ -286,7 +286,7 @@ func main() {

## Implementations

* [andygrunwald/jitic](https://github.com/andygrunwald/jitic) - The Jira Ticket Checker
* [jplanckeel/jitic](https://github.com/jplanckeel/jitic) - The Jira Ticket Checker

## Development

Expand Down Expand Up @@ -318,13 +318,13 @@ We ❤️ PR's

Contribution, in any kind of way, is highly welcome!
It doesn't matter if you are not able to write code.
Creating issues or holding talks and help other people to use [go-jira](https://github.com/andygrunwald/go-jira) is contribution, too!
Creating issues or holding talks and help other people to use [go-jira](https://github.com/jplanckeel/go-jira) is contribution, too!
A few examples:

* Correct typos in the README / documentation
* Reporting bugs
* Implement a new feature or endpoint
* Sharing the love of [go-jira](https://github.com/andygrunwald/go-jira) and help people to get use to it
* Sharing the love of [go-jira](https://github.com/jplanckeel/go-jira) and help people to get use to it

If you are new to pull requests, checkout [Collaborating on projects using issues and pull requests / Creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).

Expand Down Expand Up @@ -377,7 +377,7 @@ git push --tags

Manually copy/paste text from changelog (for this new version) into the release on Github.com. E.g.

[https://github.com/andygrunwald/go-jira/releases/edit/v1.11.0](https://github.com/andygrunwald/go-jira/releases/edit/v1.11.0)
[https://github.com/jplanckeel/go-jira/releases/edit/v1.11.0](https://github.com/jplanckeel/go-jira/releases/edit/v1.11.0)

## License

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cloud/examples/addlabel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"strings"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/basic_auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/component_create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/component_get/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/createwithcustomfields/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
"github.com/trivago/tgo/tcontainer"
)

Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/do/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"net/http"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/ignorecerts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"net/http"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/jql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/newclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

// GetAllIssues will implement pagination of api and get all the issues.
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/renderedfields/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strings"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/searchpages/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cloud/examples/statuscategories/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

jira "github.com/andygrunwald/go-jira/v2/cloud"
jira "github.com/jplanckeel/go-jira/v3/cloud"
)

func main() {
Expand Down
File renamed without changes.
38 changes: 24 additions & 14 deletions cloud/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,24 +517,33 @@ type CommentVisibility struct {
// A request to a pages API will result in a values array wrapped in a JSON object with some paging metadata
// Default Pagination options
type SearchOptions struct {
// StartAt: The starting index of the returned projects. Base index: 0.
StartAt int `url:"startAt,omitempty"`
// FailFast: Fail this request early if we can't retrieve all field data.
FailFast bool `url:"failFast,omitempty"`
// FieldsByKeys: Reference fields by their key (rather than ID). The default is false.
FieldsByKeys bool `url:"fieldsByKeys,omitempty"`
// MaxResults: The maximum number of projects to return per page. Default: 50.
MaxResults int `url:"maxResults,omitempty"`
// ReconcileIssues: Strong consistency issue ids to be reconciled with search results. Accepts max 50 ids
econcileIssues []int `url:"reconcileIssues,omitempty"`
// JQL: A JQL query string to filter the results on. See https://confluence.atlassian.com/x/egORLQ for more details about JQL.
JQL string `url:"jql,omitempty"`
// NextPageToken: The token for a page to fetch that is not the first page. The first page has a nextPageToken of null. Use the nextPageToken to fetch the next page of issues.
NextPageToken string `url:"nextPageToken,omitempty"`
// Expand: Expand specific sections in the returned issues
Expand string `url:"expand,omitempty"`
Fields []string
// Properties: A list of up to 5 issue properties to include in the results. This parameter accepts a comma-separated list.
Properties []string `url:"properties,omitempty"`
Fields []string
// ValidateQuery: The validateQuery param offers control over whether to validate and how strictly to treat the validation. Default: strict.
ValidateQuery string `url:"validateQuery,omitempty"`
}

// searchResult is only a small wrapper around the Search (with JQL) method
// to be able to parse the results
type searchResult struct {
Issues []Issue `json:"issues" structs:"issues"`
StartAt int `json:"startAt" structs:"startAt"`
MaxResults int `json:"maxResults" structs:"maxResults"`
Total int `json:"total" structs:"total"`
IsLast bool `json:"isLast" structs:"isLast"`
NextPageToken string `json:"nextPageToken" structs:"nextPageToken"`
Issues []Issue `json:"issues" structs:"issues"`
}

// GetQueryOptions specifies the optional parameters for the Get Issue methods
Expand Down Expand Up @@ -1043,19 +1052,19 @@ func (s *IssueService) AddLink(ctx context.Context, issueLink *IssueLink) (*Resp
// Jira API docs: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
// This double check effort is done for v3 - Remove this two lines if this is completed.
func (s *IssueService) Search(ctx context.Context, jql string, options *SearchOptions) ([]Issue, *Response, error) {
u := url.URL{
Path: "rest/api/2/search",
Path: "rest/api/3/search/jql",
}
uv := url.Values{}
if jql != "" {
uv.Add("jql", jql)
}

if options != nil {
if options.StartAt != 0 {
uv.Add("startAt", strconv.Itoa(options.StartAt))
if options.NextPageToken != "" {
uv.Add("nextPageToken", options.NextPageToken)
}
if options.MaxResults != 0 {
uv.Add("maxResults", strconv.Itoa(options.MaxResults))
Expand Down Expand Up @@ -1095,7 +1104,7 @@ func (s *IssueService) Search(ctx context.Context, jql string, options *SearchOp
func (s *IssueService) SearchPages(ctx context.Context, jql string, options *SearchOptions, f func(Issue) error) error {
if options == nil {
options = &SearchOptions{
StartAt: 0,
NextPageToken: "",
MaxResults: 50,
}
}
Expand All @@ -1117,15 +1126,16 @@ func (s *IssueService) SearchPages(ctx context.Context, jql string, options *Sea
for _, issue := range issues {
err = f(issue)
if err != nil {

return err
}
}

if resp.StartAt+resp.MaxResults >= resp.Total {
if resp.IsLast {
return nil
}

options.StartAt += resp.MaxResults
options.NextPageToken += resp.NextPageToken
issues, resp, err = s.Search(ctx, jql, options)
if err != nil {
return err
Expand Down
Loading