gitlab-customer-support-operations_gitlab 1.0.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.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/lib/support_ops_gitlab/gitlab/badges.rb +229 -0
  3. data/lib/support_ops_gitlab/gitlab/base.rb +552 -0
  4. data/lib/support_ops_gitlab/gitlab/client.rb +51 -0
  5. data/lib/support_ops_gitlab/gitlab/commits.rb +198 -0
  6. data/lib/support_ops_gitlab/gitlab/configuration.rb +86 -0
  7. data/lib/support_ops_gitlab/gitlab/epics.rb +325 -0
  8. data/lib/support_ops_gitlab/gitlab/events.rb +167 -0
  9. data/lib/support_ops_gitlab/gitlab/gpg_keys.rb +64 -0
  10. data/lib/support_ops_gitlab/gitlab/group_memberships.rb +33 -0
  11. data/lib/support_ops_gitlab/gitlab/groups.rb +431 -0
  12. data/lib/support_ops_gitlab/gitlab/invitations.rb +72 -0
  13. data/lib/support_ops_gitlab/gitlab/issues.rb +606 -0
  14. data/lib/support_ops_gitlab/gitlab/jobs.rb +61 -0
  15. data/lib/support_ops_gitlab/gitlab/markdown.rb +54 -0
  16. data/lib/support_ops_gitlab/gitlab/merge_requests.rb +411 -0
  17. data/lib/support_ops_gitlab/gitlab/milestones.rb +195 -0
  18. data/lib/support_ops_gitlab/gitlab/namespaces.rb +184 -0
  19. data/lib/support_ops_gitlab/gitlab/notes.rb +182 -0
  20. data/lib/support_ops_gitlab/gitlab/pipelines.rb +258 -0
  21. data/lib/support_ops_gitlab/gitlab/project_access_tokens.rb +245 -0
  22. data/lib/support_ops_gitlab/gitlab/project_memberships.rb +33 -0
  23. data/lib/support_ops_gitlab/gitlab/project_webhook_events.rb +33 -0
  24. data/lib/support_ops_gitlab/gitlab/project_webhooks.rb +218 -0
  25. data/lib/support_ops_gitlab/gitlab/projects.rb +741 -0
  26. data/lib/support_ops_gitlab/gitlab/repository_files.rb +102 -0
  27. data/lib/support_ops_gitlab/gitlab/repository_submodules.rb +78 -0
  28. data/lib/support_ops_gitlab/gitlab/ssh_keys.rb +67 -0
  29. data/lib/support_ops_gitlab/gitlab/user_emails.rb +147 -0
  30. data/lib/support_ops_gitlab/gitlab/user_memberships.rb +21 -0
  31. data/lib/support_ops_gitlab/gitlab/user_tokens.rb +344 -0
  32. data/lib/support_ops_gitlab/gitlab/users.rb +1059 -0
  33. data/lib/support_ops_gitlab/gitlab.rb +45 -0
  34. data/lib/support_ops_gitlab.rb +28 -0
  35. metadata +251 -0
@@ -0,0 +1,1059 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module SupportOps.
4
+ module SupportOps
5
+ # Defines the module GitLab
6
+ module GitLab
7
+ ##
8
+ # Defines the class Users within the module {SupportOps::GitLab}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.0
12
+ # @attr [String] avatar_url URL of the user's avatar
13
+ # @attr [String] bio User’s biography
14
+ # @attr [Boolean] can_create_group User can create groups
15
+ # @attr [Boolean] can_create_project User can create projects
16
+ # @attr [Integer] color_scheme_id User’s color scheme for the file viewer
17
+ # @attr [String] commit_email User’s commit email
18
+ # @attr [String] confirmed_at Timestamp the user's account was confirmed at
19
+ # @attr [String] created_at Timestamp the user's account was created at
20
+ # @attr [Interger] created_by The ID of whomever created the user
21
+ # @attr [String] current_sign_in_at Timestamp the user's most current login
22
+ # @attr [String] current_sign_in_ip IP address used for most current login
23
+ # @attr [String] discord Discord account
24
+ # @attr [String] email User's email
25
+ # @attr [String] email_reset_offered_at Timestamp the user's got a reset email sent
26
+ # @attr [Boolean] external Flags the user as external
27
+ # @attr [Integer] extra_shared_runners_minutes_limit Additional compute minutes for this user
28
+ # @attr [Integer] followers Count of accounts following the user
29
+ # @attr [Integer] following Count of accoutns the user is following
30
+ # @attr [Boolean] force_random_password Set user password to a random value
31
+ # @attr [String] github GitHub username
32
+ # @attr [Integer] group_saml Group ID the user is tied to SAML by
33
+ # @attr [Integer] id User's ID
34
+ # @attr [Array] identities User's external identities
35
+ # @attr [Boolean] is_admin If the user is an admin or not
36
+ # @attr [Boolean] is_auditor If the user is an auditor or not
37
+ # @attr [String] job_title User's job title
38
+ # @attr [String] last_activity_on Timestamp of last actity for the user
39
+ # @attr [String] last_sign_in_at Timestamp fo the user's last login
40
+ # @attr [String] last_sign_in_ip IP of the user's last login
41
+ # @attr [String] linkedin LinkedIn
42
+ # @attr [String] local_time Human readable format of user's local time
43
+ # @attr [String] location User’s location
44
+ # @attr [Boolean] locked If the user is locked or not
45
+ # @attr [String] name Name
46
+ # @attr [Integer] namespace_id User's namespace ID
47
+ # @attr [String] note Administrator notes for this user
48
+ # @attr [String] organization Organization name
49
+ # @attr [String] password Password
50
+ # @attr [String] plan Subscription type for the user's account
51
+ # @attr [Boolean] private_profile User’s profile is private
52
+ # @attr [Integer] projects_limit Number of projects user can create
53
+ # @attr [String] pronouns User’s pronouns
54
+ # @attr [Integer] provisioned_by_group_id The group ID that provisioned the user
55
+ # @attr [String] public_email User’s public email address
56
+ # @attr [Boolean] reset_password Send user password reset link
57
+ # @attr [Array] scim_identities User's SCIM identities
58
+ # @attr [Integer] shared_runners_minutes_limit Maximum number of monthly compute minutes for this user.
59
+ # @attr [Integer] sign_in_count Number of times user has signed in
60
+ # @attr [String] skype Skype ID
61
+ # @attr [String] state User's account state
62
+ # @attr [Integer] theme_id GitLab theme for the user
63
+ # @attr [Boolean] trial If the user is using a trial or not
64
+ # @attr [String] twitter X (formerly Twitter) account
65
+ # @attr [Boolean] two_factor_enabled If the user has 2FA activated on the account
66
+ # @attr [String] username Username
67
+ # @attr [String] website_url Website URL
68
+ # @attr [String] web_url Link to the user's profile
69
+ # @attr [String] work_information
70
+ # @todo Upload an avatar for yourself > https://docs.gitlab.com/api/users/#upload-an-avatar-for-yourself
71
+ # @todo Get a count of your assigned issues, merge requests, and reviews > https://docs.gitlab.com/api/users/#get-a-count-of-your-assigned-issues-merge-requests-and-reviews
72
+ # @todo Get a count of a user’s projects, groups, issues, and merge requests > https://docs.gitlab.com/api/users/#get-a-count-of-a-users-projects-groups-issues-and-merge-requests
73
+ # @todo List a user's activity > https://docs.gitlab.com/api/users/#list-a-users-activity
74
+ # @todo Create a runner linked to a user > https://docs.gitlab.com/api/users/#create-a-runner-linked-to-a-user
75
+ # @todo Delete authentication identity from a user > https://docs.gitlab.com/api/users/#delete-authentication-identity-from-a-user
76
+ # @todo Follow a user > https://docs.gitlab.com/api/user_follow_unfollow/#follow-a-user
77
+ # @todo Unfollow a user > https://docs.gitlab.com/api/user_follow_unfollow/#unfollow-a-user
78
+ # @todo List all accounts that follow a user > https://docs.gitlab.com/api/user_follow_unfollow/#list-all-accounts-that-follow-a-user
79
+ # @todo List all accounts followed by a user > https://docs.gitlab.com/api/user_follow_unfollow/#list-all-accounts-followed-by-a-user
80
+ # @todo Get the status of a user > https://docs.gitlab.com/api/users/#get-the-status-of-a-user
81
+ # @todo Set your user status > https://docs.gitlab.com/api/users/#set-your-user-status
82
+ # @todo Get your user preferences > https://docs.gitlab.com/api/users/#get-your-user-preferences
83
+ # @todo Update your user preferences > https://docs.gitlab.com/api/users/#update-your-user-preferences
84
+ # @todo Have disable_2fa! update User object to reflect the change
85
+ # @todo Have deactivate! update User object to reflect the change
86
+ # @todo Have activate! update User object to reflect the change
87
+ # @todo Have ban! update User object to reflect the change
88
+ # @todo Have unban! update User object to reflect the change
89
+ # @todo Have block! update User object to reflect the change
90
+ # @todo Have unblock! update User object to reflect the change
91
+ # @todo Document projects
92
+ class Users < SupportOps::GitLab::Base
93
+ # @!parse
94
+ # # Creates/updates a user
95
+ # #
96
+ # # @author Jason Colyer
97
+ # # @since 1.0.0
98
+ # # @return [Object] Instance of {SupportOps::GitLab::Users}
99
+ # # @note This is inherited from {SupportOps::GitLab::Base#save!}
100
+ # # @see
101
+ # # https://docs.gitlab.com/api/users/#create-a-user
102
+ # # GitLab API > Users > Create a User
103
+ # # @see
104
+ # # https://docs.gitlab.com/api/users/#modify-a-user
105
+ # # GitLab API > Users > Modify a User
106
+ # # @example
107
+ # # require 'support_ops_gitlab'
108
+ # #
109
+ # # SupportOps::GitLab::Configuration.configure do |config|
110
+ # # config.token = ENV.fetch('GL_TOKEN')
111
+ # # config.url = 'https://gitlab.com/api/v4'
112
+ # # end
113
+ # #
114
+ # # new_user = SupportOps::GitLab::Users.new
115
+ # # new_user.email = 'roge@example.org'
116
+ # # new_user.name = 'Roger Wilco'
117
+ # #
118
+ # # new_user.save!
119
+ # #
120
+ # # pp new_user.id
121
+ # # # => 9873843
122
+ # # @example
123
+ # # require 'support_ops_gitlab'
124
+ # #
125
+ # # SupportOps::GitLab::Configuration.configure do |config|
126
+ # # config.token = ENV.fetch('GL_TOKEN')
127
+ # # config.url = 'https://gitlab.com/api/v4'
128
+ # # end
129
+ # #
130
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
131
+ # # existing_user.name = 'Roger Wilco II'
132
+ # #
133
+ # # existing_user.save!
134
+ # #
135
+ # # pp existing_user.name
136
+ # # # => "Roger Wilco II"
137
+ # def save!; end
138
+ # @!parse
139
+ # # Deletes a user
140
+ # #
141
+ # # @author Jason Colyer
142
+ # # @since 1.0.0
143
+ # # @return [Boolean]
144
+ # # @note This is inherited from {SupportOps::GitLab::Base#delete!}
145
+ # # @see
146
+ # # https://docs.gitlab.com/api/users/#delete-a-user
147
+ # # GitLab API > Users > Delete a User
148
+ # # @example
149
+ # # require 'support_ops_gitlab'
150
+ # #
151
+ # # SupportOps::GitLab::Configuration.configure do |config|
152
+ # # config.token = ENV.fetch('GL_TOKEN')
153
+ # # config.url = 'https://gitlab.com/api/v4'
154
+ # # end
155
+ # #
156
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
157
+ # # existing_user.delete!
158
+ # def delete!; end
159
+ # @!parse
160
+ # # Hard deletes a user
161
+ # #
162
+ # # @author Jason Colyer
163
+ # # @since 1.0.0
164
+ # # @return [Boolean]
165
+ # # @note This is inherited from {SupportOps::GitLab::Base#hard_delete!}
166
+ # # @see
167
+ # # https://docs.gitlab.com/api/users/#delete-a-user
168
+ # # GitLab API > Users > Delete a User
169
+ # # @example
170
+ # # require 'support_ops_gitlab'
171
+ # #
172
+ # # SupportOps::GitLab::Configuration.configure do |config|
173
+ # # config.token = ENV.fetch('GL_TOKEN')
174
+ # # config.url = 'https://gitlab.com/api/v4'
175
+ # # end
176
+ # #
177
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
178
+ # # existing_user.hard_delete!
179
+ # def hard_delete!; end
180
+ # @!parse
181
+ # # Blocks a user
182
+ # #
183
+ # # @author Jason Colyer
184
+ # # @since 1.0.0
185
+ # # @return [Boolean]
186
+ # # @note This is inherited from {SupportOps::GitLab::Base#block!}
187
+ # # @see
188
+ # # https://docs.gitlab.com/api/user_moderation/#block-access-to-a-user
189
+ # # GitLab API > User Moderation > Block access to a user
190
+ # # @example
191
+ # # require 'support_ops_gitlab'
192
+ # #
193
+ # # SupportOps::GitLab::Configuration.configure do |config|
194
+ # # config.token = ENV.fetch('GL_TOKEN')
195
+ # # config.url = 'https://gitlab.com/api/v4'
196
+ # # end
197
+ # #
198
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
199
+ # # existing_user.block!
200
+ # def block!; end
201
+ # @!parse
202
+ # # Unblocks a user
203
+ # #
204
+ # # @author Jason Colyer
205
+ # # @since 1.0.0
206
+ # # @return [Boolean]
207
+ # # @note This is inherited from {SupportOps::GitLab::Base#unblock!}
208
+ # # @see
209
+ # # https://docs.gitlab.com/api/user_moderation/#unblock-access-to-a-user
210
+ # # GitLab API > User Moderation > Unblock access to a user
211
+ # # @example
212
+ # # require 'support_ops_gitlab'
213
+ # #
214
+ # # SupportOps::GitLab::Configuration.configure do |config|
215
+ # # config.token = ENV.fetch('GL_TOKEN')
216
+ # # config.url = 'https://gitlab.com/api/v4'
217
+ # # end
218
+ # #
219
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
220
+ # # existing_user.unblock!
221
+ # def unblock!; end
222
+ # @!parse
223
+ # # Bans a user
224
+ # #
225
+ # # @author Jason Colyer
226
+ # # @since 1.0.0
227
+ # # @return [Boolean]
228
+ # # @note This is inherited from {SupportOps::GitLab::Base#ban!}
229
+ # # @see
230
+ # # https://docs.gitlab.com/api/user_moderation/#ban-a-user
231
+ # # GitLab API > User Moderation > Ban a user
232
+ # # @example
233
+ # # require 'support_ops_gitlab'
234
+ # #
235
+ # # SupportOps::GitLab::Configuration.configure do |config|
236
+ # # config.token = ENV.fetch('GL_TOKEN')
237
+ # # config.url = 'https://gitlab.com/api/v4'
238
+ # # end
239
+ # #
240
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
241
+ # # existing_user.ban!
242
+ # def ban!; end
243
+ # @!parse
244
+ # # Unbans a user
245
+ # #
246
+ # # @author Jason Colyer
247
+ # # @since 1.0.0
248
+ # # @return [Boolean]
249
+ # # @note This is inherited from {SupportOps::GitLab::Base#unban!}
250
+ # # @see
251
+ # # https://docs.gitlab.com/api/user_moderation/#unban-a-user
252
+ # # GitLab API > User Moderation > Unban a user
253
+ # # @example
254
+ # # require 'support_ops_gitlab'
255
+ # #
256
+ # # SupportOps::GitLab::Configuration.configure do |config|
257
+ # # config.token = ENV.fetch('GL_TOKEN')
258
+ # # config.url = 'https://gitlab.com/api/v4'
259
+ # # end
260
+ # #
261
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
262
+ # # existing_user.unban!
263
+ # def unban!; end
264
+ # @!parse
265
+ # # Deactivates a user
266
+ # #
267
+ # # @author Jason Colyer
268
+ # # @since 1.0.0
269
+ # # @return [Boolean]
270
+ # # @note This is inherited from {SupportOps::GitLab::Base#deactivate!}
271
+ # # @see
272
+ # # https://docs.gitlab.com/api/user_moderation/#deactivate-a-user
273
+ # # GitLab API > User Moderation > Deactivate a user
274
+ # # @example
275
+ # # require 'support_ops_gitlab'
276
+ # #
277
+ # # SupportOps::GitLab::Configuration.configure do |config|
278
+ # # config.token = ENV.fetch('GL_TOKEN')
279
+ # # config.url = 'https://gitlab.com/api/v4'
280
+ # # end
281
+ # #
282
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
283
+ # # existing_user.deactivate!
284
+ # def deactivate!; end
285
+ # @!parse
286
+ # # Reactivates a user
287
+ # #
288
+ # # @author Jason Colyer
289
+ # # @since 1.0.0
290
+ # # @return [Boolean]
291
+ # # @note This is inherited from {SupportOps::GitLab::Base#activate!}
292
+ # # @see
293
+ # # https://docs.gitlab.com/api/user_moderation/#reactivate-a-user
294
+ # # GitLab API > User Moderation > Reactivate a user
295
+ # # @example
296
+ # # require 'support_ops_gitlab'
297
+ # #
298
+ # # SupportOps::GitLab::Configuration.configure do |config|
299
+ # # config.token = ENV.fetch('GL_TOKEN')
300
+ # # config.url = 'https://gitlab.com/api/v4'
301
+ # # end
302
+ # #
303
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
304
+ # # existing_user.activate!
305
+ # def activate!; end
306
+ # @!parse
307
+ # # Approves access to a user
308
+ # #
309
+ # # @author Jason Colyer
310
+ # # @since 1.0.0
311
+ # # @return [Boolean]
312
+ # # @note This is inherited from {SupportOps::GitLab::Base#approve!}
313
+ # # @see
314
+ # # https://docs.gitlab.com/api/user_moderation/#approve-access-to-a-user
315
+ # # GitLab API > User Moderation > Approve access to a user
316
+ # # @example
317
+ # # require 'support_ops_gitlab'
318
+ # #
319
+ # # SupportOps::GitLab::Configuration.configure do |config|
320
+ # # config.token = ENV.fetch('GL_TOKEN')
321
+ # # config.url = 'https://gitlab.com/api/v4'
322
+ # # end
323
+ # #
324
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
325
+ # # existing_user.approve!
326
+ # def approve!; end
327
+ # @!parse
328
+ # # Rejects access to a user
329
+ # #
330
+ # # @author Jason Colyer
331
+ # # @since 1.0.0
332
+ # # @return [Boolean]
333
+ # # @note This is inherited from {SupportOps::GitLab::Base#reject!}
334
+ # # @see
335
+ # # https://docs.gitlab.com/api/user_moderation/#reject-access-to-a-user
336
+ # # GitLab API > User Moderation > Reject access to a user
337
+ # # @example
338
+ # # require 'support_ops_gitlab'
339
+ # #
340
+ # # SupportOps::GitLab::Configuration.configure do |config|
341
+ # # config.token = ENV.fetch('GL_TOKEN')
342
+ # # config.url = 'https://gitlab.com/api/v4'
343
+ # # end
344
+ # #
345
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
346
+ # # existing_user.reject!
347
+ # def reject!; end
348
+ # @!parse
349
+ # # Disables 2FA for a user
350
+ # #
351
+ # # @author Jason Colyer
352
+ # # @since 1.0.0
353
+ # # @return [Boolean]
354
+ # # @note This is inherited from {SupportOps::GitLab::Base#disable_2fa!}
355
+ # # @see
356
+ # # https://docs.gitlab.com/api/users/#disable-two-factor-authentication-for-a-user
357
+ # # GitLab API > Users > Disable two factor authentication for a user
358
+ # # @example
359
+ # # require 'support_ops_gitlab'
360
+ # #
361
+ # # SupportOps::GitLab::Configuration.configure do |config|
362
+ # # config.token = ENV.fetch('GL_TOKEN')
363
+ # # config.url = 'https://gitlab.com/api/v4'
364
+ # # end
365
+ # #
366
+ # # existing_user = SupportOps::GitLab::Users.get!(9873843)
367
+ # # existing_user.disable_2fa!
368
+ # def disable_2fa!; end
369
+ # @!parse
370
+ # # Lists email addresses for a user
371
+ # #
372
+ # # @author Jason Colyer
373
+ # # @since 1.0.0
374
+ # # @return [Boolean]
375
+ # # @note This is inherited from {SupportOps::GitLab::Base#emails}
376
+ # # @see
377
+ # # https://docs.gitlab.com/api/user_email_addresses/#list-all-email-addresses-for-a-user
378
+ # # GitLab API > User Email Addresses > List all email addresses for a user
379
+ # # @example
380
+ # # require 'support_ops_gitlab'
381
+ # #
382
+ # # SupportOps::GitLab::Configuration.configure do |config|
383
+ # # config.token = ENV.fetch('GL_TOKEN')
384
+ # # config.url = 'https://gitlab.com/api/v4'
385
+ # # end
386
+ # #
387
+ # # user = SupportOps::GitLab::Users.get!(123456)
388
+ # # emails = user.emails
389
+ # # pp emails.count
390
+ # # # => 2
391
+ # # pp emails.last.email
392
+ # # # => "email2@example.com"
393
+ # def disable_2fa!; end
394
+ # @!parse
395
+ # # Lists SSH keys for a user
396
+ # #
397
+ # # @author Jason Colyer
398
+ # # @since 1.0.0
399
+ # # @return [Boolean]
400
+ # # @note This is inherited from {SupportOps::GitLab::Base#ssh_keys}
401
+ # # @see
402
+ # # https://docs.gitlab.com/api/user_keys/#list-all-ssh-keys-for-a-user
403
+ # # GitLab API > SSH and GPG Keys > List all SSH keys for a user
404
+ # # @see SupportOps::GitLab::Configuration Setting up a client
405
+ # # @example
406
+ # # require 'support_ops_gitlab'
407
+ # #
408
+ # # SupportOps::GitLab::Configuration.configure do |config|
409
+ # # config.url = 'https://gitlab.example.com/api/v4'
410
+ # # config.token = 'abc123'
411
+ # # end
412
+ # #
413
+ # # user = SupportOps::GitLab::Users.get!(123456)
414
+ # # keys = user.ssh_keys
415
+ # # pp keys.count
416
+ # # # => 3
417
+ # # pp keys.last.usage_type
418
+ # # # => "auth"
419
+ # def ssh_keys; end
420
+ # @!parse
421
+ # # Lists GPG keys for a user
422
+ # #
423
+ # # @author Jason Colyer
424
+ # # @since 1.0.0
425
+ # # @return [Boolean]
426
+ # # @note This is inherited from {SupportOps::GitLab::Base#gpg_keys}
427
+ # # @see
428
+ # # https://docs.gitlab.com/api/user_keys/#list-all-gpg-keys-for-a-user
429
+ # # GitLab API > SSH and GPG Keys > List all SSH keys for a user
430
+ # # @see SupportOps::GitLab::Configuration Setting up a client
431
+ # # @example
432
+ # # require 'support_ops_gitlab'
433
+ # #
434
+ # # SupportOps::GitLab::Configuration.configure do |config|
435
+ # # config.url = 'https://gitlab.example.com/api/v4'
436
+ # # config.token = 'abc123'
437
+ # # end
438
+ # #
439
+ # # user = SupportOps::GitLab::Users.get!(123456)
440
+ # # keys = user.gpg_keys
441
+ # # pp keys.count
442
+ # # # => 3
443
+ # # pp keys.last.id
444
+ # # # => 789
445
+ # def gpg_keys; end
446
+ # @!parse
447
+ # # List projects and groups that a user is a member of
448
+ # #
449
+ # # @author Jason Colyer
450
+ # # @since 1.0.0
451
+ # # @return [Boolean]
452
+ # # @note This is inherited from {SupportOps::GitLab::Base#memberships}
453
+ # # @see
454
+ # # https://docs.gitlab.com/api/users/#list-projects-and-groups-that-a-user-is-a-member-of
455
+ # # GitLab API > Users > List projects and groups that a user is a member of
456
+ # # @see SupportOps::GitLab::Configuration Setting up a client
457
+ # # @example
458
+ # # require 'support_ops_gitlab'
459
+ # #
460
+ # # SupportOps::GitLab::Configuration.configure do |config|
461
+ # # config.url = 'https://gitlab.example.com/api/v4'
462
+ # # config.token = 'abc123'
463
+ # # end
464
+ # #
465
+ # # user = SupportOps::GitLab::Users.get!(123456)
466
+ # # memberships = user.memberships
467
+ # # pp memberships.count
468
+ # # # => 3
469
+ # # pp memberships.last.id
470
+ # # # => 789
471
+ # def memberships; end
472
+ # @!parse
473
+ # # List tokens (personal access and impersonation) for a user
474
+ # #
475
+ # # @author Jason Colyer
476
+ # # @since 1.0.0
477
+ # # @return [Boolean]
478
+ # # @note This is inherited from {SupportOps::GitLab::Base#tokens}
479
+ # # @see
480
+ # # https://docs.gitlab.com/api/personal_access_tokens/#list-all-personal-access-tokens
481
+ # # GitLab API > Personal access tokens > List all personal access tokens
482
+ # # @see
483
+ # # https://docs.gitlab.com/api/user_tokens/#list-all-impersonation-tokens-for-a-user
484
+ # # GitLab API > User tokens > List all impersonation tokens for a user
485
+ # # @see SupportOps::GitLab::Configuration Setting up a client
486
+ # # @example
487
+ # # require 'support_ops_gitlab'
488
+ # #
489
+ # # SupportOps::GitLab::Configuration.configure do |config|
490
+ # # config.url = 'https://gitlab.example.com/api/v4'
491
+ # # config.token = 'abc123'
492
+ # # end
493
+ # #
494
+ # # user = SupportOps::GitLab::Users.get!(123456)
495
+ # # tokens = user.tokens
496
+ # # pp tokens.count
497
+ # # # => 3
498
+ # # pp tokens.last.id
499
+ # # # => 789
500
+ # def tokens; end
501
+ # @!parse
502
+ # # List personal access tokens for a user
503
+ # #
504
+ # # @author Jason Colyer
505
+ # # @since 1.0.0
506
+ # # @return [Boolean]
507
+ # # @note This is inherited from {SupportOps::GitLab::Base#pats}
508
+ # # @see
509
+ # # https://docs.gitlab.com/api/personal_access_tokens/#list-all-personal-access-tokens
510
+ # # GitLab API > Personal access tokens > List all personal access tokens
511
+ # # @see SupportOps::GitLab::Configuration Setting up a client
512
+ # # @example
513
+ # # require 'support_ops_gitlab'
514
+ # #
515
+ # # SupportOps::GitLab::Configuration.configure do |config|
516
+ # # config.url = 'https://gitlab.example.com/api/v4'
517
+ # # config.token = 'abc123'
518
+ # # end
519
+ # #
520
+ # # user = SupportOps::GitLab::Users.get!(123456)
521
+ # # tokens = user.pats
522
+ # # pp tokens.count
523
+ # # # => 2
524
+ # # pp tokens.last.id
525
+ # # # => 456
526
+ # def pats; end
527
+ # @!parse
528
+ # # List impersonation tokens for a user
529
+ # #
530
+ # # @author Jason Colyer
531
+ # # @since 1.0.0
532
+ # # @return [Boolean]
533
+ # # @note This is inherited from {SupportOps::GitLab::Base#impersonations}
534
+ # # @see
535
+ # # https://docs.gitlab.com/api/user_tokens/#list-all-impersonation-tokens-for-a-user
536
+ # # GitLab API > User tokens > List all impersonation tokens for a user
537
+ # # @see SupportOps::GitLab::Configuration Setting up a client
538
+ # # @example
539
+ # # require 'support_ops_gitlab'
540
+ # #
541
+ # # SupportOps::GitLab::Configuration.configure do |config|
542
+ # # config.url = 'https://gitlab.example.com/api/v4'
543
+ # # config.token = 'abc123'
544
+ # # end
545
+ # #
546
+ # # user = SupportOps::GitLab::Users.get!(123456)
547
+ # # tokens = user.impersonations
548
+ # # pp tokens.count
549
+ # # # => 1
550
+ # # pp tokens.last.id
551
+ # # # => 789
552
+ # def impersonations; end
553
+ # @!parse
554
+ # # List events for a user
555
+ # #
556
+ # # @author Jason Colyer
557
+ # # @since 1.0.0
558
+ # # @return [Boolean]
559
+ # # @note This is inherited from {SupportOps::GitLab::Base#events}
560
+ # # @see
561
+ # # https://docs.gitlab.com/api/events/#get-contribution-events-for-a-user
562
+ # # GitLab API > Events > Get contribution events for a user
563
+ # # @see SupportOps::GitLab::Configuration Setting up a client
564
+ # # @example
565
+ # # require 'support_ops_gitlab'
566
+ # #
567
+ # # SupportOps::GitLab::Configuration.configure do |config|
568
+ # # config.url = 'https://gitlab.example.com/api/v4'
569
+ # # config.token = 'abc123'
570
+ # # end
571
+ # #
572
+ # # user = SupportOps::GitLab::Users.get!(123456)
573
+ # # events = user.events
574
+ # # pp events.count
575
+ # # # => 216
576
+ # def events; end
577
+ define_attributes :avatar_url, :bio, :can_create_group,
578
+ :can_create_project, :color_scheme_id, :commit_email,
579
+ :confirmed_at, :created_at, :created_by,
580
+ :current_sign_in_at, :current_sign_in_ip, :discord,
581
+ :email, :email_reset_offered_at, :external,
582
+ :extra_shared_runners_minutes_limit, :followers,
583
+ :following, :force_random_password, :github,
584
+ :group_saml, :id, :identities, :is_admin, :is_auditor,
585
+ :job_title, :last_activity_on, :last_sign_in_at,
586
+ :last_sign_in_ip, :linkedin, :local_time, :location,
587
+ :locked, :name, :namespace_id, :note, :organization,
588
+ :password, :plan, :private_profile,
589
+ :provisioned_by_group_id, :projects_limit, :pronouns,
590
+ :public_email, :reset_password,
591
+ :shared_runners_minutes_limit, :scim_identities,
592
+ :sign_in_count, :skype, :state, :theme_id, :trial,
593
+ :twitter, :two_factor_enabled, :username, :website_url,
594
+ :web_url, :work_information
595
+ readonly_attributes :confirmed_at, :created_at, :created_by,
596
+ :current_sign_in_at, :current_sign_in_ip,
597
+ :email_reset_offered_at, :followers, :following,
598
+ :group_saml, :id, :identities, :last_activity_on,
599
+ :last_sign_in_at, :last_sign_in_ip, :local_time,
600
+ :namespace_id, :plan, :provisioned_by_group_id,
601
+ :scim_identities, :sign_in_count, :web_url
602
+
603
+ ##
604
+ # Lists users in the GitLab system
605
+ #
606
+ # @author Jason Colyer
607
+ # @since 1.0.0
608
+ # @overload list(key: value)
609
+ # @param active [Boolean optional] Filters only active users; default is
610
+ # false
611
+ # @param admins [Boolean optional] Return only administrators; default
612
+ # is false
613
+ # @param auditors [Boolean optional] Return only auditor users; default
614
+ # is false; if not included, it returns all users
615
+ # @param blocked [Boolean optional] Filters only external users; default
616
+ # is false
617
+ # @param created_at [DateTime optional] Returns users created after
618
+ # specified time
619
+ # @param created_before [DateTime optional] Returns users created before
620
+ # specified time
621
+ # @param extern_uid [String optional] Get a single user with a specific
622
+ # external authentication provider UID
623
+ # @param external [Boolean optional] Filters only external users;
624
+ # default is false
625
+ # @param exclude_active [Boolean optional] Filters only non active
626
+ # users; default is false
627
+ # @param exclude_external [Boolean optional] Filters only non external
628
+ # users; default is false
629
+ # @param exclude_humans [Boolean optional] Filters only bot or internal
630
+ # users; default is false
631
+ # @param exclude_internal [Boolean optional] Filters only non internal
632
+ # users; default is false
633
+ # @param humans [Boolean optional] Filters only regular users that are
634
+ # not bot or internal users; default is false
635
+ # @param order_by [String optional] Return users ordered by id, name,
636
+ # username, created_at, or updated_at fields; default is id
637
+ # @param provider [String optional] The external provider
638
+ # @param saml_provider_id [Integer optional] Return only users created
639
+ # by the specified SAML provider ID; if not included, it returns all
640
+ # users
641
+ # @param search [String optional] Search for users by name, username, or
642
+ # public email
643
+ # @param skip_ldap [Boolean optional] Skip LDAP users
644
+ # @param sort [String optional] Return users sorted in asc or desc
645
+ # order; default is desc
646
+ # @param two_factor [Boolean optional] Filter users by Two-factor
647
+ # authentication; filter values are enabled or disabled; by default it
648
+ # returns all users
649
+ # @param username [String optional] Get a single user with a specific
650
+ # username
651
+ # @param without_project_bots [Boolean optional] Filters user without
652
+ # project bots; defaults to false
653
+ # @param without_projects [Boolean optional] Filter users without
654
+ # projects; default is false, which means that all users are returned,
655
+ # with and without projects.
656
+ # @param limit [Integer optional] The limit to the number of users
657
+ # returned. Default to 0 (i.e. no limit)
658
+ # @return [Array]
659
+ # @see
660
+ # https://docs.gitlab.com/api/users/#list-users
661
+ # GitLab API > Users > List users
662
+ # @see SupportOps::GitLab::Configuration Setting up a client
663
+ # @example
664
+ # require 'support_ops_gitlab'
665
+ #
666
+ # SupportOps::GitLab::Configuration.configure do |config|
667
+ # config.url = 'https://gitlab.example.com/api/v4'
668
+ # config.token = 'abc123'
669
+ # end
670
+ #
671
+ # users = SupportOps::GitLab::Users.list(limit: 250)
672
+ # pp users.count
673
+ # # => 250
674
+ # pp users.last.email
675
+ # # => "gabe@example.com"
676
+ def self.list(**args)
677
+ args[:active] = nil unless args[:active]
678
+ args[:admins] = nil unless args[:admins]
679
+ args[:auditors] = nil unless args[:auditors]
680
+ args[:blocked] = nil unless args[:blocked]
681
+ args[:created_at] = nil unless args[:created_at]
682
+ args[:created_before] = nil unless args[:created_before]
683
+ args[:exclude_active] = nil unless args[:exclude_active]
684
+ args[:exclude_external] = nil unless args[:exclude_external]
685
+ args[:exclude_humans] = nil unless args[:exclude_humans]
686
+ args[:exclude_internal] = nil unless args[:exclude_internal]
687
+ args[:external] = nil unless args[:external]
688
+ args[:extern_uid] = nil unless args[:extern_uid]
689
+ args[:humans] = nil unless args[:humans]
690
+ args[:order_by] = nil unless args[:order_by]
691
+ args[:provider] = nil unless args[:provider]
692
+ args[:saml_provider_id] = nil unless args[:saml_provider_id]
693
+ args[:search] = nil unless args[:search]
694
+ args[:skip_ldap] = nil unless args[:skip_ldap]
695
+ args[:sort] = nil unless args[:sort]
696
+ args[:two_factor] = nil unless args[:two_factor]
697
+ args[:username] = nil unless args[:username]
698
+ args[:without_project_bots] = nil unless args[:without_project_bots]
699
+ args[:without_projects] = nil unless args[:without_projects]
700
+ args[:limit] = 0 unless args[:limit]
701
+ params = ''
702
+ params += "active=#{args[:active]}&" unless args[:active].nil?
703
+ params += "admins=#{args[:admins]}&" unless args[:admins].nil?
704
+ params += "auditors=#{args[:auditors]}&" unless args[:auditors].nil?
705
+ params += "blocked=#{args[:blocked]}&" unless args[:blocked].nil?
706
+ params += "created_at=#{args[:created_at]}&" unless args[:created_at].nil?
707
+ params += "created_before=#{args[:created_before]}&" unless args[:created_before].nil?
708
+ params += "exclude_active=#{args[:exclude_active]}&" unless args[:exclude_active].nil?
709
+ params += "exclude_external=#{args[:exclude_external]}&" unless args[:exclude_external].nil?
710
+ params += "exclude_humans=#{args[:exclude_humans]}&" unless args[:exclude_humans].nil?
711
+ params += "exclude_internal=#{args[:exclude_internal]}&" unless args[:exclude_internal].nil?
712
+ params += "external=#{args[:external]}&" unless args[:external].nil?
713
+ params += "extern_uid=#{args[:extern_uid]}&" unless args[:extern_uid].nil?
714
+ params += "humans=#{args[:humans]}&" unless args[:humans].nil?
715
+ params += "order_by=#{args[:order_by]}&" unless args[:order_by].nil?
716
+ params += "provider=#{args[:provider]}&" unless args[:provider].nil?
717
+ params += "saml_provider_id=#{args[:saml_provider_id]}&" unless args[:saml_provider_id].nil?
718
+ params += "search=#{args[:search]}&" unless args[:search].nil?
719
+ params += "skip_ldap=#{args[:skip_ldap]}&" unless args[:skip_ldap].nil?
720
+ params += "sort=#{args[:sort]}&" unless args[:sort].nil?
721
+ params += "two_factor=#{args[:two_factor]}&" unless args[:two_factor].nil?
722
+ params += "username=#{args[:username]}&" unless args[:username].nil?
723
+ params += "without_project_bots=#{args[:without_project_bots]}&" unless args[:without_project_bots].nil?
724
+ params += "without_projects=#{args[:without_projects]}&" unless args[:without_projects].nil?
725
+ users = []
726
+ page = 1
727
+ loop do
728
+ response = client.connection.get("users?#{params}&page=#{page}&per_page=100")
729
+ body = Oj.load(response.body)
730
+ users += body.map { |u| Users.new(u) }
731
+ break if args[:limit].to_i.positive? && users.count >= args[:limit].to_i
732
+ break if body.count < 100
733
+
734
+ page += 1
735
+ end
736
+ return users if args[:limit].to_i.zero?
737
+
738
+ users.first(args[:limit].to_i)
739
+ end
740
+
741
+ ##
742
+ # Fetches the current user from the GitLab system
743
+ #
744
+ # @author Jason Colyer
745
+ # @since 1.0.0
746
+ # @return [Object]
747
+ # @see
748
+ # https://docs.gitlab.com/api/users/#get-the-current-user
749
+ # GitLab API > Users > Get the current user
750
+ # @see SupportOps::GitLab::Configuration Setting up a client
751
+ # @example
752
+ # require 'support_ops_gitlab'
753
+ #
754
+ # SupportOps::GitLab::Configuration.configure do |config|
755
+ # config.url = 'https://gitlab.example.com/api/v4'
756
+ # config.token = 'abc123'
757
+ # end
758
+ #
759
+ # user = SupportOps::GitLab::Users.current
760
+ # pp user.email
761
+ # # => "gabe@example.com"
762
+ def self.current
763
+ response = client.connection.get('user')
764
+ Users.new(Oj.load(response.body))
765
+ end
766
+
767
+ ##
768
+ # Locates a specific user in the GitLab system
769
+ #
770
+ # @author Jason Colyer
771
+ # @since 1.0.0
772
+ # @see
773
+ # https://docs.gitlab.com/api/users/#get-a-single-user
774
+ # GitLab API > Users > Get a single user
775
+ # @see SupportOps::GitLab::Configuration Setting up a client
776
+ # @example
777
+ # require 'support_ops_gitlab'
778
+ #
779
+ # SupportOps::GitLab::Configuration.configure do |config|
780
+ # config.url = 'https://gitlab.com/api/v4'
781
+ # config.token = 'abc123'
782
+ # end
783
+ #
784
+ # user = SupportOps::GitLab::Users.get(13983927615772)
785
+ # pp user.email
786
+ # # => "gabe@example.com"
787
+ def self.get(object)
788
+ if object.is_a? Users
789
+ Users.new(id: id).find
790
+ else
791
+ Users.new(id: object).find
792
+ end
793
+ end
794
+
795
+ ##
796
+ # Locates a specific user in the GitLab system
797
+ #
798
+ # @author Jason Colyer
799
+ # @since 1.0.0
800
+ # @see
801
+ # https://docs.gitlab.com/api/users/#get-a-single-user
802
+ # GitLab API > Users > Get a single user
803
+ # @see SupportOps::GitLab::Configuration Setting up a client
804
+ # @example
805
+ # require 'support_ops_gitlab'
806
+ #
807
+ # SupportOps::GitLab::Configuration.configure do |config|
808
+ # config.url = 'https://gitlab.com/api/v4'
809
+ # config.token = 'abc123'
810
+ # end
811
+ #
812
+ # user = SupportOps::GitLab::Users.get!(13983927615772)
813
+ # pp user.email
814
+ # # => "gabe@example.com"
815
+ def self.get!(object)
816
+ if object.is_a? Users
817
+ Users.new(id: id).find!
818
+ else
819
+ Users.new(id: object).find!
820
+ end
821
+ end
822
+
823
+ private
824
+
825
+ ##
826
+ # @private
827
+ def get_record
828
+ response = self.client.connection.get("users/#{self.id}")
829
+ return nil if response.status != 200
830
+
831
+ Oj.load(response.body)
832
+ end
833
+
834
+ ##
835
+ # @private
836
+ def create_record
837
+ response = self.client.connection.post('users', attributes_for_save.to_json)
838
+ body = Oj.load(response.body)
839
+ raise "Failed to create user => #{body}" if response.status != 201
840
+ body
841
+ end
842
+
843
+ ##
844
+ # @private
845
+ def update_record
846
+ raise "Failed to update user => You didn't change anything in the object" if attributes_for_save.keys == [:id]
847
+ response = self.client.connection.put("users/#{self.id}", attributes_for_save.to_json)
848
+ body = Oj.load(response.body)
849
+ raise "Failed to update user #{self.id} => #{body}" if response.status != 200
850
+ body
851
+ end
852
+
853
+ ##
854
+ # @private
855
+ def delete_record
856
+ response = self.client.connection.delete("users/#{self.id}")
857
+ body = Oj.load(response.body)
858
+ raise "Failed to delete user => #{body}" if response.status != 200
859
+ true
860
+ end
861
+
862
+ ##
863
+ # @private
864
+ def hard_delete_record
865
+ response = self.client.connection.delete("users/#{self.id}?hard_delete=true")
866
+ body = Oj.load(response.body)
867
+ raise "Failed to delete user => #{body}" if response.status != 200
868
+ true
869
+ end
870
+
871
+ ##
872
+ # @private
873
+ def projects_record
874
+ array = []
875
+ page = 1
876
+ loop do
877
+ response = self.client.connection.get("users/#{self.id}/projects?per_page=100&page=#{page}?statistics=true")
878
+ body = Oj.load(response.body)
879
+ array += body.map { |p| Projects.new(p) }
880
+ break if body.count < 100
881
+
882
+ page += 1
883
+ end
884
+ array
885
+ end
886
+
887
+ ##
888
+ # @private
889
+ def memberships_record
890
+ page = 1
891
+ array = []
892
+ loop do
893
+ response = self.client.connection.get("users/#{self.id}/memberships?per_page=100&page=#{page}")
894
+ body = Oj.load(response.body)
895
+ raise 'Only admins can query this' if response.status == 403
896
+ raise "No such user #{user.id}" if response.status == 404
897
+ array += body.map { |b| UserMemberships.new(b) }
898
+ break if body.count < 100
899
+
900
+ page += 1
901
+ end
902
+ array
903
+ end
904
+
905
+ ##
906
+ # @private
907
+ def ssh_keys_record
908
+ SSHKeys.list(user_id: self.id)
909
+ end
910
+
911
+ ##
912
+ # @private
913
+ def gpg_keys_record
914
+ GPGKeys.list(user_id: self.id)
915
+ end
916
+
917
+ ##
918
+ # @private
919
+ def tokens_record
920
+ pats_records + impersonations_record
921
+ end
922
+
923
+ ##
924
+ # @private
925
+ def pats_records
926
+ UserTokens.list_pats(user_id: self.id)
927
+ end
928
+
929
+ ##
930
+ # @private
931
+ def impersonations_record
932
+ UserTokens.list_impersonation(user_id: self.id)
933
+ end
934
+
935
+ ##
936
+ # @private
937
+ def block_record
938
+ response = self.client.connection.post("users/#{self.id}/block")
939
+ raise "Unable to locate user #{self.id}" if response.status == 404
940
+ raise "Failed to block user #{self.id} => code #{response.code}" if response.status != 201
941
+ true
942
+ end
943
+
944
+ ##
945
+ # @private
946
+ def unblock_record
947
+ response = self.client.connection.post("users/#{self.id}/unblock")
948
+ raise "Unable to locate user #{self.id}" if response.status == 404
949
+ raise "Failed to block user #{self.id} => code #{response.code}" if response.status != 201
950
+ true
951
+ end
952
+
953
+ ##
954
+ # @private
955
+ def ban_record
956
+ response = self.client.connection.post("users/#{self.id}/ban")
957
+ raise "Unable to locate user #{self.id}" if response.status == 404
958
+ raise "Failed to ban user #{self.id} => code #{response.code}" if response.status != 201
959
+ true
960
+ end
961
+
962
+ ##
963
+ # @private
964
+ def unban_record
965
+ response = self.client.connection.post("users/#{self.id}/unban")
966
+ raise "Unable to locate user #{self.id}" if response.status == 404
967
+ raise "Failed to unban user #{self.id} => code #{response.code}" if response.status != 201
968
+ true
969
+ end
970
+
971
+ ##
972
+ # @private
973
+ def deactivate_record
974
+ response = self.client.connection.post("users/#{self.id}/deactivate")
975
+ raise "Unable to locate user #{self.id}" if response.status == 404
976
+ raise "Failed to deactivate user #{self.id} => code #{response.code}" if response.status != 201
977
+ true
978
+ end
979
+
980
+ ##
981
+ # @private
982
+ def activate_record
983
+ response = self.client.connection.post("users/#{self.id}/activate")
984
+ raise "Unable to locate user #{self.id}" if response.status == 404
985
+ raise "Failed to activate user #{self.id} => code #{response.code}" if response.status != 201
986
+ true
987
+ end
988
+
989
+ ##
990
+ # @private
991
+ def approve_record
992
+ response = self.client.connection.post("users/#{self.id}/approve")
993
+ raise "Unable to locate user #{self.id}" if response.status == 404
994
+ raise "User #{self.id} is deactivated, so you cannot approve them" if response.status == 409
995
+ raise "Failed to approve user #{self.id} => code #{response.code}" if response.status != 201
996
+ true
997
+ end
998
+
999
+ ##
1000
+ # @private
1001
+ def reject_record
1002
+ response = self.client.connection.post("users/#{self.id}/reject")
1003
+ raise "Unable to locate user #{self.id}" if response.status == 404
1004
+ raise "User #{self.id} is not pending approval" if response.status == 409
1005
+ raise "Failed to reject user #{self.id} => code #{response.code}" if response.status != 201
1006
+ true
1007
+ end
1008
+
1009
+ ##
1010
+ # @private
1011
+ def emails_record
1012
+ UserEmails.list(user_id: self.id)
1013
+ end
1014
+
1015
+ ##
1016
+ # @private
1017
+ def support_pin_record
1018
+ if Users.current.id == self.id
1019
+ response = client.connection.get("user/support_pin")
1020
+ else
1021
+ response = client.connection.get("users/#{self.id}/support_pin")
1022
+ end
1023
+ body = Oj.load(response.body)
1024
+ raise "This requires an administrator level account" if response.status == 403
1025
+ return Hash.new if response.status == 404
1026
+
1027
+ body
1028
+ end
1029
+
1030
+ ##
1031
+ # @private
1032
+ def create_support_pin_record
1033
+ raise 'You can only do this for your own user' unless Users.current.id == self.id
1034
+
1035
+ response = client.connection.post("user/support_pin")
1036
+ body = Oj.load(response.body)
1037
+ pp response.status
1038
+ raise "Unable to create support pin => #{body}" unless response.status == 201
1039
+ body
1040
+ end
1041
+
1042
+ ##
1043
+ # @private
1044
+ def disable_2fa_record
1045
+ response = self.client.connection.patch("users/#{self.id}/disable_two_factor")
1046
+ raise "Unable to locate user #{self.id}" if response.status == 404
1047
+ raise "User #{self.id} is not pending approval" if response.status == 409
1048
+ raise "Failed to reject user #{self.id} => code #{response.code}" if response.status != 201
1049
+ true
1050
+ end
1051
+
1052
+ ##
1053
+ # @private
1054
+ def events_record
1055
+ Events.list_user(user_id: self.id)
1056
+ end
1057
+ end
1058
+ end
1059
+ end