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
@@ -160,7 +160,7 @@ module JSS
|
|
160
160
|
def building= (new_val)
|
161
161
|
return nil if @building == new_val
|
162
162
|
new_val = new_val.to_s.strip
|
163
|
-
raise JSS::NoSuchItemError, "No building named #{new_val} exists in the JSS" unless new_val.empty? or JSS::Building.all_names.include? new_val
|
163
|
+
raise JSS::NoSuchItemError, "No building named #{new_val} exists in the JSS" unless new_val.empty? or JSS::Building.all_names(api: @api).include? new_val
|
164
164
|
@building = new_val
|
165
165
|
@need_to_update = true
|
166
166
|
end
|
@@ -169,7 +169,7 @@ module JSS
|
|
169
169
|
def department= (new_val)
|
170
170
|
return nil if @department == new_val
|
171
171
|
new_val = new_val.to_s.strip
|
172
|
-
raise JSS::NoSuchItemError, "No department named #{new_val} exists in the JSS" unless new_val.empty? or JSS::Department.all_names.include? new_val
|
172
|
+
raise JSS::NoSuchItemError, "No department named #{new_val} exists in the JSS" unless new_val.empty? or JSS::Department.all_names(api: @api).include? new_val
|
173
173
|
@department = new_val
|
174
174
|
@need_to_update = true
|
175
175
|
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
### Copyright 2017 Pixar
|
2
2
|
|
3
|
-
###
|
3
|
+
###
|
4
4
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
5
|
### with the following modification; you may not use this file except in
|
6
6
|
### compliance with the Apache License and the following modification to it:
|
7
7
|
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
-
###
|
8
|
+
###
|
9
9
|
### 6. Trademarks. This License does not grant permission to use the trade
|
10
10
|
### names, trademarks, service marks, or product names of the Licensor
|
11
11
|
### and its affiliates, except as required to comply with Section 4(c) of
|
12
12
|
### the License and to reproduce the content of the NOTICE file.
|
13
|
-
###
|
13
|
+
###
|
14
14
|
### You may obtain a copy of the Apache License at
|
15
|
-
###
|
15
|
+
###
|
16
16
|
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
-
###
|
17
|
+
###
|
18
18
|
### Unless required by applicable law or agreed to in writing, software
|
19
19
|
### distributed under the Apache License with the above modification is
|
20
20
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
21
|
### KIND, either express or implied. See the Apache License for the specific
|
22
22
|
### language governing permissions and limitations under the Apache License.
|
23
|
-
###
|
23
|
+
###
|
24
24
|
###
|
25
25
|
|
26
26
|
###
|
@@ -77,7 +77,6 @@ module JSS
|
|
77
77
|
### Extended Class Methods
|
78
78
|
#####################################
|
79
79
|
|
80
|
-
###
|
81
80
|
### Perform a match, returning an Array of Hashes, one for each item matched
|
82
81
|
###
|
83
82
|
### At the moment, it appears the search is an "exact match" search
|
@@ -87,10 +86,10 @@ module JSS
|
|
87
86
|
###
|
88
87
|
### @return [Array<Hash>] the item smatched.
|
89
88
|
###
|
90
|
-
def match(term)
|
89
|
+
def match(term, api: JSS.api )
|
91
90
|
raise JSS::InvalidDataError, "Match term may not be empty" if term.to_s.empty?
|
92
91
|
rsrc = "#{self::RSRC_BASE}/#{JSS::Matchable::MATCH_RSRC}/#{term}"
|
93
|
-
|
92
|
+
api.get_rsrc(rsrc)[self::RSRC_LIST_KEY]
|
94
93
|
end
|
95
94
|
|
96
95
|
end # module Matchable
|
@@ -192,53 +192,53 @@ module JSS
|
|
192
192
|
#####################################
|
193
193
|
|
194
194
|
# @return [Array<String>] all mobiledevice serial_numbers
|
195
|
-
def self.all_serial_numbers(refresh = false)
|
196
|
-
all(refresh).map { |i| i[:serial_number] }
|
195
|
+
def self.all_serial_numbers(refresh = false, api: JSS.api)
|
196
|
+
all(refresh, api: API).map { |i| i[:serial_number] }
|
197
197
|
end
|
198
198
|
|
199
199
|
# @return [Array<String>] all mobiledevice phone numbers
|
200
|
-
def self.all_phone_numbers(refresh = false)
|
201
|
-
all(refresh).map { |i| i[:phone_number] }.reject(&:empty?)
|
200
|
+
def self.all_phone_numbers(refresh = false, api: JSS.api)
|
201
|
+
all(refresh, api: API).map { |i| i[:phone_number] }.reject(&:empty?)
|
202
202
|
end
|
203
203
|
|
204
204
|
# @return [Array<String>] all mobiledevice wifi mac addrs
|
205
|
-
def self.all_wifi_mac_addresses(refresh = false)
|
206
|
-
all(refresh).map { |i| i[:wifi_mac_address] }
|
205
|
+
def self.all_wifi_mac_addresses(refresh = false, api: JSS.api)
|
206
|
+
all(refresh, api: API).map { |i| i[:wifi_mac_address] }
|
207
207
|
end
|
208
208
|
|
209
209
|
# @return [Array<String>] all mobiledevice wifi mac addrs
|
210
|
-
def self.all_mac_addresses(refresh = false)
|
211
|
-
all_wifi_mac_addresses(refresh)
|
210
|
+
def self.all_mac_addresses(refresh = false, api: JSS.api)
|
211
|
+
all_wifi_mac_addresses(refresh, api: API)
|
212
212
|
end
|
213
213
|
|
214
214
|
# @return [Array<String>] all mobiledevice udids
|
215
|
-
def self.all_udids(refresh = false)
|
216
|
-
all(refresh).map { |i| i[:udid] }
|
215
|
+
def self.all_udids(refresh = false, api: JSS.api)
|
216
|
+
all(refresh, api: API).map { |i| i[:udid] }
|
217
217
|
end
|
218
218
|
|
219
219
|
# @return [Array<Hash>] the list of all managed mobile devices
|
220
|
-
def self.all_managed(refresh = false)
|
221
|
-
all(refresh).select { |d| d[:managed] }
|
220
|
+
def self.all_managed(refresh = false, api: JSS.api)
|
221
|
+
all(refresh, api: API).select { |d| d[:managed] }
|
222
222
|
end
|
223
223
|
|
224
224
|
# @return [Array<Hash>] the list of all unmanaged mobile devices
|
225
|
-
def self.all_unmanaged(refresh = false)
|
226
|
-
all(refresh).reject { |d| d[:managed] }
|
225
|
+
def self.all_unmanaged(refresh = false, api: JSS.api)
|
226
|
+
all(refresh, api: API).reject { |d| d[:managed] }
|
227
227
|
end
|
228
228
|
|
229
229
|
# @return [Array<Hash>] the list of all iPhones
|
230
|
-
def self.all_iphones(refresh = false)
|
231
|
-
all(refresh).select { |d| d[:model].start_with? 'iPhone' }
|
230
|
+
def self.all_iphones(refresh = false, api: JSS.api)
|
231
|
+
all(refresh, api: API).select { |d| d[:model].start_with? 'iPhone' }
|
232
232
|
end
|
233
233
|
|
234
234
|
# @return [Array<Hash>] the list of all iPads
|
235
|
-
def self.all_ipads(refresh = false)
|
236
|
-
all(refresh).select { |d| d[:model].start_with? 'iPad' }
|
235
|
+
def self.all_ipads(refresh = false, api: JSS.api)
|
236
|
+
all(refresh, api: API).select { |d| d[:model].start_with? 'iPad' }
|
237
237
|
end
|
238
238
|
|
239
239
|
# @return [Array<Hash>] the list of all iPads
|
240
|
-
def self.all_apple_tvs(refresh = false)
|
241
|
-
all(refresh).select { |d| d[:model_identifier].start_with? 'AppleTV' }
|
240
|
+
def self.all_apple_tvs(refresh = false, api: JSS.api)
|
241
|
+
all(refresh, api: API).select { |d| d[:model_identifier].start_with? 'AppleTV' }
|
242
242
|
end
|
243
243
|
|
244
244
|
# Send an MDM command to one or more mobile devices by id or name
|
@@ -253,10 +253,13 @@ module JSS
|
|
253
253
|
#
|
254
254
|
# @param data[String] Some commands require extra data.
|
255
255
|
#
|
256
|
+
# @param api[JSS::APIConnection] the APi to query. Defaults to the
|
257
|
+
# currently active API, see {JSS::APIConnection}
|
258
|
+
#
|
256
259
|
# @return [String] The uuid of the MDM command sent, if applicable
|
257
260
|
# (blank pushes do not generate uuids)
|
258
261
|
#
|
259
|
-
def self.send_mdm_command(targets, command, data = nil)
|
262
|
+
def self.send_mdm_command(targets, command, data = nil, api: JSS.api)
|
260
263
|
raise JSS::NoSuchItemError, "Unknown command '#{command}'" unless MDM_COMMANDS.keys.include? command
|
261
264
|
|
262
265
|
command = MDM_COMMANDS[command]
|
@@ -271,10 +274,10 @@ module JSS
|
|
271
274
|
|
272
275
|
# make sure its an array of ids
|
273
276
|
targets.map! do |md|
|
274
|
-
if all_ids.include? md.to_i
|
277
|
+
if all_ids(api: api).include? md.to_i
|
275
278
|
md.to_i
|
276
|
-
elsif all_names.include? md
|
277
|
-
map_all_ids_to(:name
|
279
|
+
elsif all_names(api: api).include? md
|
280
|
+
map_all_ids_to(:name, api: api.invert[md])
|
278
281
|
else
|
279
282
|
raise JSS::NoSuchItemError, "No mobile device found matching '#{md}'"
|
280
283
|
end # if
|
@@ -282,26 +285,26 @@ module JSS
|
|
282
285
|
|
283
286
|
cmd_rsrc << "/id/#{targets.join ','}"
|
284
287
|
|
285
|
-
result =
|
288
|
+
result = api.post_rsrc cmd_rsrc, nil
|
286
289
|
result =~ %r{<uuid>(.*)</uuid>}
|
287
290
|
Regexp.last_match(1)
|
288
291
|
end
|
289
292
|
|
290
|
-
def self.management_history(identifier, subset = nil )
|
293
|
+
def self.management_history(identifier, subset = nil, api: JSS.api)
|
291
294
|
id = nil
|
292
295
|
if identifier.is_a? Integer
|
293
296
|
id = identifier
|
294
297
|
else
|
295
298
|
key = case identifier
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
id = map_all_ids_to(key).invert[identifier]
|
299
|
+
when *all_names(api: api) then :name
|
300
|
+
when *all_serial_numbers(api: api) then :serial_number
|
301
|
+
when *all_mac_addresses(api: api) then :mac_address
|
302
|
+
when *all_udids(api: api) then :udid
|
303
|
+
end
|
304
|
+
id = map_all_ids_to(key, api: api).invert[identifier]
|
302
305
|
end # if identifier.is_a? Integer
|
303
306
|
|
304
|
-
raise JSS::NoSuchItemError, "No MobileDevice found matching #{identifier}" unless id && all_ids.include?(id)
|
307
|
+
raise JSS::NoSuchItemError, "No MobileDevice found matching #{identifier}" unless id && all_ids(api: api).include?(id)
|
305
308
|
|
306
309
|
rsrc = "#{HISTORY_RSRC}/id/#{id}"
|
307
310
|
|
@@ -310,7 +313,7 @@ module JSS
|
|
310
313
|
rsrc << "/subset/#{subset}"
|
311
314
|
end
|
312
315
|
|
313
|
-
hist =
|
316
|
+
hist = api.get_rsrc(rsrc)[:mobile_device_history]
|
314
317
|
subset ? hist[subset] : hist
|
315
318
|
end
|
316
319
|
|
@@ -547,7 +550,7 @@ module JSS
|
|
547
550
|
# @return [String] The command uuid
|
548
551
|
#
|
549
552
|
def blank_push
|
550
|
-
self.class.send_mdm_command @id, :blank_push
|
553
|
+
self.class.send_mdm_command @id, :blank_push, api: @api
|
551
554
|
end #
|
552
555
|
|
553
556
|
# Send an update_inventory MDM command
|
@@ -557,7 +560,7 @@ module JSS
|
|
557
560
|
# @return [String] The command uuid
|
558
561
|
#
|
559
562
|
def update_inventory
|
560
|
-
self.class.send_mdm_command @id, :update_inventory
|
563
|
+
self.class.send_mdm_command @id, :update_inventory, api: @api
|
561
564
|
end
|
562
565
|
|
563
566
|
# Send a device_lock MDM command
|
@@ -569,7 +572,7 @@ module JSS
|
|
569
572
|
# @return [String] The command uuid
|
570
573
|
#
|
571
574
|
def device_lock(message)
|
572
|
-
self.class.send_mdm_command @id, :device_lock, message
|
575
|
+
self.class.send_mdm_command @id, :device_lock, message, api: @api
|
573
576
|
end
|
574
577
|
|
575
578
|
# Send an erase_device MDM command
|
@@ -579,7 +582,7 @@ module JSS
|
|
579
582
|
# @return [String] The command uuid
|
580
583
|
#
|
581
584
|
def erase_device
|
582
|
-
self.class.send_mdm_command @id, :erase_device
|
585
|
+
self.class.send_mdm_command @id, :erase_device, api: @api
|
583
586
|
end
|
584
587
|
|
585
588
|
# Send a clear_passcode MDM command
|
@@ -589,7 +592,7 @@ module JSS
|
|
589
592
|
# @return [String] The command uuid
|
590
593
|
#
|
591
594
|
def clear_passcode
|
592
|
-
self.class.send_mdm_command @id, :clear_passcode
|
595
|
+
self.class.send_mdm_command @id, :clear_passcode, api: @api
|
593
596
|
end
|
594
597
|
|
595
598
|
# Send a unmanage_device MDM command
|
@@ -599,7 +602,7 @@ module JSS
|
|
599
602
|
# @return [String] The command uuid
|
600
603
|
#
|
601
604
|
def unmanage_device
|
602
|
-
@managed = false if self.class.send_mdm_command(@id, :unmanage_device)
|
605
|
+
@managed = false if self.class.send_mdm_command(@id, :unmanage_device, api: @api)
|
603
606
|
end
|
604
607
|
|
605
608
|
# Send a ClearRestrictionsPassword MDM command
|
@@ -609,7 +612,7 @@ module JSS
|
|
609
612
|
# @return [String] The command uuid
|
610
613
|
#
|
611
614
|
def clear_restrictions_password
|
612
|
-
self.class.send_mdm_command @id, :clear_restrictions_password
|
615
|
+
self.class.send_mdm_command @id, :clear_restrictions_password, api: @api
|
613
616
|
end
|
614
617
|
|
615
618
|
# Send a SettingsEnableDataRoaming MDM command
|
@@ -619,7 +622,7 @@ module JSS
|
|
619
622
|
# @return [String] The command uuid
|
620
623
|
#
|
621
624
|
def enable_data_roaming
|
622
|
-
self.class.send_mdm_command @id, :enable_data_roaming
|
625
|
+
self.class.send_mdm_command @id, :enable_data_roaming, api: @api
|
623
626
|
end
|
624
627
|
|
625
628
|
# Send a disable_data_roaming MDM command
|
@@ -629,7 +632,7 @@ module JSS
|
|
629
632
|
# @return [String] The command uuid
|
630
633
|
#
|
631
634
|
def disable_data_roaming
|
632
|
-
self.class.send_mdm_command @id, :disable_data_roaming
|
635
|
+
self.class.send_mdm_command @id, :disable_data_roaming, api: @api
|
633
636
|
end
|
634
637
|
|
635
638
|
# Send a enable_voice_roaming MDM command
|
@@ -639,7 +642,7 @@ module JSS
|
|
639
642
|
# @return [String] The command uuid
|
640
643
|
#
|
641
644
|
def enable_voice_roaming
|
642
|
-
self.class.send_mdm_command @id, :enable_voice_roaming
|
645
|
+
self.class.send_mdm_command @id, :enable_voice_roaming, api: @api
|
643
646
|
end
|
644
647
|
|
645
648
|
# Send a disable_voice_roaming MDM command
|
@@ -649,7 +652,7 @@ module JSS
|
|
649
652
|
# @return [String] The command uuid
|
650
653
|
#
|
651
654
|
def disable_voice_roaming
|
652
|
-
self.class.send_mdm_command @id, :disable_voice_roaming
|
655
|
+
self.class.send_mdm_command @id, :disable_voice_roaming, api: @api
|
653
656
|
end
|
654
657
|
|
655
658
|
# Send a enable_app_analytics MDM command
|
@@ -659,7 +662,7 @@ module JSS
|
|
659
662
|
# @return [String] The command uuid
|
660
663
|
#
|
661
664
|
def enable_app_analytics
|
662
|
-
self.class.send_mdm_command @id, :enable_app_analytics
|
665
|
+
self.class.send_mdm_command @id, :enable_app_analytics, api: @api
|
663
666
|
end
|
664
667
|
|
665
668
|
# Send a disable_app_analytics MDM command
|
@@ -669,7 +672,7 @@ module JSS
|
|
669
672
|
# @return [String] The command uuid
|
670
673
|
#
|
671
674
|
def disable_app_analytics
|
672
|
-
self.class.send_mdm_command @id, :disable_app_analytics
|
675
|
+
self.class.send_mdm_command @id, :disable_app_analytics, api: @api
|
673
676
|
end
|
674
677
|
|
675
678
|
# Send a enable_diagnostic_submission MDM command
|
@@ -679,7 +682,7 @@ module JSS
|
|
679
682
|
# @return [String] The command uuid
|
680
683
|
#
|
681
684
|
def enable_diagnostic_submission
|
682
|
-
self.class.send_mdm_command @id, :enable_diagnostic_submission
|
685
|
+
self.class.send_mdm_command @id, :enable_diagnostic_submission, api: @api
|
683
686
|
end
|
684
687
|
|
685
688
|
# Send a disable_diagnostic_submission MDM command
|
@@ -689,7 +692,7 @@ module JSS
|
|
689
692
|
# @return [String] The command uuid
|
690
693
|
#
|
691
694
|
def disable_diagnostic_submission
|
692
|
-
self.class.send_mdm_command @id, :disable_diagnostic_submission
|
695
|
+
self.class.send_mdm_command @id, :disable_diagnostic_submission, api: @api
|
693
696
|
end
|
694
697
|
|
695
698
|
# Send a device_name MDM command
|
@@ -701,7 +704,7 @@ module JSS
|
|
701
704
|
# @return [String] The command uuid
|
702
705
|
#
|
703
706
|
def device_name(new_name)
|
704
|
-
self.class.send_mdm_command @id, :device_name, new_name
|
707
|
+
self.class.send_mdm_command @id, :device_name, new_name, api: @api
|
705
708
|
end
|
706
709
|
|
707
710
|
# Send a shutdown device MDM command
|
@@ -711,7 +714,7 @@ module JSS
|
|
711
714
|
# @return [String] The command uuid
|
712
715
|
#
|
713
716
|
def shutdown
|
714
|
-
self.class.send_mdm_command @id, :shutdown
|
717
|
+
self.class.send_mdm_command @id, :shutdown, api: @api
|
715
718
|
end
|
716
719
|
|
717
720
|
# Send a restart device MDM command
|
@@ -721,10 +724,9 @@ module JSS
|
|
721
724
|
# @return [String] The command uuid
|
722
725
|
#
|
723
726
|
def restart
|
724
|
-
self.class.send_mdm_command @id, :restart
|
727
|
+
self.class.send_mdm_command @id, :restart, api: @api
|
725
728
|
end
|
726
729
|
|
727
|
-
|
728
730
|
# The full management History data for this Mobile Device
|
729
731
|
#
|
730
732
|
# @return [Hash] Keys are:
|
@@ -736,7 +738,7 @@ module JSS
|
|
736
738
|
# ebooks: see managed
|
737
739
|
#
|
738
740
|
def management_history
|
739
|
-
self.class.management_history @id
|
741
|
+
self.class.management_history @id, api: @api
|
740
742
|
end
|
741
743
|
|
742
744
|
# The user_location subset of the full history
|
@@ -747,7 +749,7 @@ module JSS
|
|
747
749
|
# objects
|
748
750
|
#
|
749
751
|
def user_location_history
|
750
|
-
self.class.management_history @id, :user_location
|
752
|
+
self.class.management_history @id, :user_location, api: @api
|
751
753
|
end
|
752
754
|
|
753
755
|
# The management_commands subset of the full history
|
@@ -758,7 +760,7 @@ module JSS
|
|
758
760
|
# #failed_mdm_commands
|
759
761
|
#
|
760
762
|
def management_command_history
|
761
|
-
self.class.management_history @id, :management_commands
|
763
|
+
self.class.management_history @id, :management_commands, api: @api
|
762
764
|
end
|
763
765
|
alias mdm_command_history management_command_history
|
764
766
|
|
@@ -802,7 +804,7 @@ module JSS
|
|
802
804
|
# #failed_managed_apps
|
803
805
|
#
|
804
806
|
def managed_app_history
|
805
|
-
self.class.management_history @id, :applications
|
807
|
+
self.class.management_history @id, :applications, api: @api
|
806
808
|
end
|
807
809
|
|
808
810
|
# The apps that have been installed via MDM
|
@@ -860,7 +862,7 @@ module JSS
|
|
860
862
|
# @return [Array<Hash>] One hash per event
|
861
863
|
#
|
862
864
|
def audit_history
|
863
|
-
self.class.management_history @id, :audits
|
865
|
+
self.class.management_history @id, :audits, api: @api
|
864
866
|
end
|
865
867
|
|
866
868
|
# The ebooks subset of the full history
|
@@ -870,7 +872,7 @@ module JSS
|
|
870
872
|
# #failed_managed_ebooks
|
871
873
|
#
|
872
874
|
def managed_ebook_history
|
873
|
-
self.class.management_history @id, :ebooks
|
875
|
+
self.class.management_history @id, :ebooks, api: @api
|
874
876
|
end
|
875
877
|
|
876
878
|
# The ebooks that have been installed via MDM
|
@@ -52,8 +52,8 @@ module JSS
|
|
52
52
|
# Class Methods
|
53
53
|
#####################################
|
54
54
|
|
55
|
-
def self.all_bundle_ids(refresh = false)
|
56
|
-
all(refresh).map { |mda| mda[:bundle_id] }
|
55
|
+
def self.all_bundle_ids(refresh = false, api: JSS.api)
|
56
|
+
all(refresh, api: api).map { |mda| mda[:bundle_id] }
|
57
57
|
end
|
58
58
|
|
59
59
|
# Class Constants
|
@@ -422,7 +422,7 @@ module JSS
|
|
422
422
|
#
|
423
423
|
def refresh_ipa
|
424
424
|
return nil unless @in_jss
|
425
|
-
fresh_data =
|
425
|
+
fresh_data = @api.get_rsrc(@rest_rsrc)[self.class::RSRC_OBJECT_KEY]
|
426
426
|
@ipa = fresh_data[:general][:ipa]
|
427
427
|
end
|
428
428
|
|
@@ -72,14 +72,14 @@ module JSS
|
|
72
72
|
###
|
73
73
|
### Using the #include? method on those Ranges is very useful.
|
74
74
|
###
|
75
|
+
### @param refresh[Boolean] re-read the data from the API?
|
76
|
+
###
|
77
|
+
### @param api[JSS::APIConnection] The API connection to query
|
78
|
+
###
|
75
79
|
### @return [Hash{Integer => Range}] the network segments as IPv4 address Ranges
|
76
80
|
###
|
77
|
-
def self.network_ranges(refresh = false)
|
78
|
-
|
79
|
-
return @network_ranges if @network_ranges
|
80
|
-
@network_ranges = {}
|
81
|
-
all(refresh).each { |ns| @network_ranges[ns[:id]] = IPAddr.new(ns[:starting_address])..IPAddr.new(ns[:ending_address]) }
|
82
|
-
@network_ranges
|
81
|
+
def self.network_ranges(refresh = false, api: JSS.api)
|
82
|
+
api.network_ranges refresh
|
83
83
|
end # def network_segments
|
84
84
|
|
85
85
|
### An alias for {NetworkSegment.network_ranges}
|
@@ -88,8 +88,8 @@ module JSS
|
|
88
88
|
###
|
89
89
|
### @see {NetworkSegment::network_ranges}
|
90
90
|
###
|
91
|
-
def self.subnets(refresh = false)
|
92
|
-
network_ranges refresh
|
91
|
+
def self.subnets(refresh = false, api: JSS.api)
|
92
|
+
network_ranges refresh, api: api
|
93
93
|
end
|
94
94
|
|
95
95
|
### Given a starting address & ending address, mask, or cidr,
|
@@ -186,29 +186,34 @@ module JSS
|
|
186
186
|
###
|
187
187
|
### @param ip[String, IPAddr] the IP address to locate
|
188
188
|
###
|
189
|
+
### @param refresh[Boolean] should the data be re-queried?
|
190
|
+
###
|
191
|
+
### @param api[JSS::APIConnection] The API connection to query
|
192
|
+
###
|
189
193
|
### @return [Array<Integer>] the ids of the NetworkSegments containing the given ip
|
190
194
|
###
|
191
|
-
def self.network_segments_for_ip(ip)
|
192
|
-
|
193
|
-
matches = []
|
194
|
-
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
|
195
|
-
matches
|
195
|
+
def self.network_segments_for_ip(ip, refresh = false, api: JSS.api)
|
196
|
+
api.network_segments_for_ip ip, refresh
|
196
197
|
end
|
197
198
|
|
198
|
-
|
199
|
-
|
199
|
+
# @deprecated use network_segments_for_ip
|
200
|
+
# Backward compatibility
|
201
|
+
def self.network_segment_for_ip(ip, api: JSS.api)
|
202
|
+
network_segments_for_ip(ip, api: api)
|
200
203
|
end
|
201
204
|
|
202
205
|
### Find the current network segment ids for the machine running this code
|
203
206
|
###
|
204
207
|
### @return [Array<Integer>] the NetworkSegment ids for this machine right now.
|
205
208
|
###
|
206
|
-
def self.my_network_segments
|
207
|
-
network_segment_for_ip JSS::Client.my_ip_address
|
209
|
+
def self.my_network_segments(api: JSS.api)
|
210
|
+
network_segment_for_ip JSS::Client.my_ip_address, api: api
|
208
211
|
end
|
209
212
|
|
210
|
-
|
211
|
-
|
213
|
+
# @deprecated use my_network_segments
|
214
|
+
# Backward compatibility
|
215
|
+
def self.my_network_segment(api: JSS.api)
|
216
|
+
my_network_segments api: api
|
212
217
|
end
|
213
218
|
|
214
219
|
### Attributes
|