Class: Readiness::GitLab::Epics
- Inherits:
-
Client
- Object
- Client
- Readiness::GitLab::Epics
show all
- Defined in:
- lib/support_readiness/gitlab/epics.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
-
.assign_issue!(client, epic, issue) ⇒ Hash
Assigns an issue to an epic.
-
.find(client, group, iid) ⇒ Hash
Locates an epic within GitLab.
-
.find!(client, group, iid) ⇒ Object
Locates an epic within GitLab.
-
.issues(client, epic) ⇒ Array
Lists issues within an epic.
-
.list(client, group, filters = []) ⇒ Array
-
.remove_issue!(client, epic, issue) ⇒ Hash
Removes an issue to an epic.
Instance Method Summary
collapse
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Constructor Details
#initialize(object = {}) ⇒ Epics
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/support_readiness/gitlab/epics.rb', line 28
def initialize(object = {})
@author = object['author']
@closed_at = object['closed_at']
@color = object['color']
@created_at = object['created_at']
@description = object['description']
@downvotes = object['downvotes']
@due_date = object['due_date']
@due_date_fixed = object['due_date_fixed']
@due_date_from_inherited_source = object['due_date_from_inherited_source']
@due_date_from_milestones = object['due_date_from_milestones']
@due_date_is_fixed = object['due_date_is_fixed']
@end_date = object['end_date']
@group_id = object['group_id']
@id = object['id']
@iid = object['iid']
@imported = object['imported']
@imported_from = object['imported_from']
@labels = object['labels']
@_links = object['_links']
@parent_id = object['parent_id']
@parent_iid = object['parent_iid']
@reference = object['reference']
@references = object['references']
@start_date = object['start_date']
@start_date_fixed = object['start_date_fixed']
@start_date_from_inherited_source = object['start_date_from_inherited_source']
@start_date_from_milestones = object['start_date_from_milestones']
@state = object['state']
@subscribed = object['subscribed']
@title = object['title']
@updated_at = object['updated_at']
@upvotes = object['upvotes']
@web_url = object['web_url']
end
|
Instance Attribute Details
#_links ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def _links
@_links
end
|
#author ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def author
@author
end
|
#closed_at ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def closed_at
@closed_at
end
|
#color ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def color
@color
end
|
#created_at ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def created_at
@created_at
end
|
#description ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def description
@description
end
|
#downvotes ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def downvotes
@downvotes
end
|
#due_date ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def due_date
@due_date
end
|
#due_date_fixed ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def due_date_fixed
@due_date_fixed
end
|
#due_date_from_inherited_source ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def due_date_from_inherited_source
@due_date_from_inherited_source
end
|
#due_date_from_milestones ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def due_date_from_milestones
@due_date_from_milestones
end
|
#due_date_is_fixed ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def due_date_is_fixed
@due_date_is_fixed
end
|
#end_date ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def end_date
@end_date
end
|
#group_id ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def group_id
@group_id
end
|
#id ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def id
@id
end
|
#iid ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def iid
@iid
end
|
#imported ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def imported
@imported
end
|
#imported_from ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def imported_from
@imported_from
end
|
#labels ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def labels
@labels
end
|
#parent_id ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def parent_id
@parent_id
end
|
#parent_iid ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def parent_iid
@parent_iid
end
|
#reference ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def reference
@reference
end
|
#references ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def references
@references
end
|
#start_date ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def start_date
@start_date
end
|
#start_date_fixed ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def start_date_fixed
@start_date_fixed
end
|
#start_date_from_inherited_source ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def start_date_from_inherited_source
@start_date_from_inherited_source
end
|
#start_date_from_milestones ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def start_date_from_milestones
@start_date_from_milestones
end
|
#state ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def state
@state
end
|
#subscribed ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def subscribed
@subscribed
end
|
#title ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def title
@title
end
|
#updated_at ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def updated_at
@updated_at
end
|
#upvotes ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def upvotes
@upvotes
end
|
#web_url ⇒ Object
17
18
19
|
# File 'lib/support_readiness/gitlab/epics.rb', line 17
def web_url
@web_url
end
|
Class Method Details
.assign_issue!(client, epic, issue) ⇒ Hash
Assigns an issue to an epic. This will exit on error
214
215
216
217
218
|
# File 'lib/support_readiness/gitlab/epics.rb', line 214
def self.assign_issue!(client, epic, issue)
response = client.connection.post "groups/#{epic.group_id}/epics/#{epic.iid}/issues/#{issue.id}"
handle_request_error(1, 'GitLab', response.status, { action: "Assign issue epic #{epic.iid}", id: issue.id }) unless response.status == 200
Oj.load(response.body)
end
|
.find(client, group, iid) ⇒ Hash
Locates an epic within GitLab. This will not exit on error (except Authentication errors)
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/support_readiness/gitlab/epics.rb', line 119
def self.find(client, group, iid)
response = client.connection.get "groups/#{group.id}/epics/#{iid}"
return { "message" => "Epic not found" } if response.status == 403
handle_request_error(0, 'GitLab', response.status, { action: 'get', id: iid }) unless response.status == 200
return Epics.new(Oj.load(response.body)) if response.status == 200
Oj.load(response.body)
end
|
.find!(client, group, iid) ⇒ Object
Locates an epic within GitLab. This will exit on error
149
150
151
152
153
154
155
|
# File 'lib/support_readiness/gitlab/epics.rb', line 149
def self.find!(client, group, iid)
response = client.connection.get "groups/#{group.id}/epics/#{iid}"
handle_request_error(1, 'GitLab', 404, { action: 'Find epic', id: iid }) if response.status == 403
handle_request_error(1, 'GitLab', response.status, { action: 'Find epic', id: iid }) unless response.status == 200
Epics.new(Oj.load(response.body))
end
|
.issues(client, epic) ⇒ Array
Lists issues within an epic. This method can take a long time to run depending on the parameters used.
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/support_readiness/gitlab/epics.rb', line 177
def self.issues(client, epic)
array = []
page = 1
loop do
response = client.connection.get "groups/#{epic.group_id}/epics/#{epic.iid}/issues?per_page=100&page=#{page}"
handle_request_error(0, 'GitLab', response.status) unless response.status == 200
body = Oj.load(response.body)
array += body.map { |e| Issues.new(e) }
break if body.count < 100
page += 1
end
array
end
|
.list(client, group, filters = []) ⇒ Array
Lists epics in a group. This method can take a long time to run depending on the parameters used.
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/support_readiness/gitlab/epics.rb', line 85
def self.list(client, group, filters = [])
array = []
page = 1
loop do
response = client.connection.get "groups/#{group.id}/epics?per_page=100&page=#{page}&#{to_param_string(filters)}"
handle_request_error(0, 'GitLab', response.status) unless response.status == 200
body = Oj.load(response.body)
array += body.map { |e| Epics.new(e) }
break if body.count < 100
page += 1
end
array
end
|
.remove_issue!(client, epic, issue) ⇒ Hash
Removes an issue to an epic. The issue object must be obtained via #list. This will exit on error
242
243
244
245
246
247
248
249
|
# File 'lib/support_readiness/gitlab/epics.rb', line 242
def self.remove_issue!(client, epic, issue)
return handle_request_error(1, 'GitLab', 400, { action: "No issue provided to remove from epic #{epic.iid}", id: '' }) if issue.nil?
return handle_request_error(1, 'GitLab', 400, { action: "Issue is not assigned to epic #{epic.iid}", id: issue.iid }) if issue.epic_issue_id.nil?
response = client.connection.delete "groups/#{epic.group_id}/epics/#{epic.iid}/issues/#{issue.epic_issue_id}"
handle_request_error(1, 'GitLab', response.status, { action: "Remove issue from epic #{epic.iid}", id: issue.iid }) unless response.status == 200
Oj.load(response.body)
end
|