ruby-jss 1.3.3 → 1.6.0b1

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.

Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +142 -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 +36 -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 +1 -3
  35. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +13 -13
  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 +10 -20
  51. data/lib/jss/api_object/advanced_search.rb +27 -26
  52. data/lib/jss/api_object/app_store_country_codes.rb +298 -0
  53. data/lib/jss/api_object/categorizable.rb +1 -1
  54. data/lib/jss/api_object/computer.rb +13 -0
  55. data/lib/jss/api_object/configuration_profile.rb +61 -5
  56. data/lib/jss/api_object/directory_binding_type.rb +66 -60
  57. data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
  58. data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
  59. data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
  60. data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
  61. data/lib/jss/api_object/distribution_point.rb +2 -2
  62. data/lib/jss/api_object/dock_item.rb +102 -96
  63. data/lib/jss/api_object/ebook.rb +1 -2
  64. data/lib/jss/api_object/extendable.rb +1 -1
  65. data/lib/jss/api_object/extension_attribute.rb +4 -3
  66. data/lib/jss/api_object/group.rb +33 -2
  67. data/lib/jss/api_object/mac_application.rb +107 -8
  68. data/lib/jss/api_object/network_segment.rb +45 -13
  69. data/lib/jss/api_object/patch_source.rb +10 -9
  70. data/lib/jss/api_object/policy.rb +267 -28
  71. data/lib/jss/api_object/printer.rb +10 -4
  72. data/lib/jss/api_object/scopable.rb +10 -15
  73. data/lib/jss/api_object/scopable/scope.rb +389 -73
  74. data/lib/jss/api_object/script.rb +242 -352
  75. data/lib/jss/api_object/self_servable.rb +17 -9
  76. data/lib/jss/api_object/uploadable.rb +1 -1
  77. data/lib/jss/api_object/user.rb +43 -2
  78. data/lib/jss/api_object/vpp_account.rb +209 -0
  79. data/lib/jss/api_object/vppable.rb +169 -13
  80. data/lib/jss/client/management_action.rb +1 -2
  81. data/lib/jss/composer.rb +2 -2
  82. data/lib/jss/exceptions.rb +3 -0
  83. data/lib/jss/server.rb +15 -0
  84. data/lib/jss/utility.rb +213 -45
  85. data/lib/jss/validate.rb +53 -10
  86. data/lib/jss/version.rb +1 -1
  87. metadata +50 -66
  88. data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
  89. data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
  90. data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
  91. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
  92. data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
  93. data/lib/jamf/api/json_objects/android_details.rb +0 -139
  94. data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
  95. data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
  96. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
  97. data/lib/jamf/api/json_objects/criterion.rb +0 -152
  98. data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
  99. data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
  100. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
  101. data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
  102. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
  103. data/lib/jamf/api/json_objects/ios_details.rb +0 -244
  104. data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
  105. data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
  106. data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
  107. data/lib/jamf/api/mixins/locatable.rb +0 -124
  108. data/lib/jamf/api/mixins/referable.rb +0 -92
  109. data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
  110. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
  111. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
  112. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +0 -45
  113. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
  114. data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
  115. data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
  116. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
  117. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -198,7 +198,7 @@ module JSS
198
198
 
199
199
  if cat.is_a? String
200
200
  @category_name = cat
201
- @category_id = JSS::Category.category_id_from_name @category_name
201
+ @category_id = JSS::Category.category_id_from_name @category_name, api: @api
202
202
  else
203
203
  @category_name = cat[:name]
204
204
  @category_id = cat[:id]
@@ -1046,6 +1046,19 @@ module JSS
1046
1046
  @need_to_update = true
1047
1047
  end
1048
1048
 
1049
+ # flush the logs for this computer in a given policy
1050
+ # @see JSS::Policy.flush_logs
1051
+ #
1052
+ def flush_policy_logs(policy, older_than: 0, period: :days)
1053
+ JSS::Policy.flush_logs(
1054
+ policy,
1055
+ older_than: older_than,
1056
+ period: period,
1057
+ computers: [@id],
1058
+ api: @api
1059
+ )
1060
+ end
1061
+
1049
1062
  def barcode1=(new_val)
1050
1063
  new_val = new_val.strip
1051
1064
  return nil if @barcode1 == new_val
@@ -23,7 +23,6 @@
23
23
  #
24
24
  #
25
25
 
26
- #
27
26
  module JSS
28
27
 
29
28
  # Classes
@@ -56,6 +55,11 @@ module JSS
56
55
  # which DISTRIBUTION_METHODS means we're in self service?
57
56
  SELF_SERVICE_DIST_METHOD = 'Make Available in Self Service'.freeze
58
57
 
58
+ # when a change is made, which in-scope machines should get
59
+ # the changed profile?
60
+ REDEPLOY_NEWLY_ASSIGNED = 'Newly Assigned'.freeze
61
+ REDEPLOY_ALL = 'All'.freeze
62
+
59
63
  # Our SelfService deploys profiles
60
64
  SELF_SERVICE_PAYLOAD = :profile
61
65
 
@@ -68,7 +72,6 @@ module JSS
68
72
  # How is the category stored in the API data?
69
73
  CATEGORY_DATA_TYPE = Hash
70
74
 
71
-
72
75
  # Attributes
73
76
  ###################################
74
77
 
@@ -78,7 +81,11 @@ module JSS
78
81
  # @return [String] the uuid of this profile. NOT Updatable
79
82
  attr_reader :uuid
80
83
 
81
- # @return [Boolean] Should this profile be redeployed when an inventory update happens?
84
+ # @return [String] When a change is made to the profile, which scoped machines
85
+ # should get the changes? This will always contain REDEPLOY_NEWLY_ASSIGNED
86
+ # when fetched, but can be set to REDEPLOY_ALL via the redeploy_to_all:
87
+ # parameter to #update & #save. After the update is complete, it reverts
88
+ # to REDEPLOY_NEWLY_ASSIGNED
82
89
  attr_reader :redeploy_on_update
83
90
 
84
91
  # @return [String] the plist containing the payloads for this profile. NOT Updatable
@@ -116,7 +123,7 @@ module JSS
116
123
  #
117
124
  # @return [Hash] the parsed payloads plist.
118
125
  def parsed_payloads
119
- Plist.parse_xml @payloads
126
+ JSS.parse_plist @payloads
120
127
  end
121
128
 
122
129
  # @return [Array<Hash>] the individual payloads from the payload Plist
@@ -125,12 +132,58 @@ module JSS
125
132
  parsed_payloads['PayloadContent']
126
133
  end
127
134
 
135
+ # @param new_content [Array<Hash>] replace the payload content entirely.
136
+ #
137
+ # The 'payload' of a config profile is an XML Plist. The top-level key
138
+ # of that plist 'PayloadContent' contains an Array of Dicts, each one being
139
+ # a part of the payload for the profile.
140
+ #
141
+ # When replacing the PayloadContent Array, using this method, provide a
142
+ # *ruby* Array full of *ruby* hashes, and they will be converted to a
143
+ # Plist and embedded into the API XML appropriately.
144
+ #
145
+ # WARNING: This is experimental! Editing the Plist Payload of a Config
146
+ # profile may break the profile. Make sure you test on a fake profile
147
+ # before using this method in production.
148
+ #
149
+ # @return [void]
150
+ #
151
+ def payload_content=(new_content)
152
+ payload_plist_data = parsed_payloads
153
+ payload_plist_data['PayloadContent'] = new_content
154
+ @payloads = JSS.xml_plist_from new_content
155
+ @need_to_update = true
156
+ @update_payloads = true
157
+ end
158
+
128
159
  # @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
129
160
  #
130
161
  def payload_types
131
162
  payload_content.map { |p| p['PayloadType'] }
132
163
  end
133
164
 
165
+ # clear flag after updating
166
+ def update(redeploy_to_all: false)
167
+ @redeploy_on_update = redeploy_to_all ? REDEPLOY_ALL : REDEPLOY_NEWLY_ASSIGNED
168
+ super()
169
+ # always reset to newly assigned
170
+ @redeploy_on_update = REDEPLOY_NEWLY_ASSIGNED
171
+ @update_payloads = nil
172
+ end
173
+
174
+ # wrapper with param
175
+ def save(redeploy_to_all: false)
176
+ if @in_jss
177
+ raise JSS::UnsupportedError, 'Updating this object in the JSS is currently not supported by ruby-jss' unless updatable?
178
+
179
+ update redeploy_to_all: redeploy_to_all
180
+ else
181
+ raise JSS::UnsupportedError, 'Creating this object in the JSS is currently not supported by ruby-jss' unless creatable?
182
+
183
+ create
184
+ end
185
+ end
186
+
134
187
  # Private Instance Methods
135
188
  ###################################
136
189
  private
@@ -142,7 +195,10 @@ module JSS
142
195
  gen = obj.add_element('general')
143
196
  gen.add_element('description').text = @description
144
197
  gen.add_element('redeploy_on_update').text = @redeploy_on_update
145
-
198
+ if @update_payloads
199
+ payloads_plist_xml = JSS.escape_xml(@payloads.gsub(/^\t*/, '').gsub(">\n", '>'))
200
+ gen.add_element('payloads').text = payloads_plist_xml
201
+ end
146
202
  obj << @scope.scope_xml
147
203
  add_self_service_xml doc
148
204
  add_category_to_xml doc
@@ -25,66 +25,72 @@
25
25
 
26
26
  module JSS
27
27
 
28
- # Module for containing the different types of DirectoryBindings stored within the JSS
29
- module DirectoryBindingType
30
-
31
- # Module Variables
32
- #####################################
33
-
34
- # Module Methods
35
- #####################################
36
- def should_update
37
- @need_to_update = true
38
- end
39
-
40
- def set_type_settings(settings)
41
- @type_settings = settings
42
- @type_settings.container = self
43
- end
44
-
45
- # Classes
46
- #####################################
47
-
48
- # A generic binding type class that sets common variables, methods, and constructors
49
- # for all the different directory binding types.
50
- #
51
- # @author Tyler Morgan
52
- class DirectoryBindingType
53
- # Mix-Ins
54
- #####################################
55
-
56
- # Class Methods
57
- #####################################
58
-
59
- # Class Constants
60
- #####################################
61
-
62
- # The different network protocols supported.
63
- NETWORK_PROTOCOL = {
64
- afp: "AFP",
65
- smb: "SMB"
66
- }.freeze
67
-
68
-
69
- # The different home folder types.
70
- HOME_FOLDER_TYPE = {
71
- network: "Network",
72
- local: "Local",
73
- either: "Either",
74
- mobile: "Mobile"
75
- }.freeze
76
-
77
- # Attributes
78
- #####################################
79
-
80
- # This is used to properly handle updating the containing object.
81
- attr_accessor :container
82
- end
28
+ # Module for containing the different types of DirectoryBindings stored within the JSS
29
+ module DirectoryBindingType
30
+
31
+ # Module Variables
32
+ #####################################
33
+
34
+ # Module Methods
35
+ #####################################
36
+ def should_update
37
+ @need_to_update = true
38
+ end
39
+
40
+ def set_type_settings(settings)
41
+ @type_settings = settings
42
+ @type_settings.container = self
43
+ end
44
+
45
+ # Classes
46
+ #####################################
47
+
48
+ # A generic binding type class that sets common variables, methods, and constructors
49
+ # for all the different directory binding types.
50
+ #
51
+ # @author Tyler Morgan
52
+ class DirectoryBindingType
53
+
54
+
55
+ # Mix-Ins
56
+ #####################################
57
+
58
+ # Class Methods
59
+ #####################################
60
+
61
+ # Class Constants
62
+ #####################################
63
+
64
+ # The different network protocols supported.
65
+ NETWORK_PROTOCOL = {
66
+ afp: 'AFP',
67
+ smb: 'SMB'
68
+ }.freeze
69
+
70
+ # The different home folder types.
71
+ HOME_FOLDER_TYPE = {
72
+ network: 'Network',
73
+ local: 'Local',
74
+ either: 'Either',
75
+ mobile: 'Mobile'
76
+ }.freeze
77
+
78
+ # Attributes
79
+ #####################################
80
+
81
+ # This is used to properly handle updating the containing object.
82
+ attr_accessor :container
83
+
84
+
85
+ end
86
+
87
+
83
88
  end
89
+
84
90
  end
85
91
 
86
- require "jss/api_object/directory_binding_type/active_directory"
87
- require "jss/api_object/directory_binding_type/open_directory"
88
- require "jss/api_object/directory_binding_type/admitmac"
89
- require "jss/api_object/directory_binding_type/centrify"
90
- require "jss/api_object/directory_binding_type/powerbroker_identity_services"
92
+ require 'jss/api_object/directory_binding_type/active_directory'
93
+ require 'jss/api_object/directory_binding_type/open_directory'
94
+ require 'jss/api_object/directory_binding_type/admitmac'
95
+ require 'jss/api_object/directory_binding_type/centrify'
96
+ require 'jss/api_object/directory_binding_type/powerbroker_identity_services'
@@ -259,11 +259,17 @@ module JSS
259
259
  # @return [void]
260
260
  def default_shell=(newvalue)
261
261
 
262
- # Data Check
263
- raise JSS::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
262
+ new =
263
+ if newvalue.to_s.empty?
264
+ JSS::BLANK
265
+ else
266
+ # Data Check
267
+ raise JSS::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
268
+ newvalue
269
+ end
264
270
 
265
271
  # Update Value
266
- @default_shell = newvalue
272
+ @default_shell = new
267
273
 
268
274
  # Set the object to needing to be updated.
269
275
  self.container&.should_update
@@ -280,12 +286,17 @@ module JSS
280
286
  #
281
287
  # @return [void]
282
288
  def uid=(newvalue)
283
-
284
- # Data Check
285
- raise JSS::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
289
+ new =
290
+ if newvalue.to_s.empty?
291
+ JSS::BLANK
292
+ else
293
+ # Data Check
294
+ raise JSS::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
295
+ newvalue
296
+ end
286
297
 
287
298
  # Update Value
288
- @uid = newvalue
299
+ @uid = new
289
300
 
290
301
  # Set the object to needing to be updated.
291
302
  self.container&.should_update
@@ -302,12 +313,17 @@ module JSS
302
313
  #
303
314
  # @return [void]
304
315
  def forest=(newvalue)
305
-
306
- # Data Check
307
- raise JSS::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
308
-
316
+ new =
317
+ if newvalue.to_s.empty?
318
+ JSS::BLANK
319
+ else
320
+ # Data Check
321
+ raise JSS::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
322
+ newvalue
323
+ end
324
+
309
325
  # Update Value
310
- @forest = newvalue
326
+ @forest = new
311
327
 
312
328
  # Set the object to needing to be updated.
313
329
  self.container&.should_update
@@ -323,12 +339,17 @@ module JSS
323
339
  #
324
340
  # @return [void]
325
341
  def user_gid=(newvalue)
326
-
327
- # Data Check
328
- raise JSS::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
342
+ new =
343
+ if newvalue.to_s.empty?
344
+ JSS::BLANK
345
+ else
346
+ # Data Check
347
+ raise JSS::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
348
+ newvalue
349
+ end
329
350
 
330
351
  # Update Value
331
- @user_gid = newvalue
352
+ @user_gid = new
332
353
 
333
354
  # Set the object to needing to be updated.
334
355
  self.container&.should_update
@@ -345,12 +366,17 @@ module JSS
345
366
  #
346
367
  # @return [void]
347
368
  def gid=(newvalue)
348
-
349
- # Data Check
350
- raise JSS::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
351
-
369
+ new =
370
+ if newvalue.to_s.empty?
371
+ JSS::BLANK
372
+ else
373
+ # Data Check
374
+ raise JSS::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
375
+ newvalue
376
+ end
377
+
352
378
  # Update Value
353
- @gid = newvalue
379
+ @gid = new
354
380
 
355
381
  # Set the object to needing to be updated.
356
382
  self.container&.should_update
@@ -389,12 +415,17 @@ module JSS
389
415
  #
390
416
  # @return [void]
391
417
  def preferred_domain=(newvalue)
392
-
393
- # Data Check
394
- raise JSS::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
418
+ new =
419
+ if newvalue.to_s.empty?
420
+ JSS::BLANK
421
+ else
422
+ # Data Check
423
+ raise JSS::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
424
+ newvalue
425
+ end
395
426
 
396
427
  # Update Value
397
- @preferred_domain = newvalue
428
+ @preferred_domain = new
398
429
 
399
430
  # Set the object to needing to be updated.
400
431
  self.container&.should_update
@@ -411,16 +442,22 @@ module JSS
411
442
  #
412
443
  # @return [void]
413
444
  def admin_groups=(newvalue)
414
-
415
- # Data Check
416
- raise JSS::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
417
-
445
+ new =
446
+ if newvalue.to_s.empty?
447
+ JSS::BLANK
448
+ else
449
+ # Data Check
450
+ raise JSS::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
451
+
452
+ if newvalue.is_a? Array
453
+ newvalue.join ","
454
+ else
455
+ newvalue
456
+ end
457
+ end
458
+
418
459
  # Update Value
419
- if newvalue.is_a? Array
420
- @admin_groups = newvalue.join ","
421
- else
422
- @admin_groups = newvalue
423
- end
460
+ @admin_groups = new
424
461
 
425
462
  # Set the object to needing to be updated.
426
463
  self.container&.should_update
@@ -24,502 +24,571 @@
24
24
  ###
25
25
 
26
26
  module JSS
27
-
28
- # Module for containing the different types of DirectoryBindings stored within the JSS
29
-
30
- module DirectoryBindingType
31
-
32
- # Module Variables
33
- #####################################
34
-
35
- # Module Methods
36
- #####################################
37
-
38
- # Classes
39
- #####################################
40
-
41
- # Class for the specific ADmitMac DirectoryBinding type stored within the JSS
42
- #
43
- # @author Tyler Morgan
44
- #
45
- # @note "Map Home Directory To Attribute" is currently only available in the Jamf Pro UI not through the API.
46
- #
47
- # Attributes
48
- # @!attribute [rw] require_confirmation
49
- # @!attribute [rw] local_home
50
- # @!attribute [rw] mount_style
51
- # @!attribute [rw] default_shell
52
- # @!attribute [rw] mount_network_home
53
- # @!attribute [rw] place_home_folders
54
- # @!attribute [rw] uid
55
- # @!attribute [rw] user_gid
56
- # @!attribute [rw] gid
57
- # @!attribute [rw] admin_group
58
- # @!attribute [rw] cached_credentials
59
- # @!attribute [rw] add_user_to_local
60
- # @!attribute [rw] users_ou
61
- # @!attribute [rw] groups_ou
62
- # @!attribute [rw] printers_ou
63
- # @!attribute [rw] shared_folders_ou
64
- # TODO: Include default values upon creation
65
-
66
- class ADmitMac < DirectoryBindingType
67
- # Mix-Ins
68
- #####################################
69
-
70
- # Class Methods
71
- #####################################
72
-
73
- # Class Constants
74
- #####################################
75
-
76
- # Attributes
77
- #####################################
78
-
79
- attr_reader :require_confirmation
80
- attr_reader :local_home
81
- attr_reader :mount_style
82
- attr_reader :default_shell
83
- attr_reader :mount_network_home
84
- attr_reader :place_home_folders
85
- attr_reader :uid
86
- attr_reader :user_gid
87
- attr_reader :gid
88
- attr_reader :admin_group
89
- attr_reader :cached_credentials
90
- attr_reader :add_user_to_local
91
- attr_reader :users_ou
92
- attr_reader :groups_ou
93
- attr_reader :printers_ou
94
- attr_reader :shared_folders_ou
95
-
96
- # Constructor
97
- #####################################
98
-
99
- # An initializer for the ADmitMac object.
100
- #
101
- # @author Tyler Morgan
102
- # @see JSS::DirectoryBinding
103
- # @see JSS::DirectoryBindingType
104
- #
105
- # @note Due to a JSS API funk, mount_style is not able to be configured through the API. It is linked to place_home_folders
106
- #
107
- # @param [Hash] initialize data
108
- def initialize(init_data)
109
-
110
- # Return without processing anything since there is
111
- # nothing to process.
112
- return if init_data.nil?
113
-
114
- # Process the provided information
115
- @require_confirmation = init_data[:require_confirmation]
116
- @default_shell = init_data[:default_shell]
117
- @mount_network_home = init_data[:mount_network_home]
118
- @place_home_folders = init_data[:place_home_folders]
119
- @uid = init_data[:uid]
120
- @user_gid = init_data[:user_gid]
121
- @gid = init_data[:gid]
122
- @cached_credentials = init_data[:cached_credentials]
123
- @add_user_to_local = init_data[:add_user_to_local]
124
- @users_ou = init_data[:users_ou]
125
- @groups_ou = init_data[:groups_ou]
126
- @printers_ou = init_data[:printers_ou]
127
- @shared_folders_ou = init_data[:shared_folders_ou]
128
- @mount_style = init_data[:mount_style]
129
-
130
- if init_data[:local_home].nil? || init_data[:local_home].is_a?(String)
131
- raise JSS::InvalidDataError, "Local Home must be one of #{HOME_FOLDER_TYPE.values.join(', ')}." unless HOME_FOLDER_TYPE.values.include? init_data[:local_home] || init_data[:local_home].nil?
132
-
133
- @local_home = init_data[:local_home]
134
- else
135
- raise JSS::InvalidDataError, "Local Home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}." unless HOME_FOLDER_TYPE.keys.include? init_data[:local_home]
136
- end
137
-
138
- if init_data[:admin_group].nil?
139
- # This is needed since we have the ability to add and
140
- # remove admin groups from this array.
141
- @admin_group = []
142
- elsif init_data[:admin_group].is_a? String
143
- @admin_group = init_data[:admin_group].split(',')
144
- else
145
- @admin_group = init_data[:admin_group]
146
- end
147
- end
148
-
149
-
150
-
151
- # Public Instance Methods
152
- #####################################
153
-
154
- # Require confirmation before creating a mobile account on the system.
155
- #
156
- # @author Tyler Morgan
157
- #
158
- # @param newvalue [Bool]
159
- #
160
- # @raise [JSS::InvalidDataError] If the new value doesn't match a Bool value
161
- #
162
- # @return [void]
163
- def require_confirmation=(newvalue)
164
-
165
- raise JSS::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a? Bool
166
-
167
- @require_confirmation = newvalue
168
-
169
- self.container&.should_update
170
- end
171
-
172
-
173
- # The type of home directory type created upon logging into a system
174
- #
175
- # @author Tyler Morgan
176
- #
177
- # @param newvalue [Symbol] The key specific to the folder type you want in HOME_FOLDER_TYPE
178
- # @see JSS::DirectoryBindingType::HOME_FOLDER_TYPE
179
- #
180
- # @raise [JSS::InvalidDataError] If the new value is not one of the possible keys in HOME_FOLDER_TYPE
181
- #
182
- # @return [void]
183
- def local_home=(newvalue)
184
-
185
- raise JSS::InvalidDataError, "local_home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}." unless HOME_FOLDER_TYPE.keys.include? newvalue
186
-
187
- @local_home = HOME_FOLDER_TYPE[newvalue]
188
-
189
- self.container&.should_update
190
- end
191
-
192
- # The default shell assigned first upon logging into a system
193
- #
194
- # @author Tyler Morgan
195
- #
196
- # @param newvalue [String] The string path of the shell file being set as the default
197
- #
198
- # @raise [JSS::InvalidDataError] If the new value is not a String
199
- #
200
- # @return [void]
201
- def default_shell=(newvalue)
202
-
203
- raise JSS::InvalidDataError, "default_shell must be empty or a string." unless newvalue.is_a?(String)
204
-
205
- @default_shell = newvalue
206
-
207
- self.container&.should_update
208
- end
209
27
 
210
-
211
- # Mount network home folder on desktop
212
- #
213
- # @author Tyler Morgan
214
- #
215
- # @param newvalue [Bool]
216
- #
217
- # @raise [JSS::InvalidDataError] If the new value is not a Bool
218
- #
219
- # @return [void]
220
- def mount_network_home=(newvalue)
221
-
222
- raise JSS::InvalidDataError, "mount_network_home must be true or false." unless newvalue.is_a? Bool
223
-
224
- @mount_network_home = newvalue
225
-
226
- self.container&.should_update
28
+ # Module for containing the different types of DirectoryBindings stored within the JSS
29
+
30
+ module DirectoryBindingType
31
+
32
+ # Module Variables
33
+ #####################################
34
+
35
+ # Module Methods
36
+ #####################################
37
+
38
+ # Classes
39
+ #####################################
40
+
41
+ # Class for the specific ADmitMac DirectoryBinding type stored within the JSS
42
+ #
43
+ # @author Tyler Morgan
44
+ #
45
+ # @note "Map Home Directory To Attribute" is currently only available in the Jamf Pro UI not through the API.
46
+ #
47
+ # Attributes
48
+ # @!attribute [rw] require_confirmation
49
+ # @!attribute [rw] local_home
50
+ # @!attribute [rw] mount_style
51
+ # @!attribute [rw] default_shell
52
+ # @!attribute [rw] mount_network_home
53
+ # @!attribute [rw] place_home_folders
54
+ # @!attribute [rw] uid
55
+ # @!attribute [rw] user_gid
56
+ # @!attribute [rw] gid
57
+ # @!attribute [rw] admin_group
58
+ # @!attribute [rw] cached_credentials
59
+ # @!attribute [rw] add_user_to_local
60
+ # @!attribute [rw] users_ou
61
+ # @!attribute [rw] groups_ou
62
+ # @!attribute [rw] printers_ou
63
+ # @!attribute [rw] shared_folders_ou
64
+ # TODO: Include default values upon creation
65
+ class ADmitMac < DirectoryBindingType
66
+
67
+ # Mix-Ins
68
+ #####################################
69
+
70
+ # Class Methods
71
+ #####################################
72
+
73
+ # Class Constants
74
+ #####################################
75
+
76
+ # Attributes
77
+ #####################################
78
+
79
+ attr_reader :require_confirmation
80
+ attr_reader :local_home
81
+ attr_reader :mount_style
82
+ attr_reader :default_shell
83
+ attr_reader :mount_network_home
84
+ attr_reader :place_home_folders
85
+ attr_reader :uid
86
+ attr_reader :user_gid
87
+ attr_reader :gid
88
+ attr_reader :admin_group
89
+ attr_reader :cached_credentials
90
+ attr_reader :add_user_to_local
91
+ attr_reader :users_ou
92
+ attr_reader :groups_ou
93
+ attr_reader :printers_ou
94
+ attr_reader :shared_folders_ou
95
+
96
+ # Constructor
97
+ #####################################
98
+
99
+ # An initializer for the ADmitMac object.
100
+ #
101
+ # @author Tyler Morgan
102
+ # @see JSS::DirectoryBinding
103
+ # @see JSS::DirectoryBindingType
104
+ #
105
+ # @note Due to a JSS API funk, mount_style is not able to be configured through the API. It is linked to place_home_folders
106
+ #
107
+ # @param [Hash] initialize data
108
+ def initialize(init_data)
109
+ # Return without processing anything since there is
110
+ # nothing to process.
111
+ return if init_data.nil?
112
+
113
+ # Process the provided information
114
+ @require_confirmation = init_data[:require_confirmation]
115
+ @default_shell = init_data[:default_shell]
116
+ @mount_network_home = init_data[:mount_network_home]
117
+ @place_home_folders = init_data[:place_home_folders]
118
+ @uid = init_data[:uid]
119
+ @user_gid = init_data[:user_gid]
120
+ @gid = init_data[:gid]
121
+ @cached_credentials = init_data[:cached_credentials]
122
+ @add_user_to_local = init_data[:add_user_to_local]
123
+ @users_ou = init_data[:users_ou]
124
+ @groups_ou = init_data[:groups_ou]
125
+ @printers_ou = init_data[:printers_ou]
126
+ @shared_folders_ou = init_data[:shared_folders_ou]
127
+ @mount_style = init_data[:mount_style]
128
+
129
+ if init_data[:local_home].nil? || init_data[:local_home].is_a?(String)
130
+ unless HOME_FOLDER_TYPE.values.include? init_data[:local_home] || init_data[:local_home].nil?
131
+ raise JSS::InvalidDataError, "Local Home must be one of #{HOME_FOLDER_TYPE.values.join(', ')}."
227
132
  end
228
133
 
229
- # Path at which home folders are placed
230
- #
231
- # @author Tyler Morgan
232
- #
233
- # @param newvalue [String] The string path of the folder which user's directory files and folders will be created
234
- #
235
- # @raise [JSS::InvalidDataError] If the new value is not a String
236
- #
237
- # @return [void]
238
- def place_home_folders=(newvalue)
239
-
240
- raise JSS::InvalidDataError, "place_home_folders must be a string." unless newvalue.is_a? String
241
-
242
- @place_home_folders = newvalue
243
-
244
- self.container&.should_update
134
+ @local_home = init_data[:local_home]
135
+ else
136
+ unless HOME_FOLDER_TYPE.keys.include? init_data[:local_home]
137
+ raise JSS::InvalidDataError, "Local Home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}."
245
138
  end
139
+ end
246
140
 
247
- # Jamf has these linked for some reason...
248
- alias mount_style place_home_folders
249
-
250
-
251
- # Map specific UID to Attribute
252
- #
253
- # @author Tyler Morgan
254
- #
255
- # @param newvalue [String] The UID you want to be mapped
256
- #
257
- # @raise [JSS::InvalidDataError] If the new value is not a String
258
- #
259
- # @return [void]
260
- def uid=(newvalue)
261
-
262
- raise JSS::InvalidDataError, "uid must be a string, integer, or nil." unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
263
-
264
- @uid = newvalue
265
-
266
- self.container&.should_update
141
+ @admin_group = if init_data[:admin_group].nil?
142
+ # This is needed since we have the ability to add and
143
+ # remove admin groups from this array.
144
+ []
145
+ elsif init_data[:admin_group].is_a? String
146
+ init_data[:admin_group].split(',')
147
+ else
148
+ init_data[:admin_group]
149
+ end
150
+ end
151
+
152
+ # Public Instance Methods
153
+ #####################################
154
+
155
+ # Require confirmation before creating a mobile account on the system.
156
+ #
157
+ # @author Tyler Morgan
158
+ #
159
+ # @param newvalue [Bool]
160
+ #
161
+ # @raise [JSS::InvalidDataError] If the new value doesn't match a Bool value
162
+ #
163
+ # @return [void]
164
+ def require_confirmation=(newvalue)
165
+ raise JSS::InvalidDataError, 'require_confirmation must be true or false.' unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
166
+
167
+ @require_confirmation = newvalue
168
+
169
+ container&.should_update
170
+ end
171
+
172
+ # The type of home directory type created upon logging into a system
173
+ #
174
+ # @author Tyler Morgan
175
+ #
176
+ # @param newvalue [Symbol] The key specific to the folder type you want in HOME_FOLDER_TYPE
177
+ # @see JSS::DirectoryBindingType::HOME_FOLDER_TYPE
178
+ #
179
+ # @raise [JSS::InvalidDataError] If the new value is not one of the possible keys in HOME_FOLDER_TYPE
180
+ #
181
+ # @return [void]
182
+ def local_home=(newvalue)
183
+ new =
184
+ if newvalue.to_s.empty?
185
+ JSS::BLANK
186
+ else
187
+ # Data Check
188
+ raise JSS::InvalidDataError, "local_home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}." unless HOME_FOLDER_TYPE.keys.include? newvalue
189
+
190
+ HOME_FOLDER_TYPE[newvalue]
267
191
  end
268
192
 
269
-
270
- # Map specific a User's GID to Attribute
271
- #
272
- # @author Tyler Morgan
273
- #
274
- # @param newvalue [String] The User's GID you want to be mapped
275
- #
276
- # @raise [JSS::InvalidDataError] If the new value is not a String
277
- #
278
- # @return [void]
279
- def user_gid=(newvalue)
280
-
281
- raise JSS::InvalidDataError, "user_gid must be a string, integer, or nil." unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
282
-
283
- @user_gid = newvalue
284
-
285
- self.container&.should_update
193
+ @local_home = new
194
+
195
+ container&.should_update
196
+ end
197
+
198
+ # The default shell assigned first upon logging into a system
199
+ #
200
+ # @author Tyler Morgan
201
+ #
202
+ # @param newvalue [String] The string path of the shell file being set as the default
203
+ #
204
+ # @raise [JSS::InvalidDataError] If the new value is not a String
205
+ #
206
+ # @return [void]
207
+ def default_shell=(newvalue)
208
+ new =
209
+ if newvalue.to_s.empty?
210
+ JSS::BLANK
211
+ else
212
+ # Data Check
213
+ raise JSS::InvalidDataError, 'default_shell must be empty or a string.' unless newvalue.is_a?(String)
214
+
215
+ newvalue
286
216
  end
287
217
 
288
-
289
- # Map specific GID to Attribute
290
- #
291
- # @author Tyler Morgan
292
- #
293
- # @param newvalue [String] The GID you want to be mapped
294
- #
295
- # @raise [JSS::InvalidDataError] If the new value is not a String
296
- #
297
- # @return [void]
298
- def gid=(newvalue)
299
-
300
- raise JSS::InvalidDataError, "gid must be a string, integer, or nil." unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
301
-
302
- @gid = newvalue
303
-
304
- self.container&.should_update
218
+ @default_shell = new
219
+
220
+ container&.should_update
221
+ end
222
+
223
+ # Mount network home folder on desktop
224
+ #
225
+ # @author Tyler Morgan
226
+ #
227
+ # @param newvalue [Bool]
228
+ #
229
+ # @raise [JSS::InvalidDataError] If the new value is not a Bool
230
+ #
231
+ # @return [void]
232
+ def mount_network_home=(newvalue)
233
+ raise JSS::InvalidDataError, 'mount_network_home must be true or false.' unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
234
+
235
+ @mount_network_home = newvalue
236
+
237
+ container&.should_update
238
+ end
239
+
240
+ # Path at which home folders are placed
241
+ #
242
+ # @author Tyler Morgan
243
+ #
244
+ # @param newvalue [String] The string path of the folder which user's directory files and folders will be created
245
+ #
246
+ # @raise [JSS::InvalidDataError] If the new value is not a String
247
+ #
248
+ # @return [void]
249
+ def place_home_folders=(newvalue)
250
+ new =
251
+ if newvalue.to_s.empty?
252
+ JSS::BLANK
253
+ else
254
+ # Data Check
255
+ raise JSS::InvalidDataError, 'place_home_folders must be a string.' unless newvalue.is_a? String
256
+
257
+ newvalue
305
258
  end
306
259
 
307
- # Set specific groups to become administrators to a system.
308
- #
309
- # @author Tyler Morgan
310
- #
311
- # @param newvalue [Array<String>] An array of all the admin group names you want to set.
312
- # @see add_admin_group
313
- # @see remove_admin_group
314
- #
315
- # @raise [JSS::InvalidDataError] If the new value is not an Array
316
- #
317
- # @return [void]
318
- def admin_group=(newvalue)
319
-
320
- raise JSS::InvalidDataError, "An Array must be provided, please use add_admin_group and remove_admin_group for individual group additions and removals." unless newvalue.is_a? Array
321
-
322
- @admin_group = newvalue
323
-
324
- self.container&.should_update
260
+ @place_home_folders = new
261
+
262
+ container&.should_update
263
+ end
264
+
265
+ # Jamf has these linked for some reason...
266
+ alias mount_style place_home_folders
267
+
268
+ # Map specific UID to Attribute
269
+ #
270
+ # @author Tyler Morgan
271
+ #
272
+ # @param newvalue [String] The UID you want to be mapped
273
+ #
274
+ # @raise [JSS::InvalidDataError] If the new value is not a String
275
+ #
276
+ # @return [void]
277
+ def uid=(newvalue)
278
+ new =
279
+ if newvalue.to_s.empty?
280
+ JSS::BLANK
281
+ else
282
+ # Data Check
283
+ raise JSS::InvalidDataError, 'uid must be a string, integer, or nil.' unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
284
+
285
+ newvalue
325
286
  end
326
287
 
327
-
328
- # The number of times a user can log into the device while not connected to a network
329
- #
330
- # @author Tyler Morgan
331
- #
332
- # @param newvalue [Integer] The number of times you want a user to login while not connected to a network
333
- #
334
- # @raise [JSS::InvalidDataError] If the new value is not an Integer
335
- #
336
- # @return [void]
337
- def cached_credentials=(newvalue)
338
-
339
- raise JSS::InvalidDataError, "cached_credentials must be an integer." unless newvalue.is_a? Integer
340
-
341
- @cached_credentials = newvalue
342
-
343
- self.container&.should_update
288
+ @uid = new
289
+
290
+ container&.should_update
291
+ end
292
+
293
+ # Map specific a User's GID to Attribute
294
+ #
295
+ # @author Tyler Morgan
296
+ #
297
+ # @param newvalue [String] The User's GID you want to be mapped
298
+ #
299
+ # @raise [JSS::InvalidDataError] If the new value is not a String
300
+ #
301
+ # @return [void]
302
+ def user_gid=(newvalue)
303
+ new =
304
+ if newvalue.to_s.empty?
305
+ JSS::BLANK
306
+ else
307
+ # Data Check
308
+ raise JSS::InvalidDataError, 'user_gid must be a string, integer, or nil.' unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
309
+
310
+ newvalue
344
311
  end
345
312
 
346
-
347
- # If the user is a member of one of the groups in admin_group, add them
348
- # to the local administrator group.
349
- #
350
- # @author Tyler Morgan
351
- # @see admin_group
352
- #
353
- # @param newvalue [Bool]
354
- #
355
- # @raise [JSS::InvalidDataError] If the new value is not a Bool
356
- #
357
- # @return [void]
358
- def add_user_to_local=(newvalue)
359
-
360
- raise JSS::InvalidDataError, "add_user_to_local must be true or false." unless newvalue.is_a? Bool
361
-
362
- @add_user_to_local = newvalue
363
-
364
- self.container&.should_update
313
+ @user_gid = new
314
+
315
+ container&.should_update
316
+ end
317
+
318
+ # Map specific GID to Attribute
319
+ #
320
+ # @author Tyler Morgan
321
+ #
322
+ # @param newvalue [String] The GID you want to be mapped
323
+ #
324
+ # @raise [JSS::InvalidDataError] If the new value is not a String
325
+ #
326
+ # @return [void]
327
+ def gid=(newvalue)
328
+ new =
329
+ if newvalue.to_s.empty?
330
+ JSS::BLANK
331
+ else
332
+ # Data Check
333
+ raise JSS::InvalidDataError, 'gid must be a string, integer, or nil.' unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
334
+
335
+ newvalue
365
336
  end
366
337
 
367
-
368
- # An OU path for specific Users
369
- #
370
- # @author Tyler Morgan
371
- #
372
- # @param newvalue [String] The OU path for the specific user
373
- # @note Not sure what this is used for
374
- #
375
- # @raise [JSS::InvalidDataError] If the new value is not a String
376
- #
377
- # @return [void]
378
- def users_ou=(newvalue)
379
-
380
- raise JSS::InvalidDataError, "users_ou must be either a string or nil." unless newvalue.is_a? String || newvalue.nil?
381
-
382
- @users_ou = newvalue
383
-
384
- self.container&.should_update
338
+ @gid = new
339
+
340
+ container&.should_update
341
+ end
342
+
343
+ # Set specific groups to become administrators to a system.
344
+ #
345
+ # @author Tyler Morgan
346
+ #
347
+ # @param newvalue [Array<String>] An array of all the admin group names you want to set.
348
+ # @see add_admin_group
349
+ # @see remove_admin_group
350
+ #
351
+ # @raise [JSS::InvalidDataError] If the new value is not an Array
352
+ #
353
+ # @return [void]
354
+ def admin_group=(newvalue)
355
+ new =
356
+ if newvalue.to_s.empty?
357
+ JSS::BLANK
358
+ else
359
+ # Data Check
360
+ unless newvalue.is_a? Array
361
+ raise JSS::InvalidDataError, 'An Array must be provided, please use add_admin_group and remove_admin_group for individual group additions and removals.'
362
+ end
363
+
364
+ newvalue
385
365
  end
386
366
 
387
-
388
- # An OU path for specific User Groups
389
- #
390
- # @author Tyler Morgan
391
- #
392
- # @param newvalue [String] The OU path for the specific user group
393
- # @note Not sure what this is used for
394
- #
395
- # @raise [JSS::InvalidDataError] If the new value is not a String
396
- #
397
- # @return [void]
398
- def groups_ou=(newvalue)
399
-
400
- raise JSS::InvalidDataError, "groups_ou must be either a string or nil." unless newvalue.is_a? String || newvalue.nil?
401
-
402
- @groups_ou = newvalue
403
-
404
- self.container&.should_update
367
+ @admin_group = new
368
+
369
+ container&.should_update
370
+ end
371
+
372
+ # The number of times a user can log into the device while not connected to a network
373
+ #
374
+ # @author Tyler Morgan
375
+ #
376
+ # @param newvalue [Integer] The number of times you want a user to login while not connected to a network
377
+ #
378
+ # @raise [JSS::InvalidDataError] If the new value is not an Integer
379
+ #
380
+ # @return [void]
381
+ def cached_credentials=(newvalue)
382
+ new =
383
+ if newvalue.to_s.empty?
384
+ JSS::BLANK
385
+ else
386
+ # Data Check
387
+ raise JSS::InvalidDataError, 'cached_credentials must be an integer.' unless newvalue.is_a? Integer
388
+
389
+ newvalue
405
390
  end
406
391
 
407
-
408
- # An OU path for specific Printers
409
- #
410
- # @author Tyler Morgan
411
- #
412
- # @param newvalue [String] The OU path for the specific printer
413
- # @note Not sure what this is used for
414
- #
415
- # @raise [JSS::InvalidDataError] If the new value is not a String
416
- #
417
- # @return [void]
418
- def printers_ou=(newvalue)
419
-
420
- raise JSS::InvalidDataError, "printers_ou must be either a string or nil." unless newvalue.is_a? String || newvalue.nil?
421
-
422
- @printers_ou = newvalue
423
-
424
- self.container&.should_update
392
+ @cached_credentials = new
393
+
394
+ container&.should_update
395
+ end
396
+
397
+ # If the user is a member of one of the groups in admin_group, add them
398
+ # to the local administrator group.
399
+ #
400
+ # @author Tyler Morgan
401
+ # @see admin_group
402
+ #
403
+ # @param newvalue [Bool]
404
+ #
405
+ # @raise [JSS::InvalidDataError] If the new value is not a Bool
406
+ #
407
+ # @return [void]
408
+ def add_user_to_local=(newvalue)
409
+ raise JSS::InvalidDataError, 'add_user_to_local must be true or false.' unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
410
+
411
+ @add_user_to_local = newvalue
412
+
413
+ container&.should_update
414
+ end
415
+
416
+ # An OU path for specific Users
417
+ #
418
+ # @author Tyler Morgan
419
+ #
420
+ # @param newvalue [String] The OU path for the specific user
421
+ # @note Not sure what this is used for
422
+ #
423
+ # @raise [JSS::InvalidDataError] If the new value is not a String
424
+ #
425
+ # @return [void]
426
+ def users_ou=(newvalue)
427
+ new =
428
+ if newvalue.to_s.empty?
429
+ JSS::BLANK
430
+ else
431
+ # Data Check
432
+ raise JSS::InvalidDataError, 'users_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
433
+
434
+ newvalue
425
435
  end
426
436
 
427
-
428
- # An OU path for specific shared folders
429
- #
430
- # @author Tyler Morgan
431
- #
432
- # @param newvalue [String] The OU path for the specific shared folders
433
- # @note Not sure what this is used for
434
- #
435
- # @raise [JSS::InvalidDataError] If the new value is not a String
436
- #
437
- # @return [void]
438
- def shared_folders_ou=(newvalue)
439
-
440
- raise JSS::InvalidDataError, "shared_folders_ou must be either a string or nil." unless newvalue.is_a? String || newvalue.nil?
441
-
442
- @shared_folders_ou = newvalue
443
-
444
- self.container&.should_update
437
+ @users_ou = new
438
+
439
+ container&.should_update
440
+ end
441
+
442
+ # An OU path for specific User Groups
443
+ #
444
+ # @author Tyler Morgan
445
+ #
446
+ # @param newvalue [String] The OU path for the specific user group
447
+ # @note Not sure what this is used for
448
+ #
449
+ # @raise [JSS::InvalidDataError] If the new value is not a String
450
+ #
451
+ # @return [void]
452
+ def groups_ou=(newvalue)
453
+ new =
454
+ if newvalue.to_s.empty?
455
+ JSS::BLANK
456
+ else
457
+ # Data Check
458
+ raise JSS::InvalidDataError, 'groups_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
459
+
460
+ newvalue
445
461
  end
446
462
 
447
-
448
- # An a specific admin group to admin_group
449
- #
450
- # @author Tyler Morgan
451
- #
452
- # @param value [String] The admin group name you wish to add to the admin group list
453
- #
454
- # @raise [JSS::InvalidDataError] If the value provided is not a String
455
- # @raise [JSS::InvalidDataError] If the group provided is already a member of the admin_group array
456
- #
457
- # @return [Array <String>] An array of all the admin groups currently set.
458
- def add_admin_group(value)
459
-
460
- raise JSS::InvalidDataError, "Admin group must be a string." unless value.is_a? String
461
- raise JSS::InvalidDataError, "Admin group \"#{value}\" already is in the list of admin groups." unless !@admin_group.include? value
462
-
463
- @admin_group << value
464
-
465
- self.container&.should_update
466
-
467
- return @admin_group
463
+ @groups_ou = new
464
+
465
+ container&.should_update
466
+ end
467
+
468
+ # An OU path for specific Printers
469
+ #
470
+ # @author Tyler Morgan
471
+ #
472
+ # @param newvalue [String] The OU path for the specific printer
473
+ # @note Not sure what this is used for
474
+ #
475
+ # @raise [JSS::InvalidDataError] If the new value is not a String
476
+ #
477
+ # @return [void]
478
+ def printers_ou=(newvalue)
479
+ new =
480
+ if newvalue.to_s.empty?
481
+ JSS::BLANK
482
+ else
483
+ # Data Check
484
+ raise JSS::InvalidDataError, 'printers_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
485
+
486
+ newvalue
468
487
  end
469
488
 
470
-
471
- # Remove a specific admin group to admin_group
472
- #
473
- # @author Tyler Morgan
474
- #
475
- # @param newvalue [String] The admin group name you wish to remove from the admin group list
476
- #
477
- # @raise [JSS::InvalidDataError] If the value provided is not a String
478
- # @raise [JSS::InvalidDataError] If the group provided is not in the admin_group array
479
- #
480
- # @return [Array <String>] An array of all the admin groups currently set.
481
- def remove_admin_group(value)
482
-
483
- raise JSS::InvalidDataError, "Admin group being removed must be a string" unless value.is_a? String
484
- raise JSS::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_group.include? value
485
-
486
- @admin_group.delete value
487
-
488
- self.container&.should_update
489
-
490
- return @admin_group
489
+ @printers_ou = new
490
+
491
+ container&.should_update
492
+ end
493
+
494
+ # An OU path for specific shared folders
495
+ #
496
+ # @author Tyler Morgan
497
+ #
498
+ # @param newvalue [String] The OU path for the specific shared folders
499
+ # @note Not sure what this is used for
500
+ #
501
+ # @raise [JSS::InvalidDataError] If the new value is not a String
502
+ #
503
+ # @return [void]
504
+ def shared_folders_ou=(newvalue)
505
+ new =
506
+ if newvalue.to_s.empty?
507
+ JSS::BLANK
508
+ else
509
+ # Data Check
510
+ raise JSS::InvalidDataError, 'shared_folders_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
511
+
512
+ newvalue
491
513
  end
492
514
 
493
-
494
- # Return a REXML Element containing the current state of the DirectoryBindingType
495
- # object for adding into the XML of the container.
496
- #
497
- # @author Tyler Morgan
498
- #
499
- # @return [REXML::Element]
500
- def type_setting_xml
501
- type_setting = REXML::Element.new "admitmac"
502
- type_setting.add_element("require_confirmation").text = @require_confirmation
503
- type_setting.add_element("local_home").text = @local_home
504
- type_setting.add_element("mount_style").text = @mount_style.downcase
505
- type_setting.add_element("default_shell").text = @default_shell
506
- type_setting.add_element("mount_network_home").text = @mount_network_home
507
- type_setting.add_element("place_home_folders").text = @place_home_folders
508
- type_setting.add_element("uid").text = @uid
509
- type_setting.add_element("user_gid").text = @user_gid
510
- type_setting.add_element("gid").text = @gid
511
- type_setting.add_element("add_user_to_local").text = @add_user_to_local
512
- type_setting.add_element("cached_credentials").text = @cached_credentials
513
- type_setting.add_element("users_ou").text = @users_ou
514
- type_setting.add_element("groups_ou").text = @groups_ou
515
- type_setting.add_element("printers_ou").text = @printers_ou
516
- type_setting.add_element("shared_folders_ou").text = @shared_folders_ou
517
- type_setting.add_element("admin_group").text = @admin_group.join(',').to_s unless @admin_group.nil?
518
-
519
- return type_setting
520
- end
521
- end
515
+ @shared_folders_ou = new
516
+
517
+ container&.should_update
518
+ end
519
+
520
+ # An a specific admin group to admin_group
521
+ #
522
+ # @author Tyler Morgan
523
+ #
524
+ # @param value [String] The admin group name you wish to add to the admin group list
525
+ #
526
+ # @raise [JSS::InvalidDataError] If the value provided is not a String
527
+ # @raise [JSS::InvalidDataError] If the group provided is already a member of the admin_group array
528
+ #
529
+ # @return [Array <String>] An array of all the admin groups currently set.
530
+ def add_admin_group(value)
531
+ raise JSS::InvalidDataError, 'Admin group must be a string.' unless value.is_a? String
532
+ raise JSS::InvalidDataError, "Admin group \"#{value}\" already is in the list of admin groups." if @admin_group.include? value
533
+
534
+ @admin_group << value
535
+
536
+ container&.should_update
537
+
538
+ @admin_group
539
+ end
540
+
541
+ # Remove a specific admin group to admin_group
542
+ #
543
+ # @author Tyler Morgan
544
+ #
545
+ # @param newvalue [String] The admin group name you wish to remove from the admin group list
546
+ #
547
+ # @raise [JSS::InvalidDataError] If the value provided is not a String
548
+ # @raise [JSS::InvalidDataError] If the group provided is not in the admin_group array
549
+ #
550
+ # @return [Array <String>] An array of all the admin groups currently set.
551
+ def remove_admin_group(value)
552
+ raise JSS::InvalidDataError, 'Admin group being removed must be a string' unless value.is_a? String
553
+ raise JSS::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_group.include? value
554
+
555
+ @admin_group.delete value
556
+
557
+ container&.should_update
558
+
559
+ @admin_group
560
+ end
561
+
562
+ # Return a REXML Element containing the current state of the DirectoryBindingType
563
+ # object for adding into the XML of the container.
564
+ #
565
+ # @author Tyler Morgan
566
+ #
567
+ # @return [REXML::Element]
568
+ def type_setting_xml
569
+ type_setting = REXML::Element.new 'admitmac'
570
+ type_setting.add_element('require_confirmation').text = @require_confirmation
571
+ type_setting.add_element('local_home').text = @local_home
572
+ type_setting.add_element('mount_style').text = @mount_style.downcase
573
+ type_setting.add_element('default_shell').text = @default_shell
574
+ type_setting.add_element('mount_network_home').text = @mount_network_home
575
+ type_setting.add_element('place_home_folders').text = @place_home_folders
576
+ type_setting.add_element('uid').text = @uid
577
+ type_setting.add_element('user_gid').text = @user_gid
578
+ type_setting.add_element('gid').text = @gid
579
+ type_setting.add_element('add_user_to_local').text = @add_user_to_local
580
+ type_setting.add_element('cached_credentials').text = @cached_credentials
581
+ type_setting.add_element('users_ou').text = @users_ou
582
+ type_setting.add_element('groups_ou').text = @groups_ou
583
+ type_setting.add_element('printers_ou').text = @printers_ou
584
+ type_setting.add_element('shared_folders_ou').text = @shared_folders_ou
585
+ type_setting.add_element('admin_group').text = @admin_group.join(',').to_s unless @admin_group.nil?
586
+
587
+ type_setting
588
+ end
522
589
 
523
590
  end
524
591
 
525
- end
592
+ end
593
+
594
+ end