ruby-jss 0.11.0 → 0.12.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e1e01930e47278eee17c14081df08c2539ff96
4
- data.tar.gz: 47d512909b8cd7ef896df540dc522961bb0f8547
3
+ metadata.gz: 0fd7571a4225c7255724e6de59c0fb44e6bd595b
4
+ data.tar.gz: fb5de557c051ae61c7993db97590195b76fa6a30
5
5
  SHA512:
6
- metadata.gz: 7e8e425f0f20337f85c915e1cc9ac8526325bc2b031f78575985de81ae4573b35fdb2b1aeefd2e2b869e594b0df0238f298693e9ac31aaa9dcca34d22c9e9290
7
- data.tar.gz: 854d85d68651dbaf22becbb6b14be2cb3734eb1943b7e1c375fbad2caa19300134490d70673660a380021848021d61ea6ad4645947145d23af4876bb46a8aca6
6
+ metadata.gz: f8ca00b8718f58bad9529b5742964c8c0c19dcfb145ed97ad30e4b2c9b9ff69fcab44fa09fe32207671c56bafd181e0c3d10d1dbcba30f599b11471ba8a4002a
7
+ data.tar.gz: 8ee7f5f01cf030dd356210e52f69b5cbcc0e231736412b0678755f6fc2ddc667d7bf47bb4c1694e8b70fa6eb234b3e41bc00a2fd2b92a7128a83396d0a65b79c
data/CHANGES.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change History
2
2
 
3
+ ## v 0.12.0, 2018-04-16
4
+
5
+ - Simplification: when building .pkg's with JSS::Composer.mk_pkg, only two params are related to Package Signing: 'signing_identity:' the name of the signing identity to use, and and 'signing_options:' a string of all other signing-related CLI options that will be passed to the pkgbuild command, e.g. keychain locations, timestamps, certs, etc. For details, see `man pkgbuild`
6
+
7
+ - Improvement: Now augmenting ruby Hashes with an embeded 'recursive-open-struct' version of themselves. This simplifies accessing values from deeply-nested Hash structures, e.g. JSS::Computer#hardware instead of `computer_instance.hardware[:storage].first[:partition][:percentage_full]` you can do `computer_instance.hardware.jss_ros.storage.first.partition.percentage_full`. See http://www.rubydoc.info/gems/ruby-jss/Hash for details. Uses the [recursive-open-struct gem](https://github.com/aetherknight/recursive-open-struct).
8
+
9
+ - Add: The computerapplications/application endpoint is now implemented as the JSS::Computer.application_installs class method so you can query lists of computers that have certain apps installed.
10
+
11
+ - Improvement: the JSS::Computer class is now defined in multiple files. The single computer.rb file was getting far to unwieldy.
12
+
13
+ - Fix: Setting the first icon of a newly-created JSS::Policy now works. Thanks @christopher.kemp for reporting this one
14
+
15
+ - Add: JSS::MobileDeviceConfigurationProfile is now more fleshed-out and is Updatable.
16
+
17
+ - Improvement: JSS::MobileDeviceConfigurationProfile and JSS::OSXConfigurationProfile now share an abstract parent class, JSS::ConfigurationProfile, containing common code.
18
+
19
+ - Fix: the SelfServable module was mis-handling 'user-removability' data for config profiles.
20
+
21
+ - Fix: Typo and missing method alias, caught by csfjeff @ github, issue #23
22
+
3
23
  ## v 0.11.0, 2018-03-12
4
24
 
5
25
  - Fix: NoMethod error when saving JSS::Policy was due to a typo in a method call.
@@ -7,7 +27,7 @@
7
27
  - Fix: Initialization of Creatable objects using certain mixins (Extendable, Sitable, Categorizable) either failed, or errored when trying to set their values. Now fixed. Thanks @mylescarrick for reporting this one.
8
28
 
9
29
  - Improvement: Updated general attributes for computers and mobile devices
10
-
30
+ s
11
31
  - Improvement: Computers and MobileDevices are now Creatable. Use the .make class method to create an unsaved instance, then .create/.save instance method to create the JSS record. Note: Mobile Devices need both a unique serial number and unique udid to be accepted by the API.
12
32
 
13
33
  - Improvement: Handling of 'site' data is now done via the JSS::Sitable mixin module
data/lib/jss.rb CHANGED
@@ -53,13 +53,14 @@ module JSS
53
53
  require 'yaml'
54
54
  require 'open3'
55
55
  require 'English'
56
+ require 'json'
56
57
 
57
58
  ###################
58
59
  ### Gems
59
60
  require 'rest-client'
60
- require 'json'
61
61
  require 'plist'
62
62
  require 'immutable-struct'
63
+ require 'recursive-open-struct'
63
64
 
64
65
  ### Constants
65
66
  #####################################
@@ -100,8 +101,6 @@ module JSS
100
101
 
101
102
  module Composer; end
102
103
 
103
-
104
-
105
104
  ### Mix-in Sub Modules with Classes
106
105
 
107
106
  module Criteriable
@@ -117,11 +116,12 @@ module JSS
117
116
 
118
117
  class APIObject; end
119
118
  class APIConnection; end
120
- class Client; end
121
119
  class DBConnection; end
122
120
  class Server; end
123
121
  class Icon; end
124
122
  class Preferences; end
123
+ class Client; end
124
+
125
125
 
126
126
  ### SubClasses
127
127
  #####################################
@@ -143,6 +143,10 @@ module JSS
143
143
  class MobileDeviceGroup < JSS::Group; end
144
144
  class UserGroup < JSS::Group; end
145
145
 
146
+ class ConfigurationProfile < JSS::APIObject; end
147
+ class OSXConfigurationProfile < JSS::ConfigurationProfile; end
148
+ class MobileDeviceConfigurationProfile < JSS::ConfigurationProfile; end
149
+
146
150
  ### APIObject Classes without SubClasses
147
151
 
148
152
  class Account < JSS::APIObject; end
@@ -155,11 +159,9 @@ module JSS
155
159
  class LDAPServer < JSS::APIObject; end
156
160
  class MacApplication < JSS::APIObject; end
157
161
  class MobileDevice < JSS::APIObject; end
158
- class MobileDeviceConfigurationProfile < JSS::APIObject; end
159
162
  class MobileDeviceApplication < JSS::APIObject; end
160
163
  class NetBootServer < JSS::APIObject; end
161
164
  class NetworkSegment < JSS::APIObject; end
162
- class OSXConfigurationProfile < JSS::APIObject; end
163
165
  class Package < JSS::APIObject; end
164
166
  class Patch < JSS::APIObject; end
165
167
  class PatchPolicy < JSS::APIObject; end
@@ -1142,6 +1142,7 @@ require 'jss/api_object/scopable'
1142
1142
 
1143
1143
  ### APIObject SubClasses with SubClasses
1144
1144
  require 'jss/api_object/advanced_search'
1145
+ require 'jss/api_object/configuration_profile'
1145
1146
  require 'jss/api_object/extension_attribute'
1146
1147
  require 'jss/api_object/group'
1147
1148
 
@@ -1158,10 +1159,8 @@ require 'jss/api_object/ldap_server'
1158
1159
  require 'jss/api_object/mac_application'
1159
1160
  require 'jss/api_object/mobile_device'
1160
1161
  require 'jss/api_object/mobile_device_application'
1161
- require 'jss/api_object/mobile_device_configuration_profile'
1162
1162
  require 'jss/api_object/netboot_server'
1163
1163
  require 'jss/api_object/network_segment'
1164
- require 'jss/api_object/osx_configuration_profile'
1165
1164
  require 'jss/api_object/package'
1166
1165
  require 'jss/api_object/patch'
1167
1166
  require 'jss/api_object/patch_policy'
@@ -482,7 +482,7 @@ module JSS
482
482
  # A subset of management data for a given computer.
483
483
  # This private method is called by self.management_data, q.v.
484
484
  #
485
- def self.management_data_subset(id, subset: nil, only: nil, api: JSS.api)
485
+ def self.management_data_subset(id, subset: nil, only: nil, api: JSS.api)
486
486
  raise "Subset must be one of :#{MGMT_DATA_SUBSETS.join ', :'}" unless MGMT_DATA_SUBSETS.include? subset
487
487
  subset_rsrc = MGMT_DATA_RSRC + "/id/#{id}/subset/#{subset}"
488
488
  subset_data = api.get_rsrc(subset_rsrc)[MGMT_DATA_KEY]
@@ -497,7 +497,6 @@ module JSS
497
497
  # identifiers
498
498
  ################
499
499
 
500
-
501
500
  # @return [String] the secondary mac address
502
501
  attr_reader :alt_mac_address
503
502
 
@@ -505,7 +504,7 @@ module JSS
505
504
  attr_reader :asset_tag
506
505
 
507
506
  # @return [String] the barcodes
508
- attr_reader :barcode_1, :barcode_2
507
+ attr_reader :barcode1, :barcode2
509
508
 
510
509
  # @return [String] The name of the distribution point for this computer
511
510
  attr_reader :distribution_point
@@ -736,10 +735,19 @@ module JSS
736
735
  def initialize(args = {})
737
736
  super args
738
737
  if @in_jss
738
+
739
+ # mutable stuff
739
740
  @alt_mac_address = @init_data[:general][:alt_mac_address]
740
741
  @asset_tag = @init_data[:general][:asset_tag]
741
- @barcode_1 = @init_data[:general][:barcode_1]
742
- @barcode_2 = @init_data[:general][:barcode_2]
742
+ @barcode1 = @init_data[:general][:barcode_1]
743
+ @barcode2 = @init_data[:general][:barcode_2]
744
+ @mac_address = @init_data[:general][:mac_address]
745
+ @managed = @init_data[:general][:remote_management][:managed]
746
+ @management_username = @init_data[:general][:remote_management][:management_username]
747
+ @serial_number = @init_data[:general][:serial_number]
748
+ @udid = @init_data[:general][:udid]
749
+
750
+ # immutable single-values
743
751
  @distribution_point = @init_data[:general][:distribution_point]
744
752
  @initial_entry_date = JSS.epoch_to_time @init_data[:general][:initial_entry_date_epoch]
745
753
  @last_enrolled = JSS.epoch_to_time @init_data[:general][:last_enrolled_date_epoch]
@@ -747,18 +755,12 @@ module JSS
747
755
  @itunes_store_account_is_active = @init_data[:general][:itunes_store_account_is_active]
748
756
  @jamf_version = @init_data[:general][:jamf_version]
749
757
  @last_contact_time = JSS.epoch_to_time @init_data[:general][:last_contact_time_epoch]
750
- @mac_address = @init_data[:general][:mac_address]
751
- @managed = @init_data[:general][:remote_management][:managed]
752
- @management_username = @init_data[:general][:remote_management][:management_username]
753
758
  @mdm_capable = @init_data[:general][:mdm_capable]
754
759
  @mdm_capable_users = @init_data[:general][:mdm_capable_users].values
755
760
  @netboot_server = @init_data[:general][:netboot_server]
756
761
  @platform = @init_data[:general][:platform]
757
762
  @report_date = JSS.epoch_to_time @init_data[:general][:report_date_epoch]
758
- @serial_number = @init_data[:general][:serial_number]
759
- @site = JSS::APIObject.get_name(@init_data[:general][:site])
760
763
  @sus = @init_data[:general][:sus]
761
- @udid = @init_data[:general][:udid]
762
764
 
763
765
  @configuration_profiles = @init_data[:configuration_profiles]
764
766
  @certificates = @init_data[:certificates]
@@ -767,6 +769,16 @@ module JSS
767
769
  @peripherals = @init_data[:peripherals]
768
770
  @software = @init_data[:software]
769
771
 
772
+ # Freeze immutable things.
773
+ # These are updated via recon, and aren't sent
774
+ # with #update, so changing them here is meaningless anyway.
775
+ @configuration_profiles.freeze
776
+ @certificates.freeze
777
+ @groups_accounts.freeze
778
+ @hardware.freeze
779
+ @peripherals.freeze
780
+ @software.freeze
781
+
770
782
  @management_password = nil
771
783
  else
772
784
  @udid = args[:udid]
@@ -774,8 +786,8 @@ module JSS
774
786
  @asset_tag = args[:asset_tag]
775
787
  @mac_address = args[:mac_address]
776
788
  @alt_mac_address = args[:alt_mac_address]
777
- @barcode_1 = args[:barcode_1]
778
- @barcode_2 = args[:barcode_2]
789
+ @barcode1 = args[:barcode_1]
790
+ @barcode2 = args[:barcode_2]
779
791
  end
780
792
  end # initialize
781
793
 
@@ -953,18 +965,18 @@ module JSS
953
965
  end
954
966
 
955
967
  #
956
- def barcode_1=(new_val)
957
- return nil if @barcode_1 == new_val
968
+ def barcode1=(new_val)
969
+ return nil if @barcode1 == new_val
958
970
  new_val.strip!
959
- @barcode_1 = new_val
971
+ @barcode1 = new_val
960
972
  @need_to_update = true
961
973
  end
962
974
 
963
975
  #
964
- def barcode_2=(new_val)
965
- return nil if @barcode_2 == new_val
976
+ def barcode2=(new_val)
977
+ return nil if @barcode2 == new_val
966
978
  new_val.strip!
967
- @barcode_2 = new_val
979
+ @barcode2 = new_val
968
980
  @need_to_update = true
969
981
  end
970
982
 
@@ -1021,8 +1033,8 @@ module JSS
1021
1033
  super
1022
1034
  @alt_mac_address = nil
1023
1035
  @asset_tag = nil
1024
- @barcode_1 = nil
1025
- @barcode_2 = nil
1036
+ @barcode1 = nil
1037
+ @barcode2 = nil
1026
1038
  @distribution_point = nil
1027
1039
  @initial_entry_date = nil
1028
1040
  @ip_address = nil
@@ -1060,8 +1072,14 @@ module JSS
1060
1072
 
1061
1073
  # aliases
1062
1074
  alias alt_macaddress alt_mac_address
1063
- alias bar_code_1 barcode_1
1064
- alias bar_code_2 barcode_2
1075
+ alias bar_code_1 barcode1
1076
+ alias bar_code_2 barcode2
1077
+ alias barcode_1 barcode1
1078
+ alias barcode_2 barcode2
1079
+ alias bar_code_1= barcode1=
1080
+ alias bar_code_2= barcode2=
1081
+ alias barcode_1= barcode1=
1082
+ alias barcode_2= barcode2=
1065
1083
  alias managed? managed
1066
1084
  alias mdm? mdm_capable
1067
1085
  alias last_recon report_date
@@ -1090,8 +1108,8 @@ module JSS
1090
1108
  general.add_element('name').text = @name
1091
1109
  general.add_element('alt_mac_address').text = @alt_mac_address
1092
1110
  general.add_element('asset_tag').text = @asset_tag
1093
- general.add_element('barcode_1').text = @barcode_1
1094
- general.add_element('barcode_2').text = @barcode_2
1111
+ general.add_element('barcode_1').text = @barcode1
1112
+ general.add_element('barcode_2').text = @barcode2
1095
1113
  general.add_element('ip_address').text = @ip_address
1096
1114
  general.add_element('mac_address').text = @mac_address
1097
1115
  general.add_element('udid').text = @udid
@@ -1116,3 +1134,5 @@ module JSS
1116
1134
  end # class Computer
1117
1135
 
1118
1136
  end # module
1137
+
1138
+ require 'jss/api_object/computer/application_installs'
@@ -0,0 +1,119 @@
1
+ # Copyright 2018 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
+ # This file implements the 'computerapplications' API endpoint, used
30
+ # for searching for computers with certain applications installed.
31
+ #
32
+ # All the methods defined here are class methods on JSS::Computer
33
+ # since they all return lists of computers and apps.
34
+ #
35
+ # The apps installed on a JSS::Computer instance are available via the
36
+ # #apps instance method (a shortcut that looks into the 'software' subset)
37
+ #
38
+
39
+ #
40
+ class Computer < JSS::APIObject
41
+
42
+ COMPUTER_APPLICATIONS_RSRC = 'computerapplications/application'.freeze
43
+
44
+ # Query the JSS for computers with some app installed. An app name is required
45
+ # as the first parameter.
46
+ #
47
+ # If no other parameters are given, returns a Hash, one key per version of the
48
+ # app. For each version there is an array of Hashes, one Hash for each
49
+ # computer with that version. The sub hashes contain keys for the computer's
50
+ # identifiers, i.e. :name, :id, :udid, :serial_number, :mac_address.
51
+ #
52
+ # If one or more inventory fields are provided in the 'fields' parameter,
53
+ # each computer's hash also has keys and values for those fields if they
54
+ # exist in the JSS. These fields are those available in the display options
55
+ # for Advanced Computer Searches (including extention attribute names) and
56
+ # their names are case-sensitive, so 'Username', not 'username'
57
+ #
58
+ # If a specific version is provided in the 'version' parameter, only computers
59
+ # containing that version of the app are returned as an Array of Hashes.
60
+ #
61
+ # If the ids_only parameter is truthy, an Array of JSS id numbers for
62
+ # computers with this app is returned. In this case the 'fields' parameter
63
+ # is ignored, however the 'version' parameters is still valid and will
64
+ # restrict the list to those computer ids with that version installed.
65
+ #
66
+ # This method implements the 'computerapplications' API endpoint.
67
+ #
68
+ # NOTE: To see all the apps installed on a specific computer, fetch the
69
+ # JSS::Computer instance and call its {JSS::Computer#apps} method.
70
+ #
71
+ # @param appname [String] The name of the app to look for, e.g. 'Transmogrifier.app'
72
+ #
73
+ # @param fields [String,Array<String>] Additional 'inventory fields' to return
74
+ # with each computer's data
75
+ #
76
+ # @param version [String] Limit search to a specific version of the app
77
+ #
78
+ # @param ids_only [Boolean] Just return an array of the id's of computers
79
+ # found with this query. Defaults to false
80
+ #
81
+ # @param api [JSS::APIConnection] The API connection to use for the query.
82
+ # default: JSS.api
83
+ #
84
+ # @return [Array<Integer>] When ids_only == true, the ids of computers with
85
+ # the app installed (possibly limited to version)
86
+ #
87
+ # @return [Array<Hash>] When version is provided, An Array of Hashes, one
88
+ # for each computer, with keys for identifiers plus any requested fields.
89
+ #
90
+ # @return [Hash{String => Array<Hash>}] When no version is provided, a Hash
91
+ # with keys for each version, pointing to an array of Hashes, one for
92
+ # each computer with that version. Each computer's Hash has keys for
93
+ # identifiers plus any requested fields.
94
+ #
95
+ #
96
+ def self.application_installs(appname, fields: [], version: nil, ids_only: false, api: JSS.api)
97
+ fields = [fields] unless fields.is_a? Array
98
+
99
+ rsrc = "#{COMPUTER_APPLICATIONS_RSRC}/#{appname}"
100
+ rsrc << "/version/#{version}" if version
101
+ rsrc << "/inventory/#{fields.join ','}" unless ids_only || fields.empty?
102
+
103
+ # get_rsrc will URI.encode the rsrc
104
+ result = api.get_rsrc(rsrc)[:computer_applications]
105
+
106
+ return result[:unique_computers].map { |c| c[:id] } if ids_only
107
+
108
+ if version.nil?
109
+ hash_by_version = {}
110
+ result[:versions].each { |v| hash_by_version[v[:number]] = v[:computers] }
111
+ return hash_by_version
112
+ end
113
+
114
+ result[:versions].first[:computers]
115
+ end # self.application_search
116
+
117
+ end # Computer
118
+
119
+ end # JSS
@@ -29,17 +29,18 @@ module JSS
29
29
  # Classes
30
30
  ###################################
31
31
 
32
- # An OS X Configuration Profile in the JSS.
32
+ # The parent class of OSXConfigurationProfile and MobileDeviceConfigurationProfile
33
33
  #
34
34
  # Note that the profile payloads and the profile UUID cannot be edited or updated with this via this class.
35
35
  # Use the web UI.
36
36
  #
37
37
  # @see JSS::APIObject
38
38
  #
39
- class OSXConfigurationProfile < JSS::APIObject
39
+ class ConfigurationProfile < JSS::APIObject
40
40
 
41
41
  # Mix-Ins
42
42
  ###################################
43
+
43
44
  include JSS::Updatable
44
45
  include JSS::Scopable
45
46
  include JSS::SelfServable
@@ -49,40 +50,14 @@ module JSS
49
50
  # Class Constants
50
51
  ###################################
51
52
 
52
- # The base for REST resources of this class
53
- RSRC_BASE = 'osxconfigurationprofiles'.freeze
54
-
55
- # the hash key used for the JSON list output of all objects in the JSS
56
- RSRC_LIST_KEY = :os_x_configuration_profiles
57
-
58
- # The hash key used for the JSON object output.
59
- # It's also used in various error messages
60
- RSRC_OBJECT_KEY = :os_x_configuration_profile
61
-
62
- # these keys, as well as :id and :name, are present in valid API JSON data for this class
63
- VALID_DATA_KEYS = %i[distribution_method scope redeploy_on_update].freeze
64
-
65
- # Our scopes deal with computers
66
- SCOPE_TARGET_KEY = :computers
67
-
68
- # Our SelfService happens on OSX
69
- SELF_SERVICE_TARGET = :osx
70
-
71
- # Our SelfService deploys profiles
72
- SELF_SERVICE_PAYLOAD = :profile
73
-
74
- # The possible values for the :distribution_method
53
+ # The possible values for the distribution_method/deployment_method
75
54
  DISTRIBUTION_METHODS = ['Install Automatically', 'Make Available in Self Service'].freeze
76
55
 
56
+ # which DISTRIBUTION_METHODS means we're in self service?
77
57
  SELF_SERVICE_DIST_METHOD = 'Make Available in Self Service'.freeze
78
58
 
79
- # The possible values for :level
80
- LEVELS = %w[user computer].freeze
81
-
82
- # the object type for this object in
83
- # the object history table.
84
- # See {APIObject#add_object_history_entry}
85
- OBJECT_HISTORY_OBJECT_TYPE = 4
59
+ # Our SelfService deploys profiles
60
+ SELF_SERVICE_PAYLOAD = :profile
86
61
 
87
62
  # Where is the Site data in the API JSON?
88
63
  SITE_SUBSET = :general
@@ -93,15 +68,6 @@ module JSS
93
68
  # @return [String] the description of this profile
94
69
  attr_reader :description
95
70
 
96
- # @return [String] the distribution_method of this profile
97
- attr_reader :distribution_method
98
-
99
- # @return [Boolean] can the user remove this profile
100
- attr_reader :user_removable
101
-
102
- # @return [String] the level (user/computer) of this profile
103
- attr_reader :level
104
-
105
71
  # @return [String] the uuid of this profile. NOT Updatable
106
72
  attr_reader :uuid
107
73
 
@@ -118,11 +84,7 @@ module JSS
118
84
  #
119
85
  def initialize(args = {})
120
86
  super
121
-
122
87
  @description = @main_subset[:description]
123
- @distribution_method = @main_subset[:distribution_method]
124
- @user_removable = @main_subset[:user_removable]
125
- @level = @main_subset[:level]
126
88
  @uuid = @main_subset[:uuid]
127
89
  @redeploy_on_update = @main_subset[:redeploy_on_update]
128
90
  @payloads = @main_subset[:payloads]
@@ -141,50 +103,9 @@ module JSS
141
103
  @need_to_update = true
142
104
  end # @param new_val[String] how should this be distributed to clients?
143
105
 
106
+ # The @payloads Plist, parsed into a Ruby object
144
107
  #
145
- # @return [void]
146
- #
147
- def distribution_method=(new_val)
148
- return nil if @distribution_method == new_val
149
- raise JSS::InvalidDataError, "New value must be one of '#{DISTRIBUTION_METHODS.join("' '")}'" unless DISTRIBUTION_METHODS.include? new_val
150
- @distribution_method = new_val
151
- @need_to_update = true
152
- end
153
-
154
- # @param new_val[Boolean] should the user be able to remove this?
155
- #
156
- # @return [void]
157
- #
158
- def user_removable=(new_val)
159
- return nil if @self_service_feature_on_main_page == new_val
160
- raise JSS::InvalidDataError, "Distribution method must be '#{SELF_SERVICE_DIST_METHOD}' to let the user remove it." unless in_self_service?
161
- raise JSS::InvalidDataError, 'New value must be true or false' unless JSS::TRUE_FALSE.include? new_val
162
- @user_removable = new_val
163
- @need_to_update = true
164
- end
165
-
166
- # @param new_val[String] the new level for this profile (user/computer)
167
- #
168
- # @return [void]
169
- #
170
- def level=(new_val)
171
- return nil if @level == new_val
172
- raise JSS::InvalidDataError, "New value must be one of '#{LEVELS.join("' '")}'" unless LEVELS.include? new_val
173
- @level = new_val
174
- @need_to_update = true
175
- end # @return [Boolean] is this profile available in Self Service?
176
-
177
- #
178
- def in_self_service?
179
- @distribution_method == SELF_SERVICE_DIST_METHOD
180
- end # @return [Boolean] is this profile removable by the user?
181
-
182
- #
183
- def user_removable?
184
- @user_removable
185
- end # @return [Hash] The payload plist parsed into a Ruby hash
186
-
187
- #
108
+ # @return [Hash] the parsed payloads plist.
188
109
  def parsed_payloads
189
110
  Plist.parse_xml @payloads
190
111
  end
@@ -201,7 +122,6 @@ module JSS
201
122
  payload_content.map { |p| p['PayloadType'] }
202
123
  end
203
124
 
204
- ###################################
205
125
  # Private Instance Methods
206
126
  ###################################
207
127
  private
@@ -209,21 +129,21 @@ module JSS
209
129
  def rest_xml
210
130
  doc = REXML::Document.new
211
131
 
212
- obj = doc.add_element RSRC_OBJECT_KEY.to_s
132
+ obj = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
213
133
  gen = obj.add_element('general')
214
134
  gen.add_element('description').text = @description
215
- gen.add_element('distribution_method').text = @distribution_method
216
- gen.add_element('user_removable').text = @user_removable
217
- gen.add_element('level').text = @level
218
135
  gen.add_element('redeploy_on_update').text = @redeploy_on_update
219
136
 
220
137
  obj << @scope.scope_xml
221
138
  add_self_service_xml doc
222
139
  add_category_to_xml doc
223
140
  add_site_to_xml doc
224
- doc.to_s
141
+ doc
225
142
  end
226
143
 
227
144
  end # class OSXConfigurationProfile
228
145
 
229
146
  end # module
147
+
148
+ require 'jss/api_object/configuration_profile/osx_configuration_profile'
149
+ require 'jss/api_object/configuration_profile/mobile_device_configuration_profile'