ruby-jss 0.6.3
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 +7 -0
- data/.yardopts +7 -0
- data/CHANGES.md +112 -0
- data/LICENSE.txt +174 -0
- data/README.md +426 -0
- data/THANKS.md +6 -0
- data/bin/cgrouper +485 -0
- data/bin/subnet-update +400 -0
- data/lib/jss-api.rb +2 -0
- data/lib/jss.rb +190 -0
- data/lib/jss/api_connection.rb +410 -0
- data/lib/jss/api_object.rb +616 -0
- data/lib/jss/api_object/advanced_search.rb +389 -0
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +95 -0
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +96 -0
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +95 -0
- data/lib/jss/api_object/building.rb +92 -0
- data/lib/jss/api_object/category.rb +147 -0
- data/lib/jss/api_object/computer.rb +852 -0
- data/lib/jss/api_object/creatable.rb +98 -0
- data/lib/jss/api_object/criteriable.rb +189 -0
- data/lib/jss/api_object/criteriable/criteria.rb +231 -0
- data/lib/jss/api_object/criteriable/criterion.rb +228 -0
- data/lib/jss/api_object/department.rb +93 -0
- data/lib/jss/api_object/distribution_point.rb +560 -0
- data/lib/jss/api_object/extendable.rb +221 -0
- data/lib/jss/api_object/extension_attribute.rb +466 -0
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +362 -0
- data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +189 -0
- data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +117 -0
- data/lib/jss/api_object/group.rb +380 -0
- data/lib/jss/api_object/group/computer_group.rb +124 -0
- data/lib/jss/api_object/group/mobile_device_group.rb +139 -0
- data/lib/jss/api_object/group/user_group.rb +139 -0
- data/lib/jss/api_object/ldap_server.rb +535 -0
- data/lib/jss/api_object/locatable.rb +286 -0
- data/lib/jss/api_object/matchable.rb +97 -0
- data/lib/jss/api_object/mobile_device.rb +556 -0
- data/lib/jss/api_object/netboot_server.rb +148 -0
- data/lib/jss/api_object/network_segment.rb +414 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +262 -0
- data/lib/jss/api_object/package.rb +839 -0
- data/lib/jss/api_object/peripheral.rb +335 -0
- data/lib/jss/api_object/peripheral_type.rb +295 -0
- data/lib/jss/api_object/policy.rb +898 -0
- data/lib/jss/api_object/purchasable.rb +316 -0
- data/lib/jss/api_object/removable_macaddr.rb +98 -0
- data/lib/jss/api_object/scopable.rb +136 -0
- data/lib/jss/api_object/scopable/scope.rb +621 -0
- data/lib/jss/api_object/script.rb +631 -0
- data/lib/jss/api_object/self_servable.rb +356 -0
- data/lib/jss/api_object/site.rb +93 -0
- data/lib/jss/api_object/software_update_server.rb +109 -0
- data/lib/jss/api_object/updatable.rb +117 -0
- data/lib/jss/api_object/uploadable.rb +138 -0
- data/lib/jss/api_object/user.rb +272 -0
- data/lib/jss/client.rb +504 -0
- data/lib/jss/compatibility.rb +66 -0
- data/lib/jss/composer.rb +185 -0
- data/lib/jss/configuration.rb +306 -0
- data/lib/jss/db_connection.rb +298 -0
- data/lib/jss/exceptions.rb +95 -0
- data/lib/jss/ruby_extensions.rb +35 -0
- data/lib/jss/ruby_extensions/filetest.rb +43 -0
- data/lib/jss/ruby_extensions/hash.rb +79 -0
- data/lib/jss/ruby_extensions/ipaddr.rb +91 -0
- data/lib/jss/ruby_extensions/pathname.rb +77 -0
- data/lib/jss/ruby_extensions/string.rb +59 -0
- data/lib/jss/ruby_extensions/time.rb +63 -0
- data/lib/jss/server.rb +108 -0
- data/lib/jss/utility.rb +478 -0
- data/lib/jss/version.rb +31 -0
- metadata +187 -0
@@ -0,0 +1,316 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
#####################################
|
29
|
+
### Module Variables
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
#####################################
|
33
|
+
### Module Methods
|
34
|
+
#####################################
|
35
|
+
|
36
|
+
#####################################
|
37
|
+
### Sub-Modules
|
38
|
+
#####################################
|
39
|
+
|
40
|
+
### A mix-in module for handling purchasing data for objects in the JSS.
|
41
|
+
###
|
42
|
+
### The JSS objects that have purchasing data all have basically the same data,
|
43
|
+
### a simple hash with these keys:
|
44
|
+
###
|
45
|
+
### - :applecare_id => String,
|
46
|
+
### - :is_leased => Boolean,
|
47
|
+
### - :is_purchased => Boolean,
|
48
|
+
### - :lease_expires => Time,
|
49
|
+
### - :life_expectancy => Integer,
|
50
|
+
### - :po_date => Time,
|
51
|
+
### - :po_number => String,
|
52
|
+
### - :purchase_price => Float,
|
53
|
+
### - :purchasing_account => String
|
54
|
+
### - :purchasing_contact => String,
|
55
|
+
### - :vendor => String,
|
56
|
+
### - :warranty_expires => Time
|
57
|
+
###
|
58
|
+
### These items become direct attributes of objects where this module is mixed-in.
|
59
|
+
###
|
60
|
+
### Classes mixing in this module must call {#parse_purchasing} in their initialization method
|
61
|
+
### in order to populate the attributes from @init_data.
|
62
|
+
###
|
63
|
+
### If the class also is Creatable or Updatable it must include the value of {#purchasing_xml} in its
|
64
|
+
### rest_xml output.
|
65
|
+
###
|
66
|
+
module Purchasable
|
67
|
+
|
68
|
+
#####################################
|
69
|
+
### Constants
|
70
|
+
#####################################
|
71
|
+
|
72
|
+
PURCHASABLE = true
|
73
|
+
|
74
|
+
SUBSET_PURCH = "Purchasing"
|
75
|
+
|
76
|
+
#####################################
|
77
|
+
### Variables
|
78
|
+
#####################################
|
79
|
+
|
80
|
+
#####################################
|
81
|
+
### Attribtues
|
82
|
+
#####################################
|
83
|
+
|
84
|
+
### @return [String]
|
85
|
+
attr_reader :applecare_id
|
86
|
+
|
87
|
+
### @return [Boolean]
|
88
|
+
attr_reader :is_leased
|
89
|
+
|
90
|
+
### @return [Time]
|
91
|
+
attr_reader :lease_expires
|
92
|
+
|
93
|
+
### @return [Boolean]
|
94
|
+
attr_reader :is_purchased
|
95
|
+
|
96
|
+
### @return [Float]
|
97
|
+
attr_reader :purchase_price
|
98
|
+
|
99
|
+
### @return [Integer]
|
100
|
+
attr_reader :life_expectancy
|
101
|
+
|
102
|
+
### @return [String]
|
103
|
+
attr_reader :po_number
|
104
|
+
|
105
|
+
### @return [Time]
|
106
|
+
attr_reader :po_date
|
107
|
+
|
108
|
+
### @return [String]
|
109
|
+
attr_reader :purchasing_account
|
110
|
+
|
111
|
+
### @return [String]
|
112
|
+
attr_reader :purchasing_contact
|
113
|
+
|
114
|
+
### @return [String]
|
115
|
+
attr_reader :vendor
|
116
|
+
|
117
|
+
### @return [Time]
|
118
|
+
attr_reader :warranty_expires
|
119
|
+
|
120
|
+
|
121
|
+
#####################################
|
122
|
+
### Mixed-in Instance Methods
|
123
|
+
#####################################
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
### @return [void]
|
129
|
+
def applecare_id= (new_val)
|
130
|
+
return nil if @applecare_id == new_val
|
131
|
+
@applecare_id = new_val
|
132
|
+
@need_to_update = true
|
133
|
+
end
|
134
|
+
|
135
|
+
### @return [void]
|
136
|
+
def is_leased= (new_val)
|
137
|
+
return nil if @is_leased == new_val
|
138
|
+
@is_leased = new_val
|
139
|
+
@need_to_update = true
|
140
|
+
end
|
141
|
+
|
142
|
+
### @return [void]
|
143
|
+
def lease_expires= (date)
|
144
|
+
parsed_date = JSS.parse_datetime date
|
145
|
+
return nil if @lease_expires == parsed_date
|
146
|
+
@lease_expires = parsed_date
|
147
|
+
@need_to_update = true
|
148
|
+
end
|
149
|
+
|
150
|
+
### @return [void]
|
151
|
+
def is_purchased= (new_val)
|
152
|
+
return nil if @is_purchased == new_val
|
153
|
+
@is_purchased = new_val
|
154
|
+
@need_to_update = true
|
155
|
+
end
|
156
|
+
|
157
|
+
### @return [void]
|
158
|
+
def purchase_price= (new_val)
|
159
|
+
return nil if @purchase_price == new_val
|
160
|
+
@purchase_price = new_val
|
161
|
+
@need_to_update = true
|
162
|
+
end
|
163
|
+
|
164
|
+
### @return [void]
|
165
|
+
def life_expectancy= (new_val)
|
166
|
+
return nil if @life_expectancy == new_val
|
167
|
+
@life_expectancy = new_val
|
168
|
+
@need_to_update = true
|
169
|
+
end
|
170
|
+
|
171
|
+
### @return [void]
|
172
|
+
def po_number= (new_val)
|
173
|
+
return nil if @po_number == new_val
|
174
|
+
@po_number = new_val
|
175
|
+
@need_to_update = true
|
176
|
+
end
|
177
|
+
|
178
|
+
### @return [void]
|
179
|
+
def po_date= (date)
|
180
|
+
parsed_date = JSS.parse_datetime date
|
181
|
+
return nil if @po_date == parsed_date
|
182
|
+
@po_date = parsed_date
|
183
|
+
@need_to_update = true
|
184
|
+
end
|
185
|
+
|
186
|
+
### @return [void]
|
187
|
+
def purchasing_account= (new_val)
|
188
|
+
return nil if @purchasing_account == new_val
|
189
|
+
@purchasing_account = new_val
|
190
|
+
@need_to_update = true
|
191
|
+
end
|
192
|
+
|
193
|
+
### @return [void]
|
194
|
+
def purchasing_contact= (new_val)
|
195
|
+
return nil if @purchasing_contact == new_val
|
196
|
+
@purchasing_contact = new_val
|
197
|
+
@need_to_update = true
|
198
|
+
end
|
199
|
+
|
200
|
+
### @return [void]
|
201
|
+
def vendor= (new_val)
|
202
|
+
return nil if @vendor == new_val
|
203
|
+
@vendor = new_val
|
204
|
+
@need_to_update = true
|
205
|
+
end
|
206
|
+
|
207
|
+
### @return [void]
|
208
|
+
def warranty_expires= (date)
|
209
|
+
parsed_date = JSS.parse_datetime date
|
210
|
+
return nil if @warranty_expires == parsed_date
|
211
|
+
@warranty_expires = parsed_date
|
212
|
+
@need_to_update = true
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
###
|
217
|
+
### @return [Boolean] does this item have any purchasing info?
|
218
|
+
###
|
219
|
+
def has_purchasing?
|
220
|
+
@applecare_id or \
|
221
|
+
@is_leased or \
|
222
|
+
@is_purchased or \
|
223
|
+
@lease_expires or \
|
224
|
+
@life_expectancy or \
|
225
|
+
@po_date or \
|
226
|
+
@po_number or \
|
227
|
+
@purchase_price or \
|
228
|
+
@purchasing_account or \
|
229
|
+
@purchasing_contact or \
|
230
|
+
@vendor or \
|
231
|
+
@warranty_expires
|
232
|
+
end
|
233
|
+
|
234
|
+
###
|
235
|
+
### All the purchasing data in a Hash, as it comes from the API.
|
236
|
+
###
|
237
|
+
### The reason it isn't stored this way is to prevent editing of the hash directly.
|
238
|
+
###
|
239
|
+
### @return [Hash<String>] the location data
|
240
|
+
###
|
241
|
+
def purchasing
|
242
|
+
{
|
243
|
+
:applecare_id => @applecare_id,
|
244
|
+
:is_leased => @is_leased,
|
245
|
+
:is_purchased => @is_purchased,
|
246
|
+
:lease_expires => @lease_expires,
|
247
|
+
:life_expectancy => @life_expectancy,
|
248
|
+
:po_date => @po_date,
|
249
|
+
:po_number => @po_number,
|
250
|
+
:purchase_price => @purchase_price,
|
251
|
+
:purchasing_account => @purchasing_account,
|
252
|
+
:purchasing_contact => @purchasing_contact,
|
253
|
+
:vendor => @vendor,
|
254
|
+
:warranty_expires => @warranty_expires,
|
255
|
+
}
|
256
|
+
end
|
257
|
+
|
258
|
+
###
|
259
|
+
### @api private
|
260
|
+
###
|
261
|
+
### Call this during initialization of
|
262
|
+
### objects that have a Purchasing subset
|
263
|
+
### and the purchasing attribute will be populated
|
264
|
+
### from @init_data
|
265
|
+
###
|
266
|
+
def parse_purchasing
|
267
|
+
return unless @init_data[:purchasing]
|
268
|
+
|
269
|
+
@purchasing = @init_data[:purchasing]
|
270
|
+
|
271
|
+
@lease_expires = JSS.epoch_to_time @purchasing[:lease_expires_epoch]
|
272
|
+
@po_date = JSS.epoch_to_time @purchasing[:po_date_epoch]
|
273
|
+
@warranty_expires = JSS.epoch_to_time @purchasing[:warranty_expires_epoch]
|
274
|
+
|
275
|
+
@applecare_id = @purchasing[:applecare_id]
|
276
|
+
@is_leased = @purchasing[:is_leased]
|
277
|
+
@is_purchased = @purchasing[:is_purchased]
|
278
|
+
@life_expectancy = @purchasing[:life_expectancy]
|
279
|
+
@po_number = @purchasing[:po_number]
|
280
|
+
@purchase_price = @purchasing[:purchase_price].to_f if @purchasing[:purchase_price]
|
281
|
+
@purchasing_account = @purchasing[:purchasing_account]
|
282
|
+
@purchasing_contact = @purchasing[:purchasing_contact]
|
283
|
+
@vendor = @purchasing[:vendor]
|
284
|
+
end
|
285
|
+
|
286
|
+
###
|
287
|
+
### @api private
|
288
|
+
###
|
289
|
+
### @return [REXML::Element] A <purchasing> element to be
|
290
|
+
### included in the rest_xml of objects that mix-in this module.
|
291
|
+
###
|
292
|
+
def purchasing_xml
|
293
|
+
purch = REXML::Element.new('purchasing')
|
294
|
+
|
295
|
+
purch.add_element('applecare_id').text = @applecare_id
|
296
|
+
purch.add_element('is_leased').text = @is_leased
|
297
|
+
purch.add_element('is_purchased').text = @is_purchased.to_s
|
298
|
+
purch.add_element('lease_expires_epoch').text = @lease_expires ? @lease_expires.to_jss_epoch : nil
|
299
|
+
# Note, life expectancy can't be an empty xml element, it must be zero if emtpy.
|
300
|
+
purch.add_element('life_expectancy').text = @life_expectancy ? @life_expectancy : 0
|
301
|
+
purch.add_element('po_date_epoch').text = @po_date ? @po_date.to_jss_epoch : nil
|
302
|
+
purch.add_element('po_number').text = @po_number
|
303
|
+
purch.add_element('purchase_price').text = @purchase_price
|
304
|
+
purch.add_element('purchasing_account').text = @purchasing_account
|
305
|
+
purch.add_element('purchasing_contact').text = @purchasing_contact
|
306
|
+
purch.add_element('vendor').text = @vendor
|
307
|
+
purch.add_element('warranty_expires_epoch').text = @warranty_expires ? @warranty_expires.to_jss_epoch : nil
|
308
|
+
return purch
|
309
|
+
end
|
310
|
+
|
311
|
+
### Aliases
|
312
|
+
alias leased? is_leased
|
313
|
+
alias purchased? is_purchased
|
314
|
+
|
315
|
+
end # module Purchasable
|
316
|
+
end # module JSS
|
@@ -0,0 +1,98 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
#####################################
|
29
|
+
### Module Variables
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
#####################################
|
33
|
+
### Module Methods
|
34
|
+
#####################################
|
35
|
+
|
36
|
+
#####################################
|
37
|
+
### Classes
|
38
|
+
#####################################
|
39
|
+
|
40
|
+
###
|
41
|
+
### A removable_macaddr in the JSS
|
42
|
+
###
|
43
|
+
### These are simple, in that they only have an ID and a name
|
44
|
+
###
|
45
|
+
### @see JSS::APIObject
|
46
|
+
###
|
47
|
+
class RemovableMacAddress < JSS::APIObject
|
48
|
+
|
49
|
+
#####################################
|
50
|
+
### Mix-Ins
|
51
|
+
#####################################
|
52
|
+
include JSS::Creatable
|
53
|
+
include JSS::Updatable
|
54
|
+
|
55
|
+
#####################################
|
56
|
+
### Class Methods
|
57
|
+
#####################################
|
58
|
+
|
59
|
+
|
60
|
+
#####################################
|
61
|
+
### Class Constants
|
62
|
+
#####################################
|
63
|
+
|
64
|
+
### The base for REST resources of this class
|
65
|
+
RSRC_BASE = "removablemacaddresses"
|
66
|
+
|
67
|
+
### the hash key used for the JSON list output of all objects in the JSS
|
68
|
+
RSRC_LIST_KEY = :removable_mac_addresses
|
69
|
+
|
70
|
+
### The hash key used for the JSON object output.
|
71
|
+
### It's also used in various error messages
|
72
|
+
RSRC_OBJECT_KEY = :removable_mac_address
|
73
|
+
|
74
|
+
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
75
|
+
VALID_DATA_KEYS = []
|
76
|
+
|
77
|
+
#####################################
|
78
|
+
### Attributes
|
79
|
+
#####################################
|
80
|
+
|
81
|
+
#####################################
|
82
|
+
### Constructor
|
83
|
+
#####################################
|
84
|
+
|
85
|
+
###
|
86
|
+
### See JSS::APIObject#initialize
|
87
|
+
###
|
88
|
+
|
89
|
+
#####################################
|
90
|
+
### Public Instance Methods
|
91
|
+
#####################################
|
92
|
+
|
93
|
+
alias macaddress name
|
94
|
+
alias mac_address name
|
95
|
+
|
96
|
+
end # class removable_macaddr
|
97
|
+
|
98
|
+
end # module
|
@@ -0,0 +1,136 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
#####################################
|
29
|
+
### Module Variables
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
#####################################
|
33
|
+
### Module Methods
|
34
|
+
#####################################
|
35
|
+
|
36
|
+
#####################################
|
37
|
+
### Sub-Modules
|
38
|
+
#####################################
|
39
|
+
|
40
|
+
###
|
41
|
+
### A mix-in module for handling scoping data for objects in the JSS.
|
42
|
+
###
|
43
|
+
### The JSS objects that can be scoped use similar data to represent
|
44
|
+
### that scoping. This module provides a consistant way to deal with scoping data
|
45
|
+
### via some instance methods and the {Scopable::Scope} class.
|
46
|
+
###
|
47
|
+
### When this module is mixed in to a {JSS::APIObject} subclass, instances of the subclass
|
48
|
+
### will have a @scope attribute containing a {JSS::Scopable::Scope} instance
|
49
|
+
###
|
50
|
+
### Classes that mix in this module must:
|
51
|
+
### - Set a Constant SCOPE_TARGET_KEY that is either :computers or :mobile_devices
|
52
|
+
### - Call {#parse_scope} during initialization to make a {JSS::Scopable::Scope} instance for their @scope attribute.
|
53
|
+
### - Include the result of self.scope.scope_xml in their own rest_xml output if they are {Updatable} or {Creatable}
|
54
|
+
###
|
55
|
+
module Scopable
|
56
|
+
|
57
|
+
#####################################
|
58
|
+
### Constants
|
59
|
+
#####################################
|
60
|
+
|
61
|
+
SCOPABLE = true
|
62
|
+
|
63
|
+
#####################################
|
64
|
+
### Variables
|
65
|
+
#####################################
|
66
|
+
|
67
|
+
#####################################
|
68
|
+
### Attribtues
|
69
|
+
#####################################
|
70
|
+
|
71
|
+
attr_reader :scope
|
72
|
+
|
73
|
+
#####################################
|
74
|
+
### Mixed-in Instance Methods
|
75
|
+
#####################################
|
76
|
+
|
77
|
+
###
|
78
|
+
### @api private
|
79
|
+
###
|
80
|
+
### Call this during initialization of objects that have a scope
|
81
|
+
### and the scope instance will be created from @init_data
|
82
|
+
###
|
83
|
+
### @return [void]
|
84
|
+
###
|
85
|
+
def parse_scope
|
86
|
+
@scope = JSS::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope]
|
87
|
+
@scope.container = self
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
###
|
92
|
+
### Change the scope
|
93
|
+
###
|
94
|
+
### @param new_scope[JSS::Scopable::Scope] the new scope
|
95
|
+
###
|
96
|
+
### @return [void]
|
97
|
+
###
|
98
|
+
def scope= (new_scope)
|
99
|
+
raise JSS::InvalidDataError, "JSS::Scopable::Scope instance required" unless new_criteria.kind_of?(JSS::Scopable::Scope)
|
100
|
+
raise JSS::InvalidDataError, "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}" unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
|
101
|
+
@scope = new_scope
|
102
|
+
@need_to_update = true
|
103
|
+
end
|
104
|
+
|
105
|
+
###
|
106
|
+
### When the scope changes, it calls this to tell us that an update is needed.
|
107
|
+
###
|
108
|
+
### @return [void]
|
109
|
+
###
|
110
|
+
def should_update
|
111
|
+
@need_to_update = true if @in_jss
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
###
|
116
|
+
### A wrapper around the update method, to try catching RestClient::Conflict
|
117
|
+
### 409 errors when we couldn't verify all ldap users/groups due to lack of ldap connections
|
118
|
+
###
|
119
|
+
def update
|
120
|
+
begin
|
121
|
+
super
|
122
|
+
|
123
|
+
rescue RestClient::Conflict => conflict
|
124
|
+
if self.scope.unable_to_verify_ldap_entries == true
|
125
|
+
raise JSS::InvalidDataError, "Potentially non-existant LDAP user or group in new scope values."
|
126
|
+
else
|
127
|
+
raise conflict
|
128
|
+
end
|
129
|
+
|
130
|
+
end # begin
|
131
|
+
end # update
|
132
|
+
|
133
|
+
end # module Scopable
|
134
|
+
end # module JSS
|
135
|
+
|
136
|
+
require "jss/api_object/scopable/scope"
|