ruby-jss 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.yardopts +7 -0
- data/CHANGES.md +112 -0
- data/LICENSE.txt +174 -0
- data/README.md +426 -0
- data/THANKS.md +6 -0
- data/bin/cgrouper +485 -0
- data/bin/subnet-update +400 -0
- data/lib/jss-api.rb +2 -0
- data/lib/jss.rb +190 -0
- data/lib/jss/api_connection.rb +410 -0
- data/lib/jss/api_object.rb +616 -0
- data/lib/jss/api_object/advanced_search.rb +389 -0
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +95 -0
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +96 -0
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +95 -0
- data/lib/jss/api_object/building.rb +92 -0
- data/lib/jss/api_object/category.rb +147 -0
- data/lib/jss/api_object/computer.rb +852 -0
- data/lib/jss/api_object/creatable.rb +98 -0
- data/lib/jss/api_object/criteriable.rb +189 -0
- data/lib/jss/api_object/criteriable/criteria.rb +231 -0
- data/lib/jss/api_object/criteriable/criterion.rb +228 -0
- data/lib/jss/api_object/department.rb +93 -0
- data/lib/jss/api_object/distribution_point.rb +560 -0
- data/lib/jss/api_object/extendable.rb +221 -0
- data/lib/jss/api_object/extension_attribute.rb +466 -0
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +362 -0
- data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +189 -0
- data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +117 -0
- data/lib/jss/api_object/group.rb +380 -0
- data/lib/jss/api_object/group/computer_group.rb +124 -0
- data/lib/jss/api_object/group/mobile_device_group.rb +139 -0
- data/lib/jss/api_object/group/user_group.rb +139 -0
- data/lib/jss/api_object/ldap_server.rb +535 -0
- data/lib/jss/api_object/locatable.rb +286 -0
- data/lib/jss/api_object/matchable.rb +97 -0
- data/lib/jss/api_object/mobile_device.rb +556 -0
- data/lib/jss/api_object/netboot_server.rb +148 -0
- data/lib/jss/api_object/network_segment.rb +414 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +262 -0
- data/lib/jss/api_object/package.rb +839 -0
- data/lib/jss/api_object/peripheral.rb +335 -0
- data/lib/jss/api_object/peripheral_type.rb +295 -0
- data/lib/jss/api_object/policy.rb +898 -0
- data/lib/jss/api_object/purchasable.rb +316 -0
- data/lib/jss/api_object/removable_macaddr.rb +98 -0
- data/lib/jss/api_object/scopable.rb +136 -0
- data/lib/jss/api_object/scopable/scope.rb +621 -0
- data/lib/jss/api_object/script.rb +631 -0
- data/lib/jss/api_object/self_servable.rb +356 -0
- data/lib/jss/api_object/site.rb +93 -0
- data/lib/jss/api_object/software_update_server.rb +109 -0
- data/lib/jss/api_object/updatable.rb +117 -0
- data/lib/jss/api_object/uploadable.rb +138 -0
- data/lib/jss/api_object/user.rb +272 -0
- data/lib/jss/client.rb +504 -0
- data/lib/jss/compatibility.rb +66 -0
- data/lib/jss/composer.rb +185 -0
- data/lib/jss/configuration.rb +306 -0
- data/lib/jss/db_connection.rb +298 -0
- data/lib/jss/exceptions.rb +95 -0
- data/lib/jss/ruby_extensions.rb +35 -0
- data/lib/jss/ruby_extensions/filetest.rb +43 -0
- data/lib/jss/ruby_extensions/hash.rb +79 -0
- data/lib/jss/ruby_extensions/ipaddr.rb +91 -0
- data/lib/jss/ruby_extensions/pathname.rb +77 -0
- data/lib/jss/ruby_extensions/string.rb +59 -0
- data/lib/jss/ruby_extensions/time.rb +63 -0
- data/lib/jss/server.rb +108 -0
- data/lib/jss/utility.rb +478 -0
- data/lib/jss/version.rb +31 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 51cf70afc810fbee9ccdecf58e5dca6692d9a26b
|
4
|
+
data.tar.gz: d669472cf36975bdc4e4c4ce65392a7c1802f416
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4d5d398bff3f5c0a0bf92b02689cd5b03d2f9c9bbc1d961eea43790524962ba3348fd034c9c974ddd4be32a2afffed23fbdce2dd9549f0cfae0ec8da429b5ad
|
7
|
+
data.tar.gz: 50b93457bd8a8b5a2226d9374ced5baacfeaba6e9ab37d7e04836cbc3b0e95d829cff1a34ed701cdfe27497f6a1c80131effe2ce794e06fe3cdc35ffe03c905c
|
data/.yardopts
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# Change History
|
2
|
+
|
3
|
+
## v0.6.2 2016-03-08
|
4
|
+
|
5
|
+
As of v0.6.2, the github project, and rubygem have been renamed to 'ruby-jss'. The 'require' name is now 'jss'.
|
6
|
+
|
7
|
+
In part this was to make the name more in-line with other ruby gems, and also to get in line with Shea Craig's [python-jss](https://github.com/sheagcraig/python-jss) and Charles Edge's [swift-jss](https://github.com/krypted/swift-jss)
|
8
|
+
|
9
|
+
Yes we now have native API access in 3 languages!
|
10
|
+
|
11
|
+
The 'jss-api' gem has been updated one last time, also to v0.6.2. That gem has a dependency on ruby-jss v0.6.2 or greater, and if you require 'jss-api' with it, it merely requires 'jss' for you. While that will provide backward-compatibility, please update your code to require 'jss' directly, since the jss-api wrapper gem won't be around forever.
|
12
|
+
|
13
|
+
#### additions & features
|
14
|
+
|
15
|
+
- JSS::Package#os_ok? and JSS::Package#processor_ok? methods can now check those things against the package settings, and not attempt to install if the machine isn't up to snuff.
|
16
|
+
|
17
|
+
- JSS::ExtensionAttribute#latest_values always now includes :username in the returned data.
|
18
|
+
|
19
|
+
#### bugfixes
|
20
|
+
|
21
|
+
- JSS::stdin_lines no longer uses a constant to store incoming stdin data at load time, which causes hangs when there's no terminal on stdin. Now stdin is only read when the method is called, and data stored in a module variable.
|
22
|
+
|
23
|
+
- JSS::Composer::mk_dmg fix for building/indexing dmg's, no longer creates an unreadable .Trashes folder.
|
24
|
+
|
25
|
+
- Several small typos and other tiny bugs.
|
26
|
+
|
27
|
+
## v0.6.1 2016-03-01
|
28
|
+
|
29
|
+
#### additions & features
|
30
|
+
|
31
|
+
- JSS::Package#install now takes :alt_download_url argument.Can be used to specify a custom URL from which to download a pkg/dmg for installation with 'jamf install'. This allows the use of cloud distribution points.
|
32
|
+
- JSS::DistributionPoint: Added reachability methods, improved assessment of mount-success. #reachable_for_download? and #reachable_for_upload? will now return a boolean indicating if the DistPoint is reachable.
|
33
|
+
|
34
|
+
## v0.6.0 2016-01-06
|
35
|
+
|
36
|
+
This version of the jss-api gem incorporates changes needed for the upcoming release of d3 (a.k.a. depot3),
|
37
|
+
a package/patch management system for Casper, which was the reason for the jss-api gem to begin with.
|
38
|
+
|
39
|
+
As such, while the JSS module will continue to be a separate git repo, specific commits of it will be
|
40
|
+
submodules of the depot3 git repo, starting with this one, or one shortly hereafter.
|
41
|
+
|
42
|
+
|
43
|
+
#### bugfixes & cleanup
|
44
|
+
|
45
|
+
- new path to the jamf binary was corrected
|
46
|
+
- fixed the logic in using the :use_ssl arg to JSS::APIConnection::connect
|
47
|
+
- Composer module no longer adds redundant .pkg extensions
|
48
|
+
- JSS::DistributionPoint, bug fix when initializing with :id=>:master
|
49
|
+
- JSS::DistributionPoint: #mount now defaults to read-only unless :rw is passed
|
50
|
+
- String: added #jss_to_time to convertion strings to Time objects using JSS::parse_time
|
51
|
+
- JSS::Package: better handling of API values like "None" and "No category assigned"
|
52
|
+
- JSS::Package: added #type to return :pkg or :dmg
|
53
|
+
- JSS::Package: Changes to #install, including return value! See NOTES below.
|
54
|
+
- lots of code cleanup
|
55
|
+
|
56
|
+
#### additions & features
|
57
|
+
|
58
|
+
- JSS::APIConnection and JSS::DBConnection determines server hostname via several means if not yet connected
|
59
|
+
- JSS::APIConnection and JSS::DBConnection can test validitiy of a server
|
60
|
+
- JSS::DBConnection now has a DEFAULT_PORT constant
|
61
|
+
|
62
|
+
|
63
|
+
NOTES:
|
64
|
+
|
65
|
+
Important: Package#install now returns a boolean indicating success of installation.
|
66
|
+
The previous return value (the Process::Status of the 'jamf install' proceess) usually returned 0 exitstatus even if the pkg install failed.
|
67
|
+
Now the actual install command is examined, and if its exitstatus is zero, Package#install returns true, else false.
|
68
|
+
|
69
|
+
Also: As of casper 9.72, the argument requirements havechanged for 'jamf install' with http downloads. This is now handled correctly
|
70
|
+
|
71
|
+
|
72
|
+
## v0.5.8 2015-09-22
|
73
|
+
|
74
|
+
#### bugfixes & cleanup
|
75
|
+
|
76
|
+
- location.rb: location value setters are now properly converted to strings
|
77
|
+
- api_connection.rb: #connect now takes :use_ssl option (defaults to true)
|
78
|
+
- api_connection.rb: #connect will accept arbitrary ports when :use_ssl is true
|
79
|
+
|
80
|
+
#### additions & features
|
81
|
+
|
82
|
+
- client.rb: looks for the new ElCap+ location for the jamf binary, falls back to old location if not found.
|
83
|
+
- Locatable#clear_location public instance method added
|
84
|
+
- TimeoutError and AuthenticationError have been added to exceptions
|
85
|
+
- Policy objects now have a #run method - attempts to execute the policy locally.
|
86
|
+
|
87
|
+
## v0.5.7 2015-05-26
|
88
|
+
|
89
|
+
#### bugfixes & cleanup
|
90
|
+
|
91
|
+
- JSS.to_s_and_a now properly converts nils to "" and []
|
92
|
+
- DBConnection.connect gracefully handle reconnecting if the old connection went away
|
93
|
+
- DBConnection.connect, and APIConnection.connect: include server name when prompting for password
|
94
|
+
- Configuration: handle lack of ENV['HOME'] when trying to expand ~ to locate user-level config file.
|
95
|
+
- MobileDevice#unmanage_device: send_mdm_command is a class method, not an instance method
|
96
|
+
- APIObject: auto-set @site and @category if applicable
|
97
|
+
- Package: os_requirements default to empty array if unset in JSS
|
98
|
+
- Package#required_processor: remove buggy line of ancient, deprecated code
|
99
|
+
- Package#upload_master_file: move autoupdate to appropriate location
|
100
|
+
|
101
|
+
## v0.5.6 2014-11-04
|
102
|
+
|
103
|
+
- now requires Ruby >= 1.9.3 and rest-client >= 1.7.0. Needed for Casper >= 9.61's lack of support for SSLv3.
|
104
|
+
- APIConnection now accepts :ssl_version option in the argument hash. Defaults to 'TLSv1'
|
105
|
+
- Configuration now supports the api_ssl_version key, used for the :ssl_version option of the APIConnection.
|
106
|
+
- the example programs have been moved to the bin directory, and are now included in the gem installation.
|
107
|
+
- many documentation updates as we adjust to being live
|
108
|
+
- minor bugfixes
|
109
|
+
|
110
|
+
## v0.5.0 2014-10-23
|
111
|
+
|
112
|
+
- first opensource release
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
|
2
|
+
Modified Apache 2.0 License
|
3
|
+
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor
|
140
|
+
and its affiliates, except as required to comply with Section 4(c) of
|
141
|
+
the License and to reproduce the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
data/README.md
ADDED
@@ -0,0 +1,426 @@
|
|
1
|
+
# ruby-jss: Access to the Casper Suite from Ruby
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/ruby-jss.svg)](http://badge.fury.io/rb/ruby-jss)
|
3
|
+
|
4
|
+
### Table of contents
|
5
|
+
* [DESCRIPTION](#description)
|
6
|
+
* [SYNOPSIS](#synopsis)
|
7
|
+
* [USAGE](#usage)
|
8
|
+
* [Connecting to the API](#connecting-to-the-api)
|
9
|
+
* [Working with JSS Objects (a.k.a REST Resources)](#working-with-jss-objects-aka-rest-resources)
|
10
|
+
* [Listing Objects](#listing-objects)
|
11
|
+
* [Retrieving Objects](#retrieving-objects)
|
12
|
+
* [Updating Objects](#updating-objects)
|
13
|
+
* [Deleting Objects](#deleting-objects)
|
14
|
+
* [OBJECTS IMPLEMENTED](#objects-implemented)
|
15
|
+
* [Creatable and Updatable](#creatable-and-updatable)
|
16
|
+
* [Updatable but not Creatable](#updatable-but-not-creatable)
|
17
|
+
* [Read-Only](#read-only)
|
18
|
+
* [Creatable and Updatable](#creatable-and-updatable)
|
19
|
+
* [Deletable](#deletable)
|
20
|
+
* [CONFIGURATION](#configuration)
|
21
|
+
* [Passwords](#passwords)
|
22
|
+
* [BEYOND THE API](#beyond-the-api)
|
23
|
+
* [REQUIREMENTS](#requirements)
|
24
|
+
* [INSTALL](#install)
|
25
|
+
* [HELP](#help)
|
26
|
+
* [LICENSE](#license)
|
27
|
+
|
28
|
+
## DESCRIPTION
|
29
|
+
|
30
|
+
The ruby-jss project 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, an enterprise-level management tool for Apple devices from [JAMF Software, LLC](http://www.jamfsoftware.com/). It is available as a [rubygem](https://rubygems.org/gems/ruby-jss), and the [source is on github](https://github.com/PixarAnimationStudios/ruby-jss).
|
31
|
+
|
32
|
+
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)
|
33
|
+
|
34
|
+
The module is not a complete implementation of the Casper API. Only some API objects are modeled, some only minimally. Of
|
35
|
+
those, some are read-only, some partially writable, some fully read-write (all implemented objects can be deleted)
|
36
|
+
See OBJECTS IMPLEMENTED for a list.
|
37
|
+
|
38
|
+
We've implemented the things we need in our environment, and as our needs grow, we'll add more.
|
39
|
+
Hopefully others will find it useful, and add more to it as well.
|
40
|
+
|
41
|
+
[Full technical documentation can be found here.](http://www.rubydoc.info/gems/ruby-jss/)
|
42
|
+
|
43
|
+
|
44
|
+
## SYNOPSIS
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'jss'
|
48
|
+
|
49
|
+
JSS::API.connect(
|
50
|
+
:user => jss_user,
|
51
|
+
:pw => jss_user_pw,
|
52
|
+
:server => jss_server_hostname
|
53
|
+
)
|
54
|
+
|
55
|
+
# get an array of data about all JSS::Package objects in the JSS:
|
56
|
+
JSS::Package.all
|
57
|
+
|
58
|
+
# get an array of names of all JSS::Package objects in the JSS:
|
59
|
+
JSS::Package.all_names
|
60
|
+
|
61
|
+
# Get a static computer group
|
62
|
+
mg = JSS::ComputerGroup.new :name => "Macs of interest"
|
63
|
+
|
64
|
+
# Add a computer to the group
|
65
|
+
mg.add_member "pricklepants"
|
66
|
+
|
67
|
+
# save my changes
|
68
|
+
mg.update
|
69
|
+
|
70
|
+
# Create a new network segment to store in the JSS
|
71
|
+
ns = JSS::NetworkSegment.new(
|
72
|
+
:id => :new,
|
73
|
+
:name => 'Private Class C',
|
74
|
+
:starting_address => '192.168.0.0',
|
75
|
+
:ending_address => '192.168.0.255'
|
76
|
+
)
|
77
|
+
|
78
|
+
# Associate this network segment with a specific building,
|
79
|
+
# which must exist in the JSS, and be listed in JSS::Building.all_names
|
80
|
+
ns.building = "Main Office"
|
81
|
+
|
82
|
+
# Associate this network segment with a specific software update server,
|
83
|
+
# which must exist in the JSS, and be listed in JSS::SoftwareUpdateServer.all_names
|
84
|
+
ns.swu_server = "Main SWU Server"
|
85
|
+
|
86
|
+
# Create the new network segment in the JSS
|
87
|
+
ns.create
|
88
|
+
```
|
89
|
+
|
90
|
+
## USAGE
|
91
|
+
|
92
|
+
### Connecting to the API
|
93
|
+
|
94
|
+
Before you can work with JSS Objects via the API, you have to connect to it.
|
95
|
+
|
96
|
+
The constant {JSS::API} contains the connection to the API (a singleton instance of {JSS::APIConnection}). When the JSS Module is first loaded, it isn't
|
97
|
+
connected. To remedy that, use JSS::API.connect, passing it values for :user, :pw, and :server:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
JSS::API.connect :user => jss_user, :pw => jss_user_pw, :server => jss_server_hostname
|
101
|
+
```
|
102
|
+
|
103
|
+
Make sure the user has privileges in the JSS to do things with API Objects.
|
104
|
+
|
105
|
+
The {JSS::API#connect} method also accepts the symbols :stdin and :prompt as values for :pw, which will cause it to read the
|
106
|
+
password from stdin, or prompt for it in the shell. See the JSS::APIConnection class for more connection options and details about its methods.
|
107
|
+
|
108
|
+
Also see {JSS::Configuration}, and the CONFIGURATION section below, for how to store
|
109
|
+
server connection parameters in a simple config file.
|
110
|
+
|
111
|
+
### Working with JSS Objects (a.k.a REST Resources)
|
112
|
+
|
113
|
+
All API Object classes are subclasses of JSS::APIObject and share methods for listing, retrieving, and deleting from the JSS. All supported objects can be listed, retrieved and deleted, but only some can be updated or created. Those classes do so by mixing in the JSS::Creatable and/or JSS::Updateable modules. See below for the level of implementation of each class.
|
114
|
+
|
115
|
+
--------
|
116
|
+
|
117
|
+
#### Listing Objects
|
118
|
+
|
119
|
+
To get an Array of every object in the JSS of some Class, call that Class's .all method:
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
JSS::Computer.all # => [{:name=>"cephei", :id=>1122},{:name=>"peterparker", :id=>1218}, {:name=>"rowdy", :id=>931}, ...]
|
123
|
+
```
|
124
|
+
|
125
|
+
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.
|
126
|
+
To get just the names or just the ids in an Array, use the .all\_names or .all\_ids Class method
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
JSS::Computer.all_names # => ["cephei", "peterparker", "rowdy", ...]
|
130
|
+
JSS::Computer.all_ids # => [1122, 1218, 931, ...]
|
131
|
+
```
|
132
|
+
|
133
|
+
Some Classes provide other ways to list objects, depending on the data available, e.g. JSS::MobileDevice.all\_udids
|
134
|
+
|
135
|
+
--------
|
136
|
+
|
137
|
+
#### Retrieving Objects
|
138
|
+
|
139
|
+
To retrieve a single object call the object's constructor (.new) and provide either :name or :id or :data.
|
140
|
+
|
141
|
+
* :name or :id will be looked up via the API
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
a_dept = JSS::Department.new :name => "Payroll" # => #<JSS::Department:0x10b4c0818...
|
145
|
+
```
|
146
|
+
|
147
|
+
* :data must be the parsed JSON output of a separate API query (a hash with symbolized keys)
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
dept_data = JSS::API.get_rsrc("departments/name/Payroll")[:department] # => {:name=>"Payroll", :id=>42}
|
151
|
+
a_dept = JSS::Department.new :data => dept_data # => #<JSS::Department:0x10b4a83f8...
|
152
|
+
```
|
153
|
+
|
154
|
+
Some subclasses 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.
|
155
|
+
|
156
|
+
--------
|
157
|
+
|
158
|
+
#### Creating Objects
|
159
|
+
|
160
|
+
Some Objects can be created anew in the JSS. To make a new object, first instantiate one using :id => :new, and provide a unique :name.
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
new_pkg = JSS::Package.new :id => :new, :name => "transmogrifier-2.3-1.pkg"
|
164
|
+
```
|
165
|
+
|
166
|
+
Then set the attributes of the new object as needed
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
new_pkg.reboot_required = false
|
170
|
+
new_pkg.category = "CoolTools"
|
171
|
+
# etc..
|
172
|
+
```
|
173
|
+
|
174
|
+
Then use the #create method to create it in the JSS.
|
175
|
+
|
176
|
+
```ruby
|
177
|
+
new_pkg.create # => 453 # the id number of the object just created
|
178
|
+
```
|
179
|
+
|
180
|
+
*NOTE* some subclasses require more data than just a :name when instantiating with :id => :new.
|
181
|
+
|
182
|
+
--------
|
183
|
+
|
184
|
+
#### Updating Objects
|
185
|
+
|
186
|
+
Some objects can be modified in the JSS.
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
existing_script = JSS::Script.new :id => 321
|
190
|
+
existing_script.name = "transmogrifier-2.3-1.post-install"
|
191
|
+
```
|
192
|
+
|
193
|
+
After changing any attributes, use the #update method (also aliased to #save) to push the changes to the JSS.
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
existing_script.update # or existing_script.save => true # the update was successful
|
197
|
+
```
|
198
|
+
|
199
|
+
--------
|
200
|
+
|
201
|
+
#### Deleting Objects
|
202
|
+
|
203
|
+
To delete an object, just call its #delete method
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
existing_script = JSS::Script.new :id => 321
|
207
|
+
existing_script.delete # => true # the delete was successful
|
208
|
+
```
|
209
|
+
|
210
|
+
See JSS::APIObject, the parent class of all API resources, for general information about creating, reading, updating/saving, and deleting resources.
|
211
|
+
|
212
|
+
See the individual subclasses for any details specific to them.
|
213
|
+
|
214
|
+
## OBJECTS IMPLEMENTED
|
215
|
+
|
216
|
+
See each Class's documentation for details.
|
217
|
+
|
218
|
+
### Creatable and Updatable
|
219
|
+
|
220
|
+
* {JSS::AdvancedComputerSearch}
|
221
|
+
* {JSS::AdvancedMobileDeviceSearch}
|
222
|
+
* {JSS::AdvancedUserSearch}
|
223
|
+
* {JSS::Building}
|
224
|
+
* {JSS::Category}
|
225
|
+
* {JSS::ComputerExtensionAttribute}
|
226
|
+
* {JSS::ComputerGroup}
|
227
|
+
* {JSS::Department}
|
228
|
+
* {JSS::MobileDeviceExtensionAttribute}
|
229
|
+
* {JSS::MobileDeviceGroup}
|
230
|
+
* {JSS::NetworkSegment}
|
231
|
+
* {JSS::Package}
|
232
|
+
* {JSS::Peripheral}
|
233
|
+
* {JSS::PeripheralType}
|
234
|
+
* {JSS::RemovableMacAddress}
|
235
|
+
* {JSS::Script}
|
236
|
+
* {JSS::User}
|
237
|
+
* {JSS::UserExtensionAttribute}
|
238
|
+
* {JSS::UserGroup}
|
239
|
+
|
240
|
+
### Updatable but not Creatable
|
241
|
+
|
242
|
+
* {JSS::Computer} - limited to modifying
|
243
|
+
* name
|
244
|
+
* barcodes
|
245
|
+
* asset tag
|
246
|
+
* ip address
|
247
|
+
* location data
|
248
|
+
* purchasing data
|
249
|
+
* editable extension attributes
|
250
|
+
* {JSS::MobileDevice} - limited to modifying
|
251
|
+
* asset tag
|
252
|
+
* location data
|
253
|
+
* purchasing data
|
254
|
+
* editable extension attributes
|
255
|
+
* {JSS::Policy} - limited to modifying
|
256
|
+
* scope (see {JSS::Scopable::Scope})
|
257
|
+
* name
|
258
|
+
* enabled
|
259
|
+
* category
|
260
|
+
* triggers
|
261
|
+
* file & process actions
|
262
|
+
|
263
|
+
**NOTE** Even in the API and the WebApp, Computer and Mobile Device data gathered by an Inventory Upate (a.k.a. 'recon') is not editable.
|
264
|
+
|
265
|
+
### Read-Only
|
266
|
+
|
267
|
+
These must be created and edited via the JSS WebApp
|
268
|
+
|
269
|
+
* {JSS::DistributionPoint}
|
270
|
+
* {JSS::LDAPServer}
|
271
|
+
* {JSS::NetBootServer}
|
272
|
+
* {JSS::SoftwareUpdateServer}
|
273
|
+
|
274
|
+
### Deletable
|
275
|
+
|
276
|
+
All supported API Objects can be deleted
|
277
|
+
|
278
|
+
Other useful classes:
|
279
|
+
|
280
|
+
* {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.
|
281
|
+
* {JSS::Client} - An object representing the local machine as a Casper-managed client, and JAMF-related info and methods
|
282
|
+
|
283
|
+
## CONFIGURATION
|
284
|
+
|
285
|
+
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.
|
286
|
+
|
287
|
+
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.
|
288
|
+
|
289
|
+
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:
|
290
|
+
|
291
|
+
attr_name: value
|
292
|
+
|
293
|
+
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.
|
294
|
+
|
295
|
+
The currently known attributes are:
|
296
|
+
|
297
|
+
* api_server_name [String] the hostname of the JSS API server
|
298
|
+
* api_server_port [Integer] the port number for the API connection
|
299
|
+
* api_verify_cert [Boolean] 'true' or 'false' - if SSL is used, should the certificate be verified? (usually false for a self-signed cert)
|
300
|
+
* api_username [String] the JSS username for connecting to the API
|
301
|
+
* api_timeout_open [Integer] the number of seconds for the open-connection timeout
|
302
|
+
* api_timeout [Integer] the number of seconds for the response timeout
|
303
|
+
|
304
|
+
To put a standard server & username on all client machines, and auto-accept the JSS's self-signed https certificate, create the file /etc/jss_gem.conf containing three lines like this:
|
305
|
+
|
306
|
+
```
|
307
|
+
api_server_name: casper.myschool.edu
|
308
|
+
api_username: readonly-api-user
|
309
|
+
api_verify_cert: false
|
310
|
+
```
|
311
|
+
|
312
|
+
and then any calls to {JSS::API.connect} will assume that server and username, and won't complain about the self-signed certificate.
|
313
|
+
|
314
|
+
### Passwords
|
315
|
+
|
316
|
+
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.
|
317
|
+
|
318
|
+
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.
|
319
|
+
|
320
|
+
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.
|
321
|
+
|
322
|
+
Here's an example of how to use a password stored in a file:
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
password = File.read "/path/to/secure/password/file" # read the password from a file
|
326
|
+
JSS::API.connect :pw => password # other arguments used from the config settings
|
327
|
+
```
|
328
|
+
|
329
|
+
And here's an example of how to read a password from a web server and use it.
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
require 'open-uri'
|
333
|
+
password = open('http://server.org.org/path/to/password').read
|
334
|
+
JSS::API.connect :pw => password # other arguments used from the config settings
|
335
|
+
```
|
336
|
+
|
337
|
+
## BEYOND THE API
|
338
|
+
|
339
|
+
While the Casper API provides access to object data in the JSS, this gem tries to use that data to provide more than just information exchange. Here are some examples of how we use the API data to provide functionality found in various Casper tools:
|
340
|
+
|
341
|
+
* Client Machine Access
|
342
|
+
* The {JSS::Client} module provides the ability to run jamf binary commands, and access the local cache of package receipts
|
343
|
+
* Package Installation
|
344
|
+
* {JSS::Package} objects can be installed on the local machine, from the appropriate distribution point
|
345
|
+
* Script Execution
|
346
|
+
* {JSS::Script} objects can be executed locally on demand
|
347
|
+
* Package Creation
|
348
|
+
* The {JSS::Composer} module provides creation of very simple .pkg and .dmg packages
|
349
|
+
* {JSS::Package} objects can upload their .pkg or .dmg files to the master distribution point ({JSS::Script} objects can also if you store them there.)
|
350
|
+
* Reporting/AdvancedSearch exporting
|
351
|
+
* {JSS::AdvancedSearch} subclasses can export their results to csv, tab, and xml files.
|
352
|
+
* LDAP Access
|
353
|
+
* {JSS::LDAPServer} objects can query the LDAP servers for user, group, and membership data.
|
354
|
+
* MDM Commands
|
355
|
+
* {JSS::MobileDevice}s (and eventually {JSS::Computer}s) can be sent MDM commands
|
356
|
+
* Extension Attributes
|
357
|
+
* {JSS::ExtensionAttribute} work with {JSS::AdvancedSearch} subclasses to provide extra reporting about Ext. Attrib. values.
|
358
|
+
|
359
|
+
## REQUIREMENTS
|
360
|
+
|
361
|
+
the JSS gem was written for:
|
362
|
+
|
363
|
+
* Mac OS X 10.8 and higher
|
364
|
+
* Casper Suite version 9.4 or higher
|
365
|
+
* Casper 9.4 - 9.6 require Ruby 1.8.7 and higher
|
366
|
+
* Casper >= 9.61 require Ruby 1.9.3 and higher
|
367
|
+
|
368
|
+
It also requires these gems, which will be installed automatically if you install JSS with `gem install jss`
|
369
|
+
|
370
|
+
* rest-client >=1.6.7 ( >= 1.7.0 with Casper >= 9.6.1) http://rubygems.org/gems/rest-client
|
371
|
+
* json or json\_pure >= 1.6.5 http://rubygems.org/gems/json or http://rubygems.org/gems/json_pure
|
372
|
+
* (only in ruby 1.8.7. Ruby >= 1.9 has json in its standard library)
|
373
|
+
* ruby-mysql >= 2.9.12 http://rubygems.org/gems/ruby-mysql
|
374
|
+
* (only for a few things that still require direct SQL access to the JSS database)
|
375
|
+
* plist =3.1.0 http://rubygems.org/gems/plist
|
376
|
+
* for the {JSS::Composer} module and {JSS::Client} class
|
377
|
+
* net-ldap >= 0.3.1 http://rubygems.org/gems/net-ldap
|
378
|
+
* for accessing the LDAP servers defined in the JSS, to check for user and group info.
|
379
|
+
|
380
|
+
## INSTALL
|
381
|
+
|
382
|
+
NOTE: You may need to install XCode, and it's CLI tools, in order to install the required gems.
|
383
|
+
|
384
|
+
In general, you can install the JSS Gem with this command:
|
385
|
+
|
386
|
+
`gem install ruby-jss`
|
387
|
+
|
388
|
+
If you're using Ruby 1.8.7 (Casper 9.4 - 9.6 only), install the following gems manually first, since the JSS gem will try to install newer, incompatible versions if they aren't pre-installed.
|
389
|
+
|
390
|
+
`gem install json -v 1.6.5`
|
391
|
+
|
392
|
+
`gem install mime-types -v 1.25.1`
|
393
|
+
|
394
|
+
`gem install rest-client -v 1.6.8`
|
395
|
+
|
396
|
+
|
397
|
+
## HELP
|
398
|
+
|
399
|
+
[Email the developer](mailto:ruby-jss@pixar.com)
|
400
|
+
|
401
|
+
[Macadmins Slack Channel](https://macadmins.slack.com/messages/#jss-api/)
|
402
|
+
|
403
|
+
## LICENSE
|
404
|
+
|
405
|
+
Copyright 2016 Pixar
|
406
|
+
|
407
|
+
Licensed under the Apache License, Version 2.0 (the "Apache License")
|
408
|
+
with the following modification; you may not use this file except in
|
409
|
+
compliance with the Apache License and the following modification to it:
|
410
|
+
|
411
|
+
Section 6. Trademarks. is deleted and replaced with:
|
412
|
+
|
413
|
+
6\. Trademarks. This License does not grant permission to use the trade
|
414
|
+
names, trademarks, service marks, or product names of the Licensor
|
415
|
+
and its affiliates, except as required to comply with Section 4(c) of
|
416
|
+
the License and to reproduce the content of the NOTICE file.
|
417
|
+
|
418
|
+
You may obtain a copy of the Apache License at
|
419
|
+
|
420
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
421
|
+
|
422
|
+
Unless required by applicable law or agreed to in writing, software
|
423
|
+
distributed under the Apache License with the above modification is
|
424
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
425
|
+
KIND, either express or implied. See the Apache License for the specific
|
426
|
+
language governing permissions and limitations under the Apache License.
|