ruby-jira 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b943c4b2403edafbd328b20a1d6dc77378a9da1c760fad052df79b06e6af64d9
4
- data.tar.gz: 9919c24e5dfecfb5cb5f5ec422cb9361fb50960f0cd25b2586924590b3d5facd
3
+ metadata.gz: 8db967aea6d2666d5d82812d3f6bdf7b35862746e9ab7d0b41cac9f4f3cde34b
4
+ data.tar.gz: cddac80bdc8823c0a439ed6ef15529b256de051f823463859f50fc44b0c387c8
5
5
  SHA512:
6
- metadata.gz: 8c0a1e01394b98162692dc8da79d96dd232e2e0474d40fd4f1fd7d11d237dee99060e79939d67f1d709fec87df9f45d007fb38cc0d58f3353e54986aafd66a96
7
- data.tar.gz: 87cead95e1bb42f69e20ea8a8bac887bd6e40b233d45e8a2b08a65a199925398f8c910b91ff1adac2f4342acea01c5d5e3fd2a08d1cde63d0f6d58d4a8e0a177
6
+ metadata.gz: b127f0122f18f5221243804aec2f75b115e326e35bdbabc25c5495392ee219a2813c3953ed7731bd440f9612deaf06028bd2cec728287991f0e675c1b01551a5
7
+ data.tar.gz: bbfc97f14cd904bfbf8b24c9012aa45813e566123ebf87600fd83840619c78aa7d58e7971c22693376d4793b3a8155d28d125f5d31a70703064c7385e8a19752
data/CHANGELOG.md CHANGED
@@ -5,12 +5,27 @@ 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.3.0] - 2026-11-27
9
+
10
+ ### Added
11
+
12
+ - Add epic and agile issue endpoints (Jira Software Cloud API) (#12) ([3ad2c31](https://github.com/macio/ruby-jira/commit/3ad2c311abae5a54de2723cbf8827400aece3ec6))
13
+ - Add board endpoints (Jira Software Cloud API) (#11) ([e62a7cb](https://github.com/macio/ruby-jira/commit/e62a7cb7c818010a0880c256690ed679e78d70eb))
14
+ - Add Jira Software Cloud agile API - sprint endpoints (#10) ([a17893d](https://github.com/macio/ruby-jira/commit/a17893dd013547430846a9a1af51901a7ced5ea4))
15
+
8
16
  ## [0.2.0] - 2026-03-14
9
17
 
10
18
  ### Added
11
19
 
20
+ - Issue-worklogs-api (#9) ([fefa37c](https://github.com/macio/ruby-jira/commit/fefa37c48ecabaf62353015c3cc3866f6bfb251d))
12
21
  - Add time tracking api (#8) ([836bc35](https://github.com/macio/ruby-jira/commit/836bc35ba53369acf683bf3c18424816b9aecf8e))
22
+ - Add project categories (#7) ([7bd8f80](https://github.com/macio/ruby-jira/commit/7bd8f8004d708ba49dd867dd4fffa083d7021886))
13
23
  - Add project properties client (#6) ([db8796f](https://github.com/macio/ruby-jira/commit/db8796fcc59f34d91b5e9835730581ff9599fb5b))
24
+ - Universal pagination (#5) ([d828945](https://github.com/macio/ruby-jira/commit/d828945b69e3e384e8e43c5b788f853bdf966963))
25
+ - Issue search api (#4) ([74f22ea](https://github.com/macio/ruby-jira/commit/74f22ea5e66583f17a124b30bc0582d81d8153a0))
26
+ - Issue comments api (#3) ([d54da8d](https://github.com/macio/ruby-jira/commit/d54da8d55c749399381c896d56ec80dfd7e9a0d1))
27
+ - Issues and permission schemes api (#2) ([d57857d](https://github.com/macio/ruby-jira/commit/d57857d0c682a338212ae1d5e2e06d78926cb767))
28
+ - Projects api methods (#1) ([e410703](https://github.com/macio/ruby-jira/commit/e4107033b0229886dab39ae865de115f78d2d911))
14
29
 
15
30
  ## [0.1.0] - 2026-03-09
16
31
 
@@ -18,5 +33,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
33
 
19
34
  - Add initial ruby-jira Jira API client gem ([09c7c53](https://github.com/macio/ruby-jira/commit/09c7c5302cec9ccd079d85f0c46466f53775e9da))
20
35
 
36
+ [0.3.0]: https://github.com/macio/ruby-jira/compare/v0.2.0...v0.3.0
21
37
  [0.2.0]: https://github.com/macio/ruby-jira/compare/v0.1.0...v0.2.0
22
38
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ruby-jira
2
2
 
3
- Ruby client for the [Jira Cloud REST API v3](https://developer.atlassian.com/cloud/jira/platform/rest/v3/).
3
+ Ruby client for the [Jira Cloud REST API v3](https://developer.atlassian.com/cloud/jira/platform/rest/v3/) and the [Jira Software Cloud REST API](https://developer.atlassian.com/cloud/jira/software/rest/intro/) (agile — sprints, boards).
4
4
 
5
5
  > Inspired by and based on the architecture of [NARKOZ/gitlab](https://github.com/NARKOZ/gitlab) — a Ruby wrapper for the GitLab API. Many thanks for the solid foundation.
6
6
 
@@ -160,6 +160,152 @@ Jira.issue_security_level_scheme("TEST")
160
160
  Jira.assign_permission_scheme("TEST", scheme_id: 101)
161
161
  ```
162
162
 
163
+ ### Epics (Jira Software Cloud API)
164
+
165
+ ```ruby
166
+ # Get a single epic
167
+ epic = Jira.epic(37)
168
+ epic.name # => "epic 1"
169
+ epic.summary # => "epic 1 summary"
170
+ epic.done # => false
171
+
172
+ # Partially update an epic
173
+ Jira.update_epic(37, { name: "New name", done: true })
174
+
175
+ # Issues in an epic (offset-paginated)
176
+ issues = Jira.epic_issues(37, maxResults: 50)
177
+ issues.total
178
+ issues.auto_paginate
179
+
180
+ # Issues with no epic assigned
181
+ Jira.issues_without_epic(jql: "project = TEST")
182
+
183
+ # Move issues to an epic / remove from epic
184
+ Jira.move_issues_to_epic(37, issues: ["TEST-1", "TEST-2"])
185
+ Jira.unassign_issues_from_epic(issues: ["TEST-3"])
186
+
187
+ # Rank an epic relative to another
188
+ Jira.rank_epic(37, { rankBeforeEpic: 42 })
189
+ ```
190
+
191
+ ### Agile Issues (Jira Software Cloud API)
192
+
193
+ ```ruby
194
+ # Get an issue with agile fields (sprint, epic, flagged)
195
+ issue = Jira.agile_issue("TEST-1")
196
+ issue.key # => "TEST-1"
197
+ issue.fields.sprint.name # => "sprint 2"
198
+ issue.fields.epic.name # => "epic 1"
199
+ issue.fields.flagged # => true
200
+
201
+ # Estimation
202
+ est = Jira.issue_estimation("TEST-1", boardId: 84)
203
+ est[:fieldId] # => "customfield_12532"
204
+ est[:value] # => "8.0"
205
+
206
+ Jira.update_issue_estimation("TEST-1", { value: "13.0" }, boardId: 84)
207
+
208
+ # Rank issues relative to another
209
+ Jira.rank_issues({ issues: ["TEST-1", "TEST-2"], rankBeforeIssue: "TEST-3" })
210
+ ```
211
+
212
+ ### Boards (Jira Software Cloud API)
213
+
214
+ Board methods use the Jira Software Cloud REST API (`/rest/agile/1.0`) transparently - no extra configuration needed.
215
+
216
+ ```ruby
217
+ # List all boards (offset-paginated)
218
+ boards = Jira.boards(type: "scrum", maxResults: 50)
219
+ boards.total
220
+ boards.first[:name] # => "scrum board"
221
+ boards.auto_paginate
222
+
223
+ # Boards for a filter
224
+ Jira.boards_for_filter(1001)
225
+
226
+ # Get / create / delete a board
227
+ board = Jira.board(84)
228
+ board.name # => "scrum board"
229
+ board.type # => "scrum"
230
+ Jira.create_board({ name: "New Board", type: "scrum", filterId: 1001 })
231
+ Jira.delete_board(84)
232
+
233
+ # Board configuration
234
+ config = Jira.board_configuration(84)
235
+ config[:columnConfig][:columns].map { |c| c[:name] } # => ["To Do", "In Progress", "Done"]
236
+
237
+ # Features (enable/disable board panels)
238
+ Jira.board_features(84)
239
+ Jira.toggle_board_feature(84, { feature: "BACKLOG", state: "ENABLED" })
240
+
241
+ # Backlog and issues
242
+ Jira.board_backlog(84, maxResults: 50)
243
+ Jira.board_issues(84, jql: "assignee = currentUser()")
244
+ Jira.move_issues_to_board(84, issues: ["TEST-1", "TEST-2"])
245
+
246
+ # Epics
247
+ Jira.board_epics(84, done: false)
248
+ Jira.board_issues_without_epic(84)
249
+ Jira.board_epic_issues(84, 37)
250
+
251
+ # Sprints
252
+ sprints = Jira.board_sprints(84, state: "active")
253
+ Jira.board_sprint_issues(84, 37)
254
+
255
+ # Projects and versions
256
+ Jira.board_projects(84)
257
+ Jira.board_projects_full(84)
258
+ Jira.board_versions(84, released: false)
259
+
260
+ # Quick filters
261
+ Jira.board_quick_filters(84)
262
+ Jira.board_quick_filter(84, 1)
263
+
264
+ # Reports
265
+ Jira.board_reports(84)
266
+
267
+ # Board properties
268
+ Jira.board_property_keys(84)
269
+ Jira.board_property(84, "my.key")
270
+ Jira.set_board_property(84, "my.key", { foo: "bar" })
271
+ Jira.delete_board_property(84, "my.key")
272
+ ```
273
+
274
+ ### Sprints (Jira Software Cloud API)
275
+
276
+ Sprint methods use the Jira Software Cloud REST API (`/rest/agile/1.0`) transparently — no extra configuration needed.
277
+
278
+ ```ruby
279
+ # Get a sprint
280
+ sprint = Jira.sprint(37)
281
+ sprint.name # => "sprint 1"
282
+ sprint.state # => "future"
283
+
284
+ # Create / update / delete
285
+ Jira.create_sprint({ name: "Sprint 5", originBoardId: 5, goal: "ship it" })
286
+ Jira.update_sprint(37, { name: "Sprint 5 — revised" }) # partial update (POST)
287
+ Jira.replace_sprint(37, { name: "Sprint 5", originBoardId: 5, state: "active" }) # full update (PUT)
288
+ Jira.delete_sprint(37)
289
+
290
+ # Issues in a sprint (offset-paginated)
291
+ issues = Jira.sprint_issues(37, maxResults: 50)
292
+ issues.total
293
+ issues.auto_paginate
294
+ issues.map { |i| i[:key] }
295
+
296
+ # Move issues into a sprint
297
+ Jira.move_issues_to_sprint(37, issues: ["TEST-1", "TEST-2"])
298
+
299
+ # Swap sprint position with another sprint
300
+ Jira.swap_sprint(37, sprint_to_swap_with: 42)
301
+
302
+ # Sprint properties
303
+ Jira.sprint_property_keys(37)
304
+ Jira.sprint_property(37, "my.key")
305
+ Jira.set_sprint_property(37, "my.key", { foo: "bar" })
306
+ Jira.delete_sprint_property(37, "my.key")
307
+ ```
308
+
163
309
  ### Pagination
164
310
 
165
311
  Jira Cloud uses multiple pagination shapes across endpoints. This gem unifies them with `auto_paginate`, `each_page`,
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jira
4
+ class Client
5
+ # Defines methods related to issues via the Jira Software Cloud API.
6
+ #
7
+ # These methods complement the Platform API issue methods in the Issues module
8
+ # with agile-specific fields and operations (sprint, epic, ranking, estimation).
9
+ #
10
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/
11
+ module AgileIssues
12
+ # Ranks issues before or after a given issue
13
+ #
14
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/#api-rest-agile-1-0-issue-rank-put
15
+ #
16
+ # @param payload [Hash] Rank payload (issues:, rankBeforeIssue:, rankAfterIssue:, rankCustomFieldId:)
17
+ # @return [nil]
18
+ def rank_issues(payload = {})
19
+ agile_put("/issue/rank", body: payload)
20
+ end
21
+
22
+ # Returns a single issue with agile-specific fields (sprint, epic, flagged)
23
+ #
24
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/#api-rest-agile-1-0-issue-issueidorkey-get
25
+ #
26
+ # @param issue_id_or_key [String] The ID or key of the issue
27
+ # @param options [Hash] Query parameters (fields:, expand:, updateHistory:)
28
+ # @return [Hash]
29
+ def agile_issue(issue_id_or_key, options = {})
30
+ agile_get("/issue/#{url_encode(issue_id_or_key)}", query: options)
31
+ end
32
+
33
+ # Returns the estimation of the issue
34
+ #
35
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/#api-rest-agile-1-0-issue-issueidorkey-estimation-get
36
+ #
37
+ # @param issue_id_or_key [String] The ID or key of the issue
38
+ # @param options [Hash] Query parameters (boardId:)
39
+ # @return [Hash]
40
+ def issue_estimation(issue_id_or_key, options = {})
41
+ agile_get("/issue/#{url_encode(issue_id_or_key)}/estimation", query: options)
42
+ end
43
+
44
+ # Updates the estimation of the issue
45
+ #
46
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/#api-rest-agile-1-0-issue-issueidorkey-estimation-put
47
+ #
48
+ # @param issue_id_or_key [String] The ID or key of the issue
49
+ # @param payload [Hash] Estimation payload (value:)
50
+ # @param options [Hash] Query parameters (boardId:)
51
+ # @return [Hash]
52
+ def update_issue_estimation(issue_id_or_key, payload = {}, options = {})
53
+ agile_put("/issue/#{url_encode(issue_id_or_key)}/estimation", body: payload, query: options)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,291 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jira
4
+ class Client
5
+ # Defines methods related to boards (Jira Software Cloud API).
6
+ #
7
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/
8
+ module Boards
9
+ # Returns all boards
10
+ #
11
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-get
12
+ #
13
+ # @param options [Hash] Query parameters (startAt:, maxResults:, type:, name:, projectKeyOrId:, ...)
14
+ # @return [Jira::PaginatedResponse]
15
+ def boards(options = {})
16
+ agile_get("/board", query: options)
17
+ end
18
+
19
+ # Creates a new board
20
+ #
21
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-post
22
+ #
23
+ # @param payload [Hash] Board payload (name:, type:, filterId:, location:)
24
+ # @return [Hash]
25
+ def create_board(payload = {})
26
+ agile_post("/board", body: payload)
27
+ end
28
+
29
+ # Returns all boards for the given filter
30
+ #
31
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-filter-filterid-get
32
+ #
33
+ # @param filter_id [Integer] The ID of the filter
34
+ # @param options [Hash] Query parameters (startAt:, maxResults:)
35
+ # @return [Jira::PaginatedResponse]
36
+ def boards_for_filter(filter_id, options = {})
37
+ agile_get("/board/filter/#{filter_id}", query: options)
38
+ end
39
+
40
+ # Returns the board for the given board ID
41
+ #
42
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-get
43
+ #
44
+ # @param board_id [Integer] The ID of the board
45
+ # @return [Hash]
46
+ def board(board_id)
47
+ agile_get("/board/#{board_id}")
48
+ end
49
+
50
+ # Deletes the board
51
+ #
52
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-delete
53
+ #
54
+ # @param board_id [Integer] The ID of the board
55
+ # @return [nil]
56
+ def delete_board(board_id)
57
+ agile_delete("/board/#{board_id}")
58
+ end
59
+
60
+ # Returns all issues in the backlog of the board
61
+ #
62
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-backlog-get
63
+ #
64
+ # @param board_id [Integer] The ID of the board
65
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
66
+ # @return [Jira::PaginatedResponse]
67
+ def board_backlog(board_id, options = {})
68
+ agile_get("/board/#{board_id}/backlog", query: options)
69
+ end
70
+
71
+ # Returns the configuration of the board
72
+ #
73
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-configuration-get
74
+ #
75
+ # @param board_id [Integer] The ID of the board
76
+ # @return [Hash]
77
+ def board_configuration(board_id)
78
+ agile_get("/board/#{board_id}/configuration")
79
+ end
80
+
81
+ # Returns all epics from the board
82
+ #
83
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-epic-get
84
+ #
85
+ # @param board_id [Integer] The ID of the board
86
+ # @param options [Hash] Query parameters (startAt:, maxResults:, done:)
87
+ # @return [Jira::PaginatedResponse]
88
+ def board_epics(board_id, options = {})
89
+ agile_get("/board/#{board_id}/epic", query: options)
90
+ end
91
+
92
+ # Returns all issues that do not belong to any epic on the board
93
+ #
94
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-epic-none-issue-get
95
+ #
96
+ # @param board_id [Integer] The ID of the board
97
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
98
+ # @return [Jira::PaginatedResponse]
99
+ def board_issues_without_epic(board_id, options = {})
100
+ agile_get("/board/#{board_id}/epic/none/issue", query: options)
101
+ end
102
+
103
+ # Returns all issues that belong to the given epic on the board
104
+ #
105
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-epic-epicid-issue-get
106
+ #
107
+ # @param board_id [Integer] The ID of the board
108
+ # @param epic_id [Integer] The ID of the epic
109
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
110
+ # @return [Jira::PaginatedResponse]
111
+ def board_epic_issues(board_id, epic_id, options = {})
112
+ agile_get("/board/#{board_id}/epic/#{epic_id}/issue", query: options)
113
+ end
114
+
115
+ # Returns the features enabled/disabled for the board
116
+ #
117
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-features-get
118
+ #
119
+ # @param board_id [Integer] The ID of the board
120
+ # @return [Hash]
121
+ def board_features(board_id)
122
+ agile_get("/board/#{board_id}/features")
123
+ end
124
+
125
+ # Toggles a feature on or off for the board
126
+ #
127
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-features-put
128
+ #
129
+ # @param board_id [Integer] The ID of the board
130
+ # @param payload [Hash] Feature toggle payload (feature:, state:)
131
+ # @return [Hash]
132
+ def toggle_board_feature(board_id, payload = {})
133
+ agile_put("/board/#{board_id}/features", body: payload)
134
+ end
135
+
136
+ # Returns all issues from the board
137
+ #
138
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-issue-get
139
+ #
140
+ # @param board_id [Integer] The ID of the board
141
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
142
+ # @return [Jira::PaginatedResponse]
143
+ def board_issues(board_id, options = {})
144
+ agile_get("/board/#{board_id}/issue", query: options)
145
+ end
146
+
147
+ # Moves issues to the backlog of the board
148
+ #
149
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-issue-post
150
+ #
151
+ # @param board_id [Integer] The ID of the board
152
+ # @param issues [Array<String>] List of issue keys or IDs
153
+ # @return [nil]
154
+ def move_issues_to_board(board_id, issues:)
155
+ agile_post("/board/#{board_id}/issue", body: { issues: issues })
156
+ end
157
+
158
+ # Returns all projects that are associated with the board
159
+ #
160
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-project-get
161
+ #
162
+ # @param board_id [Integer] The ID of the board
163
+ # @param options [Hash] Query parameters (startAt:, maxResults:)
164
+ # @return [Jira::PaginatedResponse]
165
+ def board_projects(board_id, options = {})
166
+ agile_get("/board/#{board_id}/project", query: options)
167
+ end
168
+
169
+ # Returns all projects that are associated with the board, including all issue types
170
+ #
171
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-project-full-get
172
+ #
173
+ # @param board_id [Integer] The ID of the board
174
+ # @param options [Hash] Query parameters (startAt:, maxResults:)
175
+ # @return [Jira::PaginatedResponse]
176
+ def board_projects_full(board_id, options = {})
177
+ agile_get("/board/#{board_id}/project/full", query: options)
178
+ end
179
+
180
+ # Returns the keys of all properties for the board
181
+ #
182
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-properties-get
183
+ #
184
+ # @param board_id [Integer] The ID of the board
185
+ # @return [Hash]
186
+ def board_property_keys(board_id)
187
+ agile_get("/board/#{board_id}/properties")
188
+ end
189
+
190
+ # Returns the value of the property with the given key for the board
191
+ #
192
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-properties-propertykey-get
193
+ #
194
+ # @param board_id [Integer] The ID of the board
195
+ # @param property_key [String] The key of the property
196
+ # @return [Hash]
197
+ def board_property(board_id, property_key)
198
+ agile_get("/board/#{board_id}/properties/#{url_encode(property_key)}")
199
+ end
200
+
201
+ # Sets the value of the property with the given key for the board
202
+ #
203
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-properties-propertykey-put
204
+ #
205
+ # @param board_id [Integer] The ID of the board
206
+ # @param property_key [String] The key of the property
207
+ # @param value [Hash] The value to set
208
+ # @return [nil]
209
+ def set_board_property(board_id, property_key, value = {})
210
+ agile_put("/board/#{board_id}/properties/#{url_encode(property_key)}", body: value)
211
+ end
212
+
213
+ # Deletes the property with the given key for the board
214
+ #
215
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-properties-propertykey-delete
216
+ #
217
+ # @param board_id [Integer] The ID of the board
218
+ # @param property_key [String] The key of the property
219
+ # @return [nil]
220
+ def delete_board_property(board_id, property_key)
221
+ agile_delete("/board/#{board_id}/properties/#{url_encode(property_key)}")
222
+ end
223
+
224
+ # Returns all quick filters of the board
225
+ #
226
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-quickfilter-get
227
+ #
228
+ # @param board_id [Integer] The ID of the board
229
+ # @param options [Hash] Query parameters (startAt:, maxResults:)
230
+ # @return [Jira::PaginatedResponse]
231
+ def board_quick_filters(board_id, options = {})
232
+ agile_get("/board/#{board_id}/quickfilter", query: options)
233
+ end
234
+
235
+ # Returns the quick filter for the given board and quick filter ID
236
+ #
237
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-quickfilter-quickfilterid-get
238
+ #
239
+ # @param board_id [Integer] The ID of the board
240
+ # @param quick_filter_id [Integer] The ID of the quick filter
241
+ # @return [Hash]
242
+ def board_quick_filter(board_id, quick_filter_id)
243
+ agile_get("/board/#{board_id}/quickfilter/#{quick_filter_id}")
244
+ end
245
+
246
+ # Returns the board reports
247
+ #
248
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-reports-get
249
+ #
250
+ # @param board_id [Integer] The ID of the board
251
+ # @return [Hash]
252
+ def board_reports(board_id)
253
+ agile_get("/board/#{board_id}/reports")
254
+ end
255
+
256
+ # Returns all sprints from the board
257
+ #
258
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-sprint-get
259
+ #
260
+ # @param board_id [Integer] The ID of the board
261
+ # @param options [Hash] Query parameters (startAt:, maxResults:, state:)
262
+ # @return [Jira::PaginatedResponse]
263
+ def board_sprints(board_id, options = {})
264
+ agile_get("/board/#{board_id}/sprint", query: options)
265
+ end
266
+
267
+ # Returns all issues in the sprint for the given board
268
+ #
269
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-sprint-sprintid-issue-get
270
+ #
271
+ # @param board_id [Integer] The ID of the board
272
+ # @param sprint_id [Integer] The ID of the sprint
273
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
274
+ # @return [Jira::PaginatedResponse]
275
+ def board_sprint_issues(board_id, sprint_id, options = {})
276
+ agile_get("/board/#{board_id}/sprint/#{sprint_id}/issue", query: options)
277
+ end
278
+
279
+ # Returns all versions from the board
280
+ #
281
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-version-get
282
+ #
283
+ # @param board_id [Integer] The ID of the board
284
+ # @param options [Hash] Query parameters (startAt:, maxResults:, released:)
285
+ # @return [Jira::PaginatedResponse]
286
+ def board_versions(board_id, options = {})
287
+ agile_get("/board/#{board_id}/version", query: options)
288
+ end
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jira
4
+ class Client
5
+ # Defines methods related to epics (Jira Software Cloud API).
6
+ #
7
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/
8
+ module Epics
9
+ # Returns all issues that do not belong to any epic
10
+ #
11
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-none-issue-get
12
+ #
13
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
14
+ # @return [Jira::PaginatedResponse]
15
+ def issues_without_epic(options = {})
16
+ agile_get("/epic/none/issue", query: options)
17
+ end
18
+
19
+ # Removes issues from their epic (moves them to no epic)
20
+ #
21
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-none-issue-post
22
+ #
23
+ # @param issues [Array<String>] List of issue keys or IDs
24
+ # @return [nil]
25
+ def unassign_issues_from_epic(issues:)
26
+ agile_post("/epic/none/issue", body: { issues: issues })
27
+ end
28
+
29
+ # Returns the epic for the given epic ID or key
30
+ #
31
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-epicidorkey-get
32
+ #
33
+ # @param epic_id_or_key [Integer, String] The ID or key of the epic
34
+ # @return [Hash]
35
+ def epic(epic_id_or_key)
36
+ agile_get("/epic/#{url_encode(epic_id_or_key)}")
37
+ end
38
+
39
+ # Partially updates an epic
40
+ #
41
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-epicidorkey-post
42
+ #
43
+ # @param epic_id_or_key [Integer, String] The ID or key of the epic
44
+ # @param payload [Hash] Fields to update (name:, summary:, color:, done:)
45
+ # @return [Hash]
46
+ def update_epic(epic_id_or_key, payload = {})
47
+ agile_post("/epic/#{url_encode(epic_id_or_key)}", body: payload)
48
+ end
49
+
50
+ # Returns all issues that belong to the given epic
51
+ #
52
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-epicidorkey-issue-get
53
+ #
54
+ # @param epic_id_or_key [Integer, String] The ID or key of the epic
55
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:, ...)
56
+ # @return [Jira::PaginatedResponse]
57
+ def epic_issues(epic_id_or_key, options = {})
58
+ agile_get("/epic/#{url_encode(epic_id_or_key)}/issue", query: options)
59
+ end
60
+
61
+ # Moves issues to an epic
62
+ #
63
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-epicidorkey-issue-post
64
+ #
65
+ # @param epic_id_or_key [Integer, String] The ID or key of the epic
66
+ # @param issues [Array<String>] List of issue keys or IDs
67
+ # @return [nil]
68
+ def move_issues_to_epic(epic_id_or_key, issues:)
69
+ agile_post("/epic/#{url_encode(epic_id_or_key)}/issue", body: { issues: issues })
70
+ end
71
+
72
+ # Ranks the epic before or after a given epic
73
+ #
74
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-rest-agile-1-0-epic-epicidorkey-rank-put
75
+ #
76
+ # @param epic_id_or_key [Integer, String] The ID or key of the epic
77
+ # @param payload [Hash] Rank payload (rankBeforeEpic:, rankAfterEpic:, rankCustomFieldId:)
78
+ # @return [nil]
79
+ def rank_epic(epic_id_or_key, payload = {})
80
+ agile_put("/epic/#{url_encode(epic_id_or_key)}/rank", body: payload)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jira
4
+ class Client
5
+ # Defines methods related to sprints (Jira Software Cloud API).
6
+ #
7
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/
8
+ module Sprints
9
+ # Creates a sprint
10
+ #
11
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-post
12
+ #
13
+ # @param payload [Hash] Sprint payload (name:, originBoardId:, goal:, startDate:, endDate:)
14
+ # @return [Hash]
15
+ def create_sprint(payload = {})
16
+ agile_post("/sprint", body: payload)
17
+ end
18
+
19
+ # Gets a sprint by ID
20
+ #
21
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-get
22
+ #
23
+ # @param sprint_id [Integer] The ID of the sprint
24
+ # @return [Hash]
25
+ def sprint(sprint_id)
26
+ agile_get("/sprint/#{sprint_id}")
27
+ end
28
+
29
+ # Partially updates a sprint
30
+ #
31
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-post
32
+ #
33
+ # @param sprint_id [Integer] The ID of the sprint
34
+ # @param payload [Hash] Fields to update
35
+ # @return [Hash]
36
+ def update_sprint(sprint_id, payload = {})
37
+ agile_post("/sprint/#{sprint_id}", body: payload)
38
+ end
39
+
40
+ # Fully updates a sprint (all fields required)
41
+ #
42
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-put
43
+ #
44
+ # @param sprint_id [Integer] The ID of the sprint
45
+ # @param payload [Hash] Full sprint payload
46
+ # @return [Hash]
47
+ def replace_sprint(sprint_id, payload = {})
48
+ agile_put("/sprint/#{sprint_id}", body: payload)
49
+ end
50
+
51
+ # Deletes a sprint
52
+ #
53
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-delete
54
+ #
55
+ # @param sprint_id [Integer] The ID of the sprint
56
+ # @return [nil]
57
+ def delete_sprint(sprint_id)
58
+ agile_delete("/sprint/#{sprint_id}")
59
+ end
60
+
61
+ # Gets paginated issues for a sprint
62
+ #
63
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-issue-get
64
+ #
65
+ # @param sprint_id [Integer] The ID of the sprint
66
+ # @param options [Hash] Query parameters (startAt:, maxResults:, jql:, fields:)
67
+ # @return [Jira::PaginatedResponse]
68
+ def sprint_issues(sprint_id, options = {})
69
+ agile_get("/sprint/#{sprint_id}/issue", query: options)
70
+ end
71
+
72
+ # Moves issues to a sprint
73
+ #
74
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-issue-post
75
+ #
76
+ # @param sprint_id [Integer] The ID of the sprint
77
+ # @param issues [Array<String>] List of issue keys or IDs
78
+ # @return [nil]
79
+ def move_issues_to_sprint(sprint_id, issues:)
80
+ agile_post("/sprint/#{sprint_id}/issue", body: { issues: issues })
81
+ end
82
+
83
+ # Gets property keys for a sprint
84
+ #
85
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-properties-get
86
+ #
87
+ # @param sprint_id [Integer] The ID of the sprint
88
+ # @return [Hash]
89
+ def sprint_property_keys(sprint_id)
90
+ agile_get("/sprint/#{sprint_id}/properties")
91
+ end
92
+
93
+ # Gets a single sprint property
94
+ #
95
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-properties-propertykey-get
96
+ #
97
+ # @param sprint_id [Integer] The ID of the sprint
98
+ # @param property_key [String] The property key
99
+ # @return [Hash]
100
+ def sprint_property(sprint_id, property_key)
101
+ agile_get("/sprint/#{sprint_id}/properties/#{url_encode(property_key)}")
102
+ end
103
+
104
+ # Sets or updates a sprint property
105
+ #
106
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-properties-propertykey-put
107
+ #
108
+ # @param sprint_id [Integer] The ID of the sprint
109
+ # @param property_key [String] The property key
110
+ # @param value [Hash] The property value
111
+ # @return [nil]
112
+ def set_sprint_property(sprint_id, property_key, value = {})
113
+ agile_put("/sprint/#{sprint_id}/properties/#{url_encode(property_key)}", body: value)
114
+ end
115
+
116
+ # Deletes a sprint property
117
+ #
118
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-properties-propertykey-delete
119
+ #
120
+ # @param sprint_id [Integer] The ID of the sprint
121
+ # @param property_key [String] The property key
122
+ # @return [nil]
123
+ def delete_sprint_property(sprint_id, property_key)
124
+ agile_delete("/sprint/#{sprint_id}/properties/#{url_encode(property_key)}")
125
+ end
126
+
127
+ # Swaps the position of a sprint with another sprint
128
+ #
129
+ # @url https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-sprintid-swap-post
130
+ #
131
+ # @param sprint_id [Integer] The ID of the sprint
132
+ # @param sprint_to_swap_with [Integer] The ID of the sprint to swap with
133
+ # @return [nil]
134
+ def swap_sprint(sprint_id, sprint_to_swap_with:)
135
+ agile_post("/sprint/#{sprint_id}/swap", body: { sprintToSwapWith: sprint_to_swap_with })
136
+ end
137
+ end
138
+ end
139
+ end
data/lib/jira/client.rb CHANGED
@@ -4,6 +4,9 @@ module Jira
4
4
  class Client < API
5
5
  Dir[File.expand_path("client/*.rb", __dir__)].each { |file| require file }
6
6
 
7
+ include AgileIssues
8
+ include Boards
9
+ include Epics
7
10
  include IssueComments
8
11
  include IssueSearch
9
12
  include Issues
@@ -12,6 +15,7 @@ module Jira
12
15
  include ProjectPermissionSchemes
13
16
  include ProjectProperties
14
17
  include Projects
18
+ include Sprints
15
19
  include TimeTracking
16
20
 
17
21
  # Text representation of the client, masking auth secrets.
@@ -5,28 +5,29 @@ module Jira
5
5
  class UrlBuilder
6
6
  OAUTH_API_BASE = "https://api.atlassian.com/ex/jira"
7
7
  PLATFORM_API_PATH = "/rest/api/3"
8
+ AGILE_API_PATH = "/rest/agile/1.0"
8
9
 
9
10
  def initialize(request:, authenticator:)
10
11
  @request = request
11
12
  @authenticator = authenticator
12
13
  end
13
14
 
14
- def build(path)
15
- "#{api_base_url}#{normalize_path(path)}"
15
+ def build(path, api_path: PLATFORM_API_PATH)
16
+ "#{base_url_for(api_path)}#{normalize_path(path)}"
16
17
  end
17
18
 
18
19
  def api_request_path
19
- URI.parse(api_base_url).request_uri
20
+ URI.parse(base_url_for(PLATFORM_API_PATH)).request_uri
20
21
  end
21
22
 
22
23
  private
23
24
 
24
- def api_base_url
25
+ def base_url_for(api_path)
25
26
  case @authenticator.auth_type
26
27
  when :basic
27
- "#{normalized_endpoint}#{PLATFORM_API_PATH}"
28
+ "#{normalized_endpoint}#{api_path}"
28
29
  when :oauth2
29
- "#{OAUTH_API_BASE}/#{@request.cloud_id}#{PLATFORM_API_PATH}"
30
+ "#{OAUTH_API_BASE}/#{@request.cloud_id}#{api_path}"
30
31
  end
31
32
  end
32
33
 
data/lib/jira/request.rb CHANGED
@@ -78,18 +78,18 @@ module Jira
78
78
 
79
79
  private
80
80
 
81
- def execute_request(method, path, options)
81
+ def execute_request(method, path, options, api_path: UrlBuilder::PLATFORM_API_PATH)
82
82
  params = params_builder.build(options)
83
83
  retries_left = retries_left_for(params)
84
84
  log "#{method.upcase} #{path} #{options.inspect}"
85
- result = perform_request_with_retry(method, path, params, retries_left)
85
+ result = perform_request_with_retry(method, path, params, retries_left, api_path:)
86
86
  log "→ #{result.class}"
87
- setup_pagination_fetcher!(result, method, path, options)
87
+ setup_pagination_fetcher!(result, method, path, options, api_path:)
88
88
  result
89
89
  end
90
90
 
91
- def perform_request_with_retry(method, path, params, retries_left)
92
- response = perform_request(method, path, params)
91
+ def perform_request_with_retry(method, path, params, retries_left, api_path: UrlBuilder::PLATFORM_API_PATH)
92
+ response = perform_request(method, path, params, api_path:)
93
93
  validate(response)
94
94
  rescue Jira::Error::TooManyRequests, Jira::Error::ServiceUnavailable => e
95
95
  raise e unless should_retry?(e, method, response, retries_left)
@@ -101,26 +101,32 @@ module Jira
101
101
  retry
102
102
  end
103
103
 
104
- def setup_pagination_fetcher!(result, method, path, options)
104
+ def setup_pagination_fetcher!(result, method, path, options, api_path: UrlBuilder::PLATFORM_API_PATH)
105
105
  case result
106
106
  when PaginatedResponse
107
- setup_fetcher_for(result:, method:, path:, options:, key: :startAt)
107
+ result.next_page_fetcher = next_page_lambda(method:, path:, options:, key: :startAt, api_path:)
108
108
  when CursorPaginatedResponse
109
109
  return unless result.fetcher_based_pagination?
110
110
  return if result.cursor_parameter_key.nil?
111
111
 
112
- setup_fetcher_for(result:, method:, path:, options:, key: result.cursor_parameter_key)
112
+ result.next_page_fetcher = next_page_lambda(
113
+ method:, path:, options:, key: result.cursor_parameter_key, api_path:
114
+ )
113
115
  end
114
116
  end
115
117
 
116
- def setup_fetcher_for(result:, method:, path:, options:, key:)
117
- result.next_page_fetcher = lambda do |value|
118
+ def next_page_lambda(method:, path:, options:, key:, api_path: UrlBuilder::PLATFORM_API_PATH)
119
+ lambda do |value|
118
120
  merged = duplicate_request_options(options)
119
121
  inject_pagination_parameter!(options: merged, method:, key:, value:)
120
- send(method, path, merged)
122
+ execute_request(method, path, merged, api_path:)
121
123
  end
122
124
  end
123
125
 
126
+ %w[get post put patch delete].each do |m|
127
+ define_method("agile_#{m}") { |path, opts = {}| execute_request(m, path, opts, api_path: UrlBuilder::AGILE_API_PATH) }
128
+ end
129
+
124
130
  def duplicate_request_options(options)
125
131
  duplicated = options.dup
126
132
  duplicated[:query] = options[:query].dup if options[:query].is_a?(Hash)
@@ -140,15 +146,15 @@ module Jira
140
146
  :query
141
147
  end
142
148
 
143
- def perform_request(method, path, params)
144
- self.class.send(method, build_url(path), params)
149
+ def perform_request(method, path, params, api_path: UrlBuilder::PLATFORM_API_PATH)
150
+ self.class.send(method, build_url(path, api_path:), params)
145
151
  end
146
152
 
147
153
  def retries_left_for(params)
148
154
  params.delete(:ratelimit_retries) || ratelimit_retries || Configuration::DEFAULT_RATELIMIT_RETRIES
149
155
  end
150
156
 
151
- def build_url(path) = url_builder.build(path)
157
+ def build_url(path, api_path: UrlBuilder::PLATFORM_API_PATH) = url_builder.build(path, api_path:)
152
158
 
153
159
  def authorization_header = authenticator.authorization_header
154
160
 
data/lib/jira/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jira
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Kozak
@@ -36,6 +36,9 @@ files:
36
36
  - lib/jira.rb
37
37
  - lib/jira/api.rb
38
38
  - lib/jira/client.rb
39
+ - lib/jira/client/agile_issues.rb
40
+ - lib/jira/client/boards.rb
41
+ - lib/jira/client/epics.rb
39
42
  - lib/jira/client/issue_comments.rb
40
43
  - lib/jira/client/issue_search.rb
41
44
  - lib/jira/client/issue_worklogs.rb
@@ -44,6 +47,7 @@ files:
44
47
  - lib/jira/client/project_permission_schemes.rb
45
48
  - lib/jira/client/project_properties.rb
46
49
  - lib/jira/client/projects.rb
50
+ - lib/jira/client/sprints.rb
47
51
  - lib/jira/client/time_tracking.rb
48
52
  - lib/jira/configuration.rb
49
53
  - lib/jira/error.rb