ruby-jss 0.6.4 → 0.6.5
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/lib/jss.rb +3 -0
- data/lib/jss/api_object.rb +27 -23
- data/lib/jss/api_object/account.rb +160 -0
- data/lib/jss/api_object/computer.rb +30 -12
- data/lib/jss/api_object/computer_invitation.rb +206 -0
- data/lib/jss/api_object/creatable.rb +7 -6
- data/lib/jss/api_object/distribution_point.rb +11 -6
- data/lib/jss/api_object/group.rb +13 -13
- data/lib/jss/api_object/osx_configuration_profile.rb +61 -59
- data/lib/jss/api_object/package.rb +41 -12
- data/lib/jss/api_object/restricted_software.rb +86 -0
- data/lib/jss/api_object/script.rb +1 -1
- data/lib/jss/api_object/self_servable.rb +55 -58
- data/lib/jss/api_object/updatable.rb +1 -1
- data/lib/jss/client.rb +1 -1
- data/lib/jss/version.rb +1 -1
- metadata +5 -2
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -86,6 +86,7 @@ module JSS
|
|
86
86
|
raise JSS::UnsupportedError, "Creating or editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless CREATABLE
|
87
87
|
raise AlreadyExistsError, "This #{self.class::RSRC_OBJECT_KEY} already exists. Use #update to make changes." if @in_jss
|
88
88
|
JSS::API.post_rsrc( @rest_rsrc, rest_xml) =~ /><id>(\d+)<\/id></
|
89
|
+
|
89
90
|
@id = $1.to_i
|
90
91
|
@in_jss = true
|
91
92
|
@need_to_update = false
|
@@ -118,10 +118,11 @@ module JSS
|
|
118
118
|
when 0
|
119
119
|
raise JSS::NoSuchItemError, "No distribution points defined"
|
120
120
|
when 1
|
121
|
-
self.new :id => self.all_ids[0]
|
121
|
+
@@master_distribution_point = self.new :id => self.all_ids[0]
|
122
122
|
else
|
123
|
-
self.new :id => :master
|
123
|
+
@@master_distribution_point = self.new :id => :master
|
124
124
|
end
|
125
|
+
@@master_distribution_point
|
125
126
|
end
|
126
127
|
|
127
128
|
### Get the DistributionPoint instance for the machine running
|
@@ -142,7 +143,8 @@ module JSS
|
|
142
143
|
else
|
143
144
|
nil
|
144
145
|
end
|
145
|
-
|
146
|
+
@@my_distribution_point = specific ? self.new(:name => specific) : self.master_distribution_point
|
147
|
+
@@my_distribution_point
|
146
148
|
end
|
147
149
|
|
148
150
|
#####################################
|
@@ -364,8 +366,8 @@ module JSS
|
|
364
366
|
# we don't check the pw here, because if the connection fails, we'll
|
365
367
|
# drop down below to try the password for mounting.
|
366
368
|
# we'll escape all the chars that aren't unreserved
|
367
|
-
reserved_chars = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}]")
|
368
|
-
user_pass = "#{
|
369
|
+
#reserved_chars = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}]")
|
370
|
+
user_pass = "#{CGI.escape @http_username}:#{CGI.escape ro_pw}@"
|
369
371
|
url = @http_url.sub "://#{@ip_address}", "://#{user_pass}#{@ip_address}"
|
370
372
|
else
|
371
373
|
url = @http_url
|
@@ -414,6 +416,8 @@ module JSS
|
|
414
416
|
end
|
415
417
|
|
416
418
|
|
419
|
+
|
420
|
+
|
417
421
|
###
|
418
422
|
### Mount this distribution point locally.
|
419
423
|
###
|
@@ -451,7 +455,7 @@ module JSS
|
|
451
455
|
|
452
456
|
username = access == :ro ? @read_only_username : @read_write_username
|
453
457
|
|
454
|
-
safe_pw =
|
458
|
+
safe_pw = CGI.escape password
|
455
459
|
|
456
460
|
@mount_url = "#{@connection_type.downcase}://#{username}:#{safe_pw}@#{@ip_address}/#{@share_name}"
|
457
461
|
@mnt_cmd = case @connection_type.downcase
|
@@ -484,6 +488,7 @@ module JSS
|
|
484
488
|
def unmount
|
485
489
|
return nil unless mounted?
|
486
490
|
if system "/sbin/umount '#{@mountpoint}'"
|
491
|
+
sleep 1 # the umount takes time.
|
487
492
|
@mountpoint.rmdir if @mountpoint.directory? and (not @mountpoint.mountpoint?)
|
488
493
|
@mounted = false
|
489
494
|
else
|
data/lib/jss/api_object/group.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -120,7 +120,7 @@ module JSS
|
|
120
120
|
|
121
121
|
### @return [Boolean] does this group send notifications when it changes?
|
122
122
|
attr_reader :notify_on_change
|
123
|
-
|
123
|
+
|
124
124
|
|
125
125
|
### @return [String] the :name of the site for this group
|
126
126
|
attr_reader :site
|
@@ -213,7 +213,7 @@ module JSS
|
|
213
213
|
def size
|
214
214
|
@members.count
|
215
215
|
end
|
216
|
-
|
216
|
+
|
217
217
|
|
218
218
|
###
|
219
219
|
### @return [Array<String>] the names of the group members
|
@@ -321,14 +321,14 @@ module JSS
|
|
321
321
|
@need_to_update = true
|
322
322
|
end
|
323
323
|
|
324
|
-
|
324
|
+
|
325
325
|
### aliases
|
326
|
-
|
326
|
+
|
327
327
|
alias smart? is_smart
|
328
328
|
alias notify_on_change? notify_on_change
|
329
329
|
alias notify? notify_on_change
|
330
330
|
alias count size
|
331
|
-
|
331
|
+
|
332
332
|
#####################################
|
333
333
|
### Public Instance Methods
|
334
334
|
#####################################
|
@@ -343,8 +343,8 @@ module JSS
|
|
343
343
|
###
|
344
344
|
def check_member(m)
|
345
345
|
potential_members = self.class::MEMBER_CLASS.map_all_ids_to(:name)
|
346
|
-
if m.to_s =~
|
347
|
-
return {:id=>m.to_i, :name=> potential_members[m]} if potential_members.keys.include? m.to_i
|
346
|
+
if m.to_s =~ /^\d+$/
|
347
|
+
return {:id=>m.to_i, :name=> potential_members[m]} if potential_members.keys.include? m.to_i
|
348
348
|
else
|
349
349
|
return {:name=>m, :id=> potential_members.invert[m]} if potential_members.values.include? m
|
350
350
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
26
26
|
module JSS
|
27
|
-
|
27
|
+
|
28
28
|
#####################################
|
29
29
|
### Module Variables
|
30
30
|
#####################################
|
@@ -33,103 +33,106 @@ module JSS
|
|
33
33
|
### Module Methods
|
34
34
|
#####################################
|
35
35
|
|
36
|
-
|
37
36
|
#####################################
|
38
37
|
### Classes
|
39
38
|
#####################################
|
40
39
|
|
41
|
-
###
|
40
|
+
###
|
42
41
|
### An OS X Configuration Profile in the JSS.
|
43
42
|
###
|
44
43
|
### Note that the profile payloads and the profile UUID cannot be edited or updated with this via this class.
|
45
44
|
### Use the web UI.
|
46
45
|
###
|
47
46
|
### @see JSS::APIObject
|
48
|
-
###
|
47
|
+
###
|
49
48
|
class OSXConfigurationProfile < JSS::APIObject
|
50
|
-
|
49
|
+
|
51
50
|
#####################################
|
52
51
|
### Mix-Ins
|
53
52
|
#####################################
|
54
53
|
include JSS::Updatable
|
55
54
|
include JSS::Scopable
|
56
55
|
include JSS::SelfServable
|
57
|
-
|
56
|
+
|
57
|
+
#####################################
|
58
|
+
### Class Variables
|
59
|
+
#####################################
|
60
|
+
|
58
61
|
#####################################
|
59
62
|
### Class Methods
|
60
63
|
#####################################
|
61
|
-
|
64
|
+
|
62
65
|
#####################################
|
63
66
|
### Class Constants
|
64
67
|
#####################################
|
65
|
-
|
68
|
+
|
66
69
|
### The base for REST resources of this class
|
67
70
|
RSRC_BASE = "osxconfigurationprofiles"
|
68
|
-
|
71
|
+
|
69
72
|
### the hash key used for the JSON list output of all objects in the JSS
|
70
73
|
RSRC_LIST_KEY = :os_x_configuration_profiles
|
71
|
-
|
74
|
+
|
72
75
|
### The hash key used for the JSON object output.
|
73
76
|
### It's also used in various error messages
|
74
77
|
RSRC_OBJECT_KEY = :os_x_configuration_profile
|
75
|
-
|
78
|
+
|
76
79
|
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
77
80
|
VALID_DATA_KEYS = [:distribution_method, :scope, :redeploy_on_update]
|
78
|
-
|
81
|
+
|
79
82
|
### Our scopes deal with computers
|
80
83
|
SCOPE_TARGET_KEY = :computers
|
81
|
-
|
84
|
+
|
82
85
|
### Our SelfService happens on OSX
|
83
86
|
SELF_SERVICE_TARGET = :osx
|
84
|
-
|
87
|
+
|
85
88
|
### Our SelfService deploys profiles
|
86
89
|
SELF_SERVICE_PAYLOAD = :profile
|
87
|
-
|
90
|
+
|
88
91
|
### The possible values for the :distribution_method
|
89
92
|
DISTRIBUTION_METHODS = ["Install Automatically", "Make Available in Self Service"]
|
90
|
-
|
93
|
+
|
91
94
|
SELF_SERVICE_DIST_METHOD = "Make Available in Self Service"
|
92
|
-
|
95
|
+
|
93
96
|
### The possible values for :level
|
94
97
|
LEVELS = ["user", "computer"]
|
95
|
-
|
96
|
-
|
98
|
+
|
99
|
+
|
97
100
|
#####################################
|
98
101
|
### Attributes
|
99
102
|
#####################################
|
100
|
-
|
103
|
+
|
101
104
|
### @return [String] the description of this profile
|
102
105
|
attr_reader :description
|
103
|
-
|
106
|
+
|
104
107
|
### @return [String] the distribution_method of this profile
|
105
108
|
attr_reader :distribution_method
|
106
|
-
|
109
|
+
|
107
110
|
### @return [Boolean] can the user remove this profile
|
108
111
|
attr_reader :user_removable
|
109
|
-
|
112
|
+
|
110
113
|
### @return [String] the level (user/computer) of this profile
|
111
114
|
attr_reader :level
|
112
|
-
|
115
|
+
|
113
116
|
### @return [String] the uuid of this profile. NOT Updatable
|
114
117
|
attr_reader :uuid
|
115
|
-
|
118
|
+
|
116
119
|
### @return [Boolean] Should this profile be redeployed when an inventory update happens?
|
117
120
|
attr_reader :redeploy_on_update
|
118
|
-
|
121
|
+
|
119
122
|
### @return [String] the plist containing the payloads for this profile. NOT Updatable
|
120
123
|
attr_reader :payloads
|
121
|
-
|
124
|
+
|
122
125
|
#####################################
|
123
|
-
### Constructor
|
126
|
+
### Constructor
|
124
127
|
#####################################
|
125
|
-
|
128
|
+
|
126
129
|
###
|
127
130
|
### See JSS::APIObject#initialize
|
128
131
|
###
|
129
132
|
def initialize (args = {})
|
130
|
-
|
133
|
+
|
131
134
|
super
|
132
|
-
|
135
|
+
|
133
136
|
@description = @main_subset[:description]
|
134
137
|
@distribution_method = @main_subset[:distribution_method]
|
135
138
|
@user_removable = @main_subset[:user_removable]
|
@@ -137,10 +140,9 @@ module JSS
|
|
137
140
|
@uuid = @main_subset[:uuid]
|
138
141
|
@redeploy_on_update = @main_subset[:redeploy_on_update]
|
139
142
|
@payloads = @main_subset[:payloads]
|
140
|
-
|
143
|
+
|
141
144
|
self.parse_scope
|
142
145
|
self.parse_self_service
|
143
|
-
|
144
146
|
end
|
145
147
|
|
146
148
|
#####################################
|
@@ -157,8 +159,8 @@ module JSS
|
|
157
159
|
@description = new_val.strip!
|
158
160
|
@need_to_update = true
|
159
161
|
end
|
160
|
-
|
161
|
-
|
162
|
+
|
163
|
+
|
162
164
|
###
|
163
165
|
### @param new_val[String] how should this be distributed to clients?
|
164
166
|
###
|
@@ -170,7 +172,7 @@ module JSS
|
|
170
172
|
@distribution_method = new_val
|
171
173
|
@need_to_update = true
|
172
174
|
end
|
173
|
-
|
175
|
+
|
174
176
|
###
|
175
177
|
### @param new_val[Boolean] should the user be able to remove this?
|
176
178
|
###
|
@@ -183,7 +185,7 @@ module JSS
|
|
183
185
|
@user_removable = new_val
|
184
186
|
@need_to_update = true
|
185
187
|
end
|
186
|
-
|
188
|
+
|
187
189
|
###
|
188
190
|
### @param new_val[String] the new level for this profile (user/computer)
|
189
191
|
###
|
@@ -195,53 +197,53 @@ module JSS
|
|
195
197
|
@level = new_val
|
196
198
|
@need_to_update = true
|
197
199
|
end
|
198
|
-
|
199
|
-
|
200
|
+
|
201
|
+
|
200
202
|
###
|
201
203
|
### @return [Boolean] is this profile available in Self Service?
|
202
204
|
###
|
203
205
|
def in_self_service?
|
204
206
|
@distribution_method == SELF_SERVICE_DIST_METHOD
|
205
207
|
end
|
206
|
-
|
207
|
-
|
208
|
+
|
209
|
+
|
208
210
|
###
|
209
211
|
### @return [Boolean] is this profile removable by the user?
|
210
212
|
###
|
211
213
|
def user_removable?
|
212
214
|
@user_removable
|
213
215
|
end
|
214
|
-
|
215
|
-
|
216
|
-
###
|
216
|
+
|
217
|
+
|
218
|
+
###
|
217
219
|
### @return [Hash] The payload plist parsed into a Ruby hash
|
218
220
|
###
|
219
221
|
def parsed_payloads
|
220
222
|
Plist.parse_xml @payloads
|
221
223
|
end
|
222
|
-
|
224
|
+
|
223
225
|
###
|
224
226
|
### @return [Array<Hash>] the individual payloads from the payload Plist
|
225
227
|
###
|
226
228
|
def payload_content
|
227
229
|
parsed_payloads['PayloadContent']
|
228
230
|
end
|
229
|
-
|
231
|
+
|
230
232
|
###
|
231
233
|
### @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
|
232
234
|
###
|
233
235
|
def payload_types
|
234
236
|
payload_content.map{|p| p['PayloadType'] }
|
235
237
|
end
|
236
|
-
|
238
|
+
|
237
239
|
#####################################
|
238
240
|
### Private Instance Methods
|
239
241
|
#####################################
|
240
242
|
private
|
241
|
-
|
243
|
+
|
242
244
|
def rest_xml
|
243
245
|
doc = REXML::Document.new
|
244
|
-
|
246
|
+
|
245
247
|
obj = doc.add_element RSRC_OBJECT_KEY.to_s
|
246
248
|
gen = obj.add_element('general')
|
247
249
|
gen.add_element('description').text = @description
|
@@ -249,13 +251,13 @@ module JSS
|
|
249
251
|
gen.add_element('user_removable').text = @user_removable
|
250
252
|
gen.add_element('level').text = @level
|
251
253
|
gen.add_element('redeploy_on_update').text = @redeploy_on_update
|
252
|
-
|
254
|
+
|
253
255
|
obj << @scope.scope_xml
|
254
256
|
obj << self_service_xml
|
255
|
-
|
257
|
+
|
256
258
|
return doc.to_s
|
257
259
|
end
|
258
|
-
|
260
|
+
|
259
261
|
end # class OSXConfigurationProfile
|
260
|
-
|
262
|
+
|
261
263
|
end # module
|