ruby-jira 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +53 -18
- data/lib/jira/client/issue_comments.rb +80 -0
- data/lib/jira/client/issue_search.rb +60 -0
- data/lib/jira/client/issue_worklogs.rb +123 -0
- data/lib/jira/client/issues.rb +191 -0
- data/lib/jira/client/project_categories.rb +60 -0
- data/lib/jira/client/project_permission_schemes.rb +18 -0
- data/lib/jira/client/project_properties.rb +54 -0
- data/lib/jira/client/projects.rb +60 -0
- data/lib/jira/client/time_tracking.rb +57 -0
- data/lib/jira/client.rb +6 -0
- data/lib/jira/configuration.rb +2 -0
- data/lib/jira/error.rb +3 -0
- data/lib/jira/logging.rb +15 -0
- data/lib/jira/pagination/collection_behavior.rb +72 -0
- data/lib/jira/pagination/cursor_paginated_response.rb +57 -41
- data/lib/jira/pagination/paginated_response.rb +46 -50
- data/lib/jira/request/rate_limiting.rb +6 -6
- data/lib/jira/request/response_parsing.rb +82 -16
- data/lib/jira/request.rb +44 -16
- data/lib/jira/version.rb +1 -1
- data/lib/jira.rb +2 -0
- metadata +9 -2
- data/lib/jira/request/paginated_response.rb +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b943c4b2403edafbd328b20a1d6dc77378a9da1c760fad052df79b06e6af64d9
|
|
4
|
+
data.tar.gz: 9919c24e5dfecfb5cb5f5ec422cb9361fb50960f0cd25b2586924590b3d5facd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c0a1e01394b98162692dc8da79d96dd232e2e0474d40fd4f1fd7d11d237dee99060e79939d67f1d709fec87df9f45d007fb38cc0d58f3353e54986aafd66a96
|
|
7
|
+
data.tar.gz: 87cead95e1bb42f69e20ea8a8bac887bd6e40b233d45e8a2b08a65a199925398f8c910b91ff1adac2f4342acea01c5d5e3fd2a08d1cde63d0f6d58d4a8e0a177
|
data/CHANGELOG.md
CHANGED
|
@@ -5,10 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.0] - 2026-03-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add time tracking api (#8) ([836bc35](https://github.com/macio/ruby-jira/commit/836bc35ba53369acf683bf3c18424816b9aecf8e))
|
|
13
|
+
- Add project properties client (#6) ([db8796f](https://github.com/macio/ruby-jira/commit/db8796fcc59f34d91b5e9835730581ff9599fb5b))
|
|
14
|
+
|
|
8
15
|
## [0.1.0] - 2026-03-09
|
|
9
16
|
|
|
10
17
|
### Added
|
|
11
18
|
|
|
12
19
|
- Add initial ruby-jira Jira API client gem ([09c7c53](https://github.com/macio/ruby-jira/commit/09c7c5302cec9ccd079d85f0c46466f53775e9da))
|
|
13
20
|
|
|
21
|
+
[0.2.0]: https://github.com/macio/ruby-jira/compare/v0.1.0...v0.2.0
|
|
14
22
|
|
data/README.md
CHANGED
|
@@ -39,7 +39,7 @@ JIRA_EMAIL=you@example.com
|
|
|
39
39
|
JIRA_API_TOKEN=your-api-token
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
### OAuth 2.0
|
|
42
|
+
### OAuth 2.0 - pre-fetched access token
|
|
43
43
|
|
|
44
44
|
```ruby
|
|
45
45
|
Jira.configure do |config|
|
|
@@ -50,7 +50,7 @@ Jira.configure do |config|
|
|
|
50
50
|
end
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
### OAuth 2.0
|
|
53
|
+
### OAuth 2.0 - automatic token refresh (`refresh_token` grant)
|
|
54
54
|
|
|
55
55
|
```ruby
|
|
56
56
|
Jira.configure do |config|
|
|
@@ -64,7 +64,7 @@ Jira.configure do |config|
|
|
|
64
64
|
end
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
### OAuth 2.0
|
|
67
|
+
### OAuth 2.0 - service account (`client_credentials` grant)
|
|
68
68
|
|
|
69
69
|
```ruby
|
|
70
70
|
Jira.configure do |config|
|
|
@@ -162,29 +162,39 @@ Jira.assign_permission_scheme("TEST", scheme_id: 101)
|
|
|
162
162
|
|
|
163
163
|
### Pagination
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
Jira Cloud uses multiple pagination shapes across endpoints. This gem unifies them with `auto_paginate`, `each_page`,
|
|
166
|
+
and `paginate_with_limit`.
|
|
167
|
+
|
|
168
|
+
Offset-paginated responses return `Jira::PaginatedResponse` - includes `GET /project/search`, `GET /issue/{key}/comment`,
|
|
169
|
+
`GET /issue/{key}/worklog`, and others:
|
|
166
170
|
|
|
167
171
|
```ruby
|
|
168
172
|
page = Jira.projects
|
|
169
|
-
page.total
|
|
170
|
-
page.start_at
|
|
171
|
-
page.max_results
|
|
172
|
-
page.last_page?
|
|
173
|
+
page.total # total count
|
|
174
|
+
page.start_at # current offset
|
|
175
|
+
page.max_results # page size
|
|
176
|
+
page.last_page? # isLast flag
|
|
173
177
|
page.next_page?
|
|
174
|
-
page.next_page
|
|
175
|
-
page.auto_paginate
|
|
178
|
+
page.next_page # fetches the next page
|
|
179
|
+
page.auto_paginate # fetches all pages, returns flat Array
|
|
176
180
|
page.paginate_with_limit(200)
|
|
177
181
|
page.each_page { |p| process(p) }
|
|
178
182
|
```
|
|
179
183
|
|
|
180
|
-
Cursor-paginated responses (`
|
|
184
|
+
Cursor-paginated responses (`GET /search/jql`, `POST /search/jql`) return `Jira::CursorPaginatedResponse`:
|
|
181
185
|
|
|
182
186
|
```ruby
|
|
183
|
-
|
|
187
|
+
# GET /search/jql returns minimal issue payload by default (id only).
|
|
188
|
+
# Pass fields/expand to fetch richer issue data.
|
|
189
|
+
results = Jira.search_issues_jql(
|
|
190
|
+
jql: "project = TEST ORDER BY created DESC",
|
|
191
|
+
fields: "key,summary"
|
|
192
|
+
)
|
|
184
193
|
results.next_page_token # raw token
|
|
185
194
|
results.next_page?
|
|
186
195
|
results.next_page # fetches next page automatically
|
|
187
196
|
results.auto_paginate # fetches all pages
|
|
197
|
+
results.paginate_with_limit(200)
|
|
188
198
|
```
|
|
189
199
|
|
|
190
200
|
### Rate limiting
|
|
@@ -202,7 +212,7 @@ The client automatically retries `429 Too Many Requests` and `503 Service Unavai
|
|
|
202
212
|
| `X-RateLimit-Reset` | ISO 8601 timestamp | When the rate-limit window resets (429 only) |
|
|
203
213
|
| `X-RateLimit-Limit` | integer | Max request rate for the current scope |
|
|
204
214
|
| `X-RateLimit-Remaining` | integer | Remaining capacity in the current window |
|
|
205
|
-
| `X-RateLimit-NearLimit` | `"true"` | Signals < 20% capacity remains
|
|
215
|
+
| `X-RateLimit-NearLimit` | `"true"` | Signals < 20% capacity remains - consider throttling proactively |
|
|
206
216
|
| `RateLimit-Reason` | string | Which limit was exceeded (`jira-burst-based`, `jira-quota-tenant-based`, etc.) |
|
|
207
217
|
|
|
208
218
|
**Retry strategy:** exponential backoff with proportional jitter (`delay × rand(0.7..1.3)`), respecting `Retry-After` and `X-RateLimit-Reset` headers. Falls back to backoff when no header is present.
|
|
@@ -217,6 +227,30 @@ Jira.configure do |config|
|
|
|
217
227
|
end
|
|
218
228
|
```
|
|
219
229
|
|
|
230
|
+
### Logging
|
|
231
|
+
|
|
232
|
+
Pass any `Logger`-compatible object to enable debug logging. All requests, detected response types, and rate-limit retries are logged at `DEBUG` level.
|
|
233
|
+
|
|
234
|
+
```ruby
|
|
235
|
+
require "logger"
|
|
236
|
+
|
|
237
|
+
Jira.configure do |config|
|
|
238
|
+
config.logger = Logger.new($stdout)
|
|
239
|
+
end
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Sample output:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
GET /project/search {query: {maxResults: 50}}
|
|
246
|
+
→ Jira::PaginatedResponse
|
|
247
|
+
GET /search/jql {query: {jql: "project=TEST", nextPageToken: "..."}}
|
|
248
|
+
→ Jira::CursorPaginatedResponse
|
|
249
|
+
rate limited (HTTP 429), retrying in 5.0s (3 retries left)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Logging is disabled by default (`config.logger = nil`).
|
|
253
|
+
|
|
220
254
|
### Proxy
|
|
221
255
|
|
|
222
256
|
```ruby
|
|
@@ -241,16 +275,17 @@ Jira.http_proxy("proxy.example.com", 8080, "user", "pass")
|
|
|
241
275
|
| `ratelimit_retries` | `JIRA_RATELIMIT_RETRIES` | `4` |
|
|
242
276
|
| `ratelimit_base_delay` | `JIRA_RATELIMIT_BASE_DELAY` | `2.0` |
|
|
243
277
|
| `ratelimit_max_delay` | `JIRA_RATELIMIT_MAX_DELAY` | `30.0` |
|
|
278
|
+
| `logger` | — | `nil` |
|
|
244
279
|
|
|
245
280
|
## Error handling
|
|
246
281
|
|
|
247
282
|
```ruby
|
|
248
|
-
rescue Jira::Error::Unauthorized
|
|
249
|
-
rescue Jira::Error::Forbidden
|
|
250
|
-
rescue Jira::Error::NotFound
|
|
283
|
+
rescue Jira::Error::Unauthorized # 401
|
|
284
|
+
rescue Jira::Error::Forbidden # 403
|
|
285
|
+
rescue Jira::Error::NotFound # 404
|
|
251
286
|
rescue Jira::Error::TooManyRequests # 429
|
|
252
|
-
rescue Jira::Error::ResponseError
|
|
253
|
-
rescue Jira::Error::Base
|
|
287
|
+
rescue Jira::Error::ResponseError # any other 4xx/5xx
|
|
288
|
+
rescue Jira::Error::Base # all gem errors
|
|
254
289
|
```
|
|
255
290
|
|
|
256
291
|
`Jira::Error::ResponseError` exposes:
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jira
|
|
4
|
+
class Client
|
|
5
|
+
# Defines methods related to issue comments.
|
|
6
|
+
#
|
|
7
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/
|
|
8
|
+
module IssueComments
|
|
9
|
+
# Returns a paginated list of comments specified by a list of comment IDs
|
|
10
|
+
#
|
|
11
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-comment-list-post
|
|
12
|
+
#
|
|
13
|
+
# @param payload [Hash] Payload with comment IDs (e.g. { ids: [1, 2, 3] })
|
|
14
|
+
# @param options [Hash] Query parameters (e.g. expand:)
|
|
15
|
+
# @return [Jira::PaginatedResponse]
|
|
16
|
+
def comments_by_ids(payload = {}, options = {})
|
|
17
|
+
post("/comment/list", body: payload, query: options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns all comments for an issue
|
|
21
|
+
#
|
|
22
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-get
|
|
23
|
+
#
|
|
24
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
25
|
+
# @param options [Hash] Query parameters (e.g. startAt:, maxResults:, orderBy:, expand:)
|
|
26
|
+
# @return [Jira::PaginatedResponse]
|
|
27
|
+
def issue_comments(issue_id_or_key, options = {})
|
|
28
|
+
get("/issue/#{url_encode(issue_id_or_key)}/comment", query: options)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Adds a comment to an issue
|
|
32
|
+
#
|
|
33
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post
|
|
34
|
+
#
|
|
35
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
36
|
+
# @param payload [Hash] Comment payload
|
|
37
|
+
# @param options [Hash] Query parameters (e.g. expand:)
|
|
38
|
+
# @return [Hash]
|
|
39
|
+
def add_comment(issue_id_or_key, payload = {}, options = {})
|
|
40
|
+
post("/issue/#{url_encode(issue_id_or_key)}/comment", body: payload, query: options)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Returns a single comment for an issue
|
|
44
|
+
#
|
|
45
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-id-get
|
|
46
|
+
#
|
|
47
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
48
|
+
# @param comment_id [Integer, String] The ID of the comment
|
|
49
|
+
# @param options [Hash] Query parameters
|
|
50
|
+
# @return [Hash]
|
|
51
|
+
def issue_comment(issue_id_or_key, comment_id, options = {})
|
|
52
|
+
get("/issue/#{url_encode(issue_id_or_key)}/comment/#{comment_id}", query: options)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Updates a comment on an issue
|
|
56
|
+
#
|
|
57
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-id-put
|
|
58
|
+
#
|
|
59
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
60
|
+
# @param comment_id [Integer, String] The ID of the comment
|
|
61
|
+
# @param payload [Hash] Comment payload
|
|
62
|
+
# @param options [Hash] Query parameters (e.g. expand:)
|
|
63
|
+
# @return [Hash]
|
|
64
|
+
def update_comment(issue_id_or_key, comment_id, payload = {}, options = {})
|
|
65
|
+
put("/issue/#{url_encode(issue_id_or_key)}/comment/#{comment_id}", body: payload, query: options)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Deletes a comment from an issue
|
|
69
|
+
#
|
|
70
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-id-delete
|
|
71
|
+
#
|
|
72
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
73
|
+
# @param comment_id [Integer, String] The ID of the comment
|
|
74
|
+
# @return [nil]
|
|
75
|
+
def delete_comment(issue_id_or_key, comment_id)
|
|
76
|
+
delete("/issue/#{url_encode(issue_id_or_key)}/comment/#{comment_id}")
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jira
|
|
4
|
+
class Client
|
|
5
|
+
# Defines methods related to issue search.
|
|
6
|
+
#
|
|
7
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/
|
|
8
|
+
module IssueSearch
|
|
9
|
+
# Returns issue suggestions for auto-completion based on a query string
|
|
10
|
+
#
|
|
11
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-issue-picker-get
|
|
12
|
+
#
|
|
13
|
+
# @param options [Hash] Query parameters (e.g. query:, currentJQL:, currentIssueKey:)
|
|
14
|
+
# @return [Hash]
|
|
15
|
+
def issue_picker(options = {})
|
|
16
|
+
get("/issue/picker", query: options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Checks whether one or more issues would be returned by a JQL query
|
|
20
|
+
#
|
|
21
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-jql-match-post
|
|
22
|
+
#
|
|
23
|
+
# @param payload [Hash] Payload with JQL queries and issue IDs to match
|
|
24
|
+
# @return [Hash]
|
|
25
|
+
def match_issues(payload = {})
|
|
26
|
+
post("/jql/match", body: payload)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Returns an approximate count of issues matching a JQL query
|
|
30
|
+
#
|
|
31
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-approximate-count-post
|
|
32
|
+
#
|
|
33
|
+
# @param payload [Hash] Payload with JQL query (e.g. { jql: "project = EX" })
|
|
34
|
+
# @return [Hash]
|
|
35
|
+
def approximate_issue_count(payload = {})
|
|
36
|
+
post("/search/approximate-count", body: payload)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Searches for issues using JQL with reconciliation (GET)
|
|
40
|
+
#
|
|
41
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get
|
|
42
|
+
#
|
|
43
|
+
# @param options [Hash] Query parameters (e.g. jql:, nextPageToken:, maxResults:, fields:)
|
|
44
|
+
# @return [Jira::CursorPaginatedResponse]
|
|
45
|
+
def search_issues_jql(options = {})
|
|
46
|
+
get("/search/jql", query: options)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Searches for issues using JQL with reconciliation (POST)
|
|
50
|
+
#
|
|
51
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-post
|
|
52
|
+
#
|
|
53
|
+
# @param payload [Hash] Search payload (e.g. jql:, nextPageToken:, maxResults:, fields:)
|
|
54
|
+
# @return [Jira::CursorPaginatedResponse]
|
|
55
|
+
def search_issues_jql_post(payload = {})
|
|
56
|
+
post("/search/jql", body: payload)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jira
|
|
4
|
+
class Client
|
|
5
|
+
# Defines methods related to issue worklogs.
|
|
6
|
+
#
|
|
7
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/
|
|
8
|
+
module IssueWorklogs
|
|
9
|
+
# Returns worklogs for an issue
|
|
10
|
+
#
|
|
11
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-get
|
|
12
|
+
#
|
|
13
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
14
|
+
# @param options [Hash] Query parameters
|
|
15
|
+
# @return [Jira::PaginatedResponse]
|
|
16
|
+
def issue_worklogs(issue_id_or_key, options = {})
|
|
17
|
+
get("/issue/#{url_encode(issue_id_or_key)}/worklog", query: options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Adds a worklog to an issue
|
|
21
|
+
#
|
|
22
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-post
|
|
23
|
+
#
|
|
24
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
25
|
+
# @param payload [Hash] Worklog payload
|
|
26
|
+
# @param options [Hash] Query parameters
|
|
27
|
+
# @return [Hash]
|
|
28
|
+
def add_worklog(issue_id_or_key, payload = {}, options = {})
|
|
29
|
+
post("/issue/#{url_encode(issue_id_or_key)}/worklog", body: payload, query: options)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Bulk deletes worklogs from an issue
|
|
33
|
+
#
|
|
34
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-delete
|
|
35
|
+
#
|
|
36
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
37
|
+
# @param payload [Hash] Worklog IDs payload
|
|
38
|
+
# @return [nil]
|
|
39
|
+
def bulk_delete_worklogs(issue_id_or_key, payload = {})
|
|
40
|
+
delete("/issue/#{url_encode(issue_id_or_key)}/worklog", body: payload)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Bulk moves worklogs from an issue
|
|
44
|
+
#
|
|
45
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-move-post
|
|
46
|
+
#
|
|
47
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
48
|
+
# @param payload [Hash] Move worklogs payload
|
|
49
|
+
# @return [nil]
|
|
50
|
+
def bulk_move_worklogs(issue_id_or_key, payload = {})
|
|
51
|
+
post("/issue/#{url_encode(issue_id_or_key)}/worklog/move", body: payload)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Returns a single worklog for an issue
|
|
55
|
+
#
|
|
56
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-id-get
|
|
57
|
+
#
|
|
58
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
59
|
+
# @param worklog_id [Integer, String] The ID of the worklog
|
|
60
|
+
# @param options [Hash] Query parameters
|
|
61
|
+
# @return [Hash]
|
|
62
|
+
def worklog(issue_id_or_key, worklog_id, options = {})
|
|
63
|
+
get("/issue/#{url_encode(issue_id_or_key)}/worklog/#{worklog_id}", query: options)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Updates a worklog on an issue
|
|
67
|
+
#
|
|
68
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-id-put
|
|
69
|
+
#
|
|
70
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
71
|
+
# @param worklog_id [Integer, String] The ID of the worklog
|
|
72
|
+
# @param payload [Hash] Worklog payload
|
|
73
|
+
# @param options [Hash] Query parameters
|
|
74
|
+
# @return [Hash]
|
|
75
|
+
def update_worklog(issue_id_or_key, worklog_id, payload = {}, options = {})
|
|
76
|
+
put("/issue/#{url_encode(issue_id_or_key)}/worklog/#{worklog_id}", body: payload, query: options)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Deletes a worklog from an issue
|
|
80
|
+
#
|
|
81
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-id-delete
|
|
82
|
+
#
|
|
83
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
84
|
+
# @param worklog_id [Integer, String] The ID of the worklog
|
|
85
|
+
# @param options [Hash] Query parameters
|
|
86
|
+
# @return [nil]
|
|
87
|
+
def delete_worklog(issue_id_or_key, worklog_id, options = {})
|
|
88
|
+
delete("/issue/#{url_encode(issue_id_or_key)}/worklog/#{worklog_id}", query: options)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Returns IDs of worklogs deleted since a given time
|
|
92
|
+
#
|
|
93
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-worklog-deleted-get
|
|
94
|
+
#
|
|
95
|
+
# @param options [Hash] Query parameters (e.g. since:)
|
|
96
|
+
# @return [Jira::CursorPaginatedResponse]
|
|
97
|
+
def deleted_worklog_ids(options = {})
|
|
98
|
+
get("/worklog/deleted", query: options)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Returns worklogs for a list of IDs
|
|
102
|
+
#
|
|
103
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-worklog-list-post
|
|
104
|
+
#
|
|
105
|
+
# @param payload [Hash] Worklog IDs payload
|
|
106
|
+
# @param options [Hash] Query parameters
|
|
107
|
+
# @return [Array<Hash>]
|
|
108
|
+
def worklogs_for_ids(payload = {}, options = {})
|
|
109
|
+
post("/worklog/list", body: payload, query: options)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Returns IDs of worklogs updated since a given time
|
|
113
|
+
#
|
|
114
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-worklog-updated-get
|
|
115
|
+
#
|
|
116
|
+
# @param options [Hash] Query parameters (e.g. since:)
|
|
117
|
+
# @return [Jira::CursorPaginatedResponse]
|
|
118
|
+
def updated_worklog_ids(options = {})
|
|
119
|
+
get("/worklog/updated", query: options)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
data/lib/jira/client/issues.rb
CHANGED
|
@@ -3,17 +3,33 @@
|
|
|
3
3
|
module Jira
|
|
4
4
|
class Client
|
|
5
5
|
# Defines methods related to issues.
|
|
6
|
+
#
|
|
7
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/
|
|
6
8
|
module Issues
|
|
7
9
|
# Creates a new issue
|
|
8
10
|
#
|
|
11
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post
|
|
12
|
+
#
|
|
9
13
|
# @param payload [Hash] Issue payload
|
|
10
14
|
# @return [Hash]
|
|
11
15
|
def create_issue(payload = {})
|
|
12
16
|
post("/issue", body: payload)
|
|
13
17
|
end
|
|
14
18
|
|
|
19
|
+
# Creates multiple issues in a single request
|
|
20
|
+
#
|
|
21
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulk-post
|
|
22
|
+
#
|
|
23
|
+
# @param payload [Hash] Bulk issue creation payload
|
|
24
|
+
# @return [Hash]
|
|
25
|
+
def bulk_create_issues(payload = {})
|
|
26
|
+
post("/issue/bulk", body: payload)
|
|
27
|
+
end
|
|
28
|
+
|
|
15
29
|
# Gets a single issue
|
|
16
30
|
#
|
|
31
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-get
|
|
32
|
+
#
|
|
17
33
|
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
18
34
|
# @param options [Hash] Query parameters
|
|
19
35
|
# @return [Hash]
|
|
@@ -23,6 +39,8 @@ module Jira
|
|
|
23
39
|
|
|
24
40
|
# Updates an existing issue
|
|
25
41
|
#
|
|
42
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put
|
|
43
|
+
#
|
|
26
44
|
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
27
45
|
# @param payload [Hash] Issue payload
|
|
28
46
|
# @param options [Hash] Query parameters
|
|
@@ -30,6 +48,179 @@ module Jira
|
|
|
30
48
|
def edit_issue(issue_id_or_key, payload = {}, options = {})
|
|
31
49
|
put("/issue/#{url_encode(issue_id_or_key)}", body: payload, query: options)
|
|
32
50
|
end
|
|
51
|
+
|
|
52
|
+
# Deletes an issue
|
|
53
|
+
#
|
|
54
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-delete
|
|
55
|
+
#
|
|
56
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
57
|
+
# @param options [Hash] Query parameters (e.g. deleteSubtasks)
|
|
58
|
+
# @return [nil]
|
|
59
|
+
def delete_issue(issue_id_or_key, options = {})
|
|
60
|
+
delete("/issue/#{url_encode(issue_id_or_key)}", query: options)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Assigns an issue to a user
|
|
64
|
+
#
|
|
65
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-assignee-put
|
|
66
|
+
#
|
|
67
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
68
|
+
# @param payload [Hash] Assignee payload (e.g. { accountId: "..." })
|
|
69
|
+
# @return [nil]
|
|
70
|
+
def assign_issue(issue_id_or_key, payload = {})
|
|
71
|
+
put("/issue/#{url_encode(issue_id_or_key)}/assignee", body: payload)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Returns a list of transitions for an issue
|
|
75
|
+
#
|
|
76
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-get
|
|
77
|
+
#
|
|
78
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
79
|
+
# @param options [Hash] Query parameters
|
|
80
|
+
# @return [Hash]
|
|
81
|
+
def issue_transitions(issue_id_or_key, options = {})
|
|
82
|
+
get("/issue/#{url_encode(issue_id_or_key)}/transitions", query: options)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Performs a transition on an issue
|
|
86
|
+
#
|
|
87
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-post
|
|
88
|
+
#
|
|
89
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
90
|
+
# @param payload [Hash] Transition payload
|
|
91
|
+
# @return [nil]
|
|
92
|
+
def transition_issue(issue_id_or_key, payload = {})
|
|
93
|
+
post("/issue/#{url_encode(issue_id_or_key)}/transitions", body: payload)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Returns paginated changelog for an issue
|
|
97
|
+
#
|
|
98
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-changelog-get
|
|
99
|
+
#
|
|
100
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
101
|
+
# @param options [Hash] Query parameters
|
|
102
|
+
# @return [Jira::PaginatedResponse]
|
|
103
|
+
def issue_changelog(issue_id_or_key, options = {})
|
|
104
|
+
get("/issue/#{url_encode(issue_id_or_key)}/changelog", query: options)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Returns the watchers for an issue
|
|
108
|
+
#
|
|
109
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-watchers-get
|
|
110
|
+
#
|
|
111
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
112
|
+
# @return [Hash]
|
|
113
|
+
def issue_watchers(issue_id_or_key)
|
|
114
|
+
get("/issue/#{url_encode(issue_id_or_key)}/watchers")
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Adds a watcher to an issue
|
|
118
|
+
#
|
|
119
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-watchers-post
|
|
120
|
+
#
|
|
121
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
122
|
+
# @param account_id [String] The account ID of the user to watch the issue
|
|
123
|
+
# @return [nil]
|
|
124
|
+
def add_watcher(issue_id_or_key, account_id)
|
|
125
|
+
post("/issue/#{url_encode(issue_id_or_key)}/watchers", body: account_id)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Removes a watcher from an issue
|
|
129
|
+
#
|
|
130
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-watchers-delete
|
|
131
|
+
#
|
|
132
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
133
|
+
# @param account_id [String] The account ID of the user to remove
|
|
134
|
+
# @return [nil]
|
|
135
|
+
def remove_watcher(issue_id_or_key, account_id:)
|
|
136
|
+
delete("/issue/#{url_encode(issue_id_or_key)}/watchers", query: { accountId: account_id })
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Returns vote information for an issue
|
|
140
|
+
#
|
|
141
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-votes-get
|
|
142
|
+
#
|
|
143
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
144
|
+
# @return [Hash]
|
|
145
|
+
def issue_votes(issue_id_or_key)
|
|
146
|
+
get("/issue/#{url_encode(issue_id_or_key)}/votes")
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Adds a vote to an issue
|
|
150
|
+
#
|
|
151
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-votes-post
|
|
152
|
+
#
|
|
153
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
154
|
+
# @return [nil]
|
|
155
|
+
def add_vote(issue_id_or_key)
|
|
156
|
+
post("/issue/#{url_encode(issue_id_or_key)}/votes")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Removes a vote from an issue
|
|
160
|
+
#
|
|
161
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-votes-delete
|
|
162
|
+
#
|
|
163
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
164
|
+
# @return [nil]
|
|
165
|
+
def remove_vote(issue_id_or_key)
|
|
166
|
+
delete("/issue/#{url_encode(issue_id_or_key)}/votes")
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Returns remote links for an issue
|
|
170
|
+
#
|
|
171
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-remotelink-get
|
|
172
|
+
#
|
|
173
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
174
|
+
# @param options [Hash] Query parameters
|
|
175
|
+
# @return [Array<Hash>]
|
|
176
|
+
def issue_remote_links(issue_id_or_key, options = {})
|
|
177
|
+
get("/issue/#{url_encode(issue_id_or_key)}/remotelink", query: options)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Creates or updates a remote link for an issue
|
|
181
|
+
#
|
|
182
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-remotelink-post
|
|
183
|
+
#
|
|
184
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
185
|
+
# @param payload [Hash] Remote link payload
|
|
186
|
+
# @return [Hash]
|
|
187
|
+
def create_or_update_remote_link(issue_id_or_key, payload = {})
|
|
188
|
+
post("/issue/#{url_encode(issue_id_or_key)}/remotelink", body: payload)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Returns a single remote link for an issue
|
|
192
|
+
#
|
|
193
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-remotelink-linkid-get
|
|
194
|
+
#
|
|
195
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
196
|
+
# @param link_id [Integer, String] The ID of the remote link
|
|
197
|
+
# @return [Hash]
|
|
198
|
+
def remote_link(issue_id_or_key, link_id)
|
|
199
|
+
get("/issue/#{url_encode(issue_id_or_key)}/remotelink/#{link_id}")
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Updates a remote link for an issue
|
|
203
|
+
#
|
|
204
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-remotelink-linkid-put
|
|
205
|
+
#
|
|
206
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
207
|
+
# @param link_id [Integer, String] The ID of the remote link
|
|
208
|
+
# @param payload [Hash] Remote link payload
|
|
209
|
+
# @return [nil]
|
|
210
|
+
def update_remote_link(issue_id_or_key, link_id, payload = {})
|
|
211
|
+
put("/issue/#{url_encode(issue_id_or_key)}/remotelink/#{link_id}", body: payload)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Deletes a remote link from an issue
|
|
215
|
+
#
|
|
216
|
+
# @url https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-remotelink-linkid-delete
|
|
217
|
+
#
|
|
218
|
+
# @param issue_id_or_key [Integer, String] The ID or key of an issue
|
|
219
|
+
# @param link_id [Integer, String] The ID of the remote link
|
|
220
|
+
# @return [nil]
|
|
221
|
+
def delete_remote_link(issue_id_or_key, link_id)
|
|
222
|
+
delete("/issue/#{url_encode(issue_id_or_key)}/remotelink/#{link_id}")
|
|
223
|
+
end
|
|
33
224
|
end
|
|
34
225
|
end
|
|
35
226
|
end
|