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