jss-api 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/CHANGES.md +4 -0
  2. data/LICENSE.txt +174 -0
  3. data/README.md +368 -0
  4. data/THANKS.md +6 -0
  5. data/lib/jss-api.rb +549 -0
  6. data/lib/jss-api/api_connection.rb +326 -0
  7. data/lib/jss-api/api_object.rb +590 -0
  8. data/lib/jss-api/api_object/advanced_search.rb +389 -0
  9. data/lib/jss-api/api_object/advanced_search/advanced_computer_search.rb +95 -0
  10. data/lib/jss-api/api_object/advanced_search/advanced_mobile_device_search.rb +96 -0
  11. data/lib/jss-api/api_object/advanced_search/advanced_user_search.rb +95 -0
  12. data/lib/jss-api/api_object/building.rb +92 -0
  13. data/lib/jss-api/api_object/category.rb +147 -0
  14. data/lib/jss-api/api_object/computer.rb +852 -0
  15. data/lib/jss-api/api_object/creatable.rb +98 -0
  16. data/lib/jss-api/api_object/criteriable.rb +189 -0
  17. data/lib/jss-api/api_object/criteriable/criteria.rb +231 -0
  18. data/lib/jss-api/api_object/criteriable/criterion.rb +228 -0
  19. data/lib/jss-api/api_object/department.rb +93 -0
  20. data/lib/jss-api/api_object/distribution_point.rb +490 -0
  21. data/lib/jss-api/api_object/extendable.rb +221 -0
  22. data/lib/jss-api/api_object/extension_attribute.rb +457 -0
  23. data/lib/jss-api/api_object/extension_attribute/computer_extension_attribute.rb +362 -0
  24. data/lib/jss-api/api_object/extension_attribute/mobile_device_extension_attribute.rb +189 -0
  25. data/lib/jss-api/api_object/extension_attribute/user_extension_attribute.rb +117 -0
  26. data/lib/jss-api/api_object/group.rb +380 -0
  27. data/lib/jss-api/api_object/group/computer_group.rb +124 -0
  28. data/lib/jss-api/api_object/group/mobile_device_group.rb +139 -0
  29. data/lib/jss-api/api_object/group/user_group.rb +139 -0
  30. data/lib/jss-api/api_object/ldap_server.rb +535 -0
  31. data/lib/jss-api/api_object/locatable.rb +268 -0
  32. data/lib/jss-api/api_object/matchable.rb +97 -0
  33. data/lib/jss-api/api_object/mobile_device.rb +556 -0
  34. data/lib/jss-api/api_object/netboot_server.rb +148 -0
  35. data/lib/jss-api/api_object/network_segment.rb +414 -0
  36. data/lib/jss-api/api_object/package.rb +760 -0
  37. data/lib/jss-api/api_object/peripheral.rb +335 -0
  38. data/lib/jss-api/api_object/peripheral_type.rb +295 -0
  39. data/lib/jss-api/api_object/policy.rb +882 -0
  40. data/lib/jss-api/api_object/purchasable.rb +316 -0
  41. data/lib/jss-api/api_object/removable_macaddr.rb +98 -0
  42. data/lib/jss-api/api_object/scopable.rb +136 -0
  43. data/lib/jss-api/api_object/scopable/scope.rb +621 -0
  44. data/lib/jss-api/api_object/script.rb +631 -0
  45. data/lib/jss-api/api_object/site.rb +93 -0
  46. data/lib/jss-api/api_object/software_update_server.rb +109 -0
  47. data/lib/jss-api/api_object/updatable.rb +117 -0
  48. data/lib/jss-api/api_object/uploadable.rb +138 -0
  49. data/lib/jss-api/api_object/user.rb +272 -0
  50. data/lib/jss-api/client.rb +500 -0
  51. data/lib/jss-api/compatibility.rb +66 -0
  52. data/lib/jss-api/composer.rb +171 -0
  53. data/lib/jss-api/configuration.rb +301 -0
  54. data/lib/jss-api/db_connection.rb +243 -0
  55. data/lib/jss-api/exceptions.rb +83 -0
  56. data/lib/jss-api/ruby_extensions.rb +35 -0
  57. data/lib/jss-api/ruby_extensions/filetest.rb +43 -0
  58. data/lib/jss-api/ruby_extensions/hash.rb +79 -0
  59. data/lib/jss-api/ruby_extensions/ipaddr.rb +91 -0
  60. data/lib/jss-api/ruby_extensions/pathname.rb +77 -0
  61. data/lib/jss-api/ruby_extensions/string.rb +43 -0
  62. data/lib/jss-api/ruby_extensions/time.rb +63 -0
  63. data/lib/jss-api/server.rb +108 -0
  64. data/lib/jss-api/version.rb +31 -0
  65. metadata +219 -0
data/CHANGES.md ADDED
@@ -0,0 +1,4 @@
1
+ # Change History
2
+
3
+ v0.5.0 2014-10-23
4
+ - 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,368 @@
1
+ # The JSS API Ruby Gem - access to the Casper Suite from Ruby
2
+
3
+ ## DESCRIPTION
4
+
5
+ jss-api is a Ruby Gem providing access to the REST API of the JAMF Software Server (JSS) - the core of the Casper Suite
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)
10
+
11
+ The gem is not a complete implementation of the Casper API. Only some API objects are modeled, some only minimally. Of
12
+ those, some are read-only, some partially writable, some fully read-write (all implemented objects can be deleted)
13
+ See OBJECTS IMPLEMENTED for a list.
14
+
15
+ 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
17
+
18
+
19
+ ## SYNOPSIS
20
+
21
+ ```ruby
22
+ # you may need to require 'rubygems' first if you're using Ruby 1.8
23
+ require 'jss-api'
24
+
25
+ JSS::API.connect :user => jss_user, :pw => jss_user_pw, :server => jss_server_hostname
26
+
27
+ JSS::Package.all # returns an array of data about all JSS::Package objects in the JSS
28
+ JSS::Package.all_names # returns an array of names of all JSS::Package objects in the JSS
29
+
30
+ # Get a static computer group
31
+ mg = JSS::ComputerGroup.new :name => "Macs of interest"
32
+
33
+ # Add a computer to the group
34
+ mg.add_member "pricklepants"
35
+
36
+ # save my changes
37
+ mg.update
38
+
39
+ # Create a new network segment to store in the JSS
40
+ ns = JSS::NetworkSegment.new :id => :new, :name => 'Private Class C', :starting_address => '192.168.0.0', :ending_address => '192.168.0.255'
41
+
42
+ # Associate this network segment with a specific building, which must exist in the JSS, and be listed in JSS::Building.all_names
43
+ ns.building = "Main Office"
44
+
45
+ # Associate this network segment with a specific software update server, which must exist in the JSS,
46
+ # and be listed in JSS::SoftwareUpdateServer.all_names
47
+ ns.swu_server = "Main SWU Server"
48
+
49
+ # Store the new network segment in the JSS
50
+ ns.create
51
+ ```
52
+
53
+ ## USAGE
54
+
55
+ ### Connecting to the API
56
+
57
+ Before you can work with JSS Objects via the API, you have to connect to it.
58
+
59
+ 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
60
+ connected. To remedy that, use JSS::API.connect, passing it values for :user, :pw, and :server:
61
+
62
+ ```ruby
63
+ JSS::API.connect :user => jss_user, :pw => jss_user_pw, :server => jss_server_hostname
64
+ ```
65
+
66
+ Make sure the user has privileges in the JSS to do things with API Objects.
67
+
68
+ The {JSS::API#connect} method also accepts the symbols :stdin and :prompt as values for :pw, which will cause it to read the
69
+ password from stdin, or prompt for it in the shell. See the JSS::APIConnection class for more connection options and details about its methods.
70
+
71
+ Also see {JSS::Configuration}, and the CONFIGURATION section below, for how to store
72
+ server connection parameters in a simple config file.
73
+
74
+ ### Working with JSS Objects (a.k.a REST Resources)
75
+
76
+ 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.
77
+
78
+ --------
79
+
80
+ #### Listing Objects
81
+
82
+ To get an Array of every object in the JSS of some Class, call that Class's .all method:
83
+
84
+ ```ruby
85
+ JSS::Computer.all # => [{:name=>"cephei", :id=>62},{:name=>"peterparker", :id=>218}, {:name=>"rowdy", :id=>901}, ...]
86
+ ```
87
+
88
+ 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.
89
+ To get just the names or just the ids in an Array, use the .all\_names or .all\_ids Class method
90
+
91
+ ```ruby
92
+ JSS::Computer.all_names # => ["cephei", "peterparker", "rowdy", ...]
93
+ JSS::Computer.all_ids # => [62, 218, 901, ...]
94
+ ```
95
+
96
+ Some Classes provide other ways to list objects, depending on the data available, e.g. JSS::MobileDevice.all\_udids
97
+
98
+ --------
99
+
100
+ #### Retrieving Objects
101
+
102
+ To retrieve a single object call the object's constructor (.new) and provide either :name or :id or :data.
103
+
104
+ * :name or :id will be looked up via the API
105
+
106
+ ```ruby
107
+ a_dept = JSS::Department.new :name => "Payroll" # => #<JSS::Department:0x10b4c0818...
108
+ ```
109
+
110
+ * :data must be the parsed JSON output of a separate API query (a hash with symbolized keys)
111
+
112
+ ```ruby
113
+ dept_data = JSS::API.get_rsrc("departments/name/Payroll")[:department] # => {:name=>"Payroll", :id=>42}
114
+ a_dept = JSS::Department.new :data => dept_data # => #<JSS::Department:0x10b4a83f8...
115
+ ```
116
+
117
+ 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.
118
+
119
+ --------
120
+
121
+ #### Creating Objects
122
+
123
+ 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.
124
+
125
+ ```ruby
126
+ new_pkg = JSS::Package.new :id => :new, :name => "transmogrifier-2.3-1.pkg"
127
+ ```
128
+
129
+ Then set the attributes of the new object as needed
130
+
131
+ ```ruby
132
+ new_pkg.reboot_required = false
133
+ new_pkg.category = "CoolTools"
134
+ # etc..
135
+ ```
136
+
137
+ Then use the #create method to create it in the JSS.
138
+
139
+ ```ruby
140
+ new_pkg.create # => 453 # the id number of the object just created
141
+ ```
142
+
143
+ *NOTE* some subclasses require more data than just a :name when instantiating with :id => :new.
144
+
145
+ --------
146
+
147
+ #### Updating Objects
148
+
149
+ Some objects can be modified in the JSS.
150
+
151
+ ```ruby
152
+ existing_script = JSS::Script.new :id => 321
153
+ existing_script.name = "transmogrifier-2.3-1.post-install"
154
+ ```
155
+
156
+ After changing any attributes, use the #update method (also aliased to #save) to push the changes to the JSS.
157
+
158
+ ```ruby
159
+ existing_script.update # or existing_script.save => true # the update was successful
160
+ ```
161
+
162
+ --------
163
+
164
+ #### Deleting Objects
165
+
166
+ To delete an object, just call its #delete method
167
+
168
+ ```ruby
169
+ existing_script = JSS::Script.new :id => 321
170
+ existing_script.delete # => true # the delete was successful
171
+ ```
172
+
173
+
174
+ See JSS::APIObject, the parent class of all API resources, for general information about creating, reading, updating/saving, and deleting resources.
175
+
176
+ See the individual subclasses for any details specific to them.
177
+
178
+
179
+
180
+ ## OBJECTS IMPLEMENTED
181
+
182
+ See each Class's documentation for details.
183
+
184
+ ### Creatable and Updatable
185
+
186
+ * {JSS::AdvancedComputerSearch}
187
+ * {JSS::AdvancedMobileDeviceSearch}
188
+ * {JSS::AdvancedUserSearch}
189
+ * {JSS::Building}
190
+ * {JSS::Category}
191
+ * {JSS::ComputerExtensionAttribute}
192
+ * {JSS::ComputerGroup}
193
+ * {JSS::Department}
194
+ * {JSS::MobileDeviceExtensionAttribute}
195
+ * {JSS::MobileDeviceGroup}
196
+ * {JSS::NetworkSegment}
197
+ * {JSS::Package}
198
+ * {JSS::Peripheral}
199
+ * {JSS::PeripheralType}
200
+ * {JSS::RemovableMacAddress}
201
+ * {JSS::Script}
202
+ * {JSS::User}
203
+ * {JSS::UserExtensionAttribute}
204
+ * {JSS::UserGroup}
205
+
206
+ ### Updatable but not Creatable
207
+
208
+ * {JSS::Computer} - limited to modifying
209
+ * name
210
+ * barcodes
211
+ * asset tag
212
+ * ip address
213
+ * location data
214
+ * purchasing data
215
+ * editable extension attributes
216
+ * {JSS::MobileDevice} - limited to modifying
217
+ * asset tag
218
+ * location data
219
+ * purchasing data
220
+ * editable extension attributes
221
+ * {JSS::Policy} - limited to modifying
222
+ * scope (see {JSS::Scopable::Scope})
223
+ * name
224
+ * enabled
225
+ * category
226
+ * triggers
227
+ * file & process actions
228
+
229
+ **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.
230
+
231
+ ### Read-Only
232
+
233
+ These must be created and edited via the JSS WebApp
234
+
235
+ * {JSS::DistributionPoint}
236
+ * {JSS::LDAPServer}
237
+ * {JSS::NetBootServer}
238
+ * {JSS::SoftwareUpdateServer}
239
+
240
+ ### Deletable
241
+
242
+ All supported API Objects can be deleted
243
+
244
+
245
+ Other useful classes:
246
+
247
+ * {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.
248
+ * {JSS::Client} - An object representing the local machine as a Casper-managed client, and JAMF-related info and methods
249
+
250
+ ## CONFIGURATION
251
+
252
+ The {JSS::Configuration} singleton class is used to read, write, and use site-specific defaults for using the JSS Gem. When the JSS module is loaded, 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
+
254
+ The values defined in those files are used as defaults throughout the Gem. 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}.
255
+
256
+ While the {JSS::Configuration} clss 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
+
258
+ attr_name: value
259
+
260
+ 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
+
262
+ Lines starting with a # are comments and will be preserved when using #save.
263
+
264
+ The currently known attributes are:
265
+
266
+ * api_server_name [String] the hostname of the JSS API server
267
+ * 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 SSL certificate be verified (usually false for a self-signed cert)
269
+ * api_username [String] the JSS username for connecting to the API
270
+ * api_timeout_open [Integer] the number of seconds for the open-connection timeout
271
+ * api_timeout [Integer] the number of seconds for the response timeout
272
+
273
+ 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:
274
+
275
+ ```
276
+ api_server_name: casper.myschool.edu
277
+ api_username: readonly-api-user
278
+ api_verify_cert: false
279
+ ```
280
+
281
+ and then any calls to {JSS::API.connect} will assume that server and username, and won't complain about the self-signed certificate.
282
+
283
+ Note that the config files don't store passwords. You'll have to use your own methods for acquiring the password for the JSS::API.connect call. The {JSS::API#connect} method also accepts the symbols :stdin and :prompt, which will cause it to read the password from stdin, or prompt for it in
284
+ the shell.
285
+
286
+
287
+ ## BEYOND THE API
288
+
289
+ 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:
290
+
291
+ * Client Machine Access
292
+ * The {JSS::Client} module provides the ability to run jamf binary commands, and access the local cache of package receipts
293
+ * Package Installation
294
+ * {JSS::Package} objects can be installed on the local machine, from the appropriate distribution point
295
+ * Script Execution
296
+ * {JSS::Script} objects can be executed locally on demand
297
+ * Package Creation
298
+ * The {JSS::Composer} module provides creation of very simple .pkg and .dmg packages
299
+ * {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.)
300
+ * Reporting/AdvancedSearch exporting
301
+ * {JSS::AdvancedSearch} subclasses can export their results to csv, tab, and xml files.
302
+ * LDAP Access
303
+ * {JSS::LDAPServer} objects can query the LDAP servers for user, group, and membership data.
304
+ * MDM Commands
305
+ * {JSS::MobileDevice}s (and eventually {JSS::Computer}s) can be sent MDM commands
306
+ * Extension Attributes
307
+ * {JSS::ExtensionAttribute} work with {JSS::AdvancedSearch} subclasses to provide extra reporting about Ext. Attrib. values.
308
+
309
+ ## REQUIREMENTS
310
+
311
+ the JSS gem was written for:
312
+
313
+ * Mac OS X 10.8 and higher
314
+ * Casper Suite version 9.4 or higher
315
+ * Ruby 1.8.7 and 2.0.0 (the two versions that come with OS X 10.9).
316
+
317
+ It also requires these gems, which will be installed automatically if you install JSS with `gem install jss`
318
+
319
+ * rest-client >=1.6.7 http://rubygems.org/gems/rest-client
320
+ * json or json\_pure >= 1.6.5 http://rubygems.org/gems/json or http://rubygems.org/gems/json_pure
321
+ * (only in ruby 1.8.7. Ruby 2.0.0 has json in its standard library)
322
+ * ruby-mysql >= 2.9.12 http://rubygems.org/gems/ruby-mysql
323
+ * (only for a few things that still require direct SQL access to the JSS database)
324
+ * plist =3.1.0 http://rubygems.org/gems/plist
325
+ * for the {JSS::Composer} module and {JSS::Client} class
326
+ * net-ldap >= 0.3.1 http://rubygems.org/gems/net-ldap
327
+ * for accessing the LDAP servers defined in the JSS, to check for user and group info.
328
+
329
+ ## INSTALL
330
+
331
+ NOTE: You may need to install XCode, and it's CLI tools, in order to install the required gems.
332
+
333
+ In general, you can install the JSS Gem with this command:
334
+
335
+ `gem install jss-api`
336
+
337
+ If you're using Ruby 1.8.7, install the following gems manually first, since the JSS gem will try to install newer, incompatible versions if they aren't pre-installed.
338
+
339
+ `gem install json -v 1.6.5`
340
+
341
+ `gem install mime-types -v 1.25.1`
342
+
343
+ `gem install rest-client -v 1.6.8`
344
+
345
+ ## LICENSE
346
+
347
+ Copyright 2014 Pixar
348
+
349
+ Licensed under the Apache License, Version 2.0 (the "Apache License")
350
+ with the following modification; you may not use this file except in
351
+ compliance with the Apache License and the following modification to it:
352
+
353
+ Section 6. Trademarks. is deleted and replaced with:
354
+
355
+ 6\. Trademarks. This License does not grant permission to use the trade
356
+ names, trademarks, service marks, or product names of the Licensor
357
+ and its affiliates, except as required to comply with Section 4(c) of
358
+ the License and to reproduce the content of the NOTICE file.
359
+
360
+ You may obtain a copy of the Apache License at
361
+
362
+ http://www.apache.org/licenses/LICENSE-2.0
363
+
364
+ Unless required by applicable law or agreed to in writing, software
365
+ distributed under the Apache License with the above modification is
366
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
367
+ KIND, either express or implied. See the Apache License for the specific
368
+ language governing permissions and limitations under the Apache License.