ruby-jss 1.4.1 → 1.6.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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +95 -0
  3. data/THANKS.md +3 -2
  4. data/lib/jamf.rb +18 -17
  5. data/lib/jamf/api/base_classes/collection_resource.rb +613 -0
  6. data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +109 -101
  7. data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +55 -30
  8. data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +10 -6
  9. data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +4 -3
  10. data/lib/jamf/api/connection.rb +13 -9
  11. data/lib/jamf/api/connection/api_error.rb +8 -8
  12. data/lib/jamf/api/connection/token.rb +16 -15
  13. data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
  14. data/lib/jamf/api/json_objects/{location.rb → device_enrollment_device_sync_state.rb} +27 -41
  15. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
  16. data/lib/jamf/api/json_objects/{attachment.rb → locale.rb} +14 -23
  17. data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
  18. data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
  19. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
  20. data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
  21. data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
  22. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
  23. data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
  24. data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
  25. data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
  26. data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
  27. data/lib/jamf/api/mixins/change_log.rb +201 -51
  28. data/lib/jamf/api/{resources/collection_resources/computer.rb → mixins/filterable.rb} +19 -17
  29. data/lib/jamf/api/mixins/pageable.rb +208 -0
  30. data/lib/jamf/api/{json_objects/installed_application.rb → mixins/sortable.rb} +33 -33
  31. data/lib/jamf/api/resources/collection_resources/building.rb +16 -9
  32. data/lib/jamf/api/resources/collection_resources/category.rb +5 -4
  33. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +12 -5
  34. data/lib/jamf/api/resources/collection_resources/department.rb +0 -2
  35. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +10 -10
  36. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
  37. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +25 -23
  38. data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
  39. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
  40. data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
  41. data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
  42. data/lib/jamf/client.rb +3 -3
  43. data/lib/jamf/client/management_action.rb +2 -3
  44. data/lib/jamf/composer.rb +2 -2
  45. data/lib/jamf/utility.rb +35 -7
  46. data/lib/jamf/validate.rb +63 -24
  47. data/lib/jamf/version.rb +1 -1
  48. data/lib/jss.rb +2 -2
  49. data/lib/jss/api_connection.rb +114 -406
  50. data/lib/jss/api_object.rb +3 -19
  51. data/lib/jss/api_object/categorizable.rb +1 -1
  52. data/lib/jss/api_object/computer.rb +13 -0
  53. data/lib/jss/api_object/configuration_profile.rb +61 -5
  54. data/lib/jss/api_object/directory_binding_type.rb +66 -60
  55. data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
  56. data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
  57. data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
  58. data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
  59. data/lib/jss/api_object/distribution_point.rb +2 -2
  60. data/lib/jss/api_object/dock_item.rb +102 -96
  61. data/lib/jss/api_object/extendable.rb +1 -1
  62. data/lib/jss/api_object/group.rb +33 -2
  63. data/lib/jss/api_object/network_segment.rb +45 -13
  64. data/lib/jss/api_object/patch_source.rb +10 -9
  65. data/lib/jss/api_object/policy.rb +155 -25
  66. data/lib/jss/api_object/printer.rb +10 -4
  67. data/lib/jss/api_object/scopable.rb +10 -15
  68. data/lib/jss/api_object/scopable/scope.rb +31 -30
  69. data/lib/jss/api_object/script.rb +242 -352
  70. data/lib/jss/api_object/user.rb +1 -1
  71. data/lib/jss/client/management_action.rb +1 -2
  72. data/lib/jss/composer.rb +2 -2
  73. data/lib/jss/exceptions.rb +3 -0
  74. data/lib/jss/server.rb +15 -0
  75. data/lib/jss/utility.rb +213 -45
  76. data/lib/jss/version.rb +1 -1
  77. metadata +46 -64
  78. data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
  79. data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
  80. data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
  81. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
  82. data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
  83. data/lib/jamf/api/json_objects/android_details.rb +0 -139
  84. data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
  85. data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
  86. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
  87. data/lib/jamf/api/json_objects/criterion.rb +0 -152
  88. data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
  89. data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
  90. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
  91. data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
  92. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
  93. data/lib/jamf/api/json_objects/ios_details.rb +0 -244
  94. data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
  95. data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
  96. data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
  97. data/lib/jamf/api/mixins/locatable.rb +0 -124
  98. data/lib/jamf/api/mixins/referable.rb +0 -92
  99. data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
  100. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
  101. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
  102. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +0 -45
  103. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
  104. data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
  105. data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
  106. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
  107. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -106,7 +106,7 @@ module JSS
106
106
  # @return [void]
107
107
  def workstation_mode=(newvalue)
108
108
 
109
- raise JSS::InvalidDataError, "workstation_mode must be true or false." unless newvalue.is_a? Bool
109
+ raise JSS::InvalidDataError, "workstation_mode must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
110
110
 
111
111
  @workstation_mode = newvalue
112
112
 
@@ -125,7 +125,7 @@ module JSS
125
125
  # @return [void]
126
126
  def overwrite_existing=(newvalue)
127
127
 
128
- raise JSS::InvalidDataError, "overwrite_existing must be true or false." unless newvalue.is_a? Bool
128
+ raise JSS::InvalidDataError, "overwrite_existing must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
129
129
 
130
130
  @overwrite_existing = newvalue
131
131
 
@@ -144,7 +144,7 @@ module JSS
144
144
  # @return [void]
145
145
  def update_PAM=(newvalue)
146
146
 
147
- raise JSS::InvalidDataError, "update_PAM must be true or false." unless newvalue.is_a? Bool
147
+ raise JSS::InvalidDataError, "update_PAM must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
148
148
 
149
149
  @update_PAM = newvalue
150
150
 
@@ -163,9 +163,16 @@ module JSS
163
163
  # @return [void]
164
164
  def zone=(newvalue)
165
165
 
166
- raise JSS::InvalidDataError, "zone must be a string." unless newvalue.is_a? String
166
+ new =
167
+ if newvalue.to_s.empty?
168
+ JSS::BLANK
169
+ else
170
+ # Data Check
171
+ raise JSS::InvalidDataError, "zone must be a string." unless newvalue.is_a? String
172
+ newvalue
173
+ end
167
174
 
168
- @zone = newvalue
175
+ @zone = new
169
176
 
170
177
  self.container&.should_update
171
178
  end
@@ -182,9 +189,16 @@ module JSS
182
189
  # @return [void]
183
190
  def preferred_domain_server=(newvalue)
184
191
 
185
- raise JSS::InvalidDataError, "preferred_domain_server must be a string." unless newvalue.is_a? String
192
+ new =
193
+ if newvalue.to_s.empty?
194
+ JSS::BLANK
195
+ else
196
+ # Data Check
197
+ raise JSS::InvalidDataError, "preferred_domain_server must be a string." unless newvalue.is_a? String
198
+ newvalue
199
+ end
186
200
 
187
- @preferred_domain_server = newvalue
201
+ @preferred_domain_server = new
188
202
 
189
203
  self.container&.should_update
190
204
  end
@@ -93,7 +93,7 @@ module JSS
93
93
  # @return [void]
94
94
  def encrypt_using_ssl=(newvalue)
95
95
 
96
- raise JSS::InvalidDataError, "encrypt_using_ssl must be true or false." unless newvalue.is_a? Bool
96
+ raise JSS::InvalidDataError, "encrypt_using_ssl must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
97
97
 
98
98
  @encrypt_using_ssl = newvalue
99
99
 
@@ -112,7 +112,7 @@ module JSS
112
112
  # @return [void]
113
113
  def perform_secure_bind=(newvalue)
114
114
 
115
- raise JSS::InvalidDataError, "perform_secure_bind must be true or false." unless newvalue.is_a? Bool
115
+ raise JSS::InvalidDataError, "perform_secure_bind must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
116
116
 
117
117
  @perform_secure_bind = newvalue
118
118
 
@@ -131,7 +131,7 @@ module JSS
131
131
  # @return [void]
132
132
  def use_for_authentication=(newvalue)
133
133
 
134
- raise JSS::InvalidDataError, "use_for_authentication must be true or false." unless newvalue.is_a? Bool
134
+ raise JSS::InvalidDataError, "use_for_authentication must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
135
135
 
136
136
  @use_for_authentication = newvalue
137
137
 
@@ -150,7 +150,7 @@ module JSS
150
150
  # @return [void]
151
151
  def use_for_contacts=(newvalue)
152
152
 
153
- raise JSS::InvalidDataError, "use_for_contacts must be true or false." unless newvalue.is_a? Bool
153
+ raise JSS::InvalidDataError, "use_for_contacts must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
154
154
 
155
155
  @use_for_contacts = newvalue
156
156
 
@@ -407,9 +407,9 @@ module JSS
407
407
 
408
408
  begin
409
409
  mount pw, :rw
410
- return :mountable
410
+ :mountable
411
411
  rescue
412
- return false
412
+ false
413
413
  ensure
414
414
  unmount
415
415
  end
@@ -24,8 +24,9 @@
24
24
  ###
25
25
 
26
26
  module JSS
27
-
28
- # Module Variables
27
+
28
+
29
+ # Module Variables
29
30
  #####################################
30
31
 
31
32
  # Module Methods
@@ -40,98 +41,103 @@ module JSS
40
41
  # @see JSS::APIObject
41
42
  #
42
43
  class DockItem < JSS::APIObject
43
-
44
- # Mix-Ins
45
- #####################################
46
- include JSS::Creatable
47
- include JSS::Updatable
48
-
49
- # Class Methods
50
- #####################################
51
-
52
- # Class Constants
53
- #####################################
54
-
55
- # The Dock Item type
56
- DOCK_ITEM_TYPE = [
57
- "App",
58
- "File",
59
- "Folder"
60
- ].freeze
61
-
62
- # The base for REST resources of this class
63
- RSRC_BASE = 'dockitems'.freeze
64
-
65
- # the hash key used for the JSON list output of all objects in the JSS
66
- RSRC_LIST_KEY = :dock_items
67
-
68
- # The hash key used for the JSON object output.
69
- # It's also used in various error messages
70
- RSRC_OBJECT_KEY = :dock_item
71
-
72
- # the object type for this object in
73
- # the object history table.
74
- # See {APIObject#add_object_history_entry}
75
- #OBJECT_HISTORY_OBJECT_TYPE = 41
76
-
77
- # Attributes
78
- #####################################
79
- attr_reader :id
80
- attr_reader :name
81
- attr_reader :type
82
- attr_reader :path
83
-
84
- # Constructor
85
- # @see JSS::APIObject.initialize
86
- #####################################
87
- def initialize(args = {})
88
- super args
89
-
90
- @type = "App" unless !@init_data[:type].nil?
91
- @type = @init_data[:type]
92
- @path = @init_data[:path]
93
- end
94
-
95
- # Public Instance Methods
96
- #####################################
97
-
98
- # set the type
99
- #
100
- # @param newval[String] the new app type
101
- #
102
- # @return [void]
103
- #
104
- def type=(newval)
105
- raise JSS::InvalidDataError, 'Type must be a string' unless message.is_a? String
106
- raise JSS::InvalidDataError, "Type must be one of the following: #{DOCK_ITEM_TYPE.to_s}; not #{newval.to_s}" unless DOCK_ITEM_TYPE.include? newval.to_s
107
- @type = newval
108
- @need_to_update = true
109
- end
110
-
111
- # set the path
112
- #
113
- # @param newval[String] the new app path
114
- def path=(newval)
115
- raise JSS::InvalidDataError, 'Path must be a String' unless newval.is_a? String
116
- @path = newval
117
- @need_to_update = true
118
- end
119
-
120
- # private instance methods
121
- ######################
122
- private
123
-
124
- # the xml formated data for adding or updating this in the JSS
125
- #
126
- def rest_xml
127
- doc = REXML::Document.new APIConnection::XML_HEADER
128
- ns = doc.add_element RSRC_OBJECT_KEY.to_s
129
- ns.add_element('name').text = @name
130
- ns.add_element('type').text = @type.to_s
131
- ns.add_element('path').text = @path.to_s
132
- doc.to_s
133
- end # rest_xml
44
+
45
+
46
+ # Mix-Ins
47
+ #####################################
48
+ include JSS::Creatable
49
+ include JSS::Updatable
50
+
51
+ # Class Methods
52
+ #####################################
53
+
54
+ # Class Constants
55
+ #####################################
56
+
57
+ # The Dock Item type
58
+ DOCK_ITEM_TYPE = %w[
59
+ App
60
+ File
61
+ Folder
62
+ ].freeze
63
+
64
+ # The base for REST resources of this class
65
+ RSRC_BASE = 'dockitems'.freeze
66
+
67
+ # the hash key used for the JSON list output of all objects in the JSS
68
+ RSRC_LIST_KEY = :dock_items
69
+
70
+ # The hash key used for the JSON object output.
71
+ # It's also used in various error messages
72
+ RSRC_OBJECT_KEY = :dock_item
73
+
74
+ # the object type for this object in
75
+ # the object history table.
76
+ # See {APIObject#add_object_history_entry}
77
+ # OBJECT_HISTORY_OBJECT_TYPE = 41
78
+
79
+ # Attributes
80
+ #####################################
81
+ attr_reader :id
82
+ attr_reader :name
83
+ attr_reader :type
84
+ attr_reader :path
85
+
86
+ # Constructor
87
+ # @see JSS::APIObject.initialize
88
+ #####################################
89
+ def initialize(args = {})
90
+ super args
91
+
92
+ @type = 'App' if @init_data[:type].nil?
93
+ @type = @init_data[:type]
94
+ @path = @init_data[:path]
95
+ end
96
+
97
+ # Public Instance Methods
98
+ #####################################
99
+
100
+ # set the type
101
+ #
102
+ # @param newval[String] the new app type
103
+ #
104
+ # @return [void]
105
+ #
106
+ def type=(newval)
107
+ raise JSS::InvalidDataError, 'Type must be a string' unless newval.is_a? String
108
+ raise JSS::InvalidDataError, "Type must be one of the following: #{DOCK_ITEM_TYPE}; not #{newval}" unless DOCK_ITEM_TYPE.include? newval.to_s
109
+
110
+ @type = newval
111
+ @need_to_update = true
112
+ end
113
+
114
+ # set the path
115
+ #
116
+ # @param newval[String] the new app path
117
+ def path=(newval)
118
+ raise JSS::InvalidDataError, 'Path must be a String' unless newval.is_a? String
119
+
120
+ @path = newval
121
+ @need_to_update = true
134
122
  end
135
-
136
-
137
- end
123
+
124
+ # private instance methods
125
+ ######################
126
+ private
127
+
128
+ # the xml formated data for adding or updating this in the JSS
129
+ #
130
+ def rest_xml
131
+ doc = REXML::Document.new APIConnection::XML_HEADER
132
+ ns = doc.add_element RSRC_OBJECT_KEY.to_s
133
+ ns.add_element('name').text = @name
134
+ ns.add_element('type').text = @type.to_s
135
+ ns.add_element('path').text = @path.to_s
136
+ doc.to_s
137
+ end # rest_xml
138
+
139
+ end
140
+
141
+
142
+
143
+ end
@@ -23,7 +23,6 @@
23
23
  #
24
24
  #
25
25
 
26
- #
27
26
  module JSS
28
27
 
29
28
  # Sub-Modules
@@ -221,6 +220,7 @@ module JSS
221
220
  eaxml = REXML::Element.new('extension_attributes')
222
221
  @extension_attributes.each do |ea|
223
222
  next unless @changed_eas.include? ea[:name]
223
+
224
224
  ea_el = eaxml.add_element('extension_attribute')
225
225
  ea_el.add_element('name').text = ea[:name]
226
226
 
@@ -241,7 +241,7 @@ module JSS
241
241
  #
242
242
  # @param retries [Integer] If calculate_members is true, refetching the
243
243
  # group to re-read the membership can happen too fast, the JSS won't know
244
- # it exists yet and will throw a RestClient::NotFound error. If that
244
+ # it exists yet and will throw a NoSuchItem error. If that
245
245
  # happens, try again this many times with a 1 second pause between attempts.
246
246
  #
247
247
  def create(calculate_members: true, retries: 10)
@@ -256,7 +256,7 @@ module JSS
256
256
  begin
257
257
  refresh_members
258
258
  break
259
- rescue RestClient::NotFound
259
+ rescue
260
260
  sleep 1
261
261
  tries += 1
262
262
  end # begin
@@ -311,6 +311,37 @@ module JSS
311
311
  super
312
312
  end
313
313
 
314
+ # Change static group to smart group
315
+ #
316
+ # @param args[Hash] the options and settings use for switching the computer group from static group to smart group
317
+ #
318
+ # @option args criteria[Array] The criterias to be user for the smart group
319
+ def set_smart(*params)
320
+ return if @is_smart
321
+
322
+ params[:criteria] = [] if params[:criteria].nil?
323
+
324
+ criteria = params[:criteria]
325
+
326
+ @is_smart = true
327
+ @need_to_update = true
328
+ end
329
+
330
+ # Change smart group to static group
331
+ #
332
+ # @param args[Hash] the options and settings use for switching the computer group from smart group to static group
333
+ #
334
+ # @option args preserve_members[Boolean] Should the smart group preserve it's current members?
335
+ def set_static(*params)
336
+ return unless @is_smart
337
+
338
+ preserve_members = params.include? :preserve_members
339
+
340
+ @is_smart = false
341
+
342
+ clear() unless preserve_members
343
+ end
344
+
314
345
  # How many members of the group?
315
346
  #
316
347
  # @return [Integer] the number of members of the group
@@ -435,9 +435,10 @@ module JSS
435
435
  @starting_address <= thing.range.begin && @ending_address >= thing.range.end
436
436
  else
437
437
  thing = IPAddr.new thing.to_s
438
- range.include? thing
438
+ range.cover? thing
439
439
  end
440
440
  end
441
+ alias cover? include?
441
442
 
442
443
  ### Does this network segment equal another?
443
444
  ### equality means the ranges are equal
@@ -459,9 +460,17 @@ module JSS
459
460
  ### @return [void]
460
461
  ###
461
462
  def building=(newval)
462
- new = JSS::Building.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
463
- raise JSS::MissingDataError, "No building matching '#{newval}'" unless new
464
- @building = new[:name]
463
+ new =
464
+ if newval.to_s.empty?
465
+ JSS::BLANK
466
+ else
467
+ id = JSS::Building.valid_id newval
468
+ raise JSS::MissingDataError, "No building matching '#{newval}'" unless id
469
+
470
+ JSS::Building.map_all_ids_to(:name)[id]
471
+ end
472
+
473
+ @building = new
465
474
  @need_to_update = true
466
475
  end
467
476
 
@@ -484,9 +493,16 @@ module JSS
484
493
  ### @return [void]
485
494
  ###
486
495
  def department=(newval)
487
- new = JSS::Department.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
488
- raise JSS::MissingDataError, "No department matching '#{newval}' in the JSS" unless new
489
- @department = new[:name]
496
+ new =
497
+ if newval.to_s.empty?
498
+ JSS::BLANK
499
+ else
500
+ id = JSS::Department.valid_id newval
501
+ raise JSS::MissingDataError , "No department matching '#{newval}' in the JSS" unless id
502
+
503
+ JSS::Department.map_all_ids_to(:name)[id]
504
+ end
505
+ @department = new
490
506
  @need_to_update = true
491
507
  end
492
508
 
@@ -531,9 +547,17 @@ module JSS
531
547
  ### @return [void]
532
548
  ###
533
549
  def netboot_server=(newval)
534
- new = JSS::NetbootServer.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
535
- raise JSS::MissingDataError, "No netboot_server matching '#{newval}' in the JSS" unless new
536
- @netboot_server = new[:name]
550
+ new =
551
+ if newval.to_s.empty?
552
+ JSS::BLANK
553
+ else
554
+ id = JSS::NetBootServer.valid_id newval
555
+ raise JSS::MissingDataError, "No netboot_server matching '#{newval}' in the JSS" unless id
556
+
557
+ JSS::NetbootServer.map_all_ids_to(:name)[id]
558
+ end
559
+
560
+ @netboot_server = new
537
561
  @need_to_update = true
538
562
  end
539
563
 
@@ -544,9 +568,17 @@ module JSS
544
568
  ### @return [void]
545
569
  ###
546
570
  def swu_server=(newval)
547
- new = JSS::SoftwareUpdateServer.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
548
- raise JSS::MissingDataError, "No swu_server matching '#{newval}' in the JSS" unless new
549
- @swu_server = new[:name]
571
+ new =
572
+ if newval.to_s.empty?
573
+ JSS::BLANK
574
+ else
575
+ id = JSS::SoftwareUpdateServer.valid_id newval
576
+ raise JSS::MissingDataError, "No swu_server matching '#{newval}' in the JSS" unless id
577
+
578
+ JSS::SoftwareUpdateServer.map_all_ids_to(:name)[id]
579
+ end
580
+
581
+ @swu_server = new
550
582
  @need_to_update = true
551
583
  end
552
584