ruby-jss 0.10.2 → 0.11.0a5
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 +4 -4
- data/CHANGES.md +49 -2
- data/README.md +14 -7
- data/lib/jss/api_connection.rb +48 -24
- data/lib/jss/api_object/advanced_search.rb +5 -1
- data/lib/jss/api_object/computer.rb +204 -402
- data/lib/jss/api_object/computer_invitation.rb +5 -3
- data/lib/jss/api_object/ebook.rb +5 -0
- data/lib/jss/api_object/extendable.rb +13 -0
- data/lib/jss/api_object/group/computer_group.rb +4 -0
- data/lib/jss/api_object/group/mobile_device_group.rb +4 -1
- data/lib/jss/api_object/group.rb +6 -1
- data/lib/jss/api_object/mac_application.rb +5 -0
- data/lib/jss/api_object/management_history/audit_event.rb +45 -0
- data/lib/jss/api_object/management_history/casper_imaging_log.rb +37 -0
- data/lib/jss/api_object/management_history/casper_remote_log.rb +37 -0
- data/lib/jss/api_object/management_history/computer_usage_log.rb +43 -0
- data/lib/jss/api_object/management_history/ebook.rb +70 -0
- data/lib/jss/api_object/management_history/mac_app_store_app.rb +69 -0
- data/lib/jss/api_object/management_history/mdm_command.rb +96 -0
- data/lib/jss/api_object/management_history/mobile_device_app.rb +99 -0
- data/lib/jss/api_object/management_history/policy_log.rb +60 -0
- data/lib/jss/api_object/management_history/screen_sharing_log.rb +41 -0
- data/lib/jss/api_object/management_history/user_location_change.rb +66 -0
- data/lib/jss/api_object/management_history.rb +865 -0
- data/lib/jss/api_object/mdm.rb +1298 -0
- data/lib/jss/api_object/mobile_device.rb +241 -644
- data/lib/jss/api_object/mobile_device_application.rb +6 -0
- data/lib/jss/api_object/mobile_device_configuration_profile.rb +36 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +115 -151
- data/lib/jss/api_object/patch.rb +38 -0
- data/lib/jss/api_object/patch_policy.rb +38 -0
- data/lib/jss/api_object/peripheral.rb +5 -7
- data/lib/jss/api_object/policy.rb +5 -0
- data/lib/jss/api_object/restricted_software.rb +5 -0
- data/lib/jss/api_object/scopable/scope.rb +367 -411
- data/lib/jss/api_object/self_servable.rb +15 -4
- data/lib/jss/api_object/sitable.rb +197 -0
- data/lib/jss/api_object/site.rb +45 -76
- data/lib/jss/api_object/user.rb +7 -3
- data/lib/jss/api_object.rb +75 -4
- data/lib/jss/utility.rb +21 -0
- data/lib/jss/version.rb +1 -1
- data/lib/jss.rb +6 -0
- metadata +42 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c9db6dbef7526403d486b5e511d1a78a6d1e459
|
4
|
+
data.tar.gz: 6f5672d8d22feda70b4c9a7684ca73b2e64bdcaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e09669cd064fa1091f9d44506cd04454fdead9c4e8974bccaa1d123d8d7659cbb976a6c3c0edaf5e40f397d7b637621ed134c9081837ff6bccce5842ca5612
|
7
|
+
data.tar.gz: bac295fbc3b82175c1ddc1c54b4df73e1f8c2285ea21997910f0550e33a9687994d3c2bfce59a35986c2d59df63252fa69f497502b058fab6d02b33303acbcd5
|
data/CHANGES.md
CHANGED
@@ -1,9 +1,47 @@
|
|
1
1
|
# Change History
|
2
2
|
|
3
|
-
## v 0.
|
3
|
+
## v 0.11.0a5 2018-02-15
|
4
4
|
|
5
|
-
-
|
5
|
+
- Fix: Updating JSS::Extendable objects with no changes to ext. attribs will no longer erase all ext attrib values. (!)
|
6
6
|
|
7
|
+
- Improvement: Updated general attributes for computers and mobile devices
|
8
|
+
|
9
|
+
- Improvement: Computers and MobileDevices are now Creatable. Use the .make class method to create an unsaved instance, then .create/.save instance method to create the JSS record. Note: Mobile Devices need both a unique serial number and unique udid to be accepted by the API.
|
10
|
+
|
11
|
+
- Improvement: Handling of 'site' data is now done via the JSS::Sitable mixin module
|
12
|
+
|
13
|
+
- Improvement: When the JSS server's hostname ends with 'jamfcloud.com' default to SSL port 443 (vs 8443 for locally hosted JSSs)
|
14
|
+
|
15
|
+
- Improvement: ruby-jss now has a code of conduct for contributors.
|
16
|
+
|
17
|
+
- Improvement: now requires net-ldap v 0.16, for security fixes
|
18
|
+
|
19
|
+
- Add: All APIObject subclasses can be deleted without instantiating, via the .delete class method, providing an array of ids
|
20
|
+
|
21
|
+
- Improvement: All handling of MDM commands is in the JSS::MDM module, which is mixed in to Computer, ComputerGroup, MobileDevice, and MobileDeviceGroup
|
22
|
+
|
23
|
+
- Fix: Scope objects use the api connection of their container
|
24
|
+
|
25
|
+
- Improvement: Computer app usage & mgmt data methods are now class methods, so can be used without instantiating the computer.
|
26
|
+
The instance methods remain, and they now just use the class methods.
|
27
|
+
|
28
|
+
- Improvement/Change: All handling of management history for Computers and MobileDevices is in the new ManagementHistory module.
|
29
|
+
|
30
|
+
The primary query method (.management_history) returns the raw JSON data from the API, possibly for a subset of the data, as a Ruby Hash
|
31
|
+
with symbolized keys. This data is somewhat inconsistent in it's structure and content across the different types of history events,
|
32
|
+
but you're welcome to use it if needed.
|
33
|
+
|
34
|
+
All other methods now return Arrays of various instances of classes defined in the module.
|
35
|
+
|
36
|
+
For example, the {JSS::ManagementHistory.audit_history} method returns an Array of JSS::ManagementHistory::AuditEvent instances, and the
|
37
|
+
{JSS::ManagementHistory.completed_policies} gives an Array of JSS::ManagementHistory::PolicyLog objects. These objects are read-only and
|
38
|
+
provide access to their values via attribute-style methods.
|
39
|
+
|
40
|
+
As with MDM command handling, and computer app usage and mgmt data, the work is done by class methods, so that the data is available without creating instances of the Computers or MobileDevices, and the instance methods just
|
41
|
+
call the class methods.
|
42
|
+
|
43
|
+
*WARNING* these changes mean that the methods returning Arrays of ManagementHistory class instances are not backward compatible,
|
44
|
+
since the earlier versions returned Hashes
|
7
45
|
|
8
46
|
## v 0.10.1 2017-11-08
|
9
47
|
|
@@ -18,6 +56,7 @@
|
|
18
56
|
then you can call `#object_history` and `#add_object_history_entry` for individual object instances.
|
19
57
|
|
20
58
|
- Fix: Error when no storage device on a Computer is marked as the boot drive (Thanks @christopher.kemp!)
|
59
|
+
|
21
60
|
- Fix: A few lingering methods that weren't multi-APIConnection aware, are now aware
|
22
61
|
|
23
62
|
## v0.10.0 2017-10-09
|
@@ -31,17 +70,24 @@
|
|
31
70
|
|
32
71
|
The default/active connection continues to work as always, so your existing code will be fine.
|
33
72
|
See the [documentation for the JSS::APIConnection class](http://www.rubydoc.info/gems/ruby-jss/JSS/APIConnection) for details.
|
73
|
+
|
34
74
|
- Fix: Specifying port 443, as well as 8443, when connecting an APIConnection will default to using SSL. To force such a connection to NOT use SSL, provide the parameter `use_ssl: false`
|
75
|
+
|
35
76
|
- Fix: require 'English', rather than require 'english'. Thanks to HIMANSHU-ELIGIBLE @ github for catching & fixing this one.
|
77
|
+
|
36
78
|
- Fix: Popup extension attributes can always take a blank value.
|
79
|
+
|
37
80
|
- Fix: UserGroup members have a 'username' value, not 'name'
|
81
|
+
|
38
82
|
- Add: Two case-insentive string methods added to Array:
|
39
83
|
- Array#jss_ci_include_string? Takes a string, returns true if the Array contains the string without regard to case.
|
40
84
|
E.g. `['ThrAsHer'].jss_ci_include_string? 'thrasher' # => true`
|
41
85
|
- Array#jss_ci_fetch_string Takes a string and fetches it from the array, regardless of case. Nil if not found.
|
42
86
|
E.g. `['thrasher'].jss_ci_fetch_string 'ThrAsHer' # => 'thrasher'`
|
43
87
|
- Fix: APIConnection.map_all_ids wasn't honoring :refresh
|
88
|
+
|
44
89
|
- Improvement: Extendable module: only push changed EAs when `update` is called.
|
90
|
+
|
45
91
|
- Add: Computer objects now have a `last_enrolled` attribute
|
46
92
|
|
47
93
|
## v0.9.3 2017-08-08
|
@@ -49,6 +95,7 @@
|
|
49
95
|
- Add: JSS::Computer instance now allow you to modify mac_address, alt_mac_address, udid, and serial_number.
|
50
96
|
Note: even tho the WebUI doesn't allow editing of the serial_number, the API does and doing so can be useful
|
51
97
|
for dealing with duplicate SN's when a new logic board with a new udid creates a new computer entry.
|
98
|
+
|
52
99
|
- Add: JSS::Validate module, to consoliday generic data-validation methods. Methods will be moved to it from
|
53
100
|
other places over time.
|
54
101
|
|
data/README.md
CHANGED
@@ -98,17 +98,19 @@ ns.save
|
|
98
98
|
|
99
99
|
Before you can work with JSS Objects via the API, you have to connect to it.
|
100
100
|
|
101
|
-
The
|
102
|
-
|
103
|
-
in the local variables jss_user, jss_user_pw, and jss_server_hostname, and others are left as default.
|
101
|
+
The method `JSS.api` retruns the currently active connection to the API (an instance of a {JSS::APIConnection}, q.v.).
|
102
|
+
|
103
|
+
When the JSS Module is first loaded, that connection isn't connected. 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.
|
104
104
|
|
105
105
|
```ruby
|
106
106
|
JSS.api.connect user: jss_user, pw: jss_user_pw, server: jss_server_hostname
|
107
107
|
```
|
108
108
|
|
109
|
-
Make sure the user has privileges in the JSS to do things with desired Objects.
|
109
|
+
Make sure the user has privileges in the JSS to do things with desired Objects. Note that these might be more than you think, since some objects refer to other objects, like Sites and Categories.
|
110
|
+
|
111
|
+
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.
|
110
112
|
|
111
|
-
The
|
113
|
+
The connect method also accepts the symbols :stdin and :prompt as values for :pw, which will cause it to read the
|
112
114
|
password from stdin, or prompt for it in the shell. See the {JSS::APIConnection} class for more connection options and details about its methods.
|
113
115
|
|
114
116
|
Also see JSS::Configuration, and the [CONFIGURATION](#configuration) section below, for how to store
|
@@ -142,12 +144,12 @@ Some Classes provide other ways to list objects, depending on the data available
|
|
142
144
|
|
143
145
|
#### Retrieving Objects
|
144
146
|
|
145
|
-
To retrieve a single object call the class's
|
147
|
+
To retrieve a single object call the class's .fetch method and provide a name:, id:, or other valid
|
146
148
|
lookup attribute.
|
147
149
|
|
148
150
|
|
149
151
|
```ruby
|
150
|
-
a_dept = JSS::Department.fetch name:
|
152
|
+
a_dept = JSS::Department.fetch name: 'Payroll'# => #<JSS::Department:0x10b4c0818...
|
151
153
|
```
|
152
154
|
|
153
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.
|
@@ -209,6 +211,11 @@ To delete an object, just call its #delete method
|
|
209
211
|
existing_script = JSS::Script.fetch id: 321
|
210
212
|
existing_script.delete # => true # the delete was successful
|
211
213
|
```
|
214
|
+
To delete an object without fetching it, use the class's .delete method and provide the id, or an array of ids.
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
JSS::Script.delete [321, 543, 374]
|
218
|
+
```
|
212
219
|
|
213
220
|
See JSS::APIObject, the parent class of all API resources, for general information about creating, reading, updating/saving, and deleting resources.
|
214
221
|
|
data/lib/jss/api_connection.rb
CHANGED
@@ -237,11 +237,13 @@ module JSS
|
|
237
237
|
# prod2_victim_md = production_api2.fetch :MobileDevice, id: 832
|
238
238
|
#
|
239
239
|
# Here are the API calls you can make directly from an APIConnection object.
|
240
|
-
#
|
240
|
+
# They behave practically identically to the same methods in the APIObject
|
241
|
+
# subclasses, since they just call those methods, passing themselves in as the
|
242
|
+
# APIConnection to use.
|
241
243
|
#
|
242
244
|
# - {#all} The 'list' methods of the various APIObject classes. Use the 'only:'
|
243
245
|
# parameter to specify one of the sub-list-methods, like #all_ids or
|
244
|
-
# #all_laptops
|
246
|
+
# #all_laptops, e.g. `my_connection.all :computers, only: :id`
|
245
247
|
# - {#map_all_ids} the equivalent of #map_all_ids_to in the APIObject classes
|
246
248
|
# - {#valid_id} given a class and an identifier (like macaddress or udid)
|
247
249
|
# return a valid id or nil
|
@@ -254,6 +256,9 @@ module JSS
|
|
254
256
|
# - {#send_computer_mdm_command} same as {Computer.send_mdm_command}
|
255
257
|
# - {#computer_checkin_settings} same as {Computer.checkin_settings}
|
256
258
|
# - {#computer_inventory_collection_settings} same as {Computer.inventory_collection_settings}
|
259
|
+
# - {#computer_application_usage} same as {Computer.application_usage}
|
260
|
+
# - {#computer_management_data} same as {Computer.management_data}
|
261
|
+
# - {#computer_history} same as {Computer.history}
|
257
262
|
# - {#send_mobiledevice_mdm_command} same as {MobileDevice.send_mdm_command}
|
258
263
|
# - {#master_distribution_point} same as {DistributionPoint.master_distribution_point}
|
259
264
|
# - {#my_distribution_point} same as {DistributionPoint.my_distribution_point}
|
@@ -295,15 +300,21 @@ module JSS
|
|
295
300
|
# The Default port
|
296
301
|
HTTP_PORT = 9006
|
297
302
|
|
298
|
-
# The Jamf default SSL port
|
303
|
+
# The Jamf default SSL port, default for locally-hosted servers
|
299
304
|
SSL_PORT = 8443
|
300
305
|
|
301
|
-
# The https default SSL port
|
306
|
+
# The https default SSL port, default for Jamf Cloud servers
|
302
307
|
HTTPS_SSL_PORT = 443
|
303
308
|
|
304
309
|
# if either of these is specified, we'll default to SSL
|
305
310
|
SSL_PORTS = [SSL_PORT, HTTPS_SSL_PORT].freeze
|
306
311
|
|
312
|
+
# Recognize Jamf Cloud servers
|
313
|
+
JAMFCLOUD_DOMAIN = 'jamfcloud.com'.freeze
|
314
|
+
|
315
|
+
# JamfCloud connections default to 443, not 8443
|
316
|
+
JAMFCLOUD_PORT = HTTPS_SSL_PORT
|
317
|
+
|
307
318
|
# The top line of an XML doc for submitting data via API
|
308
319
|
XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.freeze
|
309
320
|
|
@@ -739,25 +750,48 @@ module JSS
|
|
739
750
|
the_class.make args
|
740
751
|
end
|
741
752
|
|
742
|
-
# Call {JSS::Computer.checkin_settings} passing this API
|
753
|
+
# Call {JSS::Computer.checkin_settings} q.v., passing this API
|
743
754
|
# connection
|
744
755
|
#
|
745
|
-
# @return (see JSS::Computer.checkin_settings)
|
746
|
-
#
|
747
756
|
def computer_checkin_settings
|
748
757
|
JSS::Computer.checkin_settings api: self
|
749
758
|
end
|
750
759
|
|
751
|
-
|
752
|
-
# Call {JSS::Computer.inventory_collection_settings} passing this API
|
760
|
+
# Call {JSS::Computer.inventory_collection_settings} q.v., passing this API
|
753
761
|
# connection
|
754
762
|
#
|
755
|
-
# @return (see JSS::Computer.checkin_settings)
|
756
|
-
#
|
757
763
|
def computer_inventory_collection_settings
|
758
764
|
JSS::Computer.inventory_collection_settings api: self
|
759
765
|
end
|
760
766
|
|
767
|
+
# Call {JSS::Computer.application_usage} q.v., passing this API
|
768
|
+
# connection
|
769
|
+
#
|
770
|
+
def computer_application_usage(ident, start_date, end_date = nil)
|
771
|
+
JSS::Computer.application_usage ident, start_date, end_date, api: self
|
772
|
+
end
|
773
|
+
|
774
|
+
# Call {JSS::Computer.management_data} q.v., passing this API
|
775
|
+
# connection
|
776
|
+
#
|
777
|
+
def computer_management_data(ident, subset: nil, only: nil)
|
778
|
+
JSS::Computer.management_data ident, subset: subset, only: only, api: self
|
779
|
+
end
|
780
|
+
|
781
|
+
# Call {JSS::Computer.history} q.v., passing this API
|
782
|
+
# connection
|
783
|
+
#
|
784
|
+
def computer_history(ident, subset: nil)
|
785
|
+
JSS::Computer.history ident, subset: subset, api: self
|
786
|
+
end
|
787
|
+
|
788
|
+
# Call {JSS::Computer.send_mdm_command} q.v., passing this API
|
789
|
+
# connection
|
790
|
+
#
|
791
|
+
def send_computer_mdm_command(targets, command, passcode = nil)
|
792
|
+
JSS::Computer.send_mdm_command targets, command, passcode, api: self
|
793
|
+
end
|
794
|
+
|
761
795
|
# Get the DistributionPoint instance for the master
|
762
796
|
# distribution point in the JSS. If there's only one
|
763
797
|
# in the JSS, return it even if not marked as master.
|
@@ -834,7 +868,7 @@ module JSS
|
|
834
868
|
#
|
835
869
|
# @return [Array<Integer>] the ids of the NetworkSegments containing the given ip
|
836
870
|
#
|
837
|
-
def network_segments_for_ip(ip
|
871
|
+
def network_segments_for_ip(ip)
|
838
872
|
ok_ip = IPAddr.new(ip)
|
839
873
|
matches = []
|
840
874
|
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
|
@@ -849,15 +883,6 @@ module JSS
|
|
849
883
|
network_segments_for_ip JSS::Client.my_ip_address
|
850
884
|
end
|
851
885
|
|
852
|
-
# Send an MDM command to one or more computers managed by
|
853
|
-
# this JSS
|
854
|
-
#
|
855
|
-
# see {JSS::Computer.send_mdm_command}
|
856
|
-
#
|
857
|
-
def send_computer_mdm_command(targets, command, passcode = nil)
|
858
|
-
JSS::Computer.send_mdm_command(targets, command, passcode, api: self)
|
859
|
-
end
|
860
|
-
|
861
886
|
# Send an MDM command to one or more mobile devices managed by
|
862
887
|
# this JSS
|
863
888
|
#
|
@@ -935,7 +960,7 @@ module JSS
|
|
935
960
|
return unless JSS::Client.installed?
|
936
961
|
# these settings can come from the jamf binary config, if this machine is a JSS client.
|
937
962
|
args[:server] ||= JSS::Client.jss_server
|
938
|
-
args[:port] ||= JSS::Client.jss_port
|
963
|
+
args[:port] ||= JSS::Client.jss_port.to_i
|
939
964
|
args[:use_ssl] ||= JSS::Client.jss_protocol.to_s.end_with? 's'
|
940
965
|
args
|
941
966
|
end
|
@@ -947,8 +972,7 @@ module JSS
|
|
947
972
|
# @return [Hash] The args with defaults applied
|
948
973
|
#
|
949
974
|
def apply_module_defaults(args)
|
950
|
-
|
951
|
-
args[:port] ||= args[:use_ssl] ? SSL_PORT : HTTP_PORT
|
975
|
+
args[:port] ||= args[:server].to_s.end_with?(JAMFCLOUD_DOMAIN) ? JAMFCLOUD_PORT : SSL_PORT
|
952
976
|
args[:timeout] ||= DFT_TIMEOUT
|
953
977
|
args[:open_timeout] ||= DFT_OPEN_TIMEOUT
|
954
978
|
args[:ssl_version] ||= DFT_SSL_VERSION
|
@@ -60,12 +60,16 @@ module JSS
|
|
60
60
|
include JSS::Creatable
|
61
61
|
include JSS::Updatable
|
62
62
|
include JSS::Criteriable
|
63
|
+
include JSS::Sitable
|
63
64
|
|
64
65
|
# Class Constants
|
65
66
|
#####################################
|
66
67
|
|
67
68
|
EXPORT_FORMATS = [:csv, :tab, :xml].freeze
|
68
69
|
|
70
|
+
# Where is site data located in the API JSON?
|
71
|
+
SITE_SUBSET = :top
|
72
|
+
|
69
73
|
# Attributes
|
70
74
|
#####################################
|
71
75
|
|
@@ -342,7 +346,7 @@ module JSS
|
|
342
346
|
|
343
347
|
df = acs.add_element('display_fields')
|
344
348
|
@display_fields.each { |f| df.add_element('display_field').add_element('name').text = f }
|
345
|
-
|
349
|
+
add_site_to_xml(doc)
|
346
350
|
doc.to_s
|
347
351
|
end # rest xml
|
348
352
|
|