ruby-jss 0.6.5 → 0.6.6
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.
- checksums.yaml +4 -4
- data/CHANGES.md +57 -5
- data/lib/jss.rb +78 -94
- data/lib/jss/api_connection.rb +8 -0
- data/lib/jss/api_object.rb +126 -102
- data/lib/jss/api_object/creatable.rb +33 -15
- data/lib/jss/api_object/distribution_point.rb +4 -1
- data/lib/jss/api_object/extension_attribute.rb +1 -1
- data/lib/jss/api_object/package.rb +121 -187
- data/lib/jss/api_object/policy.rb +590 -251
- data/lib/jss/api_object/script.rb +92 -128
- data/lib/jss/api_object/self_servable.rb +93 -117
- data/lib/jss/api_object/updatable.rb +12 -27
- data/lib/jss/api_object/uploadable.rb +12 -15
- data/lib/jss/client.rb +178 -156
- data/lib/jss/db_connection.rb +34 -49
- data/lib/jss/ruby_extensions/string.rb +25 -21
- data/lib/jss/version.rb +1 -1
- data/lib/jss/webhooks.rb +52 -0
- data/lib/jss/webhooks/README.md +269 -0
- data/lib/jss/webhooks/configuration.rb +212 -0
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation-executable +90 -0
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation.rb +44 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerAdded.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerCheckIn.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerInventoryCompleted.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerPolicyFinished.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerPushCapabilityChanged.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/JSSShutdown.json +14 -0
- data/lib/jss/webhooks/data/sample_jsons/JSSStartup.json +14 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCheckIn.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCommandCompleted.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceEnrolled.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDevicePushSent.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceUnEnrolled.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/PatchSoftwareTitleUpdated.json +14 -0
- data/lib/jss/webhooks/data/sample_jsons/PushSent.json +11 -0
- data/lib/jss/webhooks/data/sample_jsons/RestAPIOperation.json +15 -0
- data/lib/jss/webhooks/data/sample_jsons/SCEPChallenge.json +10 -0
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupComputerMembershipChange.json +13 -0
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +13 -0
- data/lib/jss/webhooks/event.rb +138 -0
- data/lib/jss/webhooks/event/computer_added.rb +37 -0
- data/lib/jss/webhooks/event/computer_check_in.rb +37 -0
- data/lib/jss/webhooks/event/computer_inventory_completed.rb +37 -0
- data/lib/jss/webhooks/event/computer_policy_finished.rb +37 -0
- data/lib/jss/webhooks/event/computer_push_capability_changed.rb +37 -0
- data/lib/jss/webhooks/event/handlers.rb +191 -0
- data/lib/jss/webhooks/event/jss_shutdown.rb +37 -0
- data/lib/jss/webhooks/event/jss_startup.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_check_in.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_command_completed.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_enrolled.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_push_sent.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_unenrolled.rb +37 -0
- data/lib/jss/webhooks/event/patch_software_title_updated.rb +37 -0
- data/lib/jss/webhooks/event/push_sent.rb +37 -0
- data/lib/jss/webhooks/event/rest_api_operation.rb +37 -0
- data/lib/jss/webhooks/event/scep_challenge.rb +37 -0
- data/lib/jss/webhooks/event/smart_group_computer_membership_change.rb +37 -0
- data/lib/jss/webhooks/event/smart_group_mobile_device_membership_change.rb +37 -0
- data/lib/jss/webhooks/event/webhook.rb +39 -0
- data/lib/jss/webhooks/event_objects.rb +111 -0
- data/lib/jss/webhooks/event_objects/computer.rb +48 -0
- data/lib/jss/webhooks/event_objects/jss.rb +35 -0
- data/lib/jss/webhooks/event_objects/mobile_device.rb +47 -0
- data/lib/jss/webhooks/event_objects/patch_software_title_update.rb +37 -0
- data/lib/jss/webhooks/event_objects/push.rb +32 -0
- data/lib/jss/webhooks/event_objects/rest_api_operation.rb +36 -0
- data/lib/jss/webhooks/event_objects/scep_challenge.rb +31 -0
- data/lib/jss/webhooks/event_objects/smart_group.rb +34 -0
- data/lib/jss/webhooks/server_app.rb +36 -0
- data/lib/jss/webhooks/server_app/routes.rb +26 -0
- data/lib/jss/webhooks/server_app/routes/handle_webhook_event.rb +38 -0
- data/lib/jss/webhooks/server_app/routes/home.rb +36 -0
- data/lib/jss/webhooks/server_app/self_signed_cert.rb +64 -0
- data/lib/jss/webhooks/server_app/server.rb +59 -0
- data/lib/jss/webhooks/version.rb +31 -0
- metadata +63 -4
|
@@ -40,18 +40,16 @@ module JSS
|
|
|
40
40
|
### A mix-in module for handling Self Service data for objects in the JSS.
|
|
41
41
|
###
|
|
42
42
|
### The JSS objects that have Self Service data return it in a :self_service subset,
|
|
43
|
-
### which
|
|
43
|
+
### which have somewhat similar data, i.e. a hash with at least these keys:
|
|
44
44
|
### - :self_service_description
|
|
45
45
|
### - :self_service_icon
|
|
46
|
-
###
|
|
47
|
-
### Most also have:
|
|
48
46
|
### - :feature_on_main_page
|
|
49
47
|
### - :self_service_categories
|
|
50
48
|
###
|
|
51
|
-
###
|
|
49
|
+
### Config Profiles in self service have this key:
|
|
52
50
|
### - :security
|
|
53
51
|
###
|
|
54
|
-
### Additionally, items that apper in
|
|
52
|
+
### Additionally, items that apper in macOS Slf Svc have these keys:
|
|
55
53
|
### - :install_button_text
|
|
56
54
|
### - :force_users_to_view_description
|
|
57
55
|
###
|
|
@@ -61,61 +59,59 @@ module JSS
|
|
|
61
59
|
### subclass's constructor will give it matching attributes with 'self_service_'
|
|
62
60
|
### appended if needed, e.g. {#self_service_feature_on_main_page}
|
|
63
61
|
###
|
|
64
|
-
### If the subclass is creatable or updatable, calling {#self_service_xml} returns
|
|
65
|
-
### a REXML element representing the Self Service subset, to be included with the
|
|
66
|
-
### #rest_xml output of the subclass.
|
|
67
62
|
###
|
|
68
63
|
### Classes including this module *must*:
|
|
69
64
|
###
|
|
70
|
-
### - Define the constant SELF_SERVICE_TARGET which contains either :
|
|
71
|
-
### - Define the constant SELF_SERVICE_PAYLOAD which contains one of :policy, :profile,
|
|
72
|
-
###
|
|
73
|
-
### -
|
|
65
|
+
### - Define the constant SELF_SERVICE_TARGET which contains either :macos or :ios
|
|
66
|
+
### - Define the constant SELF_SERVICE_PAYLOAD which contains one of :policy, :profile,
|
|
67
|
+
### :app, or :ebook
|
|
68
|
+
### - Call {#parse_self_service} in the subclass's constructor, after calling super
|
|
74
69
|
### - Define the method #in_self_service? which returns a Boolean indicating that the item is
|
|
75
|
-
### available in self service. Different API objects indicate this in different ways
|
|
76
|
-
###
|
|
77
|
-
###
|
|
78
|
-
###
|
|
70
|
+
### available in self service. Different API objects indicate this in different ways (and
|
|
71
|
+
### macOS app store apps don't provide it at all via the API,
|
|
72
|
+
### so self service can't be implemented fully)
|
|
73
|
+
### - Define the methods #add_to_self_service and #remove_from_self_service, which is handled
|
|
74
|
+
### differently for policies, apps/ebooks, and profiles
|
|
75
|
+
### - Define the method #user_removable? which returns Boolean indicating that the item
|
|
76
|
+
### can be removed by the user in SSvc. macOS profiles store this in the :user_removable
|
|
77
|
+
### key of the :general subset as a boolean, whereas iOS profiles store it in
|
|
78
|
+
### the :security hash of the :self_service data as one of 3 strings
|
|
79
|
+
### - Define the method #user_removable= which sets the appropriate values depending
|
|
80
|
+
### on the class. (see above)
|
|
81
|
+
### - Define a #set_icon_to method which takes the id of a previously uploaded
|
|
82
|
+
### icon, or a local path (String or Pathname) to an image file to use.
|
|
83
|
+
### - Include the result of {#self_service_xml} in their #rest_xml output
|
|
79
84
|
###
|
|
80
85
|
###
|
|
81
|
-
###
|
|
82
|
-
###
|
|
83
|
-
###
|
|
84
|
-
###
|
|
86
|
+
### Generating XML for PUT or POST:
|
|
87
|
+
###
|
|
88
|
+
### If the class including this module is creatable or updatable, calling {#self_service_xml}
|
|
89
|
+
### returns a REXML element representing the Self Service subset, to be included with the
|
|
90
|
+
### #rest_xml output of the subclass.
|
|
91
|
+
###
|
|
92
|
+
### Because some self-service-related data is located outside of the Self Service
|
|
93
|
+
### data subset (e.g. the deployment method for profiles is in the general subset),
|
|
94
|
+
### classes including this module *must* also account for that and add an appropriate
|
|
95
|
+
### XML element as needed.
|
|
85
96
|
###
|
|
86
97
|
module SelfServable
|
|
87
98
|
|
|
88
|
-
#####################################
|
|
89
99
|
### Constants
|
|
90
100
|
#####################################
|
|
91
101
|
|
|
92
102
|
SELF_SERVABLE = true
|
|
93
103
|
|
|
94
|
-
IOS_PROFILE_REMOVAL_OPTIONS = [
|
|
104
|
+
IOS_PROFILE_REMOVAL_OPTIONS = ['Always', 'With Authorization', 'Never'].freeze
|
|
95
105
|
|
|
96
|
-
#####################################
|
|
97
106
|
### Variables
|
|
98
107
|
#####################################
|
|
99
108
|
|
|
100
|
-
|
|
101
|
-
#####################################
|
|
102
109
|
### Attribtues
|
|
103
110
|
#####################################
|
|
104
111
|
|
|
105
|
-
|
|
106
112
|
### @return [String] The verbage that appears in SelfSvc for this item
|
|
107
113
|
attr_reader :self_service_description
|
|
108
114
|
|
|
109
|
-
### @return [Hash] The icon that appears in SelfSvc for this item
|
|
110
|
-
###
|
|
111
|
-
### The Hash contains these keys with info about the icon:
|
|
112
|
-
### - :filename => [String] The name of the image file uploaded to the JSS
|
|
113
|
-
### - :uri => [String] the URI for retriving the icon
|
|
114
|
-
### - :id => [Integer] the JSS id number for the icon (not all SSvc items have this)
|
|
115
|
-
### - :data => [String] the icon image encoded as Base64 (not all SSvc items have this)
|
|
116
|
-
###
|
|
117
|
-
attr_reader :self_service_icon
|
|
118
|
-
|
|
119
115
|
### @return [Boolean] Should this item feature on the main page of SSvc?
|
|
120
116
|
attr_reader :self_service_feature_on_main_page
|
|
121
117
|
|
|
@@ -124,6 +120,8 @@ module JSS
|
|
|
124
120
|
### Each Hash has these keys about the category
|
|
125
121
|
### - :id => [Integer] the JSS id of the category
|
|
126
122
|
### - :name => [String] the name of the category
|
|
123
|
+
###
|
|
124
|
+
### Most objects also include one or both of these keys:
|
|
127
125
|
### - :display_in => [Boolean] should the item be displayed in this category in SSvc? (OSX SSvc only)
|
|
128
126
|
### - :feature_in => [Boolean] should the item be featured in this category in SSVC? (OSX SSvc only)
|
|
129
127
|
###
|
|
@@ -132,16 +130,26 @@ module JSS
|
|
|
132
130
|
###
|
|
133
131
|
attr_reader :self_service_categories
|
|
134
132
|
|
|
135
|
-
### @return [Hash] The
|
|
133
|
+
### @return [Hash] The icon that appears in SelfSvc for this item
|
|
134
|
+
###
|
|
135
|
+
### The Hash contains these keys with info about the icon:
|
|
136
|
+
### - :uri => [String] the URI for retriving the icon
|
|
137
|
+
### - :id => [Integer] the JSS id number for the icon (not all SSvc items have this)
|
|
138
|
+
### - :data => [String] the icon image encoded as Base64 (not all SSvc items have this)
|
|
139
|
+
### - :filename => [String] The name of the image file uploaded to the JSS, if applicable
|
|
140
|
+
###
|
|
141
|
+
attr_reader :self_service_icon
|
|
142
|
+
|
|
143
|
+
### @return [Hash] The security settings for profiles in SSvc
|
|
136
144
|
###
|
|
137
145
|
### The keys are
|
|
138
|
-
### - :removal_disallowed => [String] one of the items in
|
|
146
|
+
### - :removal_disallowed => [String] one of the items in PROFILE_REMOVAL_OPTIONS
|
|
139
147
|
### - :password => [String] if :removal_disallowed is "With Authorization", this contains the passwd (in plaintext)
|
|
140
148
|
### needed to remove the profile.
|
|
141
149
|
###
|
|
142
150
|
### NOTE that the key should be called :removal_allowed, since 'Never' means it can't be removed.
|
|
143
151
|
###
|
|
144
|
-
attr_reader :
|
|
152
|
+
attr_reader :self_service_user_removable
|
|
145
153
|
|
|
146
154
|
### @return [String] The text label on the install button in SSvc (OSX SSvc only)
|
|
147
155
|
attr_reader :self_service_install_button_text
|
|
@@ -149,12 +157,10 @@ module JSS
|
|
|
149
157
|
### @return [Boolean] Should an extra window appear before the user can install the item? (OSX SSvc only)
|
|
150
158
|
attr_reader :self_service_force_users_to_view_description
|
|
151
159
|
|
|
152
|
-
|
|
153
160
|
#####################################
|
|
154
161
|
### Mixed-in Instance Methods
|
|
155
162
|
#####################################
|
|
156
163
|
|
|
157
|
-
###
|
|
158
164
|
### Call this during initialization of
|
|
159
165
|
### objects that have a self_service subset
|
|
160
166
|
### and the self_service attributes will be populated
|
|
@@ -164,84 +170,77 @@ module JSS
|
|
|
164
170
|
###
|
|
165
171
|
def parse_self_service
|
|
166
172
|
@init_data[:self_service] ||= {}
|
|
167
|
-
ss_data = @init_data[:self_service]
|
|
173
|
+
@ss_data = @init_data[:self_service]
|
|
168
174
|
|
|
169
|
-
@self_service_description = ss_data[:self_service_description]
|
|
170
|
-
@self_service_icon = ss_data[:self_service_icon]
|
|
175
|
+
@self_service_description = @ss_data[:self_service_description]
|
|
176
|
+
@self_service_icon = @ss_data[:self_service_icon]
|
|
177
|
+
@self_service_icon ||= {}
|
|
171
178
|
|
|
172
|
-
@self_service_feature_on_main_page = ss_data[:feature_on_main_page]
|
|
179
|
+
@self_service_feature_on_main_page = @ss_data[:feature_on_main_page]
|
|
180
|
+
@self_service_feature_on_main_page ||= false
|
|
173
181
|
|
|
174
|
-
@self_service_categories = ss_data[:self_service_categories]
|
|
182
|
+
@self_service_categories = @ss_data[:self_service_categories]
|
|
183
|
+
@self_service_categories ||= []
|
|
175
184
|
|
|
176
185
|
# make this an empty hash if needed
|
|
177
|
-
@self_service_security = ss_data[:security]
|
|
178
|
-
|
|
179
|
-
# if this is an osx profile, set @self_service_security[:removal_disallowed] to "Always" or "Never"
|
|
180
|
-
# to indicate the boolean :user_removable
|
|
181
|
-
if @init_data[:general].keys.include? :user_removable
|
|
182
|
-
@self_service_security[:removal_disallowed] = @init_data[:general][:user_removable] ? "Always" : "Never"
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
@self_service_install_button_text = ss_data[:install_button_text]
|
|
186
|
-
@self_service_force_users_to_view_description = ss_data[:force_users_to_view_description]
|
|
186
|
+
@self_service_security = @ss_data[:security]
|
|
187
|
+
@self_service_security ||= {}
|
|
187
188
|
|
|
188
|
-
|
|
189
|
+
@self_service_install_button_text = @ss_data[:install_button_text]
|
|
190
|
+
@self_service_install_button_text ||= 'Install'
|
|
189
191
|
|
|
192
|
+
@self_service_force_users_to_view_description = @ss_data[:force_users_to_view_description]
|
|
193
|
+
@self_service_force_users_to_view_description ||= false
|
|
194
|
+
end # parse
|
|
190
195
|
|
|
191
|
-
###
|
|
192
|
-
###
|
|
193
196
|
### Setters
|
|
194
197
|
###
|
|
195
198
|
|
|
196
|
-
###
|
|
197
199
|
### @param new_val[String] the new discription
|
|
198
200
|
###
|
|
199
201
|
### @return [void]
|
|
200
202
|
###
|
|
201
|
-
def self_service_description=
|
|
202
|
-
|
|
203
|
-
@self_service_description
|
|
203
|
+
def self_service_description=(new_val)
|
|
204
|
+
new_val.strip!
|
|
205
|
+
return if @self_service_description == new_val
|
|
206
|
+
@self_service_description = new_val
|
|
204
207
|
@need_to_update = true
|
|
205
208
|
end
|
|
206
209
|
|
|
207
|
-
###
|
|
208
210
|
### @param new_val[String] the new install button text
|
|
209
211
|
###
|
|
210
212
|
### @return [void]
|
|
211
213
|
###
|
|
212
|
-
def self_service_install_button_text=
|
|
214
|
+
def self_service_install_button_text=(new_val)
|
|
213
215
|
return nil if @self_service_install_button_text == new_val
|
|
214
|
-
raise JSS::InvalidDataError,
|
|
216
|
+
raise JSS::InvalidDataError, 'Only OS X Self Service Items can have custom button text' unless self.class::SELF_SERVICE_TARGET == :macos
|
|
215
217
|
@self_service_install_button_text = new_val.strip
|
|
216
218
|
@need_to_update = true
|
|
217
219
|
end
|
|
218
220
|
|
|
219
|
-
###
|
|
220
221
|
### @param new_val[Boolean] should this appear on the main SelfSvc page?
|
|
221
222
|
###
|
|
222
223
|
### @return [void]
|
|
223
224
|
###
|
|
224
|
-
def self_service_feature_on_main_page=
|
|
225
|
+
def self_service_feature_on_main_page=(new_val)
|
|
225
226
|
return nil if @self_service_feature_on_main_page == new_val
|
|
226
|
-
raise JSS::InvalidDataError,
|
|
227
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless JSS::TRUE_FALSE.include? new_val
|
|
227
228
|
@self_service_feature_on_main_page = new_val
|
|
228
229
|
@need_to_update = true
|
|
229
230
|
end
|
|
230
231
|
|
|
231
|
-
###
|
|
232
232
|
### @param new_val[Boolean] should this appear on the main SelfSvc page?
|
|
233
233
|
###
|
|
234
234
|
### @return [void]
|
|
235
235
|
###
|
|
236
|
-
def self_service_force_users_to_view_description=
|
|
236
|
+
def self_service_force_users_to_view_description=(new_val)
|
|
237
237
|
return nil if @self_service_force_users_to_view_description == new_val
|
|
238
|
-
raise JSS::InvalidDataError,
|
|
239
|
-
raise JSS::InvalidDataError,
|
|
238
|
+
raise JSS::InvalidDataError, 'Only OS X Self Service Items can force users to view description' unless self.class::SELF_SERVICE_TARGET == :macos
|
|
239
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless JSS::TRUE_FALSE.include? new_val
|
|
240
240
|
@self_service_force_users_to_view_description = new_val
|
|
241
241
|
@need_to_update = true
|
|
242
242
|
end
|
|
243
243
|
|
|
244
|
-
###
|
|
245
244
|
### Add or change one of the categories for this item in SSvc.
|
|
246
245
|
###
|
|
247
246
|
### @param new_cat[String] the name of a category for this item in SelfSvc
|
|
@@ -252,16 +251,16 @@ module JSS
|
|
|
252
251
|
###
|
|
253
252
|
### @return [void]
|
|
254
253
|
###
|
|
255
|
-
def add_self_service_category
|
|
254
|
+
def add_self_service_category(new_cat, display_in: true, feature_in: false)
|
|
256
255
|
new_cat.strip!
|
|
257
256
|
raise JSS::NoSuchItemError, "No category '#{new_cat}' in the JSS" unless JSS::Category.all_names(:refresh).include? new_cat
|
|
258
|
-
raise JSS::InvalidDataError,
|
|
259
|
-
raise JSS::InvalidDataError,
|
|
257
|
+
raise JSS::InvalidDataError, 'display_in must be true or false' unless JSS::TRUE_FALSE.include? display_in
|
|
258
|
+
raise JSS::InvalidDataError, 'feature_in must be true or false' unless JSS::TRUE_FALSE.include? feature_in
|
|
260
259
|
|
|
261
|
-
new_data = {:
|
|
260
|
+
new_data = { name: new_cat, display_in: display_in, feature_in: feature_in }
|
|
262
261
|
|
|
263
262
|
# see if this category is already among our categories.
|
|
264
|
-
idx = @self_service_categories.index{|c| c[new_cat
|
|
263
|
+
idx = @self_service_categories.index { |c| c[:name] == new_cat }
|
|
265
264
|
|
|
266
265
|
if idx
|
|
267
266
|
@self_service_categories[idx] = new_data
|
|
@@ -272,39 +271,17 @@ module JSS
|
|
|
272
271
|
@need_to_update = true
|
|
273
272
|
end
|
|
274
273
|
|
|
275
|
-
###
|
|
276
274
|
### Remove a category from those for this item in SSvc
|
|
277
275
|
###
|
|
278
|
-
### @param cat[String] the name of the category to remove
|
|
276
|
+
### @param cat [String] the name of the category to remove
|
|
279
277
|
###
|
|
280
278
|
### @return [void]
|
|
281
279
|
###
|
|
282
|
-
def remove_self_service_category
|
|
283
|
-
|
|
284
|
-
@self_service_categories.reject!{|c| c[:name]}
|
|
280
|
+
def remove_self_service_category(cat)
|
|
281
|
+
@self_service_categories.reject! { |c| c[:name] == cat }
|
|
285
282
|
@need_to_update = true
|
|
286
283
|
end
|
|
287
284
|
|
|
288
|
-
###
|
|
289
|
-
### Set whether or when the user can remove a profile installed with SSvc
|
|
290
|
-
###
|
|
291
|
-
### @param new_val[String] one of the values in PROFILE_REMOVAL_OPTIONS, or true or false
|
|
292
|
-
###
|
|
293
|
-
### @return [void]
|
|
294
|
-
###
|
|
295
|
-
def profile_can_be_removed (new_val)
|
|
296
|
-
|
|
297
|
-
new_val = "Always" if new_val === true
|
|
298
|
-
new_val = "Never" if new_val === false
|
|
299
|
-
|
|
300
|
-
return nil if new_val == @self_service_security[:removal_disallowed]
|
|
301
|
-
raise JSS::InvalidDataError, "" unless IOS_PROFILE_REMOVAL_OPTIONS.include? new_val
|
|
302
|
-
|
|
303
|
-
@self_service_security[:removal_disallowed] = new_val
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
###
|
|
308
285
|
### @api private
|
|
309
286
|
###
|
|
310
287
|
### Return a REXML <location> element to be
|
|
@@ -314,23 +291,21 @@ module JSS
|
|
|
314
291
|
### @return [REXML::Element]
|
|
315
292
|
###
|
|
316
293
|
def self_service_xml
|
|
317
|
-
|
|
318
294
|
ssvc = REXML::Element.new('self_service')
|
|
319
295
|
|
|
320
|
-
return ssvc unless self.in_self_service?
|
|
321
|
-
|
|
322
296
|
ssvc.add_element('self_service_description').text = @self_service_description
|
|
323
297
|
ssvc.add_element('feature_on_main_page').text = @self_service_feature_on_main_page
|
|
324
298
|
|
|
325
|
-
|
|
299
|
+
cats = ssvc.add_element('self_service_categories')
|
|
300
|
+
@self_service_categories.each do |cat|
|
|
301
|
+
catelem = cats.add_element('category')
|
|
302
|
+
catelem.add_element('name').text = cat[:name]
|
|
303
|
+
catelem.add_element('display_in').text = cat[:display_in] if cat.keys.include? :display_in
|
|
304
|
+
catelem.add_element('feature_in').text = cat[:feature_in] if cat.keys.include? :feature_in
|
|
305
|
+
end
|
|
326
306
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
# catelem = cats.add_element('category')
|
|
330
|
-
# catelem.add_element('name').text = cat[:name]
|
|
331
|
-
# catelem.add_element('display_in').text = cat[:display_in] if cat.keys.include? :display_in
|
|
332
|
-
# catelem.add_element('feature_in').text = cat[:feature_in] if cat.keys.include? :feature_in
|
|
333
|
-
# end
|
|
307
|
+
icon = ssvc.add_element('self_service_icon')
|
|
308
|
+
@self_service_icon.each { |key, val| icon.add_element(key.to_s).text = val }
|
|
334
309
|
|
|
335
310
|
unless @self_service_security.empty?
|
|
336
311
|
sec = ssvc.add_element('security')
|
|
@@ -339,9 +314,10 @@ module JSS
|
|
|
339
314
|
end
|
|
340
315
|
|
|
341
316
|
ssvc.add_element('install_button_text').text = @self_service_install_button_text if @self_service_install_button_text
|
|
342
|
-
ssvc.add_element('force_users_to_view_description').text = @self_service_force_users_to_view_description
|
|
317
|
+
ssvc.add_element('force_users_to_view_description').text = @self_service_force_users_to_view_description \
|
|
318
|
+
unless @self_service_force_users_to_view_description.nil?
|
|
343
319
|
|
|
344
|
-
|
|
320
|
+
ssvc
|
|
345
321
|
end
|
|
346
322
|
|
|
347
323
|
### aliases
|
|
@@ -1,48 +1,39 @@
|
|
|
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
|
-
###
|
|
23
22
|
###
|
|
24
|
-
|
|
25
23
|
###
|
|
26
|
-
module JSS
|
|
27
24
|
|
|
28
25
|
### A mix-in module providing object-updating via the JSS API.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
module JSS
|
|
32
27
|
|
|
33
|
-
#####################################
|
|
34
28
|
### Module Variables
|
|
35
29
|
#####################################
|
|
36
30
|
|
|
37
|
-
#####################################
|
|
38
31
|
### Module Methods
|
|
39
32
|
#####################################
|
|
40
33
|
|
|
41
|
-
#####################################
|
|
42
34
|
### Sub-Modules
|
|
43
35
|
#####################################
|
|
44
36
|
|
|
45
|
-
###
|
|
46
37
|
### A mix-in module that allows objects to be updated in the JSS via the API.
|
|
47
38
|
###
|
|
48
39
|
### When a JSS::APIObject subclass includes this module, instances of that
|
|
@@ -61,26 +52,20 @@ module JSS
|
|
|
61
52
|
###
|
|
62
53
|
module Updatable
|
|
63
54
|
|
|
64
|
-
#####################################
|
|
65
55
|
### Constants
|
|
66
56
|
#####################################
|
|
67
57
|
|
|
68
58
|
UPDATABLE = true
|
|
69
59
|
|
|
70
|
-
#####################################
|
|
71
60
|
### Attributes
|
|
72
61
|
#####################################
|
|
73
62
|
|
|
74
|
-
|
|
75
63
|
### @return [Boolean] do we have unsaved changes?
|
|
76
64
|
attr_reader :need_to_update
|
|
77
65
|
|
|
78
|
-
|
|
79
|
-
#####################################
|
|
80
66
|
### Mixed-in Instance Methods
|
|
81
67
|
#####################################
|
|
82
68
|
|
|
83
|
-
###
|
|
84
69
|
### Change the name of this item
|
|
85
70
|
### Remember to #update to push changes to the server.
|
|
86
71
|
###
|
|
@@ -88,26 +73,26 @@ module JSS
|
|
|
88
73
|
###
|
|
89
74
|
### @return [void]
|
|
90
75
|
###
|
|
91
|
-
def name=
|
|
92
|
-
raise JSS::UnsupportedError, "Editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless UPDATABLE
|
|
76
|
+
def name=(newname)
|
|
93
77
|
return nil if @name == newname
|
|
78
|
+
raise JSS::UnsupportedError, "Editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless UPDATABLE
|
|
94
79
|
raise JSS::InvalidDataError, "Names can't be empty!" if newname.to_s.empty?
|
|
95
|
-
raise JSS::AlreadyExistsError, "A #{self.class::RSRC_OBJECT_KEY} named '#{newname}' already exsists in the JSS"
|
|
80
|
+
raise JSS::AlreadyExistsError, "A #{self.class::RSRC_OBJECT_KEY} named '#{newname}' already exsists in the JSS" \
|
|
81
|
+
if self.class.all_names(:refresh).include? newname
|
|
96
82
|
@name = newname
|
|
97
83
|
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name}" if @rest_rsrc.include? '/name/'
|
|
98
84
|
@need_to_update = true
|
|
99
85
|
end # name=(newname)
|
|
100
86
|
|
|
101
|
-
###
|
|
102
87
|
### Save changes to the JSS
|
|
103
88
|
###
|
|
104
89
|
### @return [Boolean] success
|
|
105
90
|
###
|
|
106
91
|
def update
|
|
107
|
-
raise JSS::UnsupportedError, "Editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless UPDATABLE
|
|
108
92
|
return nil unless @need_to_update
|
|
93
|
+
raise JSS::UnsupportedError, "Editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless UPDATABLE
|
|
109
94
|
raise JSS::NoSuchItemError, "Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY} in the JSS before updating it." unless @in_jss
|
|
110
|
-
JSS::API.put_rsrc
|
|
95
|
+
JSS::API.put_rsrc @rest_rsrc, rest_xml
|
|
111
96
|
@need_to_update = false
|
|
112
97
|
@id
|
|
113
98
|
end # update
|