ruby-jss 2.0.0rc1 → 2.1.0b4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +31 -12
- data/README-2.0.0.md +41 -0
- data/README.md +3 -1
- data/lib/jamf/api/classic/api_objects/computer.rb +1 -0
- data/lib/jamf/api/classic/api_objects/computer_group.rb +58 -94
- data/lib/jamf/api/jamf_pro/mixins/bulk_deletable.rb +2 -2
- data/lib/jamf/api/jamf_pro/mixins/collection_resource.rb +1 -3
- data/lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb +1 -1
- data/lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb +113 -0
- data/lib/jamf/configuration.rb +55 -60
- data/lib/jamf/deprecations.rb +28 -0
- data/lib/jamf/version.rb +1 -1
- data/lib/jamf/zeitwerk_config.rb +3 -2
- data/lib/jamf.rb +4 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a00af3813560fa65f8597fc6a516d1b9933eb333f2aee3478646df1f93a45b9
|
4
|
+
data.tar.gz: 892e4f5ed6b7271c55377671ff13ccb7778a51b34d57b9da67086cd95ec7d0ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6461d576566cfd365c77ff36758a8c9558deb2bad8936b87be03f12dd3c7f7662734ec2eaaa7f1f4b5b83c9bb0264c9e06609c2f8f0ef20106d3c8db8be45484
|
7
|
+
data.tar.gz: 30a9a4dcf60a9aa0a25c4a64429e34f1f8cf6cf9609f80c94b675c0e498f74f46f3fc0842fab2d20ed248f0a792c2349a7373a273905ec45c3994b3b6f4fc3eb
|
data/CHANGES.md
CHANGED
@@ -4,30 +4,49 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
##
|
7
|
+
## _IMPORTANT_: Known Security Issue in v1.5.3 and below
|
8
8
|
|
9
|
-
Versions of ruby-jss prior to 1.6.0 contain a known security issue due to
|
9
|
+
Versions of ruby-jss prior to 1.6.0 contain a known security issue due to how we were using the 'plist' gem.
|
10
10
|
|
11
11
|
This has been resolved in 1.6.0, which now uses the CFProperlyList gem.
|
12
12
|
|
13
|
-
|
13
|
+
__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.
|
17
|
+
## \[2.1.0] - unreleased
|
18
|
+
|
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
|
18
38
|
|
19
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**
|
20
40
|
|
21
|
-
Here are the high-level changes and there are many many others. For more details, see [CHANGES-2.0.0](CHANGES-2.0.0.md)
|
41
|
+
Here are the high-level changes and there are many many others. For more details, see [CHANGES-2.0.0.md](CHANGES-2.0.0.md)
|
22
42
|
|
23
|
-
- Combined access to both APIs.
|
24
|
-
- The Classic and Jamf Pro APIs are no longer separated into the JSS and Jamf modules. There is only the `Jamf` module, and `JSS` is merely an alias of it, so all your code refering to the JSS module should still work.
|
25
|
-
- Auto-generated classes for the Jamf Pro API
|
26
|
-
- Base classes for JamfPro API objects are automatically generated from the OAPI3 Schema available at https://your.jamf.server/api/schema. This make it much simpler for ruby-jss to implement and update new and changed objects and endpoints in the Jamf Pro API.
|
27
|
-
- Code is auto-loaded from disk
|
28
|
-
- Because the auto-generated classes add hundreds of files to the gem, ruby-jss now uses [Zeitwerk](https://github.com/fxn/zeitwerk) to auto-load only the files it needs when they are needed.
|
29
43
|
- Support for Ruby 3.x
|
30
|
-
|
44
|
+
- tested in 3.0 and 3.1
|
45
|
+
- Combined access to both the Classic and Jamf Pro APIs
|
46
|
+
- A single namespace module
|
47
|
+
- Connection objects talk to both APIs & automatically handle details like bearer tokens
|
48
|
+
- Auto-generated code for Jamf Pro API objects
|
49
|
+
- Autoloading of code using [Zeitwerk](https://github.com/fxn/zeitwerk)
|
31
50
|
|
32
51
|
## \[1.6.7] - 2022-02-22
|
33
52
|
|
data/README-2.0.0.md
CHANGED
@@ -31,6 +31,7 @@ These changes have been in mind for some time, but the requirement in late 2022
|
|
31
31
|
- [No Attribute aliases for Jamf Pro API objects](#no-attribute-aliases-for-jamf-pro-api-objects)
|
32
32
|
- [Class/Mixin hierarchy for Jamf Pro API objects](#classmixin-hierarchy-for-jamf-pro-api-objects)
|
33
33
|
- [Support for 'Sticky Sessions' in Jamf Cloud](#support-for-sticky-sessions-in-jamf-cloud)
|
34
|
+
- [The valid_id method for Classic API collection classes](#the-valid_id-method-for-classic-api-collection-classes)
|
34
35
|
- [Planned deprecations](#planned-deprecations)
|
35
36
|
- [Use of the term 'api'](#use-of-the-term-api)
|
36
37
|
- [.map_all_ids_to method for Classic API collection classes](#map_all_ids_to-method-for-classic-api-collection-classes)
|
@@ -156,6 +157,9 @@ So far we've only uncovered a few areas where our ruby-jss 1.x code didn't work
|
|
156
157
|
- Subclassing ruby-jss classes in your own code.
|
157
158
|
- Those classes, and methods called on them, may need to be updated to match the new ruby-jss classes, in order to maintain _their_ backward compatibility.
|
158
159
|
|
160
|
+
- If you make calls to Classic API's `.valid_id` class method for collection classes, and you pass in an integer as a String, e.g. '1234', expecting to get the valid id of the object with the _name_ or _serial_number_ '1234' you will now get back the id 1234 if there is an object with that id. That may not be the id of the object you were looking for.
|
161
|
+
- See [The valid_id method for Classic API collection classes](#the-valid_id-method-for-classic-api-collection-classes) below for details and how to do such a validation now.
|
162
|
+
|
159
163
|
## Notable changes from ruby-jss 1.x
|
160
164
|
|
161
165
|
### Paged queries to the Jamf Pro API
|
@@ -213,6 +217,43 @@ For details about Sticky Sessions see [Sticky Sessions for Jamf Cloud](https://d
|
|
213
217
|
|
214
218
|
**WARNING:** Jamf recommends NOT using sticky sessions unless they are needed. Using them inappropriately may negatively impact performance, especially for large automated processes.
|
215
219
|
|
220
|
+
### The `valid_id` method for Classic API collection classes
|
221
|
+
|
222
|
+
In the Classic API, object ids are Integers, but in the Jamf Pro API, they are Strings containing integers.
|
223
|
+
|
224
|
+
In previous versions of ruby-jss, the `valid_id` class method for the Jamf Pro API will accept Integers and convert them to Strings to search for the valid id. In order to provide the same flexibility, `valid_id` now works the same way for regardless of which API is used.
|
225
|
+
|
226
|
+
Previously, the Classic API collection classes would return nil (no match) if you passed in an id as a string, unless you had an object with a name or other identifier with that numeric string value.
|
227
|
+
|
228
|
+
So for example, assuming you wanted to find out if the id 1234 was valid, you could do
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
ok_id = JSS::Computer.valid_id 1234
|
232
|
+
# => 1234, or nil if 1234 is not a valid id
|
233
|
+
```
|
234
|
+
|
235
|
+
But if you did
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
ok_id = JSS::Computer.valid_id '1234'
|
239
|
+
# => nil, or the id of a computer _named_ '1234'
|
240
|
+
# (no computer would have '1234' as a serialnumber, udid, or macaddress)
|
241
|
+
```
|
242
|
+
you would likely not get the integer id 1234 back.
|
243
|
+
|
244
|
+
In ruby-jss 2.0.0, the valid_id method has changed so that the second example above will return the integer id 1234, if it exists as an id. If not, it will look at other identifiers with the string value, and return the id of any match, or nil if there's no match.
|
245
|
+
|
246
|
+
The downside of this is: what if you really _are_ looking for the id of the object with the name '1234'?
|
247
|
+
|
248
|
+
To deal with that situation, the valid_id method for the Classic API now behaves like the one for the Jamf Pro API: it can accept an arbitrary key: value pair, limiting the search to the indentifier used as the key.
|
249
|
+
|
250
|
+
So you can use this to get what you're looking for
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
ok_id = JSS::Computer.valid_id name: '1234'
|
254
|
+
# => nil, or the id of a computer named '1234'
|
255
|
+
```
|
256
|
+
|
216
257
|
## Planned deprecations
|
217
258
|
|
218
259
|
Even though it was publically released in 2014, ruby-jss's origins are from 2009, so it's been around for a while. We've learned a lot since then, and lots of the old lingering code is terribly out of date.
|
data/README.md
CHANGED
@@ -3,8 +3,10 @@
|
|
3
3
|
|
4
4
|
## Version 2.0.0 has been released
|
5
5
|
|
6
|
-
Version 2.0.0 has major changes! While we've strived for backward
|
6
|
+
Version 2.0.0 has major changes! While we've strived for _mostly_ being backward compatible, and have done lots of testing, YMMV. Please report any issues.
|
7
7
|
|
8
|
+
_NOTE_: ruby-jss 2.0 is not completely backward compatible, please see [README-2.0.0.md](README-2.0.0.md) for more info
|
9
|
+
|
8
10
|
### Highlights
|
9
11
|
|
10
12
|
- Support for Ruby 3.x
|
@@ -1,83 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
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
|
-
|
71
|
-
RSRC_BASE =
|
52
|
+
# The base for REST resources of this class
|
53
|
+
RSRC_BASE = 'computergroups'
|
72
54
|
|
73
|
-
|
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
|
-
|
77
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
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::
|
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::
|
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::
|
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
|
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
|
data/lib/jamf/configuration.rb
CHANGED
@@ -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 = [
|
93
|
+
CONF_FILES = ['ruby-jss.conf', 'jss_gem.conf']
|
93
94
|
|
94
95
|
### The Pathname to the machine-wide preferences plist
|
95
|
-
GLOBAL_CONFS =
|
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 =
|
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
|
-
:
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
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|
|
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
|
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
|
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
|
-
|
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
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
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}: #{
|
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}: #{
|
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}: #{
|
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}: #{
|
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
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
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
data/lib/jamf/zeitwerk_config.rb
CHANGED
@@ -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
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.
|
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-
|
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
|
@@ -826,8 +828,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
826
828
|
- !ruby/object:Gem::Version
|
827
829
|
version: 1.3.1
|
828
830
|
requirements: []
|
829
|
-
rubygems_version: 3.1
|
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: []
|