ruby-jss 1.1.0b1 → 1.1.0b2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18ed86e89f9b9994f582c691ac460e1ee6262e67cb02fcc42352f84b6d2b1e8a
4
- data.tar.gz: f5b535f7cf9f778b42b2cc7367f2e5ddce6cbc08e766f75f5ed8413cc42efc78
3
+ metadata.gz: a50ff471b21545912900e60e06df0db44afb07369e140af205f13c3cc2bfad40
4
+ data.tar.gz: 699823c8d74f492ee99f4c1cd742783c9a033de3457ac4f6740aa777301aafd4
5
5
  SHA512:
6
- metadata.gz: 88e9391e8d5d5c8af60176599dd86303e8a48c96ba9a643664c7cf7a8d0ac257340a4d561a426ff5cd4e8c73fbfc102a0f735703fa462222fa95f4cc75a4078d
7
- data.tar.gz: 87ef3da3ad033c0f17b9511a4a265ddcf5479aee5e71d385c880a0e298627e881bb73f90814ebb4c7feac08455c321036d69802a74ef24eca74e092737d33054
6
+ metadata.gz: a8af9b0bb6b77cfc377bbd0d83759e8d4ada3868b2f13a72c4cc9820d22a7582e82e4fe118217f6bc251eb386c2a3ddbd2434e4fd9f95e06ae2a4492c5edab99
7
+ data.tar.gz: f428d23ab93e6dc3d6f279353d90299b1d64fc41093bcaeaf06d15baffa6abf931e6b76c2491ae4d53eb0747ecbdcd1a60e9b670a6f91d9e33493838c038e593
data/README.md CHANGED
@@ -30,7 +30,7 @@
30
30
  ruby-jss defines a Ruby module called JSS, which is used for accessing the 'classic' REST API of
31
31
  the JAMF Software Server (JSS), the core of Jamf Pro, an enterprise-level management tool for Apple
32
32
  devices from [Jamf.com](http://www.jamf.com/). It is available as a
33
- [rubygem](https://rubygems.org/gems/ruby-jss), and the
33
+ [ruby gem](https://rubygems.org/gems/ruby-jss), and the
34
34
  [source is on github](https://github.com/PixarAnimationStudios/ruby-jss).
35
35
 
36
36
  The module abstracts many API resources as Ruby objects, and provides methods for interacting with those
@@ -38,9 +38,7 @@ resources. It also provides some features that aren't a part of the API itself,
38
38
  Jamf-related tools, such as uploading .pkg and .dmg {JSS::Package} data to the master distribution
39
39
  point, and the installation of {JSS::Package} objects on client machines. (See [BEYOND THE API](#beyond-the-api))
40
40
 
41
- The module is not a complete implementation of the Jamf API. Only some API objects are modeled, some
42
- only minimally. Of those, some are read-only, some partially writable, some fully read-write (all
43
- implemented objects can be deleted) See [OBJECTS IMPLEMENTED](#objects-implemented) for a list.
41
+ The module is not a complete implementation of the Jamf Pro Classic API. Only some API objects are modeled, some only minimally. Of those, some are read-only, some partially writable, some fully read-write (all implemented objects can be deleted) See [OBJECTS IMPLEMENTED](#objects-implemented) for a list.
44
42
 
45
43
  We've implemented the things we need in our environment, and as our needs grow, we'll add more.
46
44
  Hopefully others will find it useful, and add more to it as well.
@@ -101,7 +99,7 @@ Before you can work with JSS Objects via the API, you have to connect to it.
101
99
 
102
100
  The method `JSS.api` returns the currently active connection to the API (an instance of a {JSS::APIConnection}, q.v.).
103
101
 
104
- When the JSS Module is first loaded, that connection object isn't connected to anything. To remedy that, use `JSS.api.connect`, passing it values for the connection. In this example, those values are stored in the local variables jss_user, jss_user_pw, and jss_server_hostname, and others are left as default.
102
+ When the JSS Module is first loaded, that connection object isn't connected to anything. To remedy that, use `JSS.api.connect`, passing it parameters for the connection. In this example, those parameters are stored in the local variables jss_user, jss_user_pw, and jss_server_hostname, and others are left as default.
105
103
 
106
104
  ```ruby
107
105
  JSS.api.connect user: jss_user, pw: jss_user_pw, server: jss_server_hostname
@@ -111,27 +109,29 @@ Make sure the user has privileges in the JSS to do things with desired objects.
111
109
 
112
110
  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 locally-hosted servers). In other situations, you can specify it with the `port:` and `use_ssl:` parameters.
113
111
 
114
- The connect method also accepts the symbols :stdin and :prompt as values for :pw, which will cause it to read the
112
+ The connect method also accepts the symbols :stdin and :prompt as values for pw:, which will cause it to read the
115
113
  password from stdin, or prompt for it in the shell. See the {JSS::APIConnection} class for more connection options and details about its methods.
116
114
 
117
115
  Also see JSS::Configuration, and the [CONFIGURATION](#configuration) section below, for how to store
118
116
  server connection parameters in a simple config file.
119
117
 
120
- ### Working with JSS Objects (a.k.a REST Resources)
118
+ ### Working with JSS Objects
121
119
 
122
120
  All of the ruby classes representing objects in Jamf Pro are subclasse of, or modules within, JSS::APIObject and share methods for creating, listing, retrieving, updating, and deleting via the API. All supported objects can be listed, retrieved and deleted, but only some can be updated or created. See below for the level of implementation of each class.
123
121
 
122
+ Some of those objects also provide access to more 'functional' API resources. For example, the API resources for sending MDM commands to computers and mobile devices are available as class and instance methods of JSS::Computer and JSS::MobileDevice, as are the API resources for accessing management history.
123
+
124
124
  --------
125
125
 
126
126
  #### Listing Objects
127
127
 
128
- To get an Array of every object in the JSS of some Class, call that Class's .all method:
128
+ To get an Array with a summary of every object in the JSS of some Class, call that Class's .all method:
129
129
 
130
130
  ```ruby
131
131
  JSS::Computer.all # => [{:name=>"cephei", :id=>1122},{:name=>"peterparker", :id=>1218}, {:name=>"rowdy", :id=>931}, ...]
132
132
  ```
133
133
 
134
- 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.
134
+ 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.
135
135
  To get just the names or just the ids in an Array, use the .all\_names or .all\_ids Class method
136
136
 
137
137
  ```ruby
@@ -139,7 +139,11 @@ JSS::Computer.all_names # => ["cephei", "peterparker", "rowdy", ...]
139
139
  JSS::Computer.all_ids # => [1122, 1218, 931, ...]
140
140
  ```
141
141
 
142
- Some Classes provide other ways to list objects, depending on the data available, e.g. JSS::MobileDevice.all\_udids or JSS::Computer.all\_laptops
142
+ Some Classes provide other ways to list objects, or subsets of them, depending on the data available, e.g. JSS::MobileDevice.all\_udids or JSS::Computer.all\_laptops
143
+
144
+ You can also perform simple searches for JSS::Computer, JSS::MobileDevice and JSS::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.
145
+
146
+ To create, modify, or perform advanced searches, use the classes JSS::AdvancedComputerSearch, JSS::AdvancedMobileDeviceSearch, and JSS::AdvancedUserSearch.
143
147
 
144
148
  --------
145
149
 
@@ -152,12 +156,9 @@ To retrieve a single object call the class's `.fetch` method and provide a name:
152
156
  a_dept = JSS::Department.fetch name: 'Payroll'# => #<JSS::Department:0x10b4c0818...
153
157
  ```
154
158
 
155
- 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.
159
+ 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:.
156
160
 
157
- You can even fetch objects without specifying the kind of identifier, e.g. `JSS::Computer.fetch 3241`, but this will be slower, since ruby-jss searches by matching the given value with all available identifiers, returning the first match.
158
-
159
- *NOTE*: For APIObject subclasses, the '.fetch' class method is now the required method to use for retrieving existing objects
160
- from the API. The '.new' method no longer works. See below for using .make to create new objects in the JSS.
161
+ You can even fetch objects without specifying the kind of identifier, e.g. `JSS::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.
161
162
 
162
163
  --------
163
164
 
@@ -168,7 +169,7 @@ Some Objects can be created anew in the JSS via ruby. To do so, first make a Rub
168
169
  ```ruby
169
170
  new_pkg = JSS::Package.make name: "transmogrifier-2.3-1.pkg"
170
171
  ```
171
- *NOTE*: some classes require more data than just a :name when created with .make.
172
+ *NOTE*: some classes require more data than just a name: when created with .make
172
173
 
173
174
  Then set the attributes of the new object as needed
174
175
 
@@ -178,16 +179,12 @@ new_pkg.category = "CoolTools"
178
179
  # etc..
179
180
  ```
180
181
 
181
- Then use the #create method to create it in the JSS. The #save method is an alias of #create
182
+ Then use the #save method to create it in the JSS. The #create method is the same
182
183
 
183
184
  ```ruby
184
- new_pkg.create # returns 453, the id number of the object just created
185
+ new_pkg.save # returns 453, the id number of the object just created
185
186
  ```
186
187
 
187
- *NOTE*: For APIObject subclasses, the '.make' class method is now the required method to use for making ruby instances to be
188
- created in the JSS. The '.new' method no longer works.
189
-
190
-
191
188
  --------
192
189
 
193
190
  #### Updating Objects
@@ -199,10 +196,10 @@ existing_script = JSS::Script.fetch id: 321
199
196
  existing_script.name = "transmogrifier-2.3-1.post-install"
200
197
  ```
201
198
 
202
- After changing any attributes, use the #update method (also aliased to #save) to push the changes to the JSS.
199
+ After changing any attributes, use the #save method (also aliased to #update) to push the changes to the JSS.
203
200
 
204
201
  ```ruby
205
- existing_script.update # => returns the id number of the object just saved
202
+ existing_script.save # => returns the id number of the object just saved
206
203
  ```
207
204
 
208
205
  --------
@@ -266,7 +263,7 @@ Here's what we've implemented so far. See each Class's [documentation(http://www
266
263
  * {JSS::WebHook}
267
264
 
268
265
 
269
- **NOTE** Computer and Mobile Device data gathered by an Inventory Upate (a.k.a. 'recon') is not editable.
266
+ **NOTE** Most Computer and MobileDevice data gathered by an Inventory Upate (a.k.a. 'recon') is not editable.
270
267
 
271
268
  ### Updatable, but must be created in the Web UI
272
269
 
@@ -293,17 +290,17 @@ All supported API Objects can be deleted
293
290
 
294
291
  #### Other useful classes & modules:
295
292
 
296
- * {JSS::APIConnection} - An object representing the connection to the REST API
293
+ * {JSS::APIConnection} - An object representing a connection to the Classic API on some server. The 'default' connection object is available via `JSS.api` but you can create others, and pass them into calls like `.fetch` as needed. This is useful when working with multiple servers at a time, such as a production and a test server. Objects retrieved from a connection know which connection they came from, and will only send changes via that connection.
297
294
  * {JSS::DBConnection} - An object representing the connection to MySQL database, if used.
298
- * {JSS::Server} - An encapsulation of some info about the JamfPro server, such as the version and license. An instance is available as an attribute of the {JSS::APIConnection} singleton.
299
- * {JSS::Client} - An object representing the local machine as a Casper-managed client, and JAMF-related info and methods
300
- * {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.
295
+ * {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}.
296
+ * {JSS::Client} - An object representing the local machine as a Jamf-managed client, and provifing Jamf-related info and methods
297
+ * {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.
301
298
  * {JSS::Scopable} - a module that handles Scope for those objects that can be scoped. It defines the Scope class used in those objects.
302
- * {JSS::MDM} - a module that handles sending MDM commands to Computers and Mobile Devices
299
+ * {JSS::MDM} - a module that handles sending MDM commands. It is accessed via the Computer and MobileDevice classes and their instances.
303
300
 
304
301
  ## Object-related API endpoints
305
302
 
306
- The classic API provides many endpoints not just for objects stored in Jamd 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.
303
+ 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.
307
304
 
308
305
  For example:
309
306
 
@@ -338,7 +335,7 @@ The currently known attributes are:
338
335
  To put a standard server & username on all client machines, and auto-accept the JSS's self-signed https certificate, create the file /etc/ruby-jss.conf containing three lines like this:
339
336
 
340
337
  ```
341
- api_server_name: casper.myschool.edu
338
+ api_server_name: jamfpro.myschool.edu
342
339
  api_username: readonly-api-user
343
340
  api_verify_cert: false
344
341
  ```
@@ -370,7 +367,7 @@ JSS.api.connect pw: password # other arguments used from the config settings
370
367
 
371
368
  ## BEYOND THE API
372
369
 
373
- While the Jamf Pro Classic API provides access to object data in the JSS, ruby-jss tries to use that data to provide more than just information exchange. Here are some examples of how ruby-jss use the API to provide functionality found in various Casper tools:
370
+ While the Jamf Pro Classic API provides access to object data in the JSS, 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:
374
371
 
375
372
  * Client Machine Access
376
373
  * The {JSS::Client} module provides the ability to run jamf binary commands, and access the local cache of package receipts
@@ -684,6 +684,9 @@ module JSS
684
684
  # Call one of the 'all*' methods on a JSS::APIObject subclass
685
685
  # using this APIConnection.
686
686
  #
687
+ #
688
+ # @deprecated please use the .all class method of the desired class
689
+ #
687
690
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass
688
691
  # see {JSS.api_object_class}
689
692
  #
@@ -709,6 +712,9 @@ module JSS
709
712
  # Call the 'map_all_ids_to' method on a JSS::APIObject subclass
710
713
  # using this APIConnection.
711
714
  #
715
+ # @deprecated please use the .map_all_ids_to class method of the desired class
716
+ #
717
+ #
712
718
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass
713
719
  # see {JSS.api_object_class}
714
720
  #
@@ -727,6 +733,9 @@ module JSS
727
733
  # Call the 'valid_id' method on a JSS::APIObject subclass
728
734
  # using this APIConnection. See {JSS::APIObject.valid_id}
729
735
  #
736
+ # @deprecated please use the .valid_id class method of the desired class
737
+ #
738
+ #
730
739
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass,
731
740
  # see {JSS.api_object_class}
732
741
  #
@@ -745,6 +754,8 @@ module JSS
745
754
  # Call the 'exist?' method on a JSS::APIObject subclass
746
755
  # using this APIConnection. See {JSS::APIObject.exist?}
747
756
  #
757
+ # @deprecated please use the .exist class method of the desired class
758
+ #
748
759
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass
749
760
  # see {JSS.api_object_class}
750
761
  #
@@ -763,6 +774,8 @@ module JSS
763
774
  #
764
775
  # See {Matchable.match}
765
776
  #
777
+ # @deprecated Please use the .match class method of the desired class
778
+ #
766
779
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass
767
780
  # see {JSS.api_object_class}
768
781
  #
@@ -777,6 +790,9 @@ module JSS
777
790
  # Retrieve an object of a given class from the API
778
791
  # See {APIObject.fetch}
779
792
  #
793
+ # @deprecated Please use the .fetch class method of the desired class
794
+ #
795
+ #
780
796
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass
781
797
  # see {JSS.api_object_class}
782
798
  #
@@ -791,6 +807,8 @@ module JSS
791
807
  # of the given class
792
808
  # See {APIObject.make}
793
809
  #
810
+ # @deprecated Please use the .make class method of the desired class
811
+ #
794
812
  # @param class_name[String,Symbol] The name of a JSS::APIObject subclass
795
813
  # see {JSS.api_object_class}
796
814
  #
@@ -804,6 +822,7 @@ module JSS
804
822
 
805
823
  # Call {JSS::Computer.checkin_settings} q.v., passing this API
806
824
  # connection
825
+ # @deprecated Please use JSS::Computer.checkin_settings
807
826
  #
808
827
  def computer_checkin_settings
809
828
  JSS::Computer.checkin_settings api: self
@@ -811,6 +830,7 @@ module JSS
811
830
 
812
831
  # Call {JSS::Computer.inventory_collection_settings} q.v., passing this API
813
832
  # connection
833
+ # @deprecated Please use JSS::Computer.inventory_collection_settings
814
834
  #
815
835
  def computer_inventory_collection_settings
816
836
  JSS::Computer.inventory_collection_settings api: self
@@ -818,6 +838,7 @@ module JSS
818
838
 
819
839
  # Call {JSS::Computer.application_usage} q.v., passing this API
820
840
  # connection
841
+ # @deprecated Please use JSS::Computer.application_usage
821
842
  #
822
843
  def computer_application_usage(ident, start_date, end_date = nil)
823
844
  JSS::Computer.application_usage ident, start_date, end_date, api: self
@@ -826,6 +847,8 @@ module JSS
826
847
  # Call {JSS::Computer.management_data} q.v., passing this API
827
848
  # connection
828
849
  #
850
+ # @deprecated Please use JSS::Computer.management_data
851
+ #
829
852
  def computer_management_data(ident, subset: nil, only: nil)
830
853
  JSS::Computer.management_data ident, subset: subset, only: only, api: self
831
854
  end
@@ -954,6 +977,21 @@ module JSS
954
977
  JSS::MobileDevice.send_mdm_command(targets, command, opts: data, api: self)
955
978
  end
956
979
 
980
+ # Empty all cached lists from this connection
981
+ # then run garbage collection to clear any available memory
982
+ #
983
+ # NOTE if you've referenced objects in these caches, those objects
984
+ # won't be removed from memory, but all cached data will be recached
985
+ # as needed.
986
+ #
987
+ # @return [void]
988
+ #
989
+ def flushcache
990
+ @object_list_cache = {}
991
+ @ext_attr_definition_cache = {}
992
+ GC.start
993
+ end
994
+
957
995
  # Remove the various cached data
958
996
  # from the instance_variables used to create
959
997
  # pretty-print (pp) output.
@@ -142,6 +142,7 @@ module JSS
142
142
  ongoing: 'Ongoing',
143
143
  once_per_computer: 'Once per computer',
144
144
  once_per_user: 'Once per user',
145
+ once_per_user_per_computer: 'Once per user per computer',
145
146
  daily: 'Once every day',
146
147
  weekly: 'Once every week',
147
148
  monthly: 'Once every month'
data/lib/jss/version.rb CHANGED
@@ -27,6 +27,6 @@
27
27
  module JSS
28
28
 
29
29
  ### The version of the JSS ruby gem
30
- VERSION = '1.1.0b1'.freeze
30
+ VERSION = '1.1.0b2'.freeze
31
31
 
32
32
  end # module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0b1
4
+ version: 1.1.0b2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lasell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-28 00:00:00.000000000 Z
12
+ date: 2019-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plist