gitlab_support_readiness 1.0.103 → 1.0.105

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8213b6d41e62c123097ae8d3515392cfa2015bf411458204ea443995ee30a2cb
4
- data.tar.gz: b4d28def67555c45d19b7262f7e05123dec524220b931295bfadba274cd70008
3
+ metadata.gz: 285979d526ebc6466de0a67ef6806bef72631628f7c8d097186bf0a23a673be9
4
+ data.tar.gz: c42893330a7738b34bab0fbe66723b1ed2e8bfacffcc667cbbc65ce36cac7fa8
5
5
  SHA512:
6
- metadata.gz: 6c66cd621d632d6fb41099c363467eaa7cc379319ba245f7db27c43389498c1dc004a40b5ed21faa202dfd5bf1d3c4f559b27bfd856b5828bf9205ec2adb107a
7
- data.tar.gz: 62dfa2b87c2e145b0ca96eafb5f3f49a5785f86c570cbfece6f8f6d8a1ab3df728ef97a2f65a92833380077ca879d362005db6b8236fb2f6cb25c4470fef92ca
6
+ metadata.gz: 44e5d5c088e3feb883d75d322f60a391ba18de3c9ade4699faaa2415d1b4a1b0d7a8c25fe4b270638606f71b0743815199fe6e3d20b72f49f4af040d43956f1b
7
+ data.tar.gz: cb2e2892c61438777545b9739eafc3a196300801b02e2cddb58eb981a80128ec5c2a493e5baf996e758a7f1b8cdde929df5f87b7a5c90e95e303bc5e08f28a9e
@@ -0,0 +1,247 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ # Defines the module GitLab
6
+ module GitLab
7
+ ##
8
+ # Defines the class Epics within the module {Readiness::GitLab}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.105
12
+ # @todo create! - https://docs.gitlab.com/ee/api/epics.html#new-epic
13
+ # @todo create_todo_item! - https://docs.gitlab.com/ee/api/epics.html#create-a-to-do-item
14
+ # @todo update! - https://docs.gitlab.com/ee/api/epics.html#update-epic
15
+ # @todo delete! - https://docs.gitlab.com/ee/api/epics.html#delete-epic
16
+ class Epics < Readiness::Client
17
+ attr_accessor :author, :closed_at, :color, :created_at, :description, :downvotes, :due_date, :due_date_fixed, :due_date_from_inherited_source, :due_date_from_milestones, :due_date_is_fixed, :end_date, :group_id, :id, :iid, :imported, :imported_from, :labels, :_links, :parent_id, :parent_iid, :reference, :references, :start_date, :start_date_fixed, :start_date_from_inherited_source, :start_date_from_milestones, :state, :subscribed, :title, :updated_at, :upvotes, :web_url
18
+
19
+ ##
20
+ # Creates a new {Readiness::GitLab::Epics} instance
21
+ #
22
+ # @author Jason Colyer
23
+ # @since 1.0.105
24
+ # @param object [Object] An instance of {Readiness::GitLab::Epics}
25
+ # @example
26
+ # require 'support_readiness'
27
+ # group = Readiness::GitLab::Epics.new
28
+ def initialize(object = {})
29
+ @author = object['author']
30
+ @closed_at = object['closed_at']
31
+ @color = object['color']
32
+ @created_at = object['created_at']
33
+ @description = object['description']
34
+ @downvotes = object['downvotes']
35
+ @due_date = object['due_date']
36
+ @due_date_fixed = object['due_date_fixed']
37
+ @due_date_from_inherited_source = object['due_date_from_inherited_source']
38
+ @due_date_from_milestones = object['due_date_from_milestones']
39
+ @due_date_is_fixed = object['due_date_is_fixed']
40
+ @end_date = object['end_date']
41
+ @group_id = object['group_id']
42
+ @id = object['id']
43
+ @iid = object['iid']
44
+ @imported = object['imported']
45
+ @imported_from = object['imported_from']
46
+ @labels = object['labels']
47
+ @_links = object['_links']
48
+ @parent_id = object['parent_id']
49
+ @parent_iid = object['parent_iid']
50
+ @reference = object['reference']
51
+ @references = object['references']
52
+ @start_date = object['start_date']
53
+ @start_date_fixed = object['start_date_fixed']
54
+ @start_date_from_inherited_source = object['start_date_from_inherited_source']
55
+ @start_date_from_milestones = object['start_date_from_milestones']
56
+ @state = object['state']
57
+ @subscribed = object['subscribed']
58
+ @title = object['title']
59
+ @updated_at = object['updated_at']
60
+ @upvotes = object['upvotes']
61
+ @web_url = object['web_url']
62
+ end
63
+
64
+ ##
65
+ # Lists epics in a group.
66
+ # This method can take a long time to run depending on the parameters used.
67
+ #
68
+ # @author Jason Colyer
69
+ # @since 1.0.105
70
+ # @param client [Object] An instance of {Readiness::GitLab::Client}
71
+ # @param group [Object] An instance of {Readiness::GitLab::Groups}
72
+ # @param filters [Array] An array of filter Strings to use. Should be in the format of key=value
73
+ # @return [Array]
74
+ # @see https://docs.gitlab.com/ee/api/epics.html#list-epics-for-a-group GitLab API > Epics > List epics for a group
75
+ # @example
76
+ # require 'support_readiness'
77
+ # config = Readiness::GitLab::Configuration.new
78
+ # config.token = 'test123abc'
79
+ # client = Readiness::GitLab::Client.new(config)
80
+ # group = Readiness::GitLab::Groups.new
81
+ # group.id = 1
82
+ # epics = Readiness::GitLab::Epics.list(client, group, ["state=opened", "include_descendant_groups=true"])
83
+ # puts epics.first.web_url
84
+ # # => "https://gitlab.com/gitlab-com/support/support-ops/-/epics/22"
85
+ def self.list(client, group, filters = [])
86
+ array = []
87
+ page = 1
88
+ loop do
89
+ response = client.connection.get "groups/#{group.id}/epics?per_page=100&page=#{page}&#{to_param_string(filters)}"
90
+ handle_request_error(0, 'GitLab', response.status) unless response.status == 200
91
+ body = Oj.load(response.body)
92
+ array += body.map { |e| Epics.new(e) }
93
+ break if body.count < 100
94
+
95
+ page += 1
96
+ end
97
+ array
98
+ end
99
+
100
+ ##
101
+ # Locates an epic within GitLab. This will not exit on error (except Authentication errors)
102
+ #
103
+ # @author Jason Colyer
104
+ # @since 1.0.105
105
+ # @param client [Object] An instance of {Readiness::GitLab::Client}
106
+ # @param group [Object] An instance of {Readiness::GitLab::Groups}
107
+ # @param iid [Integer] The epic ID to find
108
+ # @return [Hash]
109
+ # @see https://docs.gitlab.com/ee/api/epics.html#single-epic GitLab API > Epics > Single epic
110
+ # @example
111
+ # require 'support_readiness'
112
+ # config = Readiness::GitLab::Configuration.new
113
+ # config.token = 'test123abc'
114
+ # client = Readiness::GitLab::Client.new(config)
115
+ # group = Readiness::GitLab::Groups.new({ 'id' => 123 })
116
+ # epic = Readiness::GitLab::Epics.find(client, group, 5)
117
+ # puts epic.web_url
118
+ # # => "https://gitlab.com/gitlab-com/support/support-team-meta/-/issues/5"
119
+ def self.find(client, group, iid)
120
+ response = client.connection.get "groups/#{group.id}/epics/#{iid}"
121
+ handle_request_error(0, 'GitLab', response.status, { action: 'get', id: epic_id }) unless response.status == 200
122
+ return Epics.new(Oj.load(response.body)) if response.status == 200
123
+
124
+ Oj.load(response.body)
125
+ end
126
+
127
+ ##
128
+ # Locates an epic within GitLab. This will exit on error
129
+ #
130
+ # @author Jason Colyer
131
+ # @since 1.0.105
132
+ # @param client [Object] An instance of {Readiness::GitLab::Client}
133
+ # @param group [Object] An instance of {Readiness::GitLab::Groups}
134
+ # @param iid [Integer] The epic ID to find
135
+ # @return [Object]
136
+ # @see https://docs.gitlab.com/ee/api/epics.html#single-epic GitLab API > Epics > Single epic
137
+ # @example
138
+ # require 'support_readiness'
139
+ # config = Readiness::GitLab::Configuration.new
140
+ # config.token = 'test123abc'
141
+ # client = Readiness::GitLab::Client.new(config)
142
+ # group = Readiness::GitLab::Groups.new({ 'id' => 123 })
143
+ # epic = Readiness::GitLab::Epics.find!(client, group, 5)
144
+ # puts epic.web_url
145
+ # # => "https://gitlab.com/gitlab-com/support/support-team-meta/-/issues/5"
146
+ def self.find!(client, group, iid)
147
+ response = client.connection.get "groups/#{group.id}/epics/#{iid}"
148
+ handle_request_error(1, 'GitLab', response.status, { action: 'Find epic', id: iid }) unless response.status == 200
149
+ Epics.new(Oj.load(response.body))
150
+ end
151
+
152
+ ##
153
+ # Lists issues within an epic.
154
+ # This method can take a long time to run depending on the parameters used.
155
+ #
156
+ # @author Jason Colyer
157
+ # @since 1.0.105
158
+ # @param client [Object] An instance of {Readiness::GitLab::Client}
159
+ # @param epic [Object] An instance of {Readiness::GitLab::Epics}
160
+ # @return [Array]
161
+ # @see https://docs.gitlab.com/ee/api/epic_issues.html#list-issues-for-an-epic GitLab API > Issues (epic) > List issues for an epic
162
+ # @example
163
+ # require 'support_readiness'
164
+ # config = Readiness::GitLab::Configuration.new
165
+ # config.token = 'test123abc'
166
+ # client = Readiness::GitLab::Client.new(config)
167
+ # group = Readiness::GitLab::Groups.new({ 'id' => 1 })
168
+ # epic = Readiness::GitLab::Epics.find!(client, group, 5)
169
+ # issues = Readiness::GitLab::Epics.issues(client, epic)
170
+ # puts issues.count
171
+ # # => 45
172
+ def self.issues(client, epic)
173
+ array = []
174
+ page = 1
175
+ loop do
176
+ response = client.connection.get "groups/#{epic.group_id}/epics/#{epic.iid}/issues?per_page=100&page=#{page}"
177
+ handle_request_error(0, 'GitLab', response.status) unless response.status == 200
178
+ body = Oj.load(response.body)
179
+ array += body.map { |e| Issues.new(e) }
180
+ break if body.count < 100
181
+
182
+ page += 1
183
+ end
184
+ array
185
+ end
186
+
187
+ ##
188
+ # Assigns an issue to an epic. This will exit on error
189
+ #
190
+ # @author Jason Colyer
191
+ # @since 1.0.105
192
+ # @param client [Object] An instance of {Readiness::GitLab::Client}
193
+ # @param epic [Object] An instance of {Readiness::GitLab::Epics}
194
+ # @param issue [Object] An instance of {Readiness::GitLab::Issues}
195
+ # @return [Hash]
196
+ # @see https://docs.gitlab.com/ee/api/epic_issues.html#assign-an-issue-to-the-epic GitLab API > Issues (epic) > Assign an issue to the epic
197
+ # @example
198
+ # require 'support_readiness'
199
+ # config = Readiness::GitLab::Configuration.new
200
+ # config.token = 'test123abc'
201
+ # client = Readiness::GitLab::Client.new(config)
202
+ # group = Readiness::GitLab::Groups.new({ 'id' => 1 })
203
+ # epic = Readiness::GitLab::Epics.find!(client, group, 5)
204
+ # project = Readiness::GitLab::Projects.find!(client, 66)
205
+ # issue = Readiness::GitLab::Issues.find!(client, project, 23)
206
+ # assign = Readiness::GitLab::Epics.assign_issue!(client, epic, issue)
207
+ # puts assign['epic']['iid']
208
+ # # => 5
209
+ def self.assign_issue!(client, epic, issue)
210
+ response = client.connection.post "groups/#{epic.group_id}/epics/#{epic.iid}/issues/#{issue.id}"
211
+ handle_request_error(1, 'GitLab', response.status, { action: "Assign issue epic #{epic.iid}", id: issue.id }) unless response.status == 200
212
+ Oj.load(response.body)
213
+ end
214
+
215
+ ##
216
+ # Removes an issue to an epic. The issue object must be obtained via {Readiness::GitLab::Epics#list}. This will exit on error
217
+ #
218
+ # @author Jason Colyer
219
+ # @since 1.0.105
220
+ # @param client [Object] An instance of {Readiness::GitLab::Client}
221
+ # @param epic [Object] An instance of {Readiness::GitLab::Epics}
222
+ # @param issue [Object] An instance of {Readiness::GitLab::Issues}
223
+ # @return [Hash]
224
+ # @see https://docs.gitlab.com/ee/api/epic_issues.html#remove-an-issue-from-the-epic GitLab API > Issues (epic) > Remove an issue from the epic
225
+ # @example
226
+ # require 'support_readiness'
227
+ # config = Readiness::GitLab::Configuration.new
228
+ # config.token = 'test123abc'
229
+ # client = Readiness::GitLab::Client.new(config)
230
+ # group = Readiness::GitLab::Groups.new({ 'id' => 2573624 })
231
+ # epic = Readiness::GitLab::Epics.find!(gitlab_client, group, 16)
232
+ # issues = Readiness::GitLab::Epics.issues(gitlab_client, epic)
233
+ # issue = issues.detect { |i| i.iid == 2491 }
234
+ # remove = Readiness::GitLab::Epics.remove_issue!(gitlab_client, epic, issue)
235
+ # puts remove['epic']['id']
236
+ # # => 2087187
237
+ def self.remove_issue!(client, epic, issue)
238
+ return handle_request_error(1, 'GitLab', 400, { action: "No issue provided to remove from epic #{epic.iid}", id: '' }) if issue.nil?
239
+ 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?
240
+
241
+ response = client.connection.delete "groups/#{epic.group_id}/epics/#{epic.iid}/issues/#{issue.epic_issue_id}"
242
+ handle_request_error(1, 'GitLab', response.status, { action: "Remove issue from epic #{epic.iid}", id: issue.iid }) unless response.status == 200
243
+ Oj.load(response.body)
244
+ end
245
+ end
246
+ end
247
+ end
@@ -11,7 +11,7 @@ module Readiness
11
11
  # @since 1.0.0
12
12
  # @todo Anything listed on https://docs.gitlab.com/ee/api/issues.html not currently here
13
13
  class Issues < Readiness::Client
14
- attr_accessor :assignee_id, :assignee_ids, :assignees, :author, :blocking_issues_count, :closed_at, :closed_by, :confidential, :created_at, :description, :discussion_locked, :downvotes, :due_date, :epic, :has_tasks, :health_status, :id, :iid, :imported, :imported_from, :issue_type, :iteration, :labels, :_links, :merge_requests_count, :milestone, :moved_to_id, :project_id, :references, :service_desk_reply_to, :severity, :state, :state_event, :task_completion_status, :task_status, :time_stats, :title, :type, :updated_at, :upvotes, :user_notes_count, :web_url, :weight
14
+ attr_accessor :assignee_id, :assignee_ids, :assignees, :author, :blocking_issues_count, :closed_at, :closed_by, :confidential, :created_at, :description, :discussion_locked, :downvotes, :due_date, :epic, :epic_issue_id, :has_tasks, :health_status, :id, :iid, :imported, :imported_from, :issue_type, :iteration, :labels, :_links, :merge_requests_count, :milestone, :moved_to_id, :project_id, :references, :service_desk_reply_to, :severity, :state, :state_event, :task_completion_status, :task_status, :time_stats, :title, :type, :updated_at, :upvotes, :user_notes_count, :web_url, :weight
15
15
 
16
16
  ##
17
17
  # Creates a new {Readiness::GitLab::Issues} instance
@@ -37,6 +37,7 @@ module Readiness
37
37
  @downvotes = object['downvotes']
38
38
  @due_date = object['due_date']
39
39
  @epic = object['epic']
40
+ @epic_issue_id = object['epic_issue_id']
40
41
  @has_tasks = object['has_tasks']
41
42
  @health_status = object['health_status']
42
43
  @id = object['id']
@@ -10,6 +10,7 @@ module Readiness
10
10
  require "#{__dir__}/gitlab/client"
11
11
  require "#{__dir__}/gitlab/configuration"
12
12
  require "#{__dir__}/gitlab/groups"
13
+ require "#{__dir__}/gitlab/epics"
13
14
  require "#{__dir__}/gitlab/issues"
14
15
  require "#{__dir__}/gitlab/jobs"
15
16
  require "#{__dir__}/gitlab/markdown"
@@ -72,7 +72,7 @@ module Readiness
72
72
  # config.token = 'test123abc'
73
73
  # config.url = 'https://example.zendesk.com/api/v2'
74
74
  # client = Readiness::Zendesk::Client.new(config)
75
- # search = Readiness::Zendesk::Search.organzations(client, 'salesforce_id:ABCDEFGH0123456*')
75
+ # search = Readiness::Zendesk::Search.organizations(client, 'salesforce_id:ABCDEFGH0123456*')
76
76
  # pp search.first.notes
77
77
  # # => "This org is escalated. Please talk to support managers."
78
78
  def self.organizations(client, query)
@@ -120,7 +120,7 @@ module Readiness
120
120
  # config.token = 'test123abc'
121
121
  # config.url = 'https://example.zendesk.com/api/v2'
122
122
  # client = Readiness::Zendesk::Client.new(config)
123
- # search = Readiness::Zendesk::Search.searc(client, 'organization', 'salesforce_id:ABCDEFGH0123456*')
123
+ # search = Readiness::Zendesk::Search.search(client, 'organization', 'salesforce_id:ABCDEFGH0123456*')
124
124
  # pp search.first.notes
125
125
  # # => "This org is escalated. Please talk to support managers."
126
126
  def self.search(client, type, query)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_support_readiness
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.103
4
+ version: 1.0.105
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Colyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-15 00:00:00.000000000 Z
11
+ date: 2025-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -48,14 +48,14 @@ dependencies:
48
48
  name: concurrent-ruby
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - '='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.3.4
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - '='
59
59
  - !ruby/object:Gem::Version
60
60
  version: 1.3.4
61
61
  - !ruby/object:Gem::Dependency
@@ -272,6 +272,7 @@ files:
272
272
  - lib/support_readiness/gitlab.rb
273
273
  - lib/support_readiness/gitlab/client.rb
274
274
  - lib/support_readiness/gitlab/configuration.rb
275
+ - lib/support_readiness/gitlab/epics.rb
275
276
  - lib/support_readiness/gitlab/groups.rb
276
277
  - lib/support_readiness/gitlab/issues.rb
277
278
  - lib/support_readiness/gitlab/jobs.rb