gitlab_support_readiness 1.0.130 → 1.0.132

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: 0102aacc88b5b814217895ec69e839a573c84055d0b786e1116a053895989a92
4
- data.tar.gz: 40d8aa364040549bce14ee3bcd3e5c61889fd68ade93e5fc5ceda6fb73cf1fed
3
+ metadata.gz: 7aefa86729b110948e278e94a4d413fe3ba5bda9093acc857c113fe2bd8aa793
4
+ data.tar.gz: 72651512ad7e1774e9545480b1643750d205662decda5cadb6269868647974ad
5
5
  SHA512:
6
- metadata.gz: af924cefa67d6300b81fb1d8052f4db5e084d25dbe86cd1e8e953654b25d483bb6ae2e8eddb5cc59a750d3df82d55647f5c9de831fbe6eab4eb064d7110706e3
7
- data.tar.gz: 0af864729707ae8d02168ae4a6a2c50ce8f311eb997f3068d624b7e56e22d5148147067bd5e940b71a24f66579c0b1e1f8eb6dcc122ea1a784dcb44a976fe0af
6
+ metadata.gz: fa3c300cf2f5e6118bf9cd18e8d3c3c8017e699da2d3a01767616280a89fa9e2e04aceaa273620f9a993565d6c64bf1fc949223ed7133bb1e8976aa17ba79774
7
+ data.tar.gz: 0b701da3bf48d539258245893fc4fa6e11eae69cbd8f4337644019fb18037601de6b778b0cde4ac950e21870527f3c0b20fb5ef7f1f0067d5538037f197f7df5
@@ -28,8 +28,9 @@ module Readiness
28
28
  ticket.requester_id = 379855863520
29
29
  ticket.submitter_id = 379855863520
30
30
  ticket.comment = { html_body: body }
31
- ticket.subject = 'Support Internal Request - SA - Request for Support'
31
+ ticket.subject = ticket_subject
32
32
  ticket.tags = %w[support_internal_request support_valid_request support_ir_sa_request_for_support]
33
+ ticket.tags.push("support_internal_request_category_#{category}")
33
34
  ticket.priority = request_priority
34
35
  ticket.status = 'new'
35
36
  ticket.ticket_form_id = 12829030177948
@@ -176,6 +177,79 @@ module Readiness
176
177
  @collab_project ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_COLLAB_PROJECT')
177
178
  end
178
179
 
180
+ ##
181
+ # Sets the global variable ticket_subject
182
+ #
183
+ # @author Jason Colyer
184
+ # @since 1.0.131
185
+ def self.ticket_subject
186
+ @ticket_subject ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_SUBJECT', 'Support Internal Request - SA - Request for Support')
187
+ end
188
+
189
+ ##
190
+ # Sets the global variable issue_description
191
+ #
192
+ # @author Jason Colyer
193
+ # @since 1.0.131
194
+ def self.issue_description
195
+ @issue_description ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_DESCRIPTION')
196
+ end
197
+
198
+ ##
199
+ # Sets the global variable internal_request_support_sa_context
200
+ #
201
+ # @author Jason Colyer
202
+ # @since 1.0.131
203
+ def self.context
204
+ @context ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_CONTEXT')
205
+ end
206
+
207
+ ##
208
+ # Sets the global variable replication
209
+ #
210
+ # @author Jason Colyer
211
+ # @since 1.0.131
212
+ def self.replication
213
+ @replication ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_REPLICATION', '')
214
+ end
215
+
216
+ ##
217
+ # Sets the global variable arr_at_risk
218
+ #
219
+ # @author Jason Colyer
220
+ # @since 1.0.131
221
+ def self.arr_at_risk
222
+ @arr_at_risk ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_ARR', '0')
223
+ end
224
+
225
+ ##
226
+ # Sets the global variable category
227
+ #
228
+ # @author Jason Colyer
229
+ # @since 1.0.131
230
+ def self.category
231
+ @category ||= ENV.fetch('INTERNAL_REQUEST_SUPPORT_SA_CATEGORY', 'other')
232
+ end
233
+
234
+ ## Determines category value from global variable
235
+ #
236
+ #@author Jason Colyer
237
+ # @since 1.0.131
238
+ def self.category_value
239
+ case category
240
+ when 'lnr'
241
+ 'L&R (License & Registration)'
242
+ when 'com'
243
+ 'GitLab.com'
244
+ when 'sm'
245
+ 'Self-Managed'
246
+ when 'dedicated'
247
+ 'GitLab Dedicated'
248
+ else
249
+ 'Unknown'
250
+ end
251
+ end
252
+
179
253
  ##
180
254
  # Return the ticket body
181
255
  #
@@ -202,6 +276,8 @@ module Readiness
202
276
  <li>#{Readiness::SupportSuperFormProcessor::Shared.sfdc_account_string(sfdc_account)}</li>
203
277
  <li>#{Readiness::SupportSuperFormProcessor::Shared.sfdc_opportunity_string(sfdc_opportunity)}</li>
204
278
  <li>#{collab_project.empty? ? 'No collaboration project project' : "<a href='#{collab_project}' target='_blank'>Collaboration Project</a>"}</li>
279
+ <li>ARR at risk: $#{sprintf("%.2f", arr_at_risk.to_f)}</li>
280
+ <li>Request category: #{category_value}</li>
205
281
  </ul>
206
282
  <p>
207
283
  What is expected from Support?
@@ -209,6 +285,24 @@ module Readiness
209
285
  <pre>
210
286
  #{expectations}
211
287
  </pre>
288
+ <p>
289
+ Issue description
290
+ </p>
291
+ <pre>
292
+ #{issue_description}
293
+ </pre>
294
+ <p>
295
+ Context/resources
296
+ </p>
297
+ <pre>
298
+ #{context}
299
+ </pre>
300
+ <p>
301
+ Replication information
302
+ </p>
303
+ <pre>
304
+ #{replication}
305
+ </pre>
212
306
  STRING
213
307
  end
214
308
  end
@@ -9,9 +9,6 @@ module Readiness
9
9
  #
10
10
  # @author Jason Colyer
11
11
  # @since 1.0.125
12
- # @todo list - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#list-tokens
13
- # @todo show - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#show-token
14
- # @todo revoke - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#revoke-token
15
12
  class OAuthTokens < Readiness::Client
16
13
  attr_accessor :client_id, :created_at, :expires_at, :full_token, :id, :refresh_token, :refresh_token_expires_at, :scopes, :token, :used_at, :user_id
17
14
 
@@ -37,7 +34,92 @@ module Readiness
37
34
  @used_at = object['used_at']
38
35
  @user_id = object['user_id']
39
36
  end
40
-
37
+
38
+ ##
39
+ # Lists all OAuth tokens.
40
+ #
41
+ # @author Jason Colyer
42
+ # @since 1.0.132
43
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
44
+ # @return [Array]
45
+ # @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#list-tokens Zendesk API > OAuth Tokens > List Tokens
46
+ # @example
47
+ # require 'support_readiness'
48
+ # config = Readiness::Zendesk::Configuration.new
49
+ # config.username = 'alice@example.com'
50
+ # config.token = 'test123abc'
51
+ # config.url = 'https://example.zendesk.com/api/v2'
52
+ # client = Readiness::Zendesk::Client.new(config)
53
+ # oauth_tokens = Readiness::Zendesk::OAuthTokens.list(client)
54
+ # pp oauth_tokens.count
55
+ # # => 24
56
+ def self.list(client)
57
+ array = []
58
+ opts = 'page[size]=100'
59
+ loop do
60
+ response = client.connection.get("oauth/tokens?#{opts}")
61
+ handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
62
+ body = Oj.load(response.body)
63
+ array += body['tokens'].map { |t| OAuthTokens.new(t) }
64
+ break unless body['meta']['has_more']
65
+
66
+ opts = body['links']['next'].split('?').last
67
+ end
68
+ array
69
+ end
70
+
71
+ ##
72
+ # Locates an OAuth token within Zendesk. This will not exit on error (except Authentication errors)
73
+ #
74
+ # @author Jason Colyer
75
+ # @since 1.0.132
76
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
77
+ # @param tid [Integer[ The OAuth token ID to find
78
+ # @param return [Hash]
79
+ # @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#show-token Zendesk API > OAuth Tokens > Show Token
80
+ # @example
81
+ # require 'support_readiness'
82
+ # config = Readiness::Zendesk::Configuration.new
83
+ # config.username = 'alice@example.com'
84
+ # config.token = 'test123abc'
85
+ # config.url = 'https://example.zendesk.com/api/v2'
86
+ # client = Readiness::Zendesk::Client.new(config)
87
+ # oauth_token = Readiness::Zendesk::OAuthTokens.find(client, 223443)
88
+ # pp oauth_token.client_id
89
+ # # => 1234
90
+ def self.find(client, tid)
91
+ response = client.connection.get("oauth/tokens/#{tid}")
92
+ handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: cid }) unless response.status == 200
93
+ return OAuthTokens.new(Oj.load(response.body)['token']) if response.status == 200
94
+
95
+ Oj.load(response.body)
96
+ end
97
+
98
+ ##
99
+ # Locates an OAuth token within Zendesk. This will exit on error
100
+ #
101
+ # @author Jason Colyer
102
+ # @since 1.0.132
103
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
104
+ # @param tid [Integer[ The OAuth token ID to find
105
+ # @param return [Hash]
106
+ # @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#show-token Zendesk API > OAuth Tokens > Show Token
107
+ # @example
108
+ # require 'support_readiness'
109
+ # config = Readiness::Zendesk::Configuration.new
110
+ # config.username = 'alice@example.com'
111
+ # config.token = 'test123abc'
112
+ # config.url = 'https://example.zendesk.com/api/v2'
113
+ # client = Readiness::Zendesk::Client.new(config)
114
+ # oauth_token = Readiness::Zendesk::OAuthTokens.find!(client, 223443)
115
+ # pp oauth_token.client_id
116
+ # # => 1234
117
+ def self.find!(client, tid)
118
+ response = client.connection.get("oauth/tokens/#{tid}")
119
+ handle_request_error(1, 'Zendesk', response.status, { action: 'Find OAuth token', id: tid }) unless response.status == 200
120
+ OAuthTokens.new(Oj.load(response.body)['token'])
121
+ end
122
+
41
123
  ##
42
124
  # Creates an Oauth token. Will exit if unsuccessful.
43
125
  #
@@ -65,9 +147,35 @@ module Readiness
65
147
  # # => "4v8AR9vXCM7dV4murXlIaBAAzDrAw9lIbaHF7X9VbVPtOABAyy3dnTtHE3A6AdNC"
66
148
  def self.create!(client, token)
67
149
  pp to_clean_json_with_key(token, 'token')
68
- response = client.connection.post 'oauth/tokens', to_clean_json_with_key(token, 'token')
69
- handle_request_error(1, 'Zendesk', response.status, { action: 'Create Oauth token', message: Oj.load(response.body)}) unless response.status == 201
70
- OAuthTokens.new(Oj.load(response.body)['token'])
150
+ response = client.connection.post 'oauth/tokens', to_clean_json_with_key(token, 'token')
151
+ handle_request_error(1, 'Zendesk', response.status, { action: 'Create Oauth token', message: Oj.load(response.body)}) unless response.status == 201
152
+ OAuthTokens.new(Oj.load(response.body)['token'])
153
+ end
154
+
155
+ ##
156
+ # Revkokes an OAuth token. Will exit if unsuccessful
157
+ #
158
+ # @author Jason Colyer
159
+ # @since 1.0.132
160
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
161
+ # @param token [Object] An instance of {Readiness::Zendesk::OAuthTokens}
162
+ # @return [Boolean]
163
+ # @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#revoke-token Zendesk API > OAuth Tokens > Revoke Token
164
+ # @example
165
+ # require 'support_readiness'
166
+ # config = Readiness::Zendesk::Configuration.new
167
+ # config.username = 'alice@example.com'
168
+ # config.token = 'test123abc'
169
+ # config.url = 'https://example.zendesk.com/api/v2'
170
+ # client = Readiness::Zendesk::Client.new(config)
171
+ # oauth_token = Readiness::Zendesk::OAuthTokens.find!(client, 223443)
172
+ # revoke = Readiness::Zendesk::OAuthTokens.revoke!(client, oauth_token)
173
+ # pp revoke
174
+ # # => true
175
+ def self.revoke!(client, token)
176
+ response = client.connection.delete "oauth/tokens/#{token.id}"
177
+ handle_request_error(1, 'Zendesk', response.status, { action: 'Revoke a token', id: token.id, message: Oj.load(response.body)}) unless response.status == 204
178
+ true
71
179
  end
72
180
  end
73
181
  end
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.130
4
+ version: 1.0.132
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-03-10 00:00:00.000000000 Z
11
+ date: 2025-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport