ruby-jss 1.4.1 → 1.5.1
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.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +38 -0
- data/lib/jamf.rb +10 -3
- data/lib/jamf/api/abstract_classes/collection_resource.rb +329 -150
- data/lib/jamf/api/abstract_classes/generic_reference.rb +9 -1
- data/lib/jamf/api/abstract_classes/json_object.rb +106 -82
- data/lib/jamf/api/abstract_classes/prestage.rb +54 -29
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +21 -0
- data/lib/jamf/api/abstract_classes/resource.rb +4 -4
- data/lib/jamf/api/abstract_classes/singleton_resource.rb +1 -1
- data/lib/jamf/api/connection.rb +13 -9
- data/lib/jamf/api/connection/api_error.rb +8 -8
- data/lib/jamf/api/connection/token.rb +16 -15
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +14 -1
- data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
- data/lib/jamf/api/json_objects/device_enrollment_device_sync_state.rb +81 -0
- data/lib/jamf/api/json_objects/locale.rb +59 -0
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
- data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
- data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
- data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
- data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
- data/lib/jamf/api/mixins/change_log.rb +201 -51
- data/lib/jamf/api/mixins/filterable.rb +51 -0
- data/lib/jamf/api/mixins/pageable.rb +208 -0
- data/lib/jamf/api/mixins/sortable.rb +59 -0
- data/lib/jamf/api/resources/collection_resources/building.rb +19 -8
- data/lib/jamf/api/resources/collection_resources/category.rb +5 -3
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +11 -4
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +10 -10
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
- data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +24 -22
- data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +14 -14
- data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
- data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
- data/lib/jamf/validate.rb +63 -24
- data/lib/jamf/version.rb +1 -1
- data/lib/jss.rb +2 -1
- data/lib/jss/api_connection.rb +110 -370
- data/lib/jss/api_object.rb +3 -19
- data/lib/jss/api_object/categorizable.rb +1 -1
- data/lib/jss/api_object/configuration_profile.rb +34 -3
- data/lib/jss/api_object/directory_binding_type.rb +66 -60
- data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
- data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
- data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
- data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
- data/lib/jss/api_object/distribution_point.rb +2 -2
- data/lib/jss/api_object/dock_item.rb +102 -96
- data/lib/jss/api_object/extendable.rb +1 -1
- data/lib/jss/api_object/group.rb +33 -2
- data/lib/jss/api_object/network_segment.rb +43 -12
- data/lib/jss/api_object/patch_source.rb +10 -9
- data/lib/jss/api_object/printer.rb +10 -4
- data/lib/jss/api_object/scopable.rb +10 -15
- data/lib/jss/exceptions.rb +3 -0
- data/lib/jss/server.rb +15 -0
- data/lib/jss/version.rb +1 -1
- metadata +37 -22
@@ -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?
|
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?
|
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?
|
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
|
-
|
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 =
|
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
|
-
|
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 =
|
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?
|
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?
|
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?
|
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?
|
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
|
|
@@ -24,8 +24,9 @@
|
|
24
24
|
###
|
25
25
|
|
26
26
|
module JSS
|
27
|
-
|
28
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
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
|
|
data/lib/jss/api_object/group.rb
CHANGED
@@ -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
|
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
|
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
|
@@ -459,9 +459,17 @@ module JSS
|
|
459
459
|
### @return [void]
|
460
460
|
###
|
461
461
|
def building=(newval)
|
462
|
-
new =
|
463
|
-
|
464
|
-
|
462
|
+
new =
|
463
|
+
if newval.to_s.empty?
|
464
|
+
JSS::BLANK
|
465
|
+
else
|
466
|
+
id = JSS::Building.valid_id newval
|
467
|
+
raise JSS::MissingDataError, "No building matching '#{newval}'" unless id
|
468
|
+
|
469
|
+
JSS::Building.map_all_ids_to(:name)[id]
|
470
|
+
end
|
471
|
+
|
472
|
+
@building = new
|
465
473
|
@need_to_update = true
|
466
474
|
end
|
467
475
|
|
@@ -484,9 +492,16 @@ module JSS
|
|
484
492
|
### @return [void]
|
485
493
|
###
|
486
494
|
def department=(newval)
|
487
|
-
new =
|
488
|
-
|
489
|
-
|
495
|
+
new =
|
496
|
+
if newval.to_s.empty?
|
497
|
+
JSS::BLANK
|
498
|
+
else
|
499
|
+
id = JSS::Department.valid_id newval
|
500
|
+
raise JSS::MissingDataError , "No department matching '#{newval}' in the JSS" unless id
|
501
|
+
|
502
|
+
JSS::Department.map_all_ids_to(:name)[id]
|
503
|
+
end
|
504
|
+
@department = new
|
490
505
|
@need_to_update = true
|
491
506
|
end
|
492
507
|
|
@@ -531,9 +546,17 @@ module JSS
|
|
531
546
|
### @return [void]
|
532
547
|
###
|
533
548
|
def netboot_server=(newval)
|
534
|
-
new =
|
535
|
-
|
536
|
-
|
549
|
+
new =
|
550
|
+
if newval.to_s.empty?
|
551
|
+
JSS::BLANK
|
552
|
+
else
|
553
|
+
id = JSS::NetBootServer.valid_id newval
|
554
|
+
raise JSS::MissingDataError, "No netboot_server matching '#{newval}' in the JSS" unless id
|
555
|
+
|
556
|
+
JSS::NetbootServer.map_all_ids_to(:name)[id]
|
557
|
+
end
|
558
|
+
|
559
|
+
@netboot_server = new
|
537
560
|
@need_to_update = true
|
538
561
|
end
|
539
562
|
|
@@ -544,9 +567,17 @@ module JSS
|
|
544
567
|
### @return [void]
|
545
568
|
###
|
546
569
|
def swu_server=(newval)
|
547
|
-
new =
|
548
|
-
|
549
|
-
|
570
|
+
new =
|
571
|
+
if newval.to_s.empty?
|
572
|
+
JSS::BLANK
|
573
|
+
else
|
574
|
+
id = JSS::SoftwareUpdateServer.valid_id newval
|
575
|
+
raise JSS::MissingDataError, "No swu_server matching '#{newval}' in the JSS" unless id
|
576
|
+
|
577
|
+
JSS::SoftwareUpdateServer.map_all_ids_to(:name)[id]
|
578
|
+
end
|
579
|
+
|
580
|
+
@swu_server = new
|
550
581
|
@need_to_update = true
|
551
582
|
end
|
552
583
|
|