Skip to content

Commit

Permalink
IssueService: Issue.Update removed, Issue.UpdateWithOptions renamed
Browse files Browse the repository at this point in the history
Related #294
  • Loading branch information
andygrunwald committed Sep 12, 2022
1 parent 295e4c7 commit e22ee9a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
37 changes: 33 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ client.Issue.Create(ctx, ...)

#### `BoardService.GetAllSprints` removed, `BoardService.GetAllSprintsWithOptions` renamed


The function `client.BoardService.GetAllSprints()` has been removed.
The function `client.BoardService.GetAllSprintsWithOptions()` has been renamed to `client.BoardService.GetAllSprints()`.

##### If you used `client.BoardService.GetAllSprints()`:
Expand Down Expand Up @@ -202,8 +200,6 @@ client.Board.GetAllSprints(context.Background(), 123, &GetAllSprintsOptions{Stat

#### `GroupService.Get` removed, `GroupService.GetWithOptions` renamed


The function `client.GroupService.Get()` has been removed.
The function `client.GroupService.GetWithOptions()` has been renamed to `client.GroupService.Get()`.

##### If you used `client.GroupService.Get()`:
Expand Down Expand Up @@ -234,6 +230,38 @@ After:
client.Group.Get(context.Background(), "default", &GroupSearchOptions{StartAt: 0, MaxResults: 2})
```

#### `Issue.Update` removed, `Issue.UpdateWithOptions` renamed

The function `client.Issue.UpdateWithOptions()` has been renamed to `client.Issue.Update()`.

##### If you used `client.Issue.Update()`:

Before:

```go
client.Issue.Update(context.Background(), issue)
```

After:

```go
client.Issue.Update(context.Background(), issue, nil)
```

##### If you used `client.Issue.UpdateWithOptions()`:

Before:

```go
client.Issue.UpdateWithOptions(context.Background(), issue, nil)
```

After:

```go
client.Issue.Update(context.Background(), issue, nil)
```

### Breaking changes

* Jira On-Premise and Jira Cloud have now different clients, because the API differs
Expand All @@ -243,6 +271,7 @@ client.Group.Get(context.Background(), "default", &GroupSearchOptions{StartAt: 0
* `context` is now a first class citizen in all API calls. Functions that had a suffix like `...WithContext` have been removed entirely. The API methods support the context now as first argument.
* `BoardService.GetAllSprints` has been removed and `BoardService.GetAllSprintsWithOptions` has been renamed to `BoardService.GetAllSprints`
* `GroupService.Get` has been removed and `GroupService.GetWithOptions` has been renamed to `GroupService.Get`
* `Issue.Update` has been removed and `Issue.UpdateWithOptions` has been renamed to `Issue.Update`

### Features

Expand Down
13 changes: 3 additions & 10 deletions cloud/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,12 +804,12 @@ func (s *IssueService) Create(ctx context.Context, issue *Issue) (*Issue, *Respo
return responseIssue, resp, nil
}

// UpdateWithOptions updates an issue from a JSON representation,
// Update updates an issue from a JSON representation,
// while also specifying query params. The issue is found by key.
//
// Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
// Caller must close resp.Body
func (s *IssueService) UpdateWithOptions(ctx context.Context, issue *Issue, opts *UpdateQueryOptions) (*Issue, *Response, error) {
func (s *IssueService) Update(ctx context.Context, issue *Issue, opts *UpdateQueryOptions) (*Issue, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", issue.Key)
url, err := addOptions(apiEndpoint, opts)
if err != nil {
Expand All @@ -831,13 +831,6 @@ func (s *IssueService) UpdateWithOptions(ctx context.Context, issue *Issue, opts
return &ret, resp, nil
}

// Update updates an issue from a JSON representation. The issue is found by key.
//
// Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
func (s *IssueService) Update(ctx context.Context, issue *Issue) (*Issue, *Response, error) {
return s.UpdateWithOptions(ctx, issue, nil)
}

// UpdateIssue updates an issue from a JSON representation. The issue is found by key.
//
// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue
Expand Down
2 changes: 1 addition & 1 deletion cloud/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestIssueService_Update(t *testing.T) {
Description: "example bug report",
},
}
issue, _, err := testClient.Issue.Update(context.Background(), i)
issue, _, err := testClient.Issue.Update(context.Background(), i, nil)
if issue == nil {
t.Error("Expected issue. Issue is nil")
}
Expand Down
13 changes: 3 additions & 10 deletions onpremise/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,12 +804,12 @@ func (s *IssueService) Create(ctx context.Context, issue *Issue) (*Issue, *Respo
return responseIssue, resp, nil
}

// UpdateWithOptions updates an issue from a JSON representation,
// Update updates an issue from a JSON representation,
// while also specifying query params. The issue is found by key.
//
// Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
// Caller must close resp.Body
func (s *IssueService) UpdateWithOptions(ctx context.Context, issue *Issue, opts *UpdateQueryOptions) (*Issue, *Response, error) {
func (s *IssueService) Update(ctx context.Context, issue *Issue, opts *UpdateQueryOptions) (*Issue, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", issue.Key)
url, err := addOptions(apiEndpoint, opts)
if err != nil {
Expand All @@ -831,13 +831,6 @@ func (s *IssueService) UpdateWithOptions(ctx context.Context, issue *Issue, opts
return &ret, resp, nil
}

// Update updates an issue from a JSON representation. The issue is found by key.
//
// Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
func (s *IssueService) Update(ctx context.Context, issue *Issue) (*Issue, *Response, error) {
return s.UpdateWithOptions(ctx, issue, nil)
}

// UpdateIssue updates an issue from a JSON representation. The issue is found by key.
//
// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue
Expand Down
2 changes: 1 addition & 1 deletion onpremise/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestIssueService_Update(t *testing.T) {
Description: "example bug report",
},
}
issue, _, err := testClient.Issue.Update(context.Background(), i)
issue, _, err := testClient.Issue.Update(context.Background(), i, nil)
if issue == nil {
t.Error("Expected issue. Issue is nil")
}
Expand Down

0 comments on commit e22ee9a

Please sign in to comment.