ruby-jss 2.0.0b3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -10
- data/README-2.0.0.md +141 -63
- data/README.md +225 -173
- data/lib/jamf/api/classic/api_objects/distribution_point.rb +12 -50
- data/lib/jamf/api/classic/api_objects/patch_title.rb +14 -9
- data/lib/jamf/api/classic/base_classes/api_object.rb +68 -9
- data/lib/jamf/api/classic/base_classes/patch_source.rb +10 -5
- data/lib/jamf/api/connection.rb +1 -1
- data/lib/jamf/api/jamf_pro/mixins/collection_resource.rb +8 -12
- data/lib/jamf/version.rb +1 -1
- data/lib/jamf/zeitwerk_config.rb +217 -0
- data/lib/jamf.rb +7 -39
- metadata +6 -6
- data/lib/zeitwerk_config.rb +0 -168
data/README.md
CHANGED
@@ -1,37 +1,55 @@
|
|
1
|
-
# ruby-jss: Working with the Jamf Pro
|
1
|
+
# ruby-jss: Working with the Jamf Pro APIs in Ruby
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/ruby-jss.svg)](http://badge.fury.io/rb/ruby-jss)
|
3
3
|
|
4
|
-
##
|
4
|
+
## Version 2.0.0 has been released
|
5
5
|
|
6
|
-
|
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
|
+
|
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
|
+
|
10
|
+
### Highlights
|
11
|
+
|
12
|
+
- Support for Ruby 3.x
|
13
|
+
- tested in 3.0 and 3.1
|
14
|
+
- Combined access to both the Classic and Jamf Pro APIs
|
15
|
+
- A single namespace module
|
16
|
+
- Connection objects talk to both APIs & automatically handle details like bearer tokens
|
17
|
+
- Auto-generated code for Jamf Pro API objects
|
18
|
+
- Autoloading of code using [Zeitwerk](https://github.com/fxn/zeitwerk)
|
19
|
+
|
20
|
+
For details about the changes, the document [README-2.0.0.md](README-2.0.0.md).
|
21
|
+
|
22
|
+
## _IMPORTANT_: Known Security Issue in v1.5.3 and below
|
23
|
+
|
24
|
+
Versions of ruby-jss prior to 1.6.0 contain a known security issue due to how we were using the 'plist' gem.
|
7
25
|
|
8
26
|
This has been resolved in 1.6.0, which now uses the CFProperlyList gem.
|
9
27
|
|
10
|
-
|
28
|
+
__Please update all installations of ruby-jss to at least v1.6.0.__
|
11
29
|
|
12
30
|
Many many thanks to actae0n of Blacksun Hackers Club for reporting this issue and providing examples of how it could be exploited.
|
13
31
|
|
14
|
-
|
32
|
+
------
|
33
|
+
|
34
|
+
# Table of contents
|
15
35
|
|
16
36
|
<!-- TOC -->
|
17
37
|
|
38
|
+
- [Version 2.0.0 has been released](#version-200-has-been-released)
|
39
|
+
- [Highlights](#highlights)
|
40
|
+
- [_IMPORTANT_: Known Security Issue in v1.5.3 and below](#_important_-known-security-issue-in-v153-and-below)
|
18
41
|
- [DESCRIPTION](#description)
|
19
|
-
- [Contact](#contact)
|
20
42
|
- [SYNOPSIS](#synopsis)
|
21
43
|
- [USAGE](#usage)
|
22
|
-
- [Connecting to the
|
23
|
-
|
44
|
+
- [Connecting to the Server](#connecting-to-the-server)
|
45
|
+
- [Using multiple connections](#using-multiple-connections)
|
46
|
+
- [Working with Jamf Objects](#working-with-jamf-objects)
|
24
47
|
- [Listing Objects](#listing-objects)
|
25
48
|
- [Retrieving Objects](#retrieving-objects)
|
26
49
|
- [Creating Objects](#creating-objects)
|
27
50
|
- [Updating Objects](#updating-objects)
|
28
51
|
- [Deleting Objects](#deleting-objects)
|
29
52
|
- [OBJECTS IMPLEMENTED](#objects-implemented)
|
30
|
-
- [Creatable and Updatable](#creatable-and-updatable)
|
31
|
-
- [Updatable, but must be created in the Web UI](#updatable-but-must-be-created-in-the-web-ui)
|
32
|
-
- [Creatable only](#creatable-only)
|
33
|
-
- [Read-Only](#read-only)
|
34
|
-
- [Deletable](#deletable)
|
35
53
|
- [Other useful classes & modules:](#other-useful-classes--modules)
|
36
54
|
- [Object-related API endpoints](#object-related-api-endpoints)
|
37
55
|
- [CONFIGURATION](#configuration)
|
@@ -39,38 +57,35 @@ Many many thanks to actae0n of Blacksun Hackers Club for reporting this issue an
|
|
39
57
|
- [BEYOND THE API](#beyond-the-api)
|
40
58
|
- [INSTALL](#install)
|
41
59
|
- [REQUIREMENTS](#requirements)
|
42
|
-
- [
|
60
|
+
- [Contact](#contact)
|
61
|
+
- [HELP & CONTACT INFO](#help--contact-info)
|
43
62
|
- [LICENSE](#license)
|
44
63
|
|
45
64
|
<!-- /TOC -->
|
46
65
|
|
47
66
|
## DESCRIPTION
|
48
67
|
|
49
|
-
ruby-jss defines a Ruby module called
|
50
|
-
|
51
|
-
devices from [Jamf.com](http://www.jamf.com/).
|
52
|
-
[ruby gem](https://rubygems.org/gems/ruby-jss), and the
|
68
|
+
ruby-jss defines a Ruby module called `Jamf`, which is used for accessing the 'Classic' and
|
69
|
+
'Jamf Pro' APIs of a Jamf Pro server. Jamf Pro is an enterprise-level management tool for Apple
|
70
|
+
devices from [Jamf.com](http://www.jamf.com/). It is available as a[ruby gem](https://rubygems.org/gems/ruby-jss), and the
|
53
71
|
[source is on github](https://github.com/PixarAnimationStudios/ruby-jss).
|
54
72
|
|
55
|
-
The module
|
56
|
-
|
57
|
-
|
58
|
-
point, and the installation of {JSS::Package} objects on client machines. (See [BEYOND THE API](#beyond-the-api))
|
73
|
+
The Jamf module maintains connections to both APIs simultaneously, and uses which ever is appropriate as needed.
|
74
|
+
Details like authentication tokens, token refreshing, JSON and XML parsing, and even knowing which resources use
|
75
|
+
which API are all handled under-the-hood.
|
59
76
|
|
60
|
-
The module
|
77
|
+
The Jamf module abstracts many API resources as Ruby objects, and provides methods for interacting with those
|
78
|
+
resources. It also provides some features that aren't a part of the API itself, but come with other
|
79
|
+
Jamf-related tools, such as uploading {Jamf::Package} files to the master distribution
|
80
|
+
point, and the installation of those objects on client machines. (See [BEYOND THE API](#beyond-the-api))
|
61
81
|
|
82
|
+
The Jamf module is not a complete implementation of the Jamf Pro APIs. Only some objects are modeled,
|
83
|
+
some only minimally. Of those, some are read-only, some partially writable, some fully read-write.
|
62
84
|
We've implemented the things we need in our environment, and as our needs grow, we'll add more.
|
63
85
|
Hopefully others will find it useful, and add more to it as well.
|
64
86
|
|
65
87
|
[Full technical documentation can be found here.](http://www.rubydoc.info/gems/ruby-jss/)
|
66
88
|
|
67
|
-
NOTE: ruby-jss 2.0.0 is in testing, see [README-2.0.0.md](README-2.0.0.md) for more info.
|
68
|
-
|
69
|
-
### Contact
|
70
|
-
|
71
|
-
If you have questions or feedback about ruby-jss, please reach out in the [#ruby-jss channel of Macadmins Slack](https://macadmins.slack.com/archives/C03C7F563MK), or open an issue on GitHub, or email ruby-jss@pixar.com.
|
72
|
-
|
73
|
-
|
74
89
|
## SYNOPSIS
|
75
90
|
|
76
91
|
Here are some simple examples of using ruby-jss
|
@@ -79,97 +94,138 @@ Here are some simple examples of using ruby-jss
|
|
79
94
|
require 'ruby-jss'
|
80
95
|
|
81
96
|
# Connect to the API
|
82
|
-
Jamf.cnx.connect
|
97
|
+
Jamf.cnx.connect "https://#{jamf_user}:#{jamf_pw}@my.jamf.server.com/"
|
83
98
|
|
84
|
-
# get an array of basic data about all
|
85
|
-
pkgs =
|
99
|
+
# get an array of basic data about all Jamf::Package objects in Jamf Pro:
|
100
|
+
pkgs = Jamf::Package.all
|
86
101
|
|
87
|
-
# get an array of names of all
|
88
|
-
pkg_names =
|
102
|
+
# get an array of names of all Jamf::Package objects in the Jamf Pro:
|
103
|
+
pkg_names = Jamf::Package.all_names
|
89
104
|
|
90
105
|
# Get a static computer group. This creates a new Ruby object
|
91
|
-
# representing the existing
|
92
|
-
|
106
|
+
# representing the existing Jamf computer group.
|
107
|
+
mac_group = Jamf::ComputerGroup.fetch name: "Macs of interest"
|
93
108
|
|
94
109
|
# Add a computer to the group
|
95
|
-
|
110
|
+
mac_group.add_member "pricklepants"
|
96
111
|
|
97
|
-
# save changes back to the
|
98
|
-
|
112
|
+
# save changes back to the server
|
113
|
+
mac_group.save
|
99
114
|
|
100
|
-
# Create a new network segment to store
|
101
|
-
# This makes a new Ruby Object that doesn't yet exist in
|
102
|
-
ns =
|
115
|
+
# Create a new network segment to store on the server.
|
116
|
+
# This makes a new Ruby Object that doesn't yet exist in Jamf Pro.
|
117
|
+
ns = Jamf::NetworkSegment.create(
|
103
118
|
name: 'Private Class C',
|
104
119
|
starting_address: '192.168.0.0',
|
105
120
|
ending_address: '192.168.0.255'
|
106
121
|
)
|
107
122
|
|
108
123
|
# Associate this network segment with a specific building,
|
109
|
-
# which must exist in
|
124
|
+
# which must exist in Jamf Pro, and be listed in Jamf::Building.all_names
|
110
125
|
ns.building = "Main Office"
|
111
126
|
|
112
127
|
# Associate this network segment with a specific software update server,
|
113
|
-
#
|
128
|
+
# which must exist in Jamf Pro, and be listed in Jamf::SoftwareUpdateServer.all_names
|
114
129
|
ns.swu_server = "Main SWU Server"
|
115
130
|
|
116
|
-
# save the new network segment
|
131
|
+
# save the new network segment to the server
|
117
132
|
ns.save
|
118
133
|
```
|
119
134
|
|
120
135
|
## USAGE
|
121
136
|
|
122
|
-
### Connecting to the
|
137
|
+
### Connecting to the Server
|
123
138
|
|
124
|
-
Before you can work with
|
139
|
+
Before you can work with Jamf Pros Objects via the APIs, you have to connect to the server.
|
125
140
|
|
126
|
-
The method `Jamf.cnx` returns the
|
141
|
+
The method `Jamf.cnx` returns the 'default' connection object (an instance of a {Jamf::APIConnection}, q.v.).
|
142
|
+
A connection object holds all the data needed to communicate with the server to which it's connected, as well as
|
143
|
+
any data cached from that server.
|
144
|
+
The default connection object is used for all communication unless a different one is explicitly passed to methods
|
145
|
+
that can accept one. See 'Using multiple connections' below.
|
127
146
|
|
128
|
-
When the
|
147
|
+
When the Jamf Module is first loaded, the default connection isn't connected a server. To remedy that, use `Jamf.cnx.connect`,
|
148
|
+
passing it parameters for the connection. In this example, those parameters are stored in the local variables jss_user,
|
149
|
+
jss_user_pw, and jss_server_hostname, and others are left as default.
|
129
150
|
|
130
151
|
```ruby
|
131
152
|
Jamf.cnx.connect user: jss_user, pw: jss_user_pw, server: jss_server_hostname
|
132
153
|
```
|
133
154
|
|
134
|
-
|
155
|
+
You can also provide a URL, optionally including the credentials, and port number. Any value not available in the URL can be passed as a normal parameter.
|
135
156
|
|
136
|
-
|
157
|
+
```ruby
|
158
|
+
Jamf.cnx.connect "https://#{jamf_user}@my.jamf.server.com/", pw: jamf_user_pw, port: 8443
|
159
|
+
```
|
160
|
+
|
161
|
+
Make sure the user has privileges in the Jamf to do things with desired objects. Note that these might be more than you think, since some objects refer to other objects, like Sites and Categories.
|
162
|
+
|
163
|
+
If the server name given ends with 'jamfcloud.com' the port number will default to 443 via SSL. Otherwise, it defaults to 8443 with SSL (the default port for on-prem. servers). In other situations, you can specify it with the `port:` and `use_ssl:` parameters.
|
137
164
|
|
138
165
|
The connect method also accepts the symbols :stdin and :prompt as values for pw:, which will cause it to read the
|
139
|
-
password from stdin, or prompt for it in the shell. See the {
|
166
|
+
password from stdin, or prompt for it in the shell. See the {Jamf::Connection} class for more connection options and details about its methods.
|
140
167
|
|
141
|
-
Also see
|
168
|
+
Also see Jamf::Configuration, and the [CONFIGURATION](#configuration) section below, for how to store
|
142
169
|
server connection parameters in a simple config file.
|
143
170
|
|
144
|
-
|
171
|
+
#### Using multiple connections
|
172
|
+
|
173
|
+
Most of the time, you'll only need a single connection to a single server, and the default connection will be sufficient. However
|
174
|
+
you can also create multiple Connection objects, to different servers, or perhaps the same server with different credentials and
|
175
|
+
access, and pass those connection objects into methods using the `cnx:` parameter as appropriate.
|
145
176
|
|
146
|
-
|
177
|
+
```ruby
|
178
|
+
# Make connections to 2 different Jamf servers.
|
179
|
+
# The .new class method accepts the same parameters as the #connect instance method,
|
180
|
+
# and will automatically pass them to the #connect method when instantiating
|
181
|
+
# the new connection object.
|
182
|
+
connection_1 = Jamf::Connection.new user: jss_user, pw: jss_user_pw, server: jss_server_hostname
|
183
|
+
connection_2 = Jamf::Connection.new user: jss_user2, pw: jss_user_pw2, server: jss_server_hostname2
|
184
|
+
|
185
|
+
# Get an array of the serialNumbers from all InventoryPreloadRecords in server 1
|
186
|
+
ipr_sns_1 = Jamf::InventoryPreloadRecord.all_serialNumbers cnx: connection_1
|
187
|
+
|
188
|
+
# Get an array of the serialNumbers from all InventoryPreloadRecords in server 2
|
189
|
+
ipr_sns_2 = Jamf::InventoryPreloadRecord.all_serialNumbers cnx: connection_2
|
190
|
+
|
191
|
+
# Find the SNs that appear in both
|
192
|
+
common_ipr_sns = ipr_sns_1 & ipr_sns_2
|
193
|
+
```
|
194
|
+
|
195
|
+
### Working with Jamf Objects
|
147
196
|
|
148
|
-
|
197
|
+
All of the ruby classes representing objects in Jamf Pro have common methods for creating, listing, retrieving, updating, and deleting via the API.
|
198
|
+
All supported objects can be listed, retrieved and deleted, but only some can be updated or created, mostly becase we haven't needed to do that ourselves
|
199
|
+
yet and haven't implemented that functionality. If you need additional features implemented, please get in touch (see 'Contact' above) or feel free to
|
200
|
+
try implementing it yourself and send us a merge request.
|
201
|
+
|
202
|
+
Some of the implemented objects also provide access to more 'functional' API resources. For example, the API resources for
|
203
|
+
sending MDM commands to computers and mobile devices are available as class and instance methods of Jamf::Computer and Jamf::MobileDevice,
|
204
|
+
as are the API resources for accessing management history.
|
149
205
|
|
150
206
|
--------
|
151
207
|
|
152
208
|
#### Listing Objects
|
153
209
|
|
154
|
-
To get an Array with a summary of every object in the
|
210
|
+
To get an Array with a summary of every object in the Jamf of some Class, call that Class's .all method:
|
155
211
|
|
156
212
|
```ruby
|
157
|
-
|
213
|
+
Jamf::Computer.all # => [{:name=>"cephei", :id=>1122},{:name=>"peterparker", :id=>1218}, {:name=>"rowdy", :id=>931}, ...]
|
158
214
|
```
|
159
215
|
|
160
216
|
The Array will contain a Hash for each item, with at least a :name and an :id. Some classes provide more summary data for each item.
|
161
217
|
To get just the names or just the ids in an Array, use the .all\_names or .all\_ids Class method
|
162
218
|
|
163
219
|
```ruby
|
164
|
-
|
165
|
-
|
220
|
+
Jamf::Computer.all_names # => ["cephei", "peterparker", "rowdy", ...]
|
221
|
+
Jamf::Computer.all_ids # => [1122, 1218, 931, ...]
|
166
222
|
```
|
167
223
|
|
168
|
-
Some Classes provide other ways to list objects, or subsets of them, depending on the data available, e.g.
|
224
|
+
Some Classes provide other ways to list objects, or subsets of them, depending on the data available, e.g. Jamf::MobileDevice.all\_udids or Jamf::Computer.all\_laptops
|
169
225
|
|
170
|
-
You can also perform simple searches for
|
226
|
+
You can also perform simple searches for Jamf::Computer, Jamf::MobileDevice and Jamf::User with the `.match` class method. This is the API equivalent of using the simple search field at the top of the Computers, Devices, or Users pages in the Jamf Pro Web interface. This method will return an Array of Hashes for the matching items. Each Hash is a summary of info about a matching item, similar to the summaries returned by the `.all` methods for those items.
|
171
227
|
|
172
|
-
To create, modify, or perform advanced searches, use the classes
|
228
|
+
To create, modify, or perform advanced searches, use the classes Jamf::AdvancedComputerSearch, Jamf::AdvancedMobileDeviceSearch, and Jamf::AdvancedUserSearch.
|
173
229
|
|
174
230
|
--------
|
175
231
|
|
@@ -179,23 +235,23 @@ To retrieve a single object call the class's `.fetch` method and provide a name:
|
|
179
235
|
|
180
236
|
|
181
237
|
```ruby
|
182
|
-
a_dept =
|
238
|
+
a_dept = Jamf::Department.fetch name: 'Payroll'# => #<Jamf::Department:0x10b4c0818...
|
183
239
|
```
|
184
240
|
|
185
241
|
Some classes can use more than just the :id and name: keys for lookups, e.g. computers can be looked up with udid:, serial_number:, or mac_address:.
|
186
242
|
|
187
|
-
You can even fetch objects without specifying the kind of identifier, e.g. `
|
243
|
+
You can even fetch objects without specifying the kind of identifier, e.g. `Jamf::Computer.fetch 'VM3X9483HD78'`, but this will be slower, since ruby-jss searches by matching the given value with all available identifiers, returning the first match.
|
188
244
|
|
189
245
|
--------
|
190
246
|
|
191
247
|
#### Creating Objects
|
192
248
|
|
193
|
-
Some Objects can be created anew in the
|
249
|
+
Some Objects can be created anew in the Jamf via ruby. To do so, first make a Ruby object using the class's `.create` method and providing a unique :name:, e.g.
|
194
250
|
|
195
251
|
```ruby
|
196
|
-
new_pkg =
|
252
|
+
new_pkg = Jamf::Package.create name: "transmogrifier-2.3-1.pkg"
|
197
253
|
```
|
198
|
-
*NOTE*: some classes require more data than just a name: when created with .
|
254
|
+
*NOTE*: some classes require more data than just a name: when created with .create
|
199
255
|
|
200
256
|
Then set the attributes of the new object as needed
|
201
257
|
|
@@ -205,7 +261,7 @@ new_pkg.category = "CoolTools"
|
|
205
261
|
# etc..
|
206
262
|
```
|
207
263
|
|
208
|
-
Then use the #save method to
|
264
|
+
Then use the #save method to send the data to the API, creating it in Jamf Pro.
|
209
265
|
|
210
266
|
```ruby
|
211
267
|
new_pkg.save # returns 453, the id number of the object just created
|
@@ -215,14 +271,14 @@ new_pkg.save # returns 453, the id number of the object just created
|
|
215
271
|
|
216
272
|
#### Updating Objects
|
217
273
|
|
218
|
-
Some objects can be modified
|
274
|
+
Some objects can be modified.
|
219
275
|
|
220
276
|
```ruby
|
221
|
-
existing_script =
|
277
|
+
existing_script = Jamf::Script.fetch id: 321
|
222
278
|
existing_script.name = "transmogrifier-2.3-1.post-install"
|
223
279
|
```
|
224
280
|
|
225
|
-
After changing any attributes, use the #save method
|
281
|
+
After changing any attributes, use the #save method to push the changes to the sever.
|
226
282
|
|
227
283
|
```ruby
|
228
284
|
existing_script.save # => returns the id number of the object just saved
|
@@ -235,16 +291,19 @@ existing_script.save # => returns the id number of the object just saved
|
|
235
291
|
To delete an object, just call its #delete method
|
236
292
|
|
237
293
|
```ruby
|
238
|
-
existing_script =
|
294
|
+
existing_script = Jamf::Script.fetch id: 321
|
239
295
|
existing_script.delete # => true # the delete was successful
|
240
296
|
```
|
241
297
|
To delete an object without fetching it, use the class's .delete method and provide the id, or an array of ids.
|
242
298
|
|
243
299
|
```ruby
|
244
|
-
|
300
|
+
Jamf::Script.delete [321, 543, 374]
|
245
301
|
```
|
246
302
|
|
247
|
-
|
303
|
+
For more details see the docs for:
|
304
|
+
- [Jamf::APIObject](http://www.rubydoc.info/gems/ruby-jss/Jamf/APIObject), the parent class of all Classic API resources
|
305
|
+
- [Jamf::OAPIObject](http://www.rubydoc.info/gems/ruby-jss/Jamf/OAPIObject), the parent class of all Jamf Pro API objects
|
306
|
+
- [Jamf::CollectionResource](http://www.rubydoc.info/gems/ruby-jss/Jamf/CollectionResource), the parent class of all Jamf Pro API collection resources
|
248
307
|
|
249
308
|
See the individual subclasses for any details specific to them.
|
250
309
|
|
@@ -252,77 +311,64 @@ See the individual subclasses for any details specific to them.
|
|
252
311
|
|
253
312
|
While the API itself supports nearly full CRUD (Create,Read,Update,Delete) for all objects, ruby-jss doesn't yet do so. Why? Because implementing the data validation and other parts needed for creating & updating can be time-consuming and we've focused on what we needed. As we keep developing ruby-jss, this list changes. If you'd like to help implement some of these objects more fully, please fork the github project and reach out to us at ruby-jss@pixar.com.
|
254
313
|
|
255
|
-
Here's what we've implemented so far. See each Class's [documentation(http://www.rubydoc.info/gems/ruby-jss)] for details.
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
* {
|
260
|
-
* {
|
261
|
-
* {
|
262
|
-
* {
|
263
|
-
* {
|
264
|
-
* {
|
265
|
-
* {
|
266
|
-
* {
|
267
|
-
* {
|
268
|
-
* {
|
269
|
-
* {
|
270
|
-
* {
|
271
|
-
* {
|
272
|
-
* {
|
273
|
-
* {
|
274
|
-
* {
|
275
|
-
* {
|
276
|
-
* {
|
277
|
-
* {
|
278
|
-
* {
|
279
|
-
* {
|
280
|
-
* {
|
281
|
-
* {
|
282
|
-
* {
|
283
|
-
* {
|
284
|
-
* {
|
285
|
-
* {
|
286
|
-
* {
|
287
|
-
* {
|
288
|
-
* {
|
289
|
-
* {
|
290
|
-
|
314
|
+
Here's some of what we've implemented so far. See each Class's [documentation(http://www.rubydoc.info/gems/ruby-jss)] for details.
|
315
|
+
|
316
|
+
|
317
|
+
* {Jamf::AdvancedComputerSearch}
|
318
|
+
* {Jamf::AdvancedMobileDeviceSearch}
|
319
|
+
* {Jamf::AdvancedUserSearch}
|
320
|
+
* {Jamf::Building}
|
321
|
+
* {Jamf::Category}
|
322
|
+
* {Jamf::Computer}
|
323
|
+
* {Jamf::ComputerExtensionAttribute}
|
324
|
+
* {Jamf::ComputerGroup}
|
325
|
+
* {Jamf::ComputerInvitation}
|
326
|
+
* {Jamf::Department}
|
327
|
+
* {Jamf::DistributionPoint}
|
328
|
+
* {Jamf::DockItem}
|
329
|
+
* {Jamf::EBook}
|
330
|
+
* {Jamf::IBeacon}
|
331
|
+
* {Jamf::LdapServer}
|
332
|
+
* {Jamf::MobileDevice}
|
333
|
+
* {Jamf::MobileDeviceApplication}
|
334
|
+
* {Jamf::MobileDeviceConfigurationProfile}
|
335
|
+
* {Jamf::MobileDeviceExtensionAttribute}
|
336
|
+
* {Jamf::MobileDeviceGroup}
|
337
|
+
* {Jamf::NetBootServer}
|
338
|
+
* {Jamf::NetworkSegment}
|
339
|
+
* {Jamf::OSXConfigurationProfile}
|
340
|
+
* {Jamf::Package}
|
341
|
+
* {Jamf::PatchTitle}
|
342
|
+
* {Jamf::PatchTitle::Version}
|
343
|
+
* {Jamf::PatchExternalSource}
|
344
|
+
* {Jamf::PatchInternalSource}
|
345
|
+
* {Jamf::PatchPolicy}
|
346
|
+
* {Jamf::Peripheral}
|
347
|
+
* {Jamf::PeripheralType}
|
348
|
+
* {Jamf::Policy} (not fully implemented)
|
349
|
+
* {Jamf::RemovableMacAddress}
|
350
|
+
* {Jamf::RestrictedSoftware}
|
351
|
+
* {Jamf::Script}
|
352
|
+
* {Jamf::Site}
|
353
|
+
* {Jamf::SoftwareUpdateServer}
|
354
|
+
* {Jamf::User}
|
355
|
+
* {Jamf::UserExtensionAttribute}
|
356
|
+
* {Jamf::UserGroup}
|
357
|
+
* {Jamf::WebHook}
|
291
358
|
|
292
359
|
**NOTE** Most Computer and MobileDevice data gathered by an Inventory Upate (a.k.a. 'recon') is not editable.
|
293
360
|
|
294
|
-
|
295
|
-
|
296
|
-
* {JSS::OSXConfigurationProfile}
|
297
|
-
* {JSS::MobileDeviceConfigurationProfile}
|
298
|
-
* {JSS::PatchInternalSource}
|
299
|
-
|
300
|
-
### Creatable only
|
301
|
-
|
302
|
-
* {JSS::ComputerInvitation}
|
303
|
-
|
304
|
-
### Read-Only
|
361
|
+
#### Other useful classes & modules:
|
305
362
|
|
306
|
-
These
|
363
|
+
These modules either provide stand-alone methods, or are mixed in to other classes to extend their functionality. See their documentation for details
|
307
364
|
|
308
|
-
* {
|
309
|
-
* {JSS::LdapServer}
|
310
|
-
* {JSS::NetBootServer}
|
311
|
-
* {JSS::SoftwareUpdateServer}
|
365
|
+
* {Jamf::Client} - An object representing the local machine as a Jamf-managed client, and provifing Jamf-related info and methods
|
312
366
|
|
313
|
-
|
367
|
+
* {Jamf::ManagementHistory} - a module for handing the management history for Computers and Mobile Devices. It defines many read-only classes representing events in a machine's history. It is accessed via the Computer and MobileDevice classes and their instances.
|
314
368
|
|
315
|
-
|
369
|
+
* {Jamf::Scopable} - a module that handles Scope for those objects that can be scoped. It defines the Scope class used in those objects. Instances of Scope are where you change targets, limitations, and exclusions.
|
316
370
|
|
317
|
-
|
318
|
-
|
319
|
-
* {JSS::APIConnection} - An object representing a connection to the Classic API on some server. The 'default' connection object is available via `Jamf.cnx` but you can create others, and pass them into calls like `.fetch` as needed. This is useful when working with multiple servers at a time, such as a production and a test server. Objects retrieved from a connection know which connection they came from, and will only send changes via that connection.
|
320
|
-
* {JSS::DBConnection} - An object representing the connection to MySQL database, if used.
|
321
|
-
* {JSS::Server} - An object representing the Jamf Pro server being used by a connection. An instance is available in the #server attribute of a {JSS::APIConnection}.
|
322
|
-
* {JSS::Client} - An object representing the local machine as a Jamf-managed client, and provifing Jamf-related info and methods
|
323
|
-
* {JSS::ManagementHistory} - a module for handing the management history for Computers and Mobile Devices. It defines many read-only classes representing events in a machine's history. It is accessed via the Computer and MobileDevice classes and their instances.
|
324
|
-
* {JSS::Scopable} - a module that handles Scope for those objects that can be scoped. It defines the Scope class used in those objects.
|
325
|
-
* {JSS::MDM} - a module that handles sending MDM commands. It is accessed via the Computer and MobileDevice classes and their instances.
|
371
|
+
* {Jamf::MDM} - a module that handles sending MDM commands. It is accessed via the Computer and MobileDevice classes and their instances.
|
326
372
|
|
327
373
|
## Object-related API endpoints
|
328
374
|
|
@@ -331,19 +377,19 @@ The classic API provides many endpoints not just for objects stored in Jamf Pro,
|
|
331
377
|
For example:
|
332
378
|
|
333
379
|
* /computerapplications, /computerapplicationusage, /computerhardwaresoftwarereports, /computerhistory, etc.
|
334
|
-
- The data provided by these endpoints are accessible via class and instance methods for {
|
380
|
+
- The data provided by these endpoints are accessible via class and instance methods for {Jamf::Computer}
|
335
381
|
* /computercheckin, /computerinventorycollection
|
336
|
-
- These endpoints deal with server-wide settings regarding computer management, and are available via {
|
382
|
+
- These endpoints deal with server-wide settings regarding computer management, and are available via {Jamf::Computer} class methods
|
337
383
|
* /computercommands, /mobiledevicecommands, /commandflush, etc.
|
338
|
-
- These endpoints provide access to the MDM infrastructure, and can be used to send MDM commands. Ruby-jss provides these as class and instance methods in {
|
384
|
+
- These endpoints provide access to the MDM infrastructure, and can be used to send MDM commands. Ruby-jss provides these as class and instance methods in {Jamf::Computer}, {Jamf::ComputerGroup}, {Jamf::MobileDevice}, and {Jamf::MobileDeviceGroup}
|
339
385
|
|
340
386
|
## CONFIGURATION
|
341
387
|
|
342
|
-
The {
|
388
|
+
The {Jamf::Configuration} singleton class is used to read, write, and use site-specific defaults for the Jamf module. When ruby-jss is required, the single instance of {Jamf::Configuration} is created and accessible via the `Jamf.config` method. At that time the system-wide file /etc/ruby-jss.conf is examined if it exists, and the items in it are loaded into the attributes of Configuration instance. The user-specific file ~/.ruby-jss.conf then is examined if it exists, and any items defined there will override those values from the system-wide file.
|
343
389
|
|
344
|
-
The values defined in those files are used as defaults throughout the module. Currently, those values are only related to establishing the API connection. For example, if a server name is defined, then a :
|
390
|
+
The values defined in those files are used as defaults throughout the module. Currently, those values are only related to establishing the API connection. For example, if a server name is defined, then a server: does not have to be specified when calling {Jamf::Connection#connect}. Values provided explicitly when calling Jamf::Connection#connect will override the config values.
|
345
391
|
|
346
|
-
While the {
|
392
|
+
While the {Jamf::Configuration} class provides methods for changing the values, saving the files, and re-reading them, or reading an arbitrary file, the files are text files with a simple format, and can be created by any means desired. The file format is one attribute per line, thus:
|
347
393
|
|
348
394
|
attr_name: value
|
349
395
|
|
@@ -351,30 +397,30 @@ Lines that don’t start with a known attribute name followed by a colon are ign
|
|
351
397
|
|
352
398
|
The currently known attributes are:
|
353
399
|
|
354
|
-
* api_server_name [String] the hostname of the
|
400
|
+
* api_server_name [String] the hostname of the Jamf API server
|
355
401
|
* api_server_port [Integer] the port number for the API connection
|
356
402
|
* api_verify_cert [Boolean] 'true' or 'false' - if SSL is used, should the certificate be verified? (usually false for a self-signed cert)
|
357
|
-
* api_username [String] the
|
403
|
+
* api_username [String] the Jamf username for connecting to the API
|
358
404
|
* api_timeout_open [Integer] the number of seconds for the open-connection timeout
|
359
405
|
* api_timeout [Integer] the number of seconds for the response timeout
|
360
406
|
|
361
|
-
To put a standard server & username on all client machines, and auto-accept the
|
407
|
+
To put a standard server & username on all client machines, and auto-accept the Jamf's self-signed https certificate, create the file /etc/ruby-jss.conf containing three lines like this:
|
362
408
|
|
363
409
|
```
|
364
410
|
api_server_name: jamfpro.myschool.edu
|
365
411
|
api_username: readonly-api-user
|
366
|
-
|
412
|
+
api_timeout: 90
|
367
413
|
```
|
368
414
|
|
369
|
-
and then any calls to Jamf.cnx.connect will assume that server and username, and
|
415
|
+
and then any calls to Jamf.cnx.connect will assume that server and username, and use a timeout of 90 seconds.
|
370
416
|
|
371
417
|
### Passwords
|
372
418
|
|
373
|
-
The config files don't store passwords and the {
|
419
|
+
The config files don't store passwords and the {Jamf::Configuration} instance doesn't work with them. You'll have to use your own methods for acquiring the password for the Jamf.cnx.connect call.
|
374
420
|
|
375
|
-
The {
|
421
|
+
The {Jamf::APIConnection.connect} method also accepts the symbols :stdin# and :prompt as values for the :pw argument, which will cause it to read the password from a line of stdin, or prompt for it in the shell.
|
376
422
|
|
377
|
-
If you must store a password in a file, or retrieve it from the network, make sure it's stored securely, and that the
|
423
|
+
If you must store a password in a file, or retrieve it from the network, make sure it's stored securely, and that the Jamf user has limited permissions.
|
378
424
|
|
379
425
|
Here's an example of how to use a password stored in a file:
|
380
426
|
|
@@ -393,56 +439,62 @@ Jamf.cnx.connect pw: password # other arguments used from the config settings
|
|
393
439
|
|
394
440
|
## BEYOND THE API
|
395
441
|
|
396
|
-
While the Jamf Pro
|
442
|
+
While the Jamf Pro APIs provide access to object data in the Jamf, ruby-jss tries to use that data to provide more than just information exchange. Here are some examples of how ruby-jss uses the API to provide functionality found in various Jamf tools:
|
397
443
|
|
398
444
|
* Client Machine Access
|
399
|
-
* The {
|
445
|
+
* The {Jamf::Client} module provides the ability to run jamf binary commands, and access the local cache of package receipts
|
400
446
|
* Package Installation
|
401
|
-
* {
|
447
|
+
* {Jamf::Package} objects can be installed on the local machine, from the appropriate distribution point
|
402
448
|
* Script Execution
|
403
|
-
* {
|
449
|
+
* {Jamf::Script} objects can be executed locally on demand
|
404
450
|
* Package Creation
|
405
|
-
* The {
|
406
|
-
* {
|
451
|
+
* The {Jamf::Composer} module provides creation of very simple .pkg and .dmg packages
|
452
|
+
* {Jamf::Package} objects can upload their .pkg or .dmg files to the master distribution point
|
407
453
|
* Reporting/AdvancedSearch exporting
|
408
|
-
* {
|
454
|
+
* {Jamf::AdvancedSearch} subclasses can export their results to csv, tab, and xml files.
|
409
455
|
* MDM Commands
|
410
|
-
* {
|
456
|
+
* {Jamf::MobileDevice}s and {Jamf::Computer}s can be sent MDM commands
|
411
457
|
* Extension Attributes
|
412
|
-
* {
|
458
|
+
* {Jamf::ExtensionAttribute} work with {Jamf::AdvancedSearch} subclasses to provide extra reporting about Extension Attribute values.
|
413
459
|
|
414
460
|
## INSTALL
|
415
461
|
|
416
|
-
NOTE: You may need to install XCode, or it's CLI tools, in order to install the required gems.
|
417
|
-
|
418
462
|
In general, you can install ruby-jss with this command:
|
419
463
|
|
420
464
|
`gem install ruby-jss`
|
421
465
|
|
422
466
|
## REQUIREMENTS
|
423
467
|
|
424
|
-
ruby-jss
|
468
|
+
ruby-jss 2.0.0 requires:
|
425
469
|
|
426
|
-
*
|
427
|
-
*
|
428
|
-
* Casper Suite version 10.4 or higher
|
470
|
+
* Ruby 2.6.3 or higher (the OS-installed ruby version for macOS 10.15 Catalina)
|
471
|
+
* Jamf Pro server version 10.35 or higher
|
429
472
|
|
430
473
|
It also requires other ruby gems, which will be installed automatically if you install with `gem install ruby-jss`
|
431
474
|
See the .gemspec file for details
|
432
475
|
|
433
476
|
|
434
|
-
|
477
|
+
### Contact
|
478
|
+
|
479
|
+
If you have questions or feedback about ruby-jss, please reach out to us via:
|
480
|
+
- The [#ruby-jss channel of Macadmins Slack](https://macadmins.slack.com/archives/C03C7F563MK)
|
481
|
+
- Open an issue on GitHub
|
482
|
+
- Email ruby-jss@pixar.com
|
483
|
+
|
484
|
+
|
485
|
+
## HELP & CONTACT INFO
|
435
486
|
|
436
487
|
Full documentation is available at [rubydoc.info](http://www.rubydoc.info/gems/ruby-jss/).
|
437
488
|
|
438
489
|
There's a [wiki on the github page](https://github.com/PixarAnimationStudios/ruby-jss/wiki), feel free to contribute examples and tidbits.
|
439
490
|
|
440
|
-
|
441
|
-
|
442
|
-
[
|
491
|
+
You can report issues in several ways:
|
492
|
+
- [Open an issue on github](https://github.com/PixarAnimationStudios/ruby-jss/issues)
|
493
|
+
- [Email the developers at ruby-jss@pixar.com](mailto:ruby-jss@pixar.com)
|
494
|
+
- Join the conversation in the [#ruby-jss Macadmins Slack Channel](https://macadmins.slack.com/archives/C03C7F563MK)
|
443
495
|
|
444
496
|
## LICENSE
|
445
497
|
|
446
498
|
Copyright 2022 Pixar
|
447
499
|
|
448
|
-
Licensed under
|
500
|
+
Licensed under a modified Apache License, Version 2.0. See LICENSE.txt for details
|