Class: SupportOps::GitLab::Base
- Inherits:
-
Object
- Object
- SupportOps::GitLab::Base
show all
- Defined in:
- lib/support_ops_gitlab/gitlab/base.rb
Overview
Direct Known Subclasses
Badges, Commits, Epics, Events, GPGKeys, GroupMemberships, Groups, Invitations, Issues, Jobs, Markdown, MergeRequestDiffs, MergeRequests, Milestones, Namespaces, Notes, Pipelines, ProjectAccessTokens, ProjectMemberships, ProjectWebhookEvents, ProjectWebhooks, Projects, RepositoryFiles, RepositorySubmodules, SSHKeys, UserEmails, UserMemberships, UserTokens, Users
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}, client = nil) ⇒ Base
Returns a new instance of Base.
40
41
42
43
44
45
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 40
def initialize(attributes = {}, client = nil)
@client = client
@original_attributes = {}
set_attributes(attributes)
store_original_attributes
end
|
Class Method Details
.attributes ⇒ Object
29
30
31
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 29
def attributes
@attributes || []
end
|
.client ⇒ Object
14
15
16
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 14
def client
Configuration.config.client
end
|
18
19
20
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 18
def configure
yield Configuration.config
end
|
.define_attributes(*attrs) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 22
def define_attributes(*attrs)
@attributes = attrs
attrs.each do |attr|
attr_accessor attr
end
end
|
.readonly_attributes(*attrs) ⇒ Object
33
34
35
36
37
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 33
def readonly_attributes(*attrs)
return @readonly_attributes || [] if attrs.empty?
@readonly_attributes = attrs
end
|
.to_hash(object) ⇒ Hash
Converts an Object to a Hash
61
62
63
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 61
def self.to_hash(object)
Hash[object.instance_variables.map { |name| [name.to_s[1..-1], object.instance_variable_get(name)] }]
end
|
Instance Method Details
#activate! ⇒ Object
187
188
189
190
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 187
def activate!
re_client_present!
activate_record
end
|
#approve! ⇒ Object
172
173
174
175
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 172
def approve!
ensure_client_present!
approve_record
end
|
#badges ⇒ Object
235
236
237
238
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 235
def badges
ensure_client_present!
badges_record
end
|
#ban! ⇒ Object
162
163
164
165
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 162
def ban!
ensure_client_present!
ban_record
end
|
#block! ⇒ Object
152
153
154
155
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 152
def block!
ensure_client_present!
block_record
end
|
#client=(new_client) ⇒ Object
320
321
322
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 320
def client=(new_client)
@client = new_client
end
|
#commits ⇒ Object
305
306
307
308
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 305
def commits
ensure_client_present!
commits_record
end
|
#contributors ⇒ Object
310
311
312
313
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 310
def contributors
ensure_client_present!
contributors_record
end
|
#create_support_pin! ⇒ Object
202
203
204
205
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 202
def create_support_pin!
ensure_client_present!
create_support_pin_record
end
|
#deactivate! ⇒ Object
182
183
184
185
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 182
def deactivate!
re_client_present!
deactivate_record
end
|
#delete! ⇒ Object
97
98
99
100
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 97
def delete!
ensure_client_present!
delete_record
end
|
#diffs ⇒ Object
315
316
317
318
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 315
def diffs
ensure_client_present!
diffs_record
end
|
#disable_2fa! ⇒ Object
207
208
209
210
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 207
def disable_2fa!
ensure_client_present!
disable_2fa_record
end
|
#discussions ⇒ Object
270
271
272
273
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 270
def discussions
ensure_client_present!
discussions_record
end
|
#emails ⇒ Object
192
193
194
195
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 192
def emails
ensure_client_present!
emails_record
end
|
#encoded_path ⇒ Object
227
228
229
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 227
def encoded_path
encoded_path_record
end
|
#events ⇒ Object
295
296
297
298
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 295
def events
ensure_client_present!
events_record
end
|
#find ⇒ Object
65
66
67
68
69
70
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 65
def find
ensure_client_present!
set_attributes(get_record)
store_original_attributes
self
end
|
#find! ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 72
def find!
ensure_client_present!
attrs = get_record
if attrs == nil
raise "Unable to locate #{self.class.name.demodulize.singularize.downcase} '#{self.id}'"
end
set_attributes(attrs)
store_original_attributes
self
end
|
#gpg_keys ⇒ Object
132
133
134
135
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 132
def gpg_keys
ensure_client_present!
gpg_keys_record
end
|
#hard_delete! ⇒ Object
102
103
104
105
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 102
def hard_delete!
ensure_client_present!
hard_delete_record
end
|
#impersonations ⇒ Object
147
148
149
150
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 147
def impersonations
ensure_client_present!
impersonations_record
end
|
#issues ⇒ Object
240
241
242
243
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 240
def issues
ensure_client_present!
issues_record
end
|
#jobs ⇒ Object
290
291
292
293
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 290
def jobs
ensure_client_present!
jobs_record
end
|
#latest_pipeline ⇒ Object
280
281
282
283
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 280
def latest_pipeline
ensure_client_present!
latest_pipeline_record
end
|
#members(**args) ⇒ Object
222
223
224
225
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 222
def members(**args)
ensure_client_present!
members_record(**args)
end
|
#memberships ⇒ Object
122
123
124
125
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 122
def memberships
ensure_client_present!
memberships_record
end
|
#merge_requests ⇒ Object
245
246
247
248
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 245
def merge_requests
ensure_client_present!
merge_requests_record
end
|
#move! ⇒ Object
250
251
252
253
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 250
def move!
ensure_client_present!
move_record
end
|
#notes ⇒ Object
265
266
267
268
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 265
def notes
ensure_client_present!
notes_record
end
|
#paid? ⇒ Boolean
231
232
233
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 231
def paid?
is_paid_record
end
|
#pats ⇒ Object
142
143
144
145
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 142
def pats
ensure_client_present!
pats_records
end
|
#pipeline_variables ⇒ Object
285
286
287
288
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 285
def pipeline_variables
ensure_client_present!
pipeline_variables_record
end
|
#pipelines ⇒ Object
275
276
277
278
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 275
def pipelines
ensure_client_present!
pipelines_record
end
|
#preferences ⇒ Object
112
113
114
115
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 112
def preferences
ensure_client_present!
preferences_record
end
|
#projects ⇒ Object
117
118
119
120
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 117
def projects
ensure_client_present!
projects_record
end
|
#reject! ⇒ Object
177
178
179
180
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 177
def reject!
ensure_client_present!
reject_record
end
|
#revoke! ⇒ Object
217
218
219
220
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 217
def revoke!
ensure_client_present!
revoke_record
end
|
#rotate! ⇒ Object
212
213
214
215
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 212
def rotate!
ensure_client_present!
rotate_record
end
|
#save! ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 83
def save!
ensure_client_present!
new_data = if id.nil?
create_record
else
update_record
end
new_data.each do |key, value|
self.instance_variable_set("@#{key}", value) if self.respond_to?("#{key}=")
end
store_original_attributes
self
end
|
#ssh_keys ⇒ Object
127
128
129
130
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 127
def ssh_keys
ensure_client_present!
ssh_keys_record
end
|
#status ⇒ Object
107
108
109
110
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 107
def status
ensure_client_present!
status_record
end
|
#store_original_attributes ⇒ Object
47
48
49
50
51
52
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 47
def store_original_attributes
@original_attributes = {}
self.class.attributes.each do |attr|
@original_attributes[attr] = instance_variable_get("@#{attr}")
end
end
|
#subscribe! ⇒ Object
255
256
257
258
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 255
def subscribe!
ensure_client_present!
subscribe_record
end
|
#support_pin ⇒ Object
197
198
199
200
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 197
def support_pin
ensure_client_present!
support_pin_record
end
|
#tokens ⇒ Object
137
138
139
140
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 137
def tokens
ensure_client_present!
tokens_record
end
|
#unban! ⇒ Object
167
168
169
170
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 167
def unban!
ensure_client_present!
unban_record
end
|
#unblock! ⇒ Object
157
158
159
160
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 157
def unblock!
ensure_client_present!
unblock_record
end
|
#unsubscribe! ⇒ Object
260
261
262
263
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 260
def unsubscribe!
ensure_client_present!
unsubscribe_record
end
|
#webhooks ⇒ Object
300
301
302
303
|
# File 'lib/support_ops_gitlab/gitlab/base.rb', line 300
def webhooks
ensure_client_present!
webhooks_record
end
|