ruby-jss 0.7.0 → 0.8.1
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.
- checksums.yaml +4 -4
- data/CHANGES.md +29 -22
- data/README.md +66 -86
- data/bin/jamfHelperBackgrounder +148 -0
- data/bin/netseg-update +0 -1
- data/lib/jss.rb +20 -9
- data/lib/jss/api_connection.rb +369 -295
- data/lib/jss/api_object.rb +651 -418
- data/lib/jss/api_object/account.rb +69 -77
- data/lib/jss/api_object/advanced_search.rb +201 -236
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +42 -42
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +33 -43
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +33 -43
- data/lib/jss/api_object/building.rb +39 -52
- data/lib/jss/api_object/categorizable.rb +221 -0
- data/lib/jss/api_object/category.rb +81 -89
- data/lib/jss/api_object/computer.rb +486 -525
- data/lib/jss/api_object/computer_invitation.rb +73 -86
- data/lib/jss/api_object/criteriable.rb +6 -7
- data/lib/jss/api_object/ebook.rb +21 -0
- data/lib/jss/api_object/extendable.rb +6 -8
- data/lib/jss/api_object/group.rb +0 -3
- data/lib/jss/api_object/locatable.rb +19 -20
- data/lib/jss/api_object/mac_application.rb +21 -0
- data/lib/jss/api_object/mobile_device.rb +30 -21
- data/lib/jss/api_object/mobile_device_application.rb +447 -0
- data/lib/jss/api_object/mobile_device_configuration_profile.rb +21 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +0 -3
- data/lib/jss/api_object/package.rb +21 -34
- data/lib/jss/api_object/peripheral.rb +16 -18
- data/lib/jss/api_object/policy.rb +5 -83
- data/lib/jss/api_object/purchasable.rb +11 -13
- data/lib/jss/api_object/scopable.rb +11 -12
- data/lib/jss/api_object/script.rb +3 -17
- data/lib/jss/api_object/self_servable.rb +419 -205
- data/lib/jss/api_object/self_servable/icon.rb +179 -0
- data/lib/jss/api_object/updatable.rb +35 -34
- data/lib/jss/api_object/uploadable.rb +72 -70
- data/lib/jss/api_object/user.rb +6 -7
- data/lib/jss/api_object/vppable.rb +117 -0
- data/lib/jss/client.rb +264 -225
- data/lib/jss/db_connection.rb +7 -5
- data/lib/jss/exceptions.rb +50 -42
- data/lib/jss/ruby_extensions.rb +8 -7
- data/lib/jss/ruby_extensions/object.rb +19 -0
- data/lib/jss/utility.rb +82 -40
- data/lib/jss/version.rb +1 -1
- metadata +37 -68
- data/bin/jss-webhook-server +0 -3
- data/lib/jss/webhooks.rb +0 -53
- data/lib/jss/webhooks/README.md +0 -269
- data/lib/jss/webhooks/configuration.rb +0 -213
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation-executable +0 -91
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation.rb +0 -45
- data/lib/jss/webhooks/data/sample_jsons/ComputerAdded.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerCheckIn.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerInventoryCompleted.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerPolicyFinished.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerPushCapabilityChanged.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/JSSShutdown.json +0 -14
- data/lib/jss/webhooks/data/sample_jsons/JSSStartup.json +0 -14
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCheckIn.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCommandCompleted.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceEnrolled.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDevicePushSent.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceUnEnrolled.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/PatchSoftwareTitleUpdated.json +0 -14
- data/lib/jss/webhooks/data/sample_jsons/PushSent.json +0 -11
- data/lib/jss/webhooks/data/sample_jsons/RestAPIOperation.json +0 -15
- data/lib/jss/webhooks/data/sample_jsons/SCEPChallenge.json +0 -10
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupComputerMembershipChange.json +0 -13
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +0 -13
- data/lib/jss/webhooks/event.rb +0 -139
- data/lib/jss/webhooks/event/computer_added.rb +0 -38
- data/lib/jss/webhooks/event/computer_check_in.rb +0 -38
- data/lib/jss/webhooks/event/computer_inventory_completed.rb +0 -38
- data/lib/jss/webhooks/event/computer_policy_finished.rb +0 -38
- data/lib/jss/webhooks/event/computer_push_capability_changed.rb +0 -38
- data/lib/jss/webhooks/event/handlers.rb +0 -192
- data/lib/jss/webhooks/event/jss_shutdown.rb +0 -38
- data/lib/jss/webhooks/event/jss_startup.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_check_in.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_command_completed.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_enrolled.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_push_sent.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_unenrolled.rb +0 -38
- data/lib/jss/webhooks/event/patch_software_title_updated.rb +0 -38
- data/lib/jss/webhooks/event/push_sent.rb +0 -38
- data/lib/jss/webhooks/event/rest_api_operation.rb +0 -38
- data/lib/jss/webhooks/event/scep_challenge.rb +0 -38
- data/lib/jss/webhooks/event/smart_group_computer_membership_change.rb +0 -38
- data/lib/jss/webhooks/event/smart_group_mobile_device_membership_change.rb +0 -38
- data/lib/jss/webhooks/event/webhook.rb +0 -40
- data/lib/jss/webhooks/event_objects.rb +0 -112
- data/lib/jss/webhooks/event_objects/computer.rb +0 -49
- data/lib/jss/webhooks/event_objects/jss.rb +0 -36
- data/lib/jss/webhooks/event_objects/mobile_device.rb +0 -48
- data/lib/jss/webhooks/event_objects/patch_software_title_update.rb +0 -38
- data/lib/jss/webhooks/event_objects/push.rb +0 -33
- data/lib/jss/webhooks/event_objects/rest_api_operation.rb +0 -37
- data/lib/jss/webhooks/event_objects/scep_challenge.rb +0 -32
- data/lib/jss/webhooks/event_objects/smart_group.rb +0 -35
- data/lib/jss/webhooks/server_app.rb +0 -37
- data/lib/jss/webhooks/server_app/routes.rb +0 -27
- data/lib/jss/webhooks/server_app/routes/handle_webhook_event.rb +0 -39
- data/lib/jss/webhooks/server_app/routes/home.rb +0 -37
- data/lib/jss/webhooks/server_app/self_signed_cert.rb +0 -65
- data/lib/jss/webhooks/server_app/server.rb +0 -60
- data/lib/jss/webhooks/version.rb +0 -32
@@ -0,0 +1,21 @@
|
|
1
|
+
# This is just a stub for now.
|
2
|
+
|
3
|
+
#
|
4
|
+
module JSS
|
5
|
+
|
6
|
+
#
|
7
|
+
class MacApplication < APIObject
|
8
|
+
|
9
|
+
### The base for REST resources of this class
|
10
|
+
RSRC_BASE = 'macapplications'.freeze
|
11
|
+
|
12
|
+
### the hash key used for the JSON list output of all objects in the JSS
|
13
|
+
RSRC_LIST_KEY = :mac_applications
|
14
|
+
|
15
|
+
### The hash key used for the JSON object output.
|
16
|
+
### It's also used in various error messages
|
17
|
+
RSRC_OBJECT_KEY = :mac_application
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
### Copyright 2017 Pixar
|
2
2
|
|
3
|
-
###
|
3
|
+
###
|
4
4
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
5
|
### with the following modification; you may not use this file except in
|
6
6
|
### compliance with the Apache License and the following modification to it:
|
7
7
|
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
-
###
|
8
|
+
###
|
9
9
|
### 6. Trademarks. This License does not grant permission to use the trade
|
10
10
|
### names, trademarks, service marks, or product names of the Licensor
|
11
11
|
### and its affiliates, except as required to comply with Section 4(c) of
|
12
12
|
### the License and to reproduce the content of the NOTICE file.
|
13
|
-
###
|
13
|
+
###
|
14
14
|
### You may obtain a copy of the Apache License at
|
15
|
-
###
|
15
|
+
###
|
16
16
|
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
-
###
|
17
|
+
###
|
18
18
|
### Unless required by applicable law or agreed to in writing, software
|
19
19
|
### distributed under the Apache License with the above modification is
|
20
20
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
21
|
### KIND, either express or implied. See the Apache License for the specific
|
22
22
|
### language governing permissions and limitations under the Apache License.
|
23
|
-
###
|
23
|
+
###
|
24
24
|
###
|
25
25
|
|
26
26
|
###
|
@@ -185,6 +185,9 @@ module JSS
|
|
185
185
|
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
186
186
|
VALID_DATA_KEYS = [:device_name, :capacity, :tethered ]
|
187
187
|
|
188
|
+
### these keys, as well as :id and :name, can be used to look up objects of this class in the JSS
|
189
|
+
OTHER_LOOKUP_KEYS = [:udid, :serialnumber, :macaddress].freeze
|
190
|
+
|
188
191
|
### This class lets us seach for computers
|
189
192
|
SEARCH_CLASS = JSS::AdvancedMobileDeviceSearch
|
190
193
|
|
@@ -271,14 +274,21 @@ module JSS
|
|
271
274
|
### @return [Time] uses the value from the API's last_inventory_update_utc
|
272
275
|
attr_reader :last_inventory_update
|
273
276
|
|
277
|
+
### @return [Time] the last time this device enrolled in Jamf
|
278
|
+
attr_reader :last_enrollment
|
279
|
+
|
274
280
|
### @return [String] the locales
|
275
281
|
attr_reader :locales
|
276
282
|
|
277
283
|
### @return [Boolean] is this device managed?
|
278
284
|
attr_reader :managed
|
279
285
|
|
286
|
+
### @return [Boolean] is this device supervised?
|
287
|
+
attr_reader :supervised
|
288
|
+
|
280
289
|
### @return [String] the display name of the model
|
281
290
|
attr_reader :model_display
|
291
|
+
alias model model_display
|
282
292
|
|
283
293
|
### @return [String] the model identifier
|
284
294
|
attr_reader :model_identifier
|
@@ -297,7 +307,7 @@ module JSS
|
|
297
307
|
|
298
308
|
### @return [String] the serial numbee
|
299
309
|
attr_reader :serial_number
|
300
|
-
|
310
|
+
|
301
311
|
|
302
312
|
### @return [String] the site associated with this device
|
303
313
|
attr_reader :site
|
@@ -411,8 +421,10 @@ module JSS
|
|
411
421
|
@languages = gen[:languages]
|
412
422
|
@last_backup_time = JSS.epoch_to_time gen[:last_backup_time_epoch]
|
413
423
|
@last_inventory_update = JSS.epoch_to_time gen[:last_inventory_update_epoch]
|
424
|
+
@last_enrollment = JSS.epoch_to_time gen[:last_enrollment_epoch]
|
414
425
|
@locales = gen[:locales]
|
415
426
|
@managed = gen[:managed]
|
427
|
+
@supervised = gen[:supervised]
|
416
428
|
@model_display = gen[:model_display]
|
417
429
|
@model_identifier = gen[:model_identifier]
|
418
430
|
@modem_firmware = gen[:modem_firmware]
|
@@ -427,10 +439,6 @@ module JSS
|
|
427
439
|
@udid = gen[:udid]
|
428
440
|
@wifi_mac_address = gen[:wifi_mac_address]
|
429
441
|
|
430
|
-
parse_location
|
431
|
-
parse_purchasing
|
432
|
-
parse_ext_attrs
|
433
|
-
|
434
442
|
@mobile_device_groups = @init_data[:mobile_device_groups]
|
435
443
|
@network = @init_data[:network]
|
436
444
|
@extension_attributes = @init_data[:extension_attributes]
|
@@ -438,6 +446,7 @@ module JSS
|
|
438
446
|
@configuration_profiles = @init_data[:configuration_profiles]
|
439
447
|
@provisioning_profiles = @init_data[:provisioning_profiles]
|
440
448
|
@security = @init_data[:security]
|
449
|
+
@applications = @init_data[:applications]
|
441
450
|
|
442
451
|
end # initialize
|
443
452
|
|
@@ -451,7 +460,7 @@ module JSS
|
|
451
460
|
def blank_push
|
452
461
|
self.class.send_mdm_command @id, :blank_push
|
453
462
|
end
|
454
|
-
|
463
|
+
|
455
464
|
|
456
465
|
|
457
466
|
###
|
@@ -475,7 +484,7 @@ module JSS
|
|
475
484
|
def device_lock
|
476
485
|
self.class.send_mdm_command @id, :device_lock
|
477
486
|
end
|
478
|
-
|
487
|
+
|
479
488
|
|
480
489
|
###
|
481
490
|
### Send an erase_device MDM command
|
@@ -487,7 +496,7 @@ module JSS
|
|
487
496
|
def erase_device
|
488
497
|
self.class.send_mdm_command @id, :erase_device
|
489
498
|
end
|
490
|
-
|
499
|
+
|
491
500
|
|
492
501
|
###
|
493
502
|
### Send a clear_passcode MDM command
|
@@ -510,14 +519,14 @@ module JSS
|
|
510
519
|
def unmanage_device
|
511
520
|
@managed = false if self.class.send_mdm_command(@id, :unmanage_device)
|
512
521
|
end
|
513
|
-
|
514
|
-
|
522
|
+
|
523
|
+
|
515
524
|
### Aliases
|
516
525
|
alias battery_percent battery_level
|
517
526
|
alias managed? managed
|
518
527
|
alias sn serial_number
|
519
528
|
alias serialnumber serial_number
|
520
|
-
|
529
|
+
|
521
530
|
alias noop blank_push
|
522
531
|
alias send_blank_push blank_push
|
523
532
|
alias recon update_inventory
|
@@ -527,10 +536,10 @@ module JSS
|
|
527
536
|
alias wipe erase_device
|
528
537
|
alias unmanage unmanage_device
|
529
538
|
alias make_unmanaged unmanage_device
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
534
543
|
##############################
|
535
544
|
# private methods
|
536
545
|
##############################
|
@@ -0,0 +1,447 @@
|
|
1
|
+
### Copyright 2017 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
###
|
27
|
+
module JSS
|
28
|
+
|
29
|
+
# Module Variables
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
# Module Methods
|
33
|
+
#####################################
|
34
|
+
|
35
|
+
# Classes
|
36
|
+
#####################################
|
37
|
+
|
38
|
+
# A Mobile Device Application in the JSS
|
39
|
+
#
|
40
|
+
class MobileDeviceApplication < JSS::APIObject
|
41
|
+
|
42
|
+
# Mix-Ins
|
43
|
+
#####################################
|
44
|
+
include JSS::Creatable
|
45
|
+
include JSS::Updatable
|
46
|
+
include JSS::Scopable
|
47
|
+
include JSS::SelfServable
|
48
|
+
include JSS::Categorizable
|
49
|
+
include JSS::Uploadable
|
50
|
+
include JSS::VPPable
|
51
|
+
|
52
|
+
# Class Methods
|
53
|
+
#####################################
|
54
|
+
|
55
|
+
# Class Constants
|
56
|
+
#####################################
|
57
|
+
|
58
|
+
# The base for REST resources of this class
|
59
|
+
RSRC_BASE = 'mobiledeviceapplications'.freeze
|
60
|
+
|
61
|
+
# the hash key used for the JSON list output of all objects in the JSS
|
62
|
+
RSRC_LIST_KEY = :mobile_device_applications
|
63
|
+
|
64
|
+
# The hash key used for the JSON object output.
|
65
|
+
# It's also used in various error messages
|
66
|
+
RSRC_OBJECT_KEY = :mobile_device_application
|
67
|
+
|
68
|
+
# these keys, as well as :id and :name, are present in valid API JSON data for this class
|
69
|
+
VALID_DATA_KEYS = [:internal_app].freeze
|
70
|
+
|
71
|
+
# See JSS::Scopable
|
72
|
+
SCOPE_TARGET_KEY = :mobile_devices
|
73
|
+
|
74
|
+
# see JSS::Uploadable
|
75
|
+
UPLOAD_TYPES = {
|
76
|
+
icon: :mobiledeviceapplicationsicon,
|
77
|
+
app: :mobiledeviceapplicationsipa,
|
78
|
+
attachment: :mobiledeviceapplications
|
79
|
+
}.freeze
|
80
|
+
|
81
|
+
# Attributes
|
82
|
+
#####################################
|
83
|
+
|
84
|
+
# NOTE: the API data contains an :icon hash in the :general subsection
|
85
|
+
# but it appears to be redundant with the one in the :self_service subsection.
|
86
|
+
# When an icon is uploaded with Uploadable, both arae changed.
|
87
|
+
# Also, mobiledeviceapplications are the only objects with such a 'top-level'
|
88
|
+
# icon, any other objects with icons keep the icon data in :self_service.
|
89
|
+
# As such, all icon handling for this class is done in the SelfServable module
|
90
|
+
|
91
|
+
|
92
|
+
# @return [String] The user-facing name (i.e. in self service)
|
93
|
+
attr_reader :display_name
|
94
|
+
|
95
|
+
# @return [String]
|
96
|
+
attr_reader :description
|
97
|
+
|
98
|
+
# @return [String] e.g. com.company.appname
|
99
|
+
attr_reader :bundle_id
|
100
|
+
|
101
|
+
# @return [String]
|
102
|
+
attr_reader :version
|
103
|
+
|
104
|
+
# @return [Boolean]
|
105
|
+
attr_reader :internal_app
|
106
|
+
|
107
|
+
# @return [Hash] The .ipa file info
|
108
|
+
attr_reader :ipa
|
109
|
+
|
110
|
+
# @return [Hash] The provisioning profile info for this app
|
111
|
+
attr_reader :provisioning_profile
|
112
|
+
|
113
|
+
# @return [String] The URL for downloading this app
|
114
|
+
attr_reader :url
|
115
|
+
|
116
|
+
# @return [String] The URL of this item in the iTunes store, if applicable
|
117
|
+
attr_reader :itunes_store_url
|
118
|
+
|
119
|
+
# @return [Boolean] Will this still appear in SelfSvc after installation (I think)
|
120
|
+
attr_reader :make_available_after_install
|
121
|
+
alias self_service_make_available_after_install make_available_after_install
|
122
|
+
|
123
|
+
# @return [String] The app's country/region code in the iTunes store
|
124
|
+
attr_reader :itunes_country_region
|
125
|
+
|
126
|
+
# @return [Integer] The last time the app and data was synced from iTunes (I think)
|
127
|
+
attr_reader :itunes_sync_time
|
128
|
+
|
129
|
+
# @return [Boolean] Should this app be mananged?
|
130
|
+
attr_reader :deploy_as_managed_app
|
131
|
+
|
132
|
+
# @return [Boolean] Should the app be removed when the device is unmanaged?
|
133
|
+
attr_reader :remove_app_when_mdm_profile_is_removed
|
134
|
+
|
135
|
+
# @return [Boolean] Should this app be able to backup its data when the device
|
136
|
+
# does its backups (to icloud or itunes)?
|
137
|
+
attr_reader :prevent_backup_of_app_data
|
138
|
+
|
139
|
+
# @return [Boolean] should the JSS update the icon and description from the app
|
140
|
+
# source?
|
141
|
+
attr_reader :keep_description_and_icon_up_to_date
|
142
|
+
|
143
|
+
# @return [Boolean] is this a free app?
|
144
|
+
attr_reader :free
|
145
|
+
alias free? free
|
146
|
+
|
147
|
+
# @return [Boolean] If the user installs this app on their own, should Jamf
|
148
|
+
# take over managing it?
|
149
|
+
attr_reader :take_over_management
|
150
|
+
|
151
|
+
# @return [Boolean] Does the app itself come from outside the JSS?
|
152
|
+
attr_reader :host_externally
|
153
|
+
|
154
|
+
# @return [String] If :host_externally is true, the URL for the app
|
155
|
+
attr_reader :external_url
|
156
|
+
|
157
|
+
# @return [String] Pre-configuration data for installing the app.
|
158
|
+
# Currently there's only one key in the :configuration hash, :preferences,
|
159
|
+
# which contains a plist <dict> element with config data.
|
160
|
+
attr_reader :configuration_prefs
|
161
|
+
|
162
|
+
|
163
|
+
# Constructor
|
164
|
+
#####################################
|
165
|
+
|
166
|
+
#
|
167
|
+
# See JSS::APIObject#initialize
|
168
|
+
#
|
169
|
+
def initialize(args)
|
170
|
+
super
|
171
|
+
general = @init_data[:general]
|
172
|
+
@display_name = general[:display_name]
|
173
|
+
@description = general[:description]
|
174
|
+
@bundle_id = general[:bundle_id] # TODO: does this get set automatically when uploading a .ipa?
|
175
|
+
@version = general[:version] # TODO: does this get set automatically when uploading a .ipa?
|
176
|
+
@ipa = general[:ipa]
|
177
|
+
@provisioning_profile = general[:provisioning_profile]
|
178
|
+
@url = general[:url]
|
179
|
+
@itunes_store_url = general[:itunes_store_url]
|
180
|
+
@make_available_after_install = general[:make_available_after_install]
|
181
|
+
@itunes_country_region = general[:itunes_country_region]
|
182
|
+
@itunes_sync_time = general[:itunes_sync_time]
|
183
|
+
@deploy_as_managed_app = general[:deploy_as_managed_app]
|
184
|
+
@remove_app_when_mdm_profile_is_removed = general[:remove_app_when_mdm_profile_is_removed]
|
185
|
+
@prevent_backup_of_app_data = general[:prevent_backup_of_app_data]
|
186
|
+
@keep_description_and_icon_up_to_date = general[:keep_description_and_icon_up_to_date]
|
187
|
+
@free = general[:free]
|
188
|
+
@take_over_management = general[:take_over_management]
|
189
|
+
@host_externally = general[:host_externally]
|
190
|
+
@external_url = general[:external_url]
|
191
|
+
@configuration_prefs = @init_data[:app_configuration][:preferences]
|
192
|
+
end
|
193
|
+
|
194
|
+
# Public Instance Methods
|
195
|
+
#####################################
|
196
|
+
|
197
|
+
# Setters
|
198
|
+
################
|
199
|
+
|
200
|
+
# Set the display_name
|
201
|
+
#
|
202
|
+
# @param new_val[#to_s] The new value
|
203
|
+
#
|
204
|
+
# @return [void]
|
205
|
+
#
|
206
|
+
def display_name=(new_val)
|
207
|
+
return nil if new_val.to_s == @display_name
|
208
|
+
@display_name = new_val.to_s
|
209
|
+
@need_to_update = true
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
# Set the description
|
214
|
+
#
|
215
|
+
# @param new_val[String] The new value
|
216
|
+
#
|
217
|
+
# @return [void]
|
218
|
+
#
|
219
|
+
def description=(new_val)
|
220
|
+
return nil if new_val.to_s == @description
|
221
|
+
@description = new_val.to_s
|
222
|
+
@need_to_update = true
|
223
|
+
end
|
224
|
+
|
225
|
+
# Set the url
|
226
|
+
#
|
227
|
+
# @param new_val[String] The new value
|
228
|
+
#
|
229
|
+
# @return [void]
|
230
|
+
#
|
231
|
+
def url=(new_val)
|
232
|
+
return nil if new_val == @url
|
233
|
+
@url = new_val
|
234
|
+
@need_to_update = true
|
235
|
+
end
|
236
|
+
|
237
|
+
# Set whether or not this app should be available
|
238
|
+
# in Self Service after being installed. (e.g. for removal)
|
239
|
+
#
|
240
|
+
# @param new_val[Boolean] The new value
|
241
|
+
#
|
242
|
+
# @return [void]
|
243
|
+
#
|
244
|
+
def make_available_after_install=(new_val)
|
245
|
+
return nil if new_val == @make_available_after_install
|
246
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
247
|
+
@make_available_after_install = new_val
|
248
|
+
@need_to_update = true
|
249
|
+
end
|
250
|
+
alias self_service_make_available_after_install= make_available_after_install=
|
251
|
+
|
252
|
+
# Set whether or not this app should be deployed as managed
|
253
|
+
#
|
254
|
+
# @param new_val[Boolean] The new value
|
255
|
+
#
|
256
|
+
# @return [void]
|
257
|
+
#
|
258
|
+
def deploy_as_managed_app=(new_val)
|
259
|
+
return nil if new_val == @deploy_as_managed_app
|
260
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
261
|
+
@deploy_as_managed_app = new_val
|
262
|
+
@need_to_update = true
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
# Set whether or not this app should be removed when
|
267
|
+
# the device is unmanaged
|
268
|
+
#
|
269
|
+
# @param new_val[Boolean] The new value
|
270
|
+
#
|
271
|
+
# @return [void]
|
272
|
+
#
|
273
|
+
def remove_app_when_mdm_profile_is_removed=(new_val)
|
274
|
+
return nil if new_val == @remove_app_when_mdm_profile_is_removed
|
275
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
276
|
+
@remove_app_when_mdm_profile_is_removed = new_val
|
277
|
+
@need_to_update = true
|
278
|
+
end
|
279
|
+
|
280
|
+
# Set whether or not the device should back up this app's data
|
281
|
+
#
|
282
|
+
# @param new_val[Boolean] The new value
|
283
|
+
#
|
284
|
+
# @return [void]
|
285
|
+
#
|
286
|
+
def prevent_backup_of_app_data=(new_val)
|
287
|
+
return nil if new_val == @prevent_backup_of_app_data
|
288
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
289
|
+
@prevent_backup_of_app_data = new_val
|
290
|
+
@need_to_update = true
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
# Set whether or not the jss should update info about this app from the app store
|
295
|
+
#
|
296
|
+
# @param new_val[Boolean] The new value
|
297
|
+
#
|
298
|
+
# @return [void]
|
299
|
+
#
|
300
|
+
def keep_description_and_icon_up_to_date=(new_val)
|
301
|
+
return nil if new_val == @keep_description_and_icon_up_to_date
|
302
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
303
|
+
@keep_description_and_icon_up_to_date = new_val
|
304
|
+
@need_to_update = true
|
305
|
+
end
|
306
|
+
|
307
|
+
# Set whether or not this is a free app
|
308
|
+
#
|
309
|
+
# @param new_val[Boolean] The new value
|
310
|
+
#
|
311
|
+
# @return [void]
|
312
|
+
#
|
313
|
+
def free=(new_val)
|
314
|
+
return nil if new_val == @free
|
315
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
316
|
+
@free = new_val
|
317
|
+
@need_to_update = true
|
318
|
+
end
|
319
|
+
|
320
|
+
# Set whether or not Jamf should manage this app even if the user installed
|
321
|
+
# it on their own.
|
322
|
+
#
|
323
|
+
# @param new_val[Boolean] The new value
|
324
|
+
#
|
325
|
+
# @return [void]
|
326
|
+
#
|
327
|
+
def take_over_management=(new_val)
|
328
|
+
return nil if new_val == @take_over_management
|
329
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
330
|
+
@take_over_management = new_val
|
331
|
+
@need_to_update = true
|
332
|
+
end
|
333
|
+
|
334
|
+
# Set whether or not this app's .ipa is hosted outside the Jamf server
|
335
|
+
#
|
336
|
+
# @param new_val[Boolean] The new value
|
337
|
+
#
|
338
|
+
# @return [void]
|
339
|
+
#
|
340
|
+
def host_externally=(new_val)
|
341
|
+
return nil if new_val == @host_externally
|
342
|
+
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
|
343
|
+
@host_externally = new_val
|
344
|
+
@need_to_update = true
|
345
|
+
end
|
346
|
+
|
347
|
+
# Set the url to use for the app if host_externally is true
|
348
|
+
#
|
349
|
+
# @param new_val[String] The new value
|
350
|
+
#
|
351
|
+
# @return [void]
|
352
|
+
#
|
353
|
+
def external_url=(new_val)
|
354
|
+
return nil if new_val == @external_url
|
355
|
+
@external_url = new_val
|
356
|
+
@need_to_update = true
|
357
|
+
end
|
358
|
+
|
359
|
+
# Set the configuration prefs for this app. The value
|
360
|
+
# must be a <dict> element from a plist
|
361
|
+
#
|
362
|
+
# @param new_val[String] The new value
|
363
|
+
#
|
364
|
+
# @return [void]
|
365
|
+
#
|
366
|
+
def configuration_prefs=(new_val)
|
367
|
+
return nil if new_val == @configuration_prefs
|
368
|
+
@configuration_prefs = new_val
|
369
|
+
@need_to_update = true
|
370
|
+
end
|
371
|
+
|
372
|
+
|
373
|
+
# Save the application to a file.
|
374
|
+
#
|
375
|
+
# @param path[Pathname, String] The path to which the file should be saved.
|
376
|
+
# If the path given is an existing directory, the ipa's current filename will
|
377
|
+
# be used, if known.
|
378
|
+
#
|
379
|
+
# @param overwrite[Boolean] Overwrite the file if it exists? Defaults to false
|
380
|
+
#
|
381
|
+
# @return [void]
|
382
|
+
#
|
383
|
+
def save_ipa(path, overwrite = false)
|
384
|
+
return nil unless @ipa[:data]
|
385
|
+
path = Pathname.new path
|
386
|
+
path = path + @ipa[:name] if path.directory? && @ipa[:name]
|
387
|
+
|
388
|
+
raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? && !overwrite
|
389
|
+
path.delete if path.exist?
|
390
|
+
path.jss_save Base64.decode64(@ipa[:data])
|
391
|
+
end
|
392
|
+
|
393
|
+
# Upload a new app .ipa file
|
394
|
+
#
|
395
|
+
# @param path[String, Pathname] The path to the .ipa file to upload
|
396
|
+
#
|
397
|
+
# @return [void]
|
398
|
+
#
|
399
|
+
def upload_ipa(path)
|
400
|
+
new_ipa = Pathname.new path
|
401
|
+
upload(:app, new_icon)
|
402
|
+
refresh_ipa
|
403
|
+
end
|
404
|
+
|
405
|
+
# Private Instance Methods
|
406
|
+
###########################################
|
407
|
+
private
|
408
|
+
|
409
|
+
# Re-read the ipa data from the API.
|
410
|
+
#
|
411
|
+
# @return [Type] description_of_returned_object
|
412
|
+
#
|
413
|
+
def refresh_ipa
|
414
|
+
return nil unless @in_jss
|
415
|
+
fresh_data = JSS::API.get_rsrc(@rest_rsrc)[self.class::RSRC_OBJECT_KEY]
|
416
|
+
@ipa = fresh_data[:general][:ipa]
|
417
|
+
end
|
418
|
+
|
419
|
+
def rest_xml
|
420
|
+
doc = REXML::Document.new JSS::APIConnection::XML_HEADER
|
421
|
+
obj = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
|
422
|
+
gen = obj.add_element 'general'
|
423
|
+
gen.add_element('display_name').text = @display_name
|
424
|
+
gen.add_element('description').text = @description
|
425
|
+
gen.add_element('url').text = @url
|
426
|
+
gen.add_element('make_available_after_install').text = @make_available_after_install
|
427
|
+
gen.add_element('deploy_as_managed_app').text = @deploy_as_managed_app
|
428
|
+
gen.add_element('remove_app_when_mdm_profile_is_removed').text = @remove_app_when_mdm_profile_is_removed
|
429
|
+
gen.add_element('prevent_backup_of_app_data').text = @prevent_backup_of_app_data
|
430
|
+
gen.add_element('keep_description_and_icon_up_to_date').text = @keep_description_and_icon_up_to_date
|
431
|
+
gen.add_element('free').text = @free
|
432
|
+
gen.add_element('take_over_management').text = @take_over_management
|
433
|
+
gen.add_element('host_externally').text = @host_externally
|
434
|
+
gen.add_element('external_url').text = @external_url
|
435
|
+
config = gen.add_element('configuration')
|
436
|
+
config.add_element('preferences').text = @configuration_prefs
|
437
|
+
obj << @scope.scope_xml
|
438
|
+
add_category_to_xml doc
|
439
|
+
add_self_service_xml doc
|
440
|
+
add_vpp_xml doc
|
441
|
+
doc.to_s
|
442
|
+
end
|
443
|
+
|
444
|
+
|
445
|
+
end # class removable_macaddr
|
446
|
+
|
447
|
+
end # module
|