ruby-jss 0.9.2 → 0.10.0a1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -1
- data/README.md +7 -7
- data/bin/cgrouper +6 -6
- data/bin/netseg-update +1 -1
- data/lib/jss.rb +1 -0
- data/lib/jss/api_connection.rb +428 -44
- data/lib/jss/api_object.rb +119 -68
- data/lib/jss/api_object/account.rb +12 -12
- data/lib/jss/api_object/advanced_search.rb +12 -12
- data/lib/jss/api_object/categorizable.rb +4 -4
- data/lib/jss/api_object/category.rb +2 -2
- data/lib/jss/api_object/computer.rb +111 -58
- data/lib/jss/api_object/computer_invitation.rb +2 -2
- data/lib/jss/api_object/creatable.rb +19 -8
- data/lib/jss/api_object/criteriable/criteria.rb +8 -8
- data/lib/jss/api_object/distribution_point.rb +14 -48
- data/lib/jss/api_object/extension_attribute.rb +14 -11
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +18 -18
- data/lib/jss/api_object/group.rb +7 -7
- data/lib/jss/api_object/ldap_server.rb +51 -60
- data/lib/jss/api_object/locatable.rb +2 -2
- data/lib/jss/api_object/matchable.rb +8 -9
- data/lib/jss/api_object/mobile_device.rb +61 -59
- data/lib/jss/api_object/mobile_device_application.rb +3 -3
- data/lib/jss/api_object/network_segment.rb +24 -19
- data/lib/jss/api_object/package.rb +6 -6
- data/lib/jss/api_object/peripheral.rb +5 -5
- data/lib/jss/api_object/policy.rb +5 -5
- data/lib/jss/api_object/restricted_software.rb +4 -4
- data/lib/jss/api_object/scopable/scope.rb +3 -3
- data/lib/jss/api_object/script.rb +1 -1
- data/lib/jss/api_object/self_servable.rb +3 -3
- data/lib/jss/api_object/self_servable/icon.rb +7 -2
- data/lib/jss/api_object/updatable.rb +2 -2
- data/lib/jss/api_object/uploadable.rb +1 -1
- data/lib/jss/api_object/user.rb +2 -2
- data/lib/jss/composer.rb +37 -10
- data/lib/jss/ruby_extensions/string.rb +51 -42
- data/lib/jss/server.rb +27 -6
- data/lib/jss/utility.rb +44 -0
- data/lib/jss/validate.rb +85 -0
- data/lib/jss/version.rb +1 -1
- metadata +5 -4
data/lib/jss/api_object.rb
CHANGED
@@ -142,22 +142,29 @@ module JSS
|
|
142
142
|
# class methods for accessing those other values as mapped Arrays,
|
143
143
|
# e.g. JSS::Computer.all_udids
|
144
144
|
#
|
145
|
-
# The results of the first query for each subclass is stored in
|
146
|
-
# and returned at every future call, so as
|
145
|
+
# The results of the first query for each subclass is stored in the .object_list_cache
|
146
|
+
# of the given JSS::APIConnection and returned at every future call, so as
|
147
|
+
# to not requery the server every time.
|
147
148
|
#
|
148
149
|
# To force requerying to get updated data, provided a non-false argument.
|
149
150
|
# I usually use :refresh, so that it's obvious what I'm doing, but true, 1,
|
150
151
|
# or anything besides false or nil will work.
|
151
152
|
#
|
153
|
+
# To query an APIConnection other than the currently active one,
|
154
|
+
# provide one via the api: named parameter.
|
155
|
+
#
|
152
156
|
# @param refresh[Boolean] should the data be re-queried from the API?
|
153
157
|
#
|
158
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
159
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
160
|
+
#
|
154
161
|
# @return [Array<Hash{:name=>String, :id=> Integer}>]
|
155
162
|
#
|
156
|
-
def self.all(refresh = false)
|
163
|
+
def self.all(refresh = false, api: JSS.api)
|
157
164
|
raise JSS::UnsupportedError, '.all can only be called on subclasses of JSS::APIObject' if self == JSS::APIObject
|
158
|
-
|
159
|
-
return
|
160
|
-
|
165
|
+
api.object_list_cache[self::RSRC_LIST_KEY] = nil if refresh
|
166
|
+
return api.object_list_cache[self::RSRC_LIST_KEY] if api.object_list_cache[self::RSRC_LIST_KEY]
|
167
|
+
api.object_list_cache[self::RSRC_LIST_KEY] = api.get_rsrc(self::RSRC_BASE)[self::RSRC_LIST_KEY]
|
161
168
|
end
|
162
169
|
|
163
170
|
# Returns an Array of the JSS id numbers of all the members
|
@@ -168,10 +175,13 @@ module JSS
|
|
168
175
|
#
|
169
176
|
# @param refresh[Boolean] should the data be re-queried from the API?
|
170
177
|
#
|
178
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
179
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
180
|
+
#
|
171
181
|
# @return [Array<Integer>] the ids of all it1ems of this subclass in the JSS
|
172
182
|
#
|
173
|
-
def self.all_ids(refresh = false)
|
174
|
-
all(refresh).map { |i| i[:id] }
|
183
|
+
def self.all_ids(refresh = false, api: JSS.api)
|
184
|
+
all(refresh, api: api).map { |i| i[:id] }
|
175
185
|
end
|
176
186
|
|
177
187
|
# Returns an Array of the JSS names of all the members
|
@@ -182,10 +192,13 @@ module JSS
|
|
182
192
|
#
|
183
193
|
# @param refresh[Boolean] should the data be re-queried from the API?
|
184
194
|
#
|
195
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
196
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
197
|
+
#
|
185
198
|
# @return [Array<String>] the names of all item of this subclass in the JSS
|
186
199
|
#
|
187
|
-
def self.all_names(refresh = false)
|
188
|
-
all(refresh).map { |i| i[:name] }
|
200
|
+
def self.all_names(refresh = false, api: JSS.api)
|
201
|
+
all(refresh, api: api).map { |i| i[:name] }
|
189
202
|
end
|
190
203
|
|
191
204
|
# Return a hash of all objects of this subclass
|
@@ -212,11 +225,14 @@ module JSS
|
|
212
225
|
#
|
213
226
|
# @param refresh[Boolean] should the data re-queried from the API?
|
214
227
|
#
|
228
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
229
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
230
|
+
#
|
215
231
|
# @return [Hash{Integer => Oject}] the associated ids and data
|
216
232
|
#
|
217
|
-
def self.map_all_ids_to(other_key, refresh = false)
|
233
|
+
def self.map_all_ids_to(other_key, refresh = false, api: JSS.api)
|
218
234
|
h = {}
|
219
|
-
all(refresh).each { |i| h[i[:id]] = i[other_key] }
|
235
|
+
all(refresh, api: api).each { |i| h[i[:id]] = i[other_key] }
|
220
236
|
h
|
221
237
|
end
|
222
238
|
|
@@ -229,55 +245,56 @@ module JSS
|
|
229
245
|
#
|
230
246
|
# @param refresh[Boolean] should the data re-queried from the API?
|
231
247
|
#
|
248
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
249
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
250
|
+
#
|
232
251
|
# @return [Hash{Integer => Object}] the objects requested
|
233
|
-
|
252
|
+
#
|
253
|
+
def self.all_objects(refresh = false, api: JSS.api)
|
234
254
|
objects_key = "#{self::RSRC_LIST_KEY}_objects".to_sym
|
235
|
-
|
236
|
-
|
237
|
-
JSS.api.object_list_cache[objects_key] = all(refresh).map { |o| new id: o[:id] }
|
255
|
+
return api.object_list_cache[objects_key] unless refresh || api.object_list_cache[objects_key].nil?
|
256
|
+
api.object_list_cache[objects_key] = all(refresh, api: api).map { |o| fetch id: o[:id], api: api }
|
238
257
|
end
|
239
258
|
|
240
259
|
# Return true or false if an object of this subclass
|
241
|
-
# with the given
|
260
|
+
# with the given Identifier exists on the server
|
242
261
|
#
|
243
|
-
# @param identfier [String,Integer]
|
262
|
+
# @param identfier [String,Integer] An identifier for an object, a value for
|
263
|
+
# one of the available lookup_keys
|
244
264
|
#
|
245
265
|
# @param refresh [Boolean] Should the data be re-read from the server
|
246
266
|
#
|
247
|
-
# @
|
267
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
268
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
248
269
|
#
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
when String
|
254
|
-
all_names(refresh).include? identfier
|
255
|
-
else
|
256
|
-
raise ArgumentError, 'Identifier must be a name (String) or id (Integer)'
|
257
|
-
end
|
270
|
+
# @return [Boolean] does an object with the given identifier exist?
|
271
|
+
#
|
272
|
+
def self.exist?(identifier, refresh = false, api: JSS.api)
|
273
|
+
!valid_id(identifier, refresh, api: api).nil?
|
258
274
|
end
|
259
275
|
|
260
276
|
# Return an id or nil if an object of this subclass
|
261
277
|
# with the given name or id exists on the server
|
262
278
|
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
266
|
-
# @param identfier [String,Integer] The name or id of object to check for
|
279
|
+
# @param identfier [String,Integer] An identifier for an object, a value for
|
280
|
+
# one of the available lookup_keys
|
267
281
|
#
|
268
282
|
# @param refresh [Boolean] Should the data be re-read from the server
|
269
283
|
#
|
284
|
+
# @param api[JSS::APIConnection] an API connection to use for the query.
|
285
|
+
# Defaults to the corrently active API. See {JSS::APIConnection}
|
286
|
+
#
|
270
287
|
# @return [Integer, nil] the id of the matching object, or nil if it doesn't exist
|
271
288
|
#
|
272
|
-
def self.valid_id(
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
289
|
+
def self.valid_id(identifier, refresh = false, api: JSS.api)
|
290
|
+
return identifier if all_ids(refresh, api: api).include? identifier
|
291
|
+
id = nil
|
292
|
+
all_lookup_keys.keys.each do |key|
|
293
|
+
next if key == :id
|
294
|
+
id = map_all_ids_to(key).invert[identifier]
|
295
|
+
return id if id
|
296
|
+
end # do key
|
297
|
+
id
|
281
298
|
end
|
282
299
|
|
283
300
|
# Convert an Array of Hashes of API object data to a
|
@@ -377,26 +394,32 @@ module JSS
|
|
377
394
|
#
|
378
395
|
def self.rsrc_keys
|
379
396
|
hash = {}
|
380
|
-
|
381
|
-
DEFAULT_LOOKUP_KEYS.merge self::OTHER_LOOKUP_KEYS
|
382
|
-
else
|
383
|
-
DEFAULT_LOOKUP_KEYS
|
384
|
-
end
|
385
|
-
all_keys.each { |key, deets| hash[key] = deets[:rsrc_key]}
|
397
|
+
all_lookup_keys.each { |key, deets| hash[key] = deets[:rsrc_key] }
|
386
398
|
hash
|
387
399
|
end
|
388
400
|
|
401
|
+
# the available list methods for an APIObject sublcass
|
402
|
+
#
|
403
|
+
# @return [Array<Symbol>] The list methods (e.g. .all_serial_numbers) for
|
404
|
+
# this APIObject subclass
|
405
|
+
#
|
406
|
+
|
407
|
+
# The combined DEFAULT_LOOKUP_KEYS and OTHER_LOOKUP_KEYS
|
408
|
+
# (which may be defined in subclasses)
|
409
|
+
#
|
410
|
+
# @return [Hash] See DEFAULT_LOOKUP_KEYS constant
|
411
|
+
#
|
412
|
+
def self.all_lookup_keys
|
413
|
+
return DEFAULT_LOOKUP_KEYS.merge(self::OTHER_LOOKUP_KEYS) if defined? self::OTHER_LOOKUP_KEYS
|
414
|
+
DEFAULT_LOOKUP_KEYS
|
415
|
+
end
|
416
|
+
|
389
417
|
# @return [Hash] the available lookup keys mapped to the appropriate
|
390
418
|
# list class method (e.g. id: :all_ids )
|
391
419
|
#
|
392
420
|
def self.lookup_key_list_methods
|
393
421
|
hash = {}
|
394
|
-
|
395
|
-
DEFAULT_LOOKUP_KEYS.merge self::OTHER_LOOKUP_KEYS
|
396
|
-
else
|
397
|
-
DEFAULT_LOOKUP_KEYS
|
398
|
-
end
|
399
|
-
all_keys.each { |key, deets| hash[key] = deets[:list]}
|
422
|
+
all_lookup_keys.each { |key, deets| hash[key] = deets[:list] }
|
400
423
|
hash
|
401
424
|
end
|
402
425
|
|
@@ -414,13 +437,14 @@ module JSS
|
|
414
437
|
#
|
415
438
|
# @return [APIObject] The ruby-instance of a JSS object
|
416
439
|
#
|
417
|
-
def self.fetch(arg)
|
440
|
+
def self.fetch(arg, api: JSS.api)
|
418
441
|
raise JSS::UnsupportedError, 'JSS::APIObject cannot be instantiated' if self.class == JSS::APIObject
|
419
442
|
|
420
443
|
# if given a hash (or a colletion of named params)
|
421
444
|
# pass to .new
|
422
445
|
if arg.is_a? Hash
|
423
|
-
raise ArgumentError, 'Use .
|
446
|
+
raise ArgumentError, 'Use .make to create new JSS objects' if arg[:id] == :new
|
447
|
+
api = arg[:api] if arg[:api]
|
424
448
|
return new arg
|
425
449
|
end
|
426
450
|
|
@@ -428,7 +452,7 @@ module JSS
|
|
428
452
|
# and if it's result includes the desired value,
|
429
453
|
# the pass they key and arg to .new
|
430
454
|
lookup_key_list_methods.each do |key, method_name|
|
431
|
-
return new({key => arg}) if
|
455
|
+
return new ({ key => arg, :api => api }) if method_name && send(method_name).include?(arg)
|
432
456
|
end # each key
|
433
457
|
|
434
458
|
# if we're here, we couldn't find a matching object
|
@@ -451,7 +475,8 @@ module JSS
|
|
451
475
|
#
|
452
476
|
# @return [APIObject] The un-created ruby-instance of a JSS object
|
453
477
|
#
|
454
|
-
def self.make(args
|
478
|
+
def self.make(**args)
|
479
|
+
args[:api] ||= JSS.api
|
455
480
|
raise JSS::UnsupportedError, 'JSS::APIObject cannot be instantiated' if self.class == JSS::APIObject
|
456
481
|
raise ArgumentError, "Use '#{self.class}.fetch id: xx' to retrieve existing JSS objects" if args[:id]
|
457
482
|
args[:id] = :new
|
@@ -464,7 +489,7 @@ module JSS
|
|
464
489
|
# These Symbols are added to VALID_DATA_KEYS for performing the
|
465
490
|
# :data validity test described above.
|
466
491
|
#
|
467
|
-
REQUIRED_DATA_KEYS = [
|
492
|
+
REQUIRED_DATA_KEYS = %i[id name].freeze
|
468
493
|
|
469
494
|
# All API objects have an id and a name. As such By these keys are available
|
470
495
|
# for object lookups.
|
@@ -473,6 +498,7 @@ module JSS
|
|
473
498
|
# which has the same format, described here:
|
474
499
|
#
|
475
500
|
# The merged Hashes DEFAULT_LOOKUP_KEYS and OTHER_LOOKUP_KEYS
|
501
|
+
# (as provided by the .all_lookup_keys Class method)
|
476
502
|
# define what unique identifiers can be passed as parameters to the
|
477
503
|
# fetch method for retrieving an object from the API.
|
478
504
|
# They also define the class methods that return a list (Array) of all such
|
@@ -494,13 +520,21 @@ module JSS
|
|
494
520
|
# }
|
495
521
|
#
|
496
522
|
DEFAULT_LOOKUP_KEYS = {
|
497
|
-
id: {rsrc_key: :id, list: :all_ids},
|
498
|
-
name: {rsrc_key: :name, list: :all_names}
|
523
|
+
id: { rsrc_key: :id, list: :all_ids },
|
524
|
+
name: { rsrc_key: :name, list: :all_names }
|
499
525
|
}.freeze
|
500
526
|
|
501
527
|
# Attributes
|
502
528
|
#####################################
|
503
529
|
|
530
|
+
# @return [JSS::APIConnection] the API connection thru which we deal with
|
531
|
+
# this object.
|
532
|
+
attr_reader :api
|
533
|
+
|
534
|
+
# @return the parsed JSON data retrieved from the API when this object was
|
535
|
+
# fetched
|
536
|
+
attr_reader :init_data
|
537
|
+
|
504
538
|
# @return [Integer] the JSS id number
|
505
539
|
attr_reader :id
|
506
540
|
|
@@ -535,7 +569,8 @@ module JSS
|
|
535
569
|
#
|
536
570
|
#
|
537
571
|
def initialize(args = {})
|
538
|
-
|
572
|
+
args[:api] ||= JSS.api
|
573
|
+
@api = args[:api]
|
539
574
|
raise JSS::UnsupportedError, 'JSS::APIObject cannot be instantiated' if self.class == JSS::APIObject
|
540
575
|
|
541
576
|
####### Previously looked-up JSON data
|
@@ -559,7 +594,6 @@ module JSS
|
|
559
594
|
@init_data = look_up_object_data(args)
|
560
595
|
end ## end arg parsing
|
561
596
|
|
562
|
-
|
563
597
|
parse_init_data
|
564
598
|
@need_to_update = false
|
565
599
|
end # init
|
@@ -652,6 +686,9 @@ module JSS
|
|
652
686
|
|
653
687
|
# Delete this item from the JSS.
|
654
688
|
#
|
689
|
+
# TODO: Make a class method for mass deletion
|
690
|
+
# without instantiating, then call it from this method.
|
691
|
+
#
|
655
692
|
# Subclasses may want to redefine this method,
|
656
693
|
# first calling super, then setting other attributes to
|
657
694
|
# nil, false, empty, etc..
|
@@ -660,7 +697,7 @@ module JSS
|
|
660
697
|
#
|
661
698
|
def delete
|
662
699
|
return nil unless @in_jss
|
663
|
-
|
700
|
+
@api.delete_rsrc @rest_rsrc
|
664
701
|
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name}"
|
665
702
|
@id = nil
|
666
703
|
@in_jss = false
|
@@ -676,6 +713,19 @@ module JSS
|
|
676
713
|
"#{self.class}, name: #{@name}, id: #{@id}"
|
677
714
|
end
|
678
715
|
|
716
|
+
# Remove the init_data and api object from
|
717
|
+
# the instance_variables used to create
|
718
|
+
# pretty-print (pp) output.
|
719
|
+
#
|
720
|
+
# @return [Array] the desired instance_variables
|
721
|
+
#
|
722
|
+
def pretty_print_instance_variables
|
723
|
+
vars = instance_variables.sort
|
724
|
+
vars.delete :@api
|
725
|
+
vars.delete :@init_data
|
726
|
+
vars
|
727
|
+
end
|
728
|
+
|
679
729
|
# Private Instance Methods
|
680
730
|
#####################################
|
681
731
|
private
|
@@ -702,7 +752,7 @@ module JSS
|
|
702
752
|
end
|
703
753
|
# and the id must be in the jss
|
704
754
|
raise NoSuchItemError, "No #{self.class::RSRC_OBJECT_KEY} with JSS id: #{@init_data[:id]}" unless \
|
705
|
-
self.class.all_ids.include? hash_to_check[:id]
|
755
|
+
self.class.all_ids(api: @api).include? hash_to_check[:id]
|
706
756
|
end # validate_init_data
|
707
757
|
|
708
758
|
# If we're making a new object in the JSS, make sure we were given
|
@@ -719,9 +769,9 @@ module JSS
|
|
719
769
|
def validate_init_for_creation(args)
|
720
770
|
raise JSS::UnsupportedError, "Creating #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless creatable?
|
721
771
|
|
722
|
-
raise JSS::MissingDataError, "You must provide a :name to create a #{self.class::RSRC_OBJECT_KEY}."
|
772
|
+
raise JSS::MissingDataError, "You must provide a :name to create a #{self.class::RSRC_OBJECT_KEY}." unless args[:name]
|
723
773
|
|
724
|
-
raise JSS::AlreadyExistsError, "A #{self.class::RSRC_OBJECT_KEY} already exists with the name '#{args[:name]}'" if self.class.all_names.include? args[:name]
|
774
|
+
raise JSS::AlreadyExistsError, "A #{self.class::RSRC_OBJECT_KEY} already exists with the name '#{args[:name]}'" if self.class.all_names(api: @api).include? args[:name]
|
725
775
|
end
|
726
776
|
|
727
777
|
# Given initialization args, perform an API lookup for an object.
|
@@ -743,7 +793,7 @@ module JSS
|
|
743
793
|
# e.g. User when loookup is by email.
|
744
794
|
rsrc_object_key = args[:rsrc_object_key] ? args[:rsrc_object_key] : self.class::RSRC_OBJECT_KEY
|
745
795
|
|
746
|
-
return
|
796
|
+
return @api.get_rsrc(rsrc)[rsrc_object_key]
|
747
797
|
rescue RestClient::ResourceNotFound
|
748
798
|
raise NoSuchItemError, "No #{self.class::RSRC_OBJECT_KEY} found matching: #{rsrc_key}/#{args[lookup_key]}"
|
749
799
|
end
|
@@ -767,6 +817,7 @@ module JSS
|
|
767
817
|
|
768
818
|
# many things have a :site
|
769
819
|
# TODO: Implement a Sitable mixin module
|
820
|
+
#
|
770
821
|
@site = JSS::APIObject.get_name(@main_subset[:site]) if @main_subset[:site]
|
771
822
|
|
772
823
|
##### Handle Mix-ins
|
@@ -792,7 +843,7 @@ module JSS
|
|
792
843
|
def find_main_subset
|
793
844
|
return @init_data if @init_data[:id] && @init_data[:name]
|
794
845
|
return @init_data[:general] if @init_data[:general] && @init_data[:general][:id] && @init_data[:general][:name]
|
795
|
-
@init_data.each do |
|
846
|
+
@init_data.each do |_key, value|
|
796
847
|
next unless value.is_a? Hash
|
797
848
|
return value if value.keys.include?(:id) && value.keys.include?(:name)
|
798
849
|
end
|
@@ -72,33 +72,33 @@ module JSS
|
|
72
72
|
#####################################
|
73
73
|
|
74
74
|
# @return [Array<Hash>] all JSS account users
|
75
|
-
def self.all_users(refresh = false)
|
76
|
-
all(refresh)[:users]
|
75
|
+
def self.all_users(refresh = false, api: JSS.api)
|
76
|
+
all(refresh, api: api)[:users]
|
77
77
|
end
|
78
78
|
|
79
79
|
# @return [Array<Hash>] all JSS account user ids
|
80
|
-
def self.all_user_ids(refresh = false)
|
81
|
-
all(refresh)[:users].map { |i| i[:id] }
|
80
|
+
def self.all_user_ids(refresh = false, api: JSS.api)
|
81
|
+
all(refresh, api: api)[:users].map { |i| i[:id] }
|
82
82
|
end
|
83
83
|
|
84
84
|
# @return [Array<Hash>] all JSS account user names
|
85
|
-
def self.all_user_names(refresh = false)
|
86
|
-
all(refresh)[:users].map { |i| i[:name] }
|
85
|
+
def self.all_user_names(refresh = false, api: JSS.api)
|
86
|
+
all(refresh, api: api)[:users].map { |i| i[:name] }
|
87
87
|
end
|
88
88
|
|
89
89
|
# @return [Array<Hash>] all JSS account groups
|
90
|
-
def self.all_groups(refresh = false)
|
91
|
-
all(refresh)[:groups]
|
90
|
+
def self.all_groups(refresh = false, api: JSS.api)
|
91
|
+
all(refresh, api: api)[:groups]
|
92
92
|
end
|
93
93
|
|
94
94
|
# @return [Array<Hash>] all JSS account group ids
|
95
|
-
def self.all_group_ids(refresh = false)
|
96
|
-
all(refresh)[:groups].map { |i| i[:id] }
|
95
|
+
def self.all_group_ids(refresh = false, api: JSS.api)
|
96
|
+
all(refresh, api: api)[:groups].map { |i| i[:id] }
|
97
97
|
end
|
98
98
|
|
99
99
|
# @return [Array<Hash>] all JSS account group names
|
100
|
-
def self.all_group_names(refresh = false)
|
101
|
-
all(refresh)[:groups].map { |i| i[:name] }
|
100
|
+
def self.all_group_names(refresh = false, api: JSS.api)
|
101
|
+
all(refresh, api: api)[:groups].map { |i| i[:name] }
|
102
102
|
end
|
103
103
|
|
104
104
|
# Attributes
|
@@ -167,11 +167,11 @@ module JSS
|
|
167
167
|
raise JSS::InvalidDataError, 'JSS::Criteriable::Criteria instance required' unless @criteria.is_a? JSS::Criteriable::Criteria
|
168
168
|
raise JSS::InvalidDataError, 'display_fields must be an Array.' unless @display_fields.is_a? Array
|
169
169
|
|
170
|
-
orig_timeout =
|
171
|
-
|
170
|
+
orig_timeout = @api.cnx.options[:timeout]
|
171
|
+
@api.timeout = 1800
|
172
172
|
super()
|
173
173
|
requery_search_results if get_results
|
174
|
-
|
174
|
+
@api.timeout = orig_timeout
|
175
175
|
|
176
176
|
@id # remember to return the id
|
177
177
|
end
|
@@ -185,11 +185,11 @@ module JSS
|
|
185
185
|
# @return [Integer] the id of the updated search
|
186
186
|
#
|
187
187
|
def update(get_results = false)
|
188
|
-
orig_timeout =
|
189
|
-
|
188
|
+
orig_timeout = @api.cnx.options[:timeout]
|
189
|
+
@api.timeout = 1800
|
190
190
|
super()
|
191
191
|
requery_search_results if get_results
|
192
|
-
|
192
|
+
@api.timeout = orig_timeout
|
193
193
|
|
194
194
|
@id # remember to return the id
|
195
195
|
end
|
@@ -201,17 +201,17 @@ module JSS
|
|
201
201
|
# @return [Array<Hash>] the new search results
|
202
202
|
#
|
203
203
|
def requery_search_results
|
204
|
-
orig_open_timeout =
|
205
|
-
orig_timeout =
|
206
|
-
|
207
|
-
|
204
|
+
orig_open_timeout = @api.cnx.options[:open_timeout]
|
205
|
+
orig_timeout = @api.cnx.options[:timeout]
|
206
|
+
@api.timeout = 1800
|
207
|
+
@api.open_timeout = 1800
|
208
208
|
begin
|
209
209
|
requery = self.class.new(id: @id)
|
210
210
|
@search_results = requery.search_results
|
211
211
|
@result_display_keys = requery.result_display_keys
|
212
212
|
ensure
|
213
|
-
|
214
|
-
|
213
|
+
@api.timeout = orig_timeout
|
214
|
+
@api.open_timeout = orig_open_timeout
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|