ruby-jss 2.0.0 → 2.1.0b4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37c859eb265ff9298b8d49a8ded47c218d3355e270bf31cf3a276c7ac6db04b2
4
- data.tar.gz: 83aac996b44f27830bcf24ee03f8ea70d4758b4e9418dfdbb8e4b2232c62c2f4
3
+ metadata.gz: 5a00af3813560fa65f8597fc6a516d1b9933eb333f2aee3478646df1f93a45b9
4
+ data.tar.gz: 892e4f5ed6b7271c55377671ff13ccb7778a51b34d57b9da67086cd95ec7d0ca
5
5
  SHA512:
6
- metadata.gz: c48ed5cafc7f2b24aba6a3eec0d83ecc8fd0a065372ef22b5d0db63c5ac8415d5033952f2a7d10d37eb29876c63bbd9775990cb9146fbd5d744dc0993955b5f2
7
- data.tar.gz: 0cc3a608b9458e1abaf2aa04d32f34858ac892889ae384ee0ac0583c683a43d2d6be7b9dbd763d59738647dc7a1dad423cdfc22441b552df71674f7736597c05
6
+ metadata.gz: 6461d576566cfd365c77ff36758a8c9558deb2bad8936b87be03f12dd3c7f7662734ec2eaaa7f1f4b5b83c9bb0264c9e06609c2f8f0ef20106d3c8db8be45484
7
+ data.tar.gz: 30a9a4dcf60a9aa0a25c4a64429e34f1f8cf6cf9609f80c94b675c0e498f74f46f3fc0842fab2d20ed248f0a792c2349a7373a273905ec45c3994b3b6f4fc3eb
data/CHANGES.md CHANGED
@@ -14,8 +14,27 @@ __Please update all installations of ruby-jss to at least v1.6.0.__
14
14
 
15
15
  Many many thanks to actae0n of Blacksun Hackers Club for reporting this issue and providing examples of how it could be exploited.
16
16
 
17
+ ## \[2.1.0] - unreleased
17
18
 
18
- ## \[2.0.0] - Unreleased
19
+ ### Added
20
+
21
+ - Support for the `/v1/jamf-management-framework/redeploy/{id}` Jamf Pro API endpoint in `Jamf::Computer` and
22
+ `Jamf::ComputerGroup`. The method `redeploy_mgmt_framework` is both a Class and an Instance method for those classes
23
+ - The instance method sends the redeployment to the single computer or all the members of the single computer group.
24
+ - The class method accepts a single id, or an array of ids.
25
+ - When using `Jamf::Computer.redeploy_mgmt_framework` provide computer ids
26
+ - When using `Jamf::ComputerGroup.redeploy_mgmt_framework` provide group ids, and all members of all groups will get
27
+ the redeployment
28
+ - In all cases the result is a Hash of target computer ids (keys) and result value for each (Strings).
29
+ - The result is either the UUID of the sent MDM command, or an error message if the MDM command couldn't be sent.
30
+ - All the code is in the `Jamf::MacOSRedeployMgmtFramework` module, q.v. in the [rubydoc documentation](https://www.rubydoc.info/gems/ruby-jss/Jamf/MacOSRedeployMgmtFramework)
31
+
32
+ ### Fixed
33
+
34
+ - A few internal rescues of a deprecated exception class
35
+ - Removed auto-loading of deprecation files; now explicitly loaded.
36
+
37
+ ## \[2.0.0] - 2022-09-12
19
38
 
20
39
  Version 2.0.0 is a major refactoring of ruby-jss. While attempting to provide as much backward compatibility as possible, there are some significant changes and v2.0.0 is not fully backward compatible. **PLEASE TEST YOUR CODE EXTENSIVELY**
21
40
 
@@ -29,8 +48,6 @@ Here are the high-level changes and there are many many others. For more details
29
48
  - Auto-generated code for Jamf Pro API objects
30
49
  - Autoloading of code using [Zeitwerk](https://github.com/fxn/zeitwerk)
31
50
 
32
-
33
-
34
51
  ## \[1.6.7] - 2022-02-22
35
52
 
36
53
  ### Added
@@ -159,6 +159,7 @@ module Jamf
159
159
  include Jamf::MDM
160
160
  include Jamf::ManagementHistory
161
161
  include Jamf::MacOSManagedUpdates
162
+ include Jamf::MacOSRedeployMgmtFramework
162
163
 
163
164
  extend Jamf::Matchable
164
165
 
@@ -1,83 +1,65 @@
1
- ### Copyright 2022 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 Jamf
28
-
29
- #####################################
30
- ### Module Constants
31
- #####################################
1
+ # Copyright 2022 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
+ #
32
25
 
33
- #####################################
34
- ### Module Variables
35
- #####################################
36
-
37
- #####################################
38
- ### Module Methods
39
- #####################################
26
+ module Jamf
40
27
 
41
- #####################################
42
- ### Classes
28
+ # Classes
43
29
  #####################################
44
30
 
45
- ###
46
- ### A computer group in the JSS
47
- ###
48
- ### See also the parent class Jamf::Group
49
- ###
50
- ### @see Jamf::APIObject
51
- ###
52
- ### @see Jamf::Group
53
- ###
31
+
32
+ # A computer group in the JSS
33
+ #
34
+ # See also the parent class Jamf::Group
35
+ #
36
+ # @see Jamf::APIObject
37
+ #
38
+ # @see Jamf::Group
39
+ #
54
40
  class ComputerGroup < Jamf::Group
55
41
 
56
- #####################################
57
- ### Mix-Ins
42
+
43
+ # Mix-Ins
58
44
  #####################################
59
45
  include Jamf::MDM
60
46
  include Jamf::MacOSManagedUpdates
47
+ include Jamf::MacOSRedeployMgmtFramework
61
48
 
62
- #####################################
63
- ### Class Methods
64
- #####################################
65
-
66
- #####################################
67
- ### Class Constants
49
+ # Class Constants
68
50
  #####################################
69
51
 
70
- ### The base for REST resources of this class
71
- RSRC_BASE = "computergroups"
52
+ # The base for REST resources of this class
53
+ RSRC_BASE = 'computergroups'
72
54
 
73
- ### the hash key used for the JSON list output of all objects in the JSS
55
+ # the hash key used for the JSON list output of all objects in the JSS
74
56
  RSRC_LIST_KEY = :computer_groups
75
57
 
76
- ### The hash key used for the JSON object output.
77
- ### It's also used in various error messages
58
+ # The hash key used for the JSON object output.
59
+ # It's also used in various error messages
78
60
  RSRC_OBJECT_KEY = :computer_group
79
61
 
80
- ### this allows the parent Group class to do things right
62
+ # this allows the parent Group class to do things right
81
63
  MEMBER_CLASS = Jamf::Computer
82
64
 
83
65
  # the XML element for immediate member additions via PUT
@@ -94,45 +76,27 @@ module Jamf
94
76
  # what kind of devices are these WRT MDM
95
77
  MDM_COMMAND_TARGET = :computergroups
96
78
 
97
- #####################################
98
- ### Class Variables
99
- #####################################
100
-
101
- #####################################
102
- ### Class Methods
103
- #####################################
104
-
105
- #####################################
106
- ### Attributes
79
+ # Public Instance Methods
107
80
  #####################################
108
81
 
109
- #####################################
110
- ### Public Instance Methods
111
- #####################################
112
-
113
-
114
- ###
115
- ### The serial numbers of members in this group
116
- ###
117
- ### @return [Array<String>] the member serial numbers
118
- ###
82
+ #
83
+ # The serial numbers of members in this group
84
+ #
85
+ # @return [Array<String>] the member serial numbers
86
+ #
119
87
  def member_serial_numbers
120
- @members.map{|m| m[:serial_number]}
88
+ @members.map { |m| m[:serial_number] }
121
89
  end
122
90
 
123
- ###
124
- ### Return an array of the mac_addrs of members in this group
125
- ###
126
- ### @return [Array<String>] the member mac addresses
127
- ###
91
+ #
92
+ # Return an array of the mac_addrs of members in this group
93
+ #
94
+ # @return [Array<String>] the member mac addresses
95
+ #
128
96
  def member_mac_addresses
129
- @members.map{|m| m[:mac_address]} + @members.map{|m| m[:alt_mac_address]}
97
+ @members.map { |m| m[:mac_address] } + @members.map { |m| m[:alt_mac_address] }
130
98
  end
131
99
 
132
- #####################################
133
- ### Private Instance Methods
134
- #####################################
135
-
136
100
  end # class ComputerGroup
137
101
 
138
102
  end # module
@@ -39,7 +39,7 @@ module Jamf
39
39
  # @param cnx [Jamf::Connection] The connection to use, default: Jamf.cnx
40
40
  #
41
41
  # TODO: fix this return value, no more ErrorInfo
42
- # @return [Array<Jamf::Connection::APIError::ErrorInfo] Info about any ids
42
+ # @return [Array<Jamf::Connection::JamfProAPIError::ErrorInfo] Info about any ids
43
43
  # that failed to be deleted.
44
44
  #
45
45
  def bulk_delete(ids, cnx: Jamf.cnx)
@@ -49,7 +49,7 @@ module Jamf
49
49
  begin
50
50
  cnx.post "#{rsrc_path}/#{DELETE_MULTIPLE_ENDPOINT}", request_body
51
51
  []
52
- rescue Jamf::Connection::APIError => e
52
+ rescue Jamf::Connection::JamfProAPIError => e
53
53
  raise e unless e.httpStatus == 400
54
54
 
55
55
  e.errors
@@ -101,12 +101,10 @@ module Jamf
101
101
  #
102
102
  # Classes including CollectionResource really need to define GET_PATH if it
103
103
  # is not the same as the LIST_PATH.
104
- # rubocop:disable Naming/AccessorMethodName
105
104
  ######################################
106
105
  def get_path
107
106
  @get_path ||= defined?(self::GET_PATH) ? self::GET_PATH : self::LIST_PATH
108
107
  end
109
- # rubocop:enable Naming/AccessorMethodName
110
108
 
111
109
  # The path for PUTting (replacing) a single object. The desired object id will
112
110
  # be appended to the end, e.g. if this value is 'v1/buildings' and you want
@@ -570,7 +568,7 @@ module Jamf
570
568
  # @param cnx [Jamf::Connection] The connection to use, default: Jamf.cnx
571
569
  #
572
570
  #
573
- # @return [Array<Jamf::Connection::APIError::ErrorInfo] Info about any ids
571
+ # @return [Array<Jamf::Connection::JamfProAPIError::ErrorInfo] Info about any ids
574
572
  # that failed to be deleted.
575
573
  #
576
574
  ######################################
@@ -156,7 +156,7 @@ module Jamf
156
156
  #
157
157
  # @see MacOSManagedUpdates.send_managed_os_update
158
158
  #
159
- def send_managed_os_update(updateAction:, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false, cnx: Jamf.cnx)
159
+ def send_managed_os_update(updateAction:, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false)
160
160
  deviceIds = is_a?(Jamf::Computer) ? @id : nil
161
161
  groupId = is_a?(Jamf::Computer) ? nil : @id
162
162
 
@@ -0,0 +1,113 @@
1
+ # Copyright 2022 Pixar
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
+ # with the following modification; you may not use this file except in
5
+ # compliance with the Apache License and the following modification to it:
6
+ # Section 6. Trademarks. is deleted and replaced with:
7
+ #
8
+ # 6. Trademarks. This License does not grant permission to use the trade
9
+ # names, trademarks, service marks, or product names of the Licensor
10
+ # and its affiliates, except as required to comply with Section 4(c) of
11
+ # the License and to reproduce the content of the NOTICE file.
12
+ #
13
+ # You may obtain a copy of the Apache License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the Apache License with the above modification is
19
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+ # KIND, either express or implied. See the Apache License for the specific
21
+ # language governing permissions and limitations under the Apache License.
22
+ #
23
+ #
24
+
25
+ module Jamf
26
+
27
+ # This module should be mixed in to Jamf::Computer and Jamf::ComputerGroup
28
+ #
29
+ # It provides access to the macos-managed-software-updates JPAPI resource for
30
+ # managed OS update commands to managed macs running Big Sur or higher.
31
+ #
32
+ module MacOSRedeployMgmtFramework
33
+
34
+ # when this module is included, also extend our Class Methods
35
+ def self.included(includer)
36
+ Jamf.load_msg "--> #{includer} is including #{self}"
37
+ includer.extend(ClassMethods)
38
+ end
39
+
40
+ # The JP API resource for redeploying the management framework
41
+ # to a computer. The id will be appended when used.
42
+ REDEPLOY_RSRC = 'v1/jamf-management-framework/redeploy'
43
+
44
+ # Class Methods
45
+ #####################################
46
+ module ClassMethods
47
+
48
+ # when this module is included, also extend our Class Methods
49
+ def self.extended(extender)
50
+ Jamf.load_msg "--> #{extender} is extending #{self}"
51
+ end
52
+
53
+ # Redeploy the Jamf Management framework to target Computers or members of ComputerGroups
54
+ #
55
+ # IMPORTANT: This only re-deploys the Jamf binary and related framework. The MDM system
56
+ # must be functioning. The target computer(s) will not re-install the framework if they
57
+ # never recieve the MDM command.
58
+ #
59
+ # @param target_ids [String, Integer, Array<String, Integer>] Jamf IDs for the
60
+ # Computer or ComputerGroup targets.
61
+ #
62
+ # @param cnx [Jamf::Connection] The API connection to use. Defaults to Jamf.cnx
63
+ #
64
+ # @return [Hash{Integer => String}] The result for each computer, either the
65
+ # uuid of the sent MDM command, or an error message.
66
+ ########################
67
+ def redeploy_mgmt_framework(target_ids, cnx: Jamf.cnx)
68
+ target_ids = target_ids.is_a?(Array) ? target_ids : [target_ids]
69
+ target_comp_ids =
70
+ if self == Jamf::Computer
71
+ target_ids
72
+
73
+ elsif self == Jamf::ComputerGroup
74
+ group_ids = target_ids.is_a?(Array) ? target_ids : [target_ids]
75
+ comp_ids = []
76
+ group_ids.each { |gid| comp_ids += JSS::ComputerGroup.fetch(id: gid).member_ids }
77
+ comp_ids
78
+
79
+ else
80
+ raise Jamf::UnsupportedError, 'This method is only available for Jamf::Computer and Jamf::ComputerGroup'
81
+ end
82
+
83
+ results = {}
84
+
85
+ target_comp_ids.uniq.compact.each do |comp_id|
86
+ result = cnx.jp_post "#{REDEPLOY_RSRC}/#{comp_id}", Jamf::BLANK
87
+
88
+ result = Jamf::OAPISchemas::RedeployJamfManagementFrameworkResponse.new result
89
+ results[comp_id] = result.commandUuid
90
+ rescue Jamf::Connection::JamfProAPIError => e
91
+ results[comp_id] = "ERROR: #{e}"
92
+ end
93
+
94
+ results
95
+ end
96
+
97
+ end # module ClassMethods
98
+
99
+ # Instance Methods
100
+ ######################################
101
+
102
+ # Send a managed update command to an instance of Computer or ComputerGroup.
103
+ # This just calls the class method of the same name.
104
+ #
105
+ # @see MacOSRedeployMgmtFramework.redeploy_mgmt_framework
106
+ #
107
+ def redeploy_mgmt_framework
108
+ self.class.redeploy_mgmt_framework @id, cnx: @cnx
109
+ end
110
+
111
+ end # module MacOSRedeployMgmtFramework
112
+
113
+ end # module Jamf
@@ -79,6 +79,7 @@ module Jamf
79
79
  ### {APIConnection#connect}, or by custom means.
80
80
  ###
81
81
  class Configuration
82
+
82
83
  include Singleton
83
84
 
84
85
  #####################################
@@ -89,31 +90,31 @@ module Jamf
89
90
  ### The first matching file is used - the array provides
90
91
  ### backward compatibility with earlier versions.
91
92
  ### Saving will always happen to the first filename
92
- CONF_FILES = [ "ruby-jss.conf", "jss_gem.conf"]
93
+ CONF_FILES = ['ruby-jss.conf', 'jss_gem.conf']
93
94
 
94
95
  ### The Pathname to the machine-wide preferences plist
95
- GLOBAL_CONFS = CONF_FILES.map{|cf| Pathname.new "/etc/#{cf}"}
96
+ GLOBAL_CONFS = CONF_FILES.map { |cf| Pathname.new "/etc/#{cf}" }
96
97
 
97
98
  ### The Pathname to the user-specific preferences plist
98
- USER_CONFS = CONF_FILES.map{|cf| ENV["HOME"] ? Pathname.new("~/.#{cf}").expand_path : nil }.compact
99
+ USER_CONFS = CONF_FILES.map { |cf| ENV['HOME'] ? Pathname.new("~/.#{cf}").expand_path : nil }.compact
99
100
 
100
101
  ### The attribute keys we maintain, and the type they should be stored as
101
102
  CONF_KEYS = {
102
- :api_server_name => :to_s,
103
- :api_server_port => :to_i,
104
- :api_ssl_version => :to_s,
105
- :api_verify_cert => :jss_to_bool,
106
- :api_username => :to_s,
107
- :api_timeout_open => :to_i,
108
- :api_timeout => :to_i,
109
- :db_server_name => :to_s,
110
- :db_server_port => :to_i,
111
- :db_server_socket => :to_s,
112
- :db_username => :to_s,
113
- :db_name => :to_s,
114
- :db_connect_timeout => :to_i,
115
- :db_read_timeout => :to_i,
116
- :db_write_timeout => :to_i
103
+ api_server_name: :to_s,
104
+ api_server_port: :to_i,
105
+ api_ssl_version: :to_s,
106
+ api_verify_cert: :jss_to_bool,
107
+ api_username: :to_s,
108
+ api_timeout_open: :to_i,
109
+ api_timeout: :to_i,
110
+ db_server_name: :to_s,
111
+ db_server_port: :to_i,
112
+ db_server_socket: :to_s,
113
+ db_username: :to_s,
114
+ db_name: :to_s,
115
+ db_connect_timeout: :to_i,
116
+ db_read_timeout: :to_i,
117
+ db_write_timeout: :to_i
117
118
  }
118
119
 
119
120
  #####################################
@@ -129,8 +130,7 @@ module Jamf
129
130
  #####################################
130
131
 
131
132
  # automatically create accessors for all the CONF_KEYS
132
- CONF_KEYS.keys.each {|k| attr_accessor k}
133
-
133
+ CONF_KEYS.keys.each { |k| attr_accessor k }
134
134
 
135
135
  #####################################
136
136
  ### Constructor
@@ -140,10 +140,8 @@ module Jamf
140
140
  ### Initialize!
141
141
  ###
142
142
  def initialize
143
-
144
143
  read_global
145
144
  read_user
146
-
147
145
  end
148
146
 
149
147
  #####################################
@@ -156,7 +154,7 @@ module Jamf
156
154
  ### @return [void]
157
155
  ###
158
156
  def clear_all
159
- CONF_KEYS.keys.each {|k| self.send "#{k}=".to_sym, nil}
157
+ CONF_KEYS.keys.each { |k| send "#{k}=".to_sym, nil }
160
158
  end
161
159
 
162
160
  ###
@@ -165,12 +163,12 @@ module Jamf
165
163
  ### @return [void]
166
164
  ###
167
165
  def read_global
168
- GLOBAL_CONFS.each { |gcf|
166
+ GLOBAL_CONFS.each do |gcf|
169
167
  if gcf.file? and gcf.readable?
170
168
  read gcf
171
169
  return
172
170
  end
173
- }
171
+ end
174
172
  end
175
173
 
176
174
  ###
@@ -179,15 +177,14 @@ module Jamf
179
177
  ### @return [void]
180
178
  ###
181
179
  def read_user
182
- USER_CONFS.each { |ucf|
180
+ USER_CONFS.each do |ucf|
183
181
  if ucf.file? and ucf.readable?
184
182
  read ucf
185
183
  return
186
184
  end
187
- }
185
+ end
188
186
  end
189
187
 
190
-
191
188
  ###
192
189
  ### Clear the settings and reload the prefs files, or another file if provided
193
190
  ###
@@ -203,10 +200,9 @@ module Jamf
203
200
  end
204
201
  read_global
205
202
  read_user
206
- return true
203
+ true
207
204
  end
208
205
 
209
-
210
206
  ###
211
207
  ### Save the prefs into a file
212
208
  ###
@@ -216,10 +212,10 @@ module Jamf
216
212
  ###
217
213
  def save(file)
218
214
  path = case file
219
- when :global then GLOBAL_CONFS.first
220
- when :user then USER_CONFS.first
221
- else Pathname.new(file)
222
- end
215
+ when :global then GLOBAL_CONFS.first
216
+ when :user then USER_CONFS.first
217
+ else Pathname.new(file)
218
+ end
223
219
 
224
220
  raise Jamf::MissingDataError, "No HOME environment variable, can't write to user conf file." if path.nil?
225
221
 
@@ -229,21 +225,20 @@ module Jamf
229
225
 
230
226
  # go thru the known attributes/keys
231
227
  CONF_KEYS.keys.sort.each do |k|
232
-
233
228
  # if the key exists, update it.
234
229
  if data =~ /^#{k}:/
235
- data.sub!(/^#{k}:.*$/, "#{k}: #{self.send k}")
230
+ data.sub!(/^#{k}:.*$/, "#{k}: #{send k}")
236
231
 
237
232
  # if not, add it to the end unless it's nil
238
233
  else
239
- data += "\n#{k}: #{self.send k}" unless self.send(k).nil?
234
+ data += "\n#{k}: #{send k}" unless send(k).nil?
240
235
  end # if data =~ /^#{k}:/
241
- end #each do |k|
236
+ end # each do |k|
242
237
 
243
238
  else # not readable, make a new file
244
- data = ""
239
+ data = ''
245
240
  CONF_KEYS.keys.sort.each do |k|
246
- data << "#{k}: #{self.send k}\n" unless self.send(k).nil?
241
+ data << "#{k}: #{send k}\n" unless send(k).nil?
247
242
  end
248
243
  end # if path readable
249
244
 
@@ -252,14 +247,13 @@ module Jamf
252
247
  path.jss_save data
253
248
  end # read file
254
249
 
255
-
256
250
  ###
257
251
  ### Print out the current settings to stdout
258
252
  ###
259
253
  ### @return [void]
260
254
  ###
261
255
  def print
262
- CONF_KEYS.keys.sort.each{|k| puts "#{k}: #{self.send k}"}
256
+ CONF_KEYS.keys.sort.each { |k| puts "#{k}: #{send k}" }
263
257
  end
264
258
 
265
259
  #####################################
@@ -275,28 +269,29 @@ module Jamf
275
269
  ### @return [void]
276
270
  ###
277
271
  def read(file)
278
-
279
272
  Pathname.new(file).read.each_line do |line|
280
- # skip blank lines and those starting with #
281
- next if line =~ /^\s*(#|$)/
282
-
283
- line.strip =~ /^(\w+?):\s*(\S.*)$/
284
- next unless $1
285
- attr = $1.to_sym
286
- setter = "#{attr}=".to_sym
287
- value = $2.strip
288
-
289
- if CONF_KEYS.keys.include? attr
290
- if value
291
- # convert the value to the correct class
292
- value = value.send(CONF_KEYS[attr])
293
- end
294
- self.send(setter, value)
295
- end # if
296
- end # do line
273
+ # skip blank lines and those starting with #
274
+ next if line =~ /^\s*(#|$)/
275
+
276
+ line.strip =~ /^(\w+?):\s*(\S.*)$/
277
+ next unless Regexp.last_match(1)
297
278
 
279
+ attr = Regexp.last_match(1).to_sym
280
+ setter = "#{attr}=".to_sym
281
+ value = Regexp.last_match(2).strip
282
+
283
+ next unless CONF_KEYS.keys.include? attr
284
+
285
+ if value
286
+ # convert the value to the correct class
287
+ value = value.send(CONF_KEYS[attr])
288
+ end
289
+ send(setter, value)
290
+ # if
291
+ end # do line
298
292
  end # read file
299
293
 
300
294
  end # class Preferences
301
295
 
296
+
302
297
  end # module
@@ -0,0 +1,28 @@
1
+ ### Copyright 2022 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
+ require 'jamf/deprecations/deprecated_api_connection_class'
27
+ require 'jamf/deprecations/deprecated_api_constant'
28
+ require 'jamf/deprecations/deprecated_config_constant'
data/lib/jamf/version.rb CHANGED
@@ -27,6 +27,6 @@
27
27
  module Jamf
28
28
 
29
29
  ### The version of ruby-jss
30
- VERSION = '2.0.0'.freeze
30
+ VERSION = '2.1.0b4'.freeze
31
31
 
32
32
  end # module
@@ -89,8 +89,6 @@ module JamfZeitwerkConfig
89
89
  loader.collapse("#{__dir__}/api/jamf_pro/base_classes")
90
90
  loader.collapse("#{__dir__}/api/jamf_pro/other_classes")
91
91
 
92
- loader.collapse("#{__dir__}/deprecations")
93
-
94
92
  ##### Inflected Paths
95
93
 
96
94
  # filenames => Constants, which don't adhere to zeitwerk's parsing standards.
@@ -130,6 +128,7 @@ module JamfZeitwerkConfig
130
128
  loader.inflector.inflect 'md_prestage_names' => 'MobileDevicePrestageNames'
131
129
  loader.inflector.inflect 'md_prestage_skip_setup_items' => 'MobileDevicePrestageSkipSetupItems'
132
130
  loader.inflector.inflect 'macos_managed_updates' => 'MacOSManagedUpdates'
131
+ loader.inflector.inflect 'macos_redeploy_mgmt_framework' => 'MacOSRedeployMgmtFramework'
133
132
 
134
133
  # deprecations, separated so they load only when used.
135
134
  # When its time to get rid of them, delete the files from the
@@ -147,6 +146,8 @@ module JamfZeitwerkConfig
147
146
  loader.ignore "#{__dir__}/ruby_extensions.rb"
148
147
  loader.ignore "#{__dir__}/ruby_extensions"
149
148
  loader.ignore "#{__dir__}/exceptions.rb"
149
+ loader.ignore "#{__dir__}/deprecations"
150
+ loader.ignore "#{__dir__}/deprecations.rb"
150
151
 
151
152
  lib_dir = Pathname.new(__dir__).parent.to_s
152
153
  loader.ignore "#{lib_dir}/ruby-jss.rb"
data/lib/jamf.rb CHANGED
@@ -89,3 +89,7 @@ JSS = Jamf
89
89
 
90
90
  # testing zeitwerk loading, the the desired file is present
91
91
  JamfZeitwerkConfig.eager_load_for_testing
92
+
93
+ # Load more non-autoloaded stuff, but this stuff needs
94
+ # to happen after zeitwerk loading is active.
95
+ require 'jamf/deprecations'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jss
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0b4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lasell
8
8
  - Aurica Hayes
9
9
  - Kristoffer Landes
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-09-12 00:00:00.000000000 Z
13
+ date: 2022-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: CFPropertyList
@@ -290,6 +290,7 @@ files:
290
290
  - lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb
291
291
  - lib/jamf/api/jamf_pro/mixins/lockable.rb
292
292
  - lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb
293
+ - lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb
293
294
  - lib/jamf/api/jamf_pro/mixins/prestage.rb
294
295
  - lib/jamf/api/jamf_pro/mixins/sortable.rb
295
296
  - lib/jamf/api/jamf_pro/mixins/uncreatable.rb
@@ -747,6 +748,7 @@ files:
747
748
  - lib/jamf/configuration.rb
748
749
  - lib/jamf/constants.rb
749
750
  - lib/jamf/db_connection.rb
751
+ - lib/jamf/deprecations.rb
750
752
  - lib/jamf/deprecations/deprecated_api_connection_class.rb
751
753
  - lib/jamf/deprecations/deprecated_api_constant.rb
752
754
  - lib/jamf/deprecations/deprecated_config_constant.rb
@@ -806,7 +808,7 @@ homepage: http://pixaranimationstudios.github.io/ruby-jss/
806
808
  licenses:
807
809
  - Nonstandard
808
810
  metadata: {}
809
- post_install_message:
811
+ post_install_message:
810
812
  rdoc_options:
811
813
  - "--title"
812
814
  - JSS
@@ -822,12 +824,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
822
824
  version: 2.6.3
823
825
  required_rubygems_version: !ruby/object:Gem::Requirement
824
826
  requirements:
825
- - - ">="
827
+ - - ">"
826
828
  - !ruby/object:Gem::Version
827
- version: '0'
829
+ version: 1.3.1
828
830
  requirements: []
829
- rubygems_version: 3.1.4
830
- signing_key:
831
+ rubygems_version: 3.0.3.1
832
+ signing_key:
831
833
  specification_version: 4
832
834
  summary: A Ruby interface to the Jamf Pro REST APIs
833
835
  test_files: []