jss-api 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +52 -30
- data/lib/jss-api/version.rb +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -2,18 +2,14 @@
|
|
2
2
|
|
3
3
|
## DESCRIPTION
|
4
4
|
|
5
|
-
jss-api
|
6
|
-
from JAMF Software, LLC. It defines the JSS module, which abstracts API resources as Ruby objects, and provides methods for interacting with those
|
7
|
-
resources. It also provides some features that aren't a part of the API itself, but come with other Casper-related
|
8
|
-
tools, such as uploading .pkg and .dmg {JSS::Package} data to the master distribution point, and the installation
|
9
|
-
of {JSS::Package} objects on client machines. (See BEYOND THE API)
|
5
|
+
The jss-api gem provides a Ruby module called JSS, which is used for accessing the REST API of the JAMF Software Server (JSS) - the core of the Casper Suite from JAMF Software, LLC. The module abstracts API resources as Ruby objects, and provides methods for interacting with those resources. It also provides some features that aren't a part of the API itself, but come with other Casper-related tools, such as uploading .pkg and .dmg {JSS::Package} data to the master distribution point, and the installation of {JSS::Package} objects on client machines. (See BEYOND THE API)
|
10
6
|
|
11
|
-
The
|
7
|
+
The module is not a complete implementation of the Casper API. Only some API objects are modeled, some only minimally. Of
|
12
8
|
those, some are read-only, some partially writable, some fully read-write (all implemented objects can be deleted)
|
13
9
|
See OBJECTS IMPLEMENTED for a list.
|
14
10
|
|
15
11
|
We've implemented the things we need in our environment, and as our needs grow, we'll add more.
|
16
|
-
Hopefully others will find it useful, and add more to it as well
|
12
|
+
Hopefully others will find it useful, and add more to it as well.
|
17
13
|
|
18
14
|
|
19
15
|
## SYNOPSIS
|
@@ -22,10 +18,17 @@ Hopefully others will find it useful, and add more to it as well
|
|
22
18
|
# you may need to require 'rubygems' first if you're using Ruby 1.8
|
23
19
|
require 'jss-api'
|
24
20
|
|
25
|
-
JSS::API.connect
|
21
|
+
JSS::API.connect(
|
22
|
+
:user => jss_user,
|
23
|
+
:pw => jss_user_pw,
|
24
|
+
:server => jss_server_hostname
|
25
|
+
)
|
26
|
+
|
27
|
+
# get an array of data about all JSS::Package objects in the JSS:
|
28
|
+
JSS::Package.all
|
26
29
|
|
27
|
-
|
28
|
-
JSS::Package.all_names
|
30
|
+
# get an array of names of all JSS::Package objects in the JSS:
|
31
|
+
JSS::Package.all_names
|
29
32
|
|
30
33
|
# Get a static computer group
|
31
34
|
mg = JSS::ComputerGroup.new :name => "Macs of interest"
|
@@ -37,16 +40,22 @@ mg.add_member "pricklepants"
|
|
37
40
|
mg.update
|
38
41
|
|
39
42
|
# Create a new network segment to store in the JSS
|
40
|
-
ns = JSS::NetworkSegment.new
|
41
|
-
|
42
|
-
|
43
|
+
ns = JSS::NetworkSegment.new(
|
44
|
+
:id => :new,
|
45
|
+
:name => 'Private Class C',
|
46
|
+
:starting_address => '192.168.0.0',
|
47
|
+
:ending_address => '192.168.0.255'
|
48
|
+
)
|
49
|
+
|
50
|
+
# Associate this network segment with a specific building,
|
51
|
+
# which must exist in the JSS, and be listed in JSS::Building.all_names
|
43
52
|
ns.building = "Main Office"
|
44
53
|
|
45
|
-
# Associate this network segment with a specific software update server,
|
46
|
-
# and be listed in JSS::SoftwareUpdateServer.all_names
|
54
|
+
# Associate this network segment with a specific software update server,
|
55
|
+
# which must exist in the JSS, and be listed in JSS::SoftwareUpdateServer.all_names
|
47
56
|
ns.swu_server = "Main SWU Server"
|
48
57
|
|
49
|
-
#
|
58
|
+
# Create the new network segment in the JSS
|
50
59
|
ns.create
|
51
60
|
```
|
52
61
|
|
@@ -82,7 +91,7 @@ All API Object classes are subclasses of JSS::APIObject and share methods for li
|
|
82
91
|
To get an Array of every object in the JSS of some Class, call that Class's .all method:
|
83
92
|
|
84
93
|
```ruby
|
85
|
-
JSS::Computer.all # => [{:name=>"cephei", :id=>
|
94
|
+
JSS::Computer.all # => [{:name=>"cephei", :id=>1122},{:name=>"peterparker", :id=>1218}, {:name=>"rowdy", :id=>931}, ...]
|
86
95
|
```
|
87
96
|
|
88
97
|
The Array will contain a Hash for each item, with at least a :name and an :id. Some classes provide more data for each item.
|
@@ -90,7 +99,7 @@ To get just the names or just the ids in an Array, use the .all\_names or .all\_
|
|
90
99
|
|
91
100
|
```ruby
|
92
101
|
JSS::Computer.all_names # => ["cephei", "peterparker", "rowdy", ...]
|
93
|
-
JSS::Computer.all_ids # => [
|
102
|
+
JSS::Computer.all_ids # => [1122, 1218, 931, ...]
|
94
103
|
```
|
95
104
|
|
96
105
|
Some Classes provide other ways to list objects, depending on the data available, e.g. JSS::MobileDevice.all\_udids
|
@@ -170,13 +179,10 @@ existing_script = JSS::Script.new :id => 321
|
|
170
179
|
existing_script.delete # => true # the delete was successful
|
171
180
|
```
|
172
181
|
|
173
|
-
|
174
182
|
See JSS::APIObject, the parent class of all API resources, for general information about creating, reading, updating/saving, and deleting resources.
|
175
183
|
|
176
184
|
See the individual subclasses for any details specific to them.
|
177
185
|
|
178
|
-
|
179
|
-
|
180
186
|
## OBJECTS IMPLEMENTED
|
181
187
|
|
182
188
|
See each Class's documentation for details.
|
@@ -241,7 +247,6 @@ These must be created and edited via the JSS WebApp
|
|
241
247
|
|
242
248
|
All supported API Objects can be deleted
|
243
249
|
|
244
|
-
|
245
250
|
Other useful classes:
|
246
251
|
|
247
252
|
* {JSS::Server} - An encapsulation of some info about the server, such as the JSS version and license. An instance is available as an attribute of the {JSS::APIConnection} singleton.
|
@@ -249,23 +254,21 @@ Other useful classes:
|
|
249
254
|
|
250
255
|
## CONFIGURATION
|
251
256
|
|
252
|
-
The {JSS::Configuration} singleton class is used to read, write, and use site-specific defaults for
|
257
|
+
The {JSS::Configuration} singleton class is used to read, write, and use site-specific defaults for the JSS module. When the Module is required, the single instance of {JSS::Configuration} is created and stored in the constant {JSS::CONFIG}. At that time the system-wide file /etc/jss_gem.conf is examined if it exists, and the items in it are loaded into the attributes of {JSS::CONFIG}. The user-specific file ~/.jss_gem.conf then is examined if it exists, and any items defined there will override those values from the system-wide file.
|
253
258
|
|
254
|
-
The values defined in those files are used as defaults throughout the
|
259
|
+
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 {JSS::API#connect}. Values provided explicitly when calling JSS::API.connect will override the config values.
|
255
260
|
|
256
|
-
While the {JSS::Configuration}
|
261
|
+
While the {JSS::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:
|
257
262
|
|
258
263
|
attr_name: value
|
259
264
|
|
260
265
|
Lines that don’t start with a known attribute name followed by a colon are ignored. If an attribute is defined more than once, the last one wins.
|
261
266
|
|
262
|
-
Lines starting with a # are comments and will be preserved when using #save.
|
263
|
-
|
264
267
|
The currently known attributes are:
|
265
268
|
|
266
269
|
* api_server_name [String] the hostname of the JSS API server
|
267
270
|
* api_server_port [Integer] the port number for the API connection
|
268
|
-
* api_verify_cert [Boolean] 'true' or 'false' - if SSL is used, should the
|
271
|
+
* api_verify_cert [Boolean] 'true' or 'false' - if SSL is used, should the certificate be verified? (usually false for a self-signed cert)
|
269
272
|
* api_username [String] the JSS username for connecting to the API
|
270
273
|
* api_timeout_open [Integer] the number of seconds for the open-connection timeout
|
271
274
|
* api_timeout [Integer] the number of seconds for the response timeout
|
@@ -280,9 +283,28 @@ api_verify_cert: false
|
|
280
283
|
|
281
284
|
and then any calls to {JSS::API.connect} will assume that server and username, and won't complain about the self-signed certificate.
|
282
285
|
|
283
|
-
|
284
|
-
|
286
|
+
### Passwords
|
287
|
+
|
288
|
+
The config files don't store passwords and the {JSS::Configuration} instance doesn't work with them. You'll have to use your own methods for acquiring the password for the JSS::API.connect call.
|
285
289
|
|
290
|
+
The {JSS::API#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.
|
291
|
+
|
292
|
+
If you must store a password in a file, or retrieve it from the network, make sure it's stored securely, and that the JSS user has limited permissions.
|
293
|
+
|
294
|
+
Here's an example of how to use a password stored in a file:
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
password = File.read "/path/to/secure/password/file" # read the password from a file
|
298
|
+
JSS::API.connect :pw => password # other arguments used from the config settings
|
299
|
+
```
|
300
|
+
|
301
|
+
And here's an example of how to read a password from a web server and use it.
|
302
|
+
|
303
|
+
```ruby
|
304
|
+
require 'open-uri'
|
305
|
+
password = open('http://server.org.org/path/to/password').read
|
306
|
+
JSS::API.connect :pw => password # other arguments used from the config settings
|
307
|
+
```
|
286
308
|
|
287
309
|
## BEYOND THE API
|
288
310
|
|
data/lib/jss-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jss-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 5
|
10
|
+
version: 0.5.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Lasell
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-10-
|
18
|
+
date: 2014-10-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: plist
|
@@ -101,7 +101,7 @@ dependencies:
|
|
101
101
|
version: "0"
|
102
102
|
type: :runtime
|
103
103
|
version_requirements: *id006
|
104
|
-
description: " The JSS
|
104
|
+
description: " The jss-api gem provides the JSS module, a framework for interacting with the REST API of the\n JAMF Software Server (JSS), the core of the Casper Suite from JAMF Software, LLC.\n JSS API objects are implemented as Ruby classes, and interact with each oher to\n allow simpler automation of Casper-related tasks. For details see the README file.\"\n"
|
105
105
|
email: chrisl@pixar.com
|
106
106
|
executables: []
|
107
107
|
|
@@ -177,7 +177,7 @@ files:
|
|
177
177
|
- LICENSE.txt
|
178
178
|
- CHANGES.md
|
179
179
|
- THANKS.md
|
180
|
-
homepage: http://pixaranimationstudios.github.io/jss-api-gem/
|
180
|
+
homepage: http://pixaranimationstudios.github.io/jss-api-gem/
|
181
181
|
licenses:
|
182
182
|
- Modified Apache-2.0
|
183
183
|
post_install_message:
|