ruby-jss 0.7.0 → 0.8.1

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.

Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +29 -22
  3. data/README.md +66 -86
  4. data/bin/jamfHelperBackgrounder +148 -0
  5. data/bin/netseg-update +0 -1
  6. data/lib/jss.rb +20 -9
  7. data/lib/jss/api_connection.rb +369 -295
  8. data/lib/jss/api_object.rb +651 -418
  9. data/lib/jss/api_object/account.rb +69 -77
  10. data/lib/jss/api_object/advanced_search.rb +201 -236
  11. data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +42 -42
  12. data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +33 -43
  13. data/lib/jss/api_object/advanced_search/advanced_user_search.rb +33 -43
  14. data/lib/jss/api_object/building.rb +39 -52
  15. data/lib/jss/api_object/categorizable.rb +221 -0
  16. data/lib/jss/api_object/category.rb +81 -89
  17. data/lib/jss/api_object/computer.rb +486 -525
  18. data/lib/jss/api_object/computer_invitation.rb +73 -86
  19. data/lib/jss/api_object/criteriable.rb +6 -7
  20. data/lib/jss/api_object/ebook.rb +21 -0
  21. data/lib/jss/api_object/extendable.rb +6 -8
  22. data/lib/jss/api_object/group.rb +0 -3
  23. data/lib/jss/api_object/locatable.rb +19 -20
  24. data/lib/jss/api_object/mac_application.rb +21 -0
  25. data/lib/jss/api_object/mobile_device.rb +30 -21
  26. data/lib/jss/api_object/mobile_device_application.rb +447 -0
  27. data/lib/jss/api_object/mobile_device_configuration_profile.rb +21 -0
  28. data/lib/jss/api_object/osx_configuration_profile.rb +0 -3
  29. data/lib/jss/api_object/package.rb +21 -34
  30. data/lib/jss/api_object/peripheral.rb +16 -18
  31. data/lib/jss/api_object/policy.rb +5 -83
  32. data/lib/jss/api_object/purchasable.rb +11 -13
  33. data/lib/jss/api_object/scopable.rb +11 -12
  34. data/lib/jss/api_object/script.rb +3 -17
  35. data/lib/jss/api_object/self_servable.rb +419 -205
  36. data/lib/jss/api_object/self_servable/icon.rb +179 -0
  37. data/lib/jss/api_object/updatable.rb +35 -34
  38. data/lib/jss/api_object/uploadable.rb +72 -70
  39. data/lib/jss/api_object/user.rb +6 -7
  40. data/lib/jss/api_object/vppable.rb +117 -0
  41. data/lib/jss/client.rb +264 -225
  42. data/lib/jss/db_connection.rb +7 -5
  43. data/lib/jss/exceptions.rb +50 -42
  44. data/lib/jss/ruby_extensions.rb +8 -7
  45. data/lib/jss/ruby_extensions/object.rb +19 -0
  46. data/lib/jss/utility.rb +82 -40
  47. data/lib/jss/version.rb +1 -1
  48. metadata +37 -68
  49. data/bin/jss-webhook-server +0 -3
  50. data/lib/jss/webhooks.rb +0 -53
  51. data/lib/jss/webhooks/README.md +0 -269
  52. data/lib/jss/webhooks/configuration.rb +0 -213
  53. data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation-executable +0 -91
  54. data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation.rb +0 -45
  55. data/lib/jss/webhooks/data/sample_jsons/ComputerAdded.json +0 -27
  56. data/lib/jss/webhooks/data/sample_jsons/ComputerCheckIn.json +0 -27
  57. data/lib/jss/webhooks/data/sample_jsons/ComputerInventoryCompleted.json +0 -27
  58. data/lib/jss/webhooks/data/sample_jsons/ComputerPolicyFinished.json +0 -27
  59. data/lib/jss/webhooks/data/sample_jsons/ComputerPushCapabilityChanged.json +0 -27
  60. data/lib/jss/webhooks/data/sample_jsons/JSSShutdown.json +0 -14
  61. data/lib/jss/webhooks/data/sample_jsons/JSSStartup.json +0 -14
  62. data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCheckIn.json +0 -26
  63. data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCommandCompleted.json +0 -26
  64. data/lib/jss/webhooks/data/sample_jsons/MobileDeviceEnrolled.json +0 -26
  65. data/lib/jss/webhooks/data/sample_jsons/MobileDevicePushSent.json +0 -26
  66. data/lib/jss/webhooks/data/sample_jsons/MobileDeviceUnEnrolled.json +0 -26
  67. data/lib/jss/webhooks/data/sample_jsons/PatchSoftwareTitleUpdated.json +0 -14
  68. data/lib/jss/webhooks/data/sample_jsons/PushSent.json +0 -11
  69. data/lib/jss/webhooks/data/sample_jsons/RestAPIOperation.json +0 -15
  70. data/lib/jss/webhooks/data/sample_jsons/SCEPChallenge.json +0 -10
  71. data/lib/jss/webhooks/data/sample_jsons/SmartGroupComputerMembershipChange.json +0 -13
  72. data/lib/jss/webhooks/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +0 -13
  73. data/lib/jss/webhooks/event.rb +0 -139
  74. data/lib/jss/webhooks/event/computer_added.rb +0 -38
  75. data/lib/jss/webhooks/event/computer_check_in.rb +0 -38
  76. data/lib/jss/webhooks/event/computer_inventory_completed.rb +0 -38
  77. data/lib/jss/webhooks/event/computer_policy_finished.rb +0 -38
  78. data/lib/jss/webhooks/event/computer_push_capability_changed.rb +0 -38
  79. data/lib/jss/webhooks/event/handlers.rb +0 -192
  80. data/lib/jss/webhooks/event/jss_shutdown.rb +0 -38
  81. data/lib/jss/webhooks/event/jss_startup.rb +0 -38
  82. data/lib/jss/webhooks/event/mobile_device_check_in.rb +0 -38
  83. data/lib/jss/webhooks/event/mobile_device_command_completed.rb +0 -38
  84. data/lib/jss/webhooks/event/mobile_device_enrolled.rb +0 -38
  85. data/lib/jss/webhooks/event/mobile_device_push_sent.rb +0 -38
  86. data/lib/jss/webhooks/event/mobile_device_unenrolled.rb +0 -38
  87. data/lib/jss/webhooks/event/patch_software_title_updated.rb +0 -38
  88. data/lib/jss/webhooks/event/push_sent.rb +0 -38
  89. data/lib/jss/webhooks/event/rest_api_operation.rb +0 -38
  90. data/lib/jss/webhooks/event/scep_challenge.rb +0 -38
  91. data/lib/jss/webhooks/event/smart_group_computer_membership_change.rb +0 -38
  92. data/lib/jss/webhooks/event/smart_group_mobile_device_membership_change.rb +0 -38
  93. data/lib/jss/webhooks/event/webhook.rb +0 -40
  94. data/lib/jss/webhooks/event_objects.rb +0 -112
  95. data/lib/jss/webhooks/event_objects/computer.rb +0 -49
  96. data/lib/jss/webhooks/event_objects/jss.rb +0 -36
  97. data/lib/jss/webhooks/event_objects/mobile_device.rb +0 -48
  98. data/lib/jss/webhooks/event_objects/patch_software_title_update.rb +0 -38
  99. data/lib/jss/webhooks/event_objects/push.rb +0 -33
  100. data/lib/jss/webhooks/event_objects/rest_api_operation.rb +0 -37
  101. data/lib/jss/webhooks/event_objects/scep_challenge.rb +0 -32
  102. data/lib/jss/webhooks/event_objects/smart_group.rb +0 -35
  103. data/lib/jss/webhooks/server_app.rb +0 -37
  104. data/lib/jss/webhooks/server_app/routes.rb +0 -27
  105. data/lib/jss/webhooks/server_app/routes/handle_webhook_event.rb +0 -39
  106. data/lib/jss/webhooks/server_app/routes/home.rb +0 -37
  107. data/lib/jss/webhooks/server_app/self_signed_cert.rb +0 -65
  108. data/lib/jss/webhooks/server_app/server.rb +0 -60
  109. data/lib/jss/webhooks/version.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b5245057f32987e52e0753f330b6b2fdd3b5a26
4
- data.tar.gz: 8028f472e0694cfc2dd1fbf93914369482fdddd5
3
+ metadata.gz: 4328e0cc23db07a92bfa3136ea036a84b614eb38
4
+ data.tar.gz: 9ec5ef3a805471764d22061b7a15e809eb966e27
5
5
  SHA512:
6
- metadata.gz: c4b8aaa54395cf65ccd910b15694edef02d70899169ef3f433f61721b2729d5b7af31558990bb88e2b48ef829079cf2f0bcf81fbe49f463059977e4ff39aef84
7
- data.tar.gz: 8577fd4833e3f93c6582612210ca63dd2ec9da3249f1e199f1471c12569b5e7bdd247e42d1acb818f779a06ef57b5f7c97906995a1717c9548b906a1f44fceea
6
+ metadata.gz: c3f80986485ec6620fc9f2b9ee45b6ce3bc68390a8db443abd1ad26362222602f09638b34600e6e378ebd2c61f771d8ba109a185013d0f9361763f18ab0fbb68
7
+ data.tar.gz: 1b8ebb3ffafc7562a3f9c4ad08cc8b562b1596d9c523ce69f57820016ee8d393e3b8009d27e5fdf7e9491fee2a739652e7accf56cc27713f5da4d76c277284b6
data/CHANGES.md CHANGED
@@ -1,8 +1,36 @@
1
1
  # Change History
2
2
 
3
+ ## v0.8.1 2017-06-05
4
+
5
+ - Improvement: Support for the new semantic versioning of Jamf products starting with Jamf Pro 9.99
6
+ - The alpha 'Webhooks framework' has been removed from ruby-jss and will reappear soon as it's own project with a new name.
7
+ - Fix: JSS::Package uploading and zipping wasn't worked correctly, should be now.
8
+ - Improvement: JSS::APIObject and subclasses now have .fetch and .make class methods which are wrappers for .new. .fetch is the preferred way to retrieve instances of existing API objects, and .make for making not-yet-existing objects to be created in the JSS. The .new class method still works as before, but is considered deprecated.
9
+ - Improvement: JSS::APIConnection now has a #rest_url attribute that returns the base of the url for the current REST connection, e.g. "https://jamf.company.com:8443/JSSResource", or nil if not connected.
10
+
11
+ ## v0.8.0 2017-04-07
12
+
13
+ - Change: Lots of code cleanup to follow RuboCop guidelines (more of this comming)
14
+ - Fix: sometimes the port would default to 80 rather than 8443
15
+ - Fix?: sometimes DB connections would double-disconnect, causing superfluous exceptions.
16
+ - Change: APIConnection class is no longer a singleton. The first step towards the ability to swap between multiple connections.
17
+ - Add: #port, #protocol, and #last_http_response to APIConnection instances
18
+ - Change: Improved APIConnection's ability to figure out default connection settings
19
+ - Add: APIConnection#post_rsrc and #put_rsrc now catch and re-raise HTTP 409 Conflict errors as JSS::ConflictError with error message about what caused the conflict.
20
+ - Improvement: APIObject mixin module parsing is now handled automatically by the APIObject superclass.
21
+ - Improvement: APIObject subclasses have predicate methods to see if they have various mixed-in abilities, e.g. #creatable?, #locatable?
22
+ - Change: All handling of Category data in non-Category objects is in a new Categorizable mixin module.
23
+ - Add: JSS::MobileDeviceApplication class
24
+ - Add: JSS::Icon class, handled by the improved SelfServable mixin module
25
+ - Add: JSS::Client.jamf_helper method now takes arg_string:, output_file: and abandon_process: parameters.
26
+ - Add: executable bin/jamfHelperBackgrounder, wrapper to run jamfHelper as a stand-alone process, allowing polcies to continue while a window is displayed
27
+ - Add: explicitly require the standard library 'English', and start using it rather than cryptic globals like $! and $@
28
+ - Add: first attempts at adding SSL/TLS support to the Webhooks framework.
29
+ - NOTE: the Webhooks framework is still 'alpha' code, and will be moved into a separate git repo eventually. It doesn't rely on ruby-jss.
30
+
3
31
  ## v0.7.0 2017-02-01
4
32
 
5
- - JSS::NetworkSegment - many bugfixes and cleanup. I didn't really have a proper grasp of IP CIDR masks before and how the (don't) related to the IP ranges used by Network Segments in the JSS. They CIDRs and full netmasks can still be used to set the ending addresses of NetworkSegment objects, but the #cidr method is gone, since it was meaningless for segments that didn't match subnet-ranges.
33
+ - JSS::NetworkSegment - many bugfixes and cleanup. I didn't really have a proper grasp of IP CIDR masks before and how they (don't) relate to the IP ranges used by Network Segments in the JSS. The CIDRs and full netmasks can still be used to set the ending addresses of NetworkSegment objects, but the #cidr method is gone, since it was meaningless for segments that didn't match subnet-ranges.
6
34
  - subnect-update, the example command in the bin directory, has been renamed to negseg-update. It's also been cleaned up and uses the new functionality of JSS::NetworkSegment.
7
35
  - JSS::DBConnection - fixed a bug where meaningless IO 'stream closed' errors would appear when closing the DB connection.
8
36
 
@@ -14,49 +42,31 @@
14
42
  ## v0.6.6 2016-11-30
15
43
 
16
44
  - Added String#jss_to_pathname to convert Strings to Pathname instances in JSS::Configuration.
17
-
18
45
  - JSS::DBConnection#connect now returns the server hostname, to match the behavior of JSS::APIConnection#connect
19
-
20
46
  - JSS::Client: added .console_user method
21
-
22
47
  - JSS::Policy, now creatable, and self-servable, and more attributes are updatable
23
-
24
48
  - JSS::SelfServable, finally getting this module functional, at least for policies
25
-
26
49
  - JSS::Creatable, added #clone method - all creatable objects can be cloned easily.
27
-
28
50
  - JSS::APIObject, added .exist? and .valid_id class methods and #to_s instance method
29
-
30
51
  - Change the mountpoint directory for JSS::DistributionPoint#mount to /tmp, because Sierra doesn't allow mounting in /Volumes except by root. (Thanks @LM2807! )
31
-
32
52
  - Starting cleaning up code to better adhere to [RuboCop](http://rubocop.readthedocs.io/en/latest/) standards
33
-
34
53
  - Added alpha version of a JSS WebHooks framwork
35
54
 
36
55
  ## v0.6.5 2016-08-10
37
56
 
38
57
  - Cleanup of redundant constants (Thanks @aurica!)
39
-
40
58
  - Added JSS::ComputerInvitation class (Thanks @tostart-pickagreatname!)
41
-
42
59
  - Added JSS::Account class (Thanks @JonPulsifer!)
43
-
44
60
  - Added JSS::OSXConfigurationProfile class (Thanks @tostart-pickagreatname!)
45
-
46
61
  - JSS::Computer: added methods #boot_drive, #filevault2_enabled?, and #filevault1_accounts
47
-
48
62
  - Various small bugfixes & improvements
49
63
 
50
64
  ## v0.6.4 2016-03-24
51
65
 
52
66
  - JSS::Package#dlete can optionally delete the master file at the same time
53
-
54
67
  - Added an example ruby-jss.conf file with internal documentation
55
-
56
68
  - Various small bugfixes & improvements
57
-
58
69
  - Updated the config file name to match the new gem name, maintaining backwards compatibility
59
-
60
70
  - Improved error messages
61
71
 
62
72
  ## v0.6.3 2016-03-09
@@ -76,15 +86,12 @@ The 'jss-api' gem has been updated one last time, also to v0.6.2. That gem has a
76
86
  #### additions & features
77
87
 
78
88
  - 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.
79
-
80
89
  - JSS::ExtensionAttribute#latest_values always now includes :username in the returned data.
81
90
 
82
91
  #### bugfixes
83
92
 
84
93
  - 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.
85
-
86
94
  - JSS::Composer::mk_dmg fix for building/indexing dmg's, no longer creates an unreadable .Trashes folder.
87
-
88
95
  - Several small typos and other tiny bugs.
89
96
 
90
97
  ## v0.6.1 2016-03-01
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ruby-jss: Access to the Casper Suite from Ruby
1
+ # ruby-jss: Access to the Jamf Pro from Ruby
2
2
  [![Gem Version](https://badge.fury.io/rb/ruby-jss.svg)](http://badge.fury.io/rb/ruby-jss)
3
3
 
4
4
  ### Table of contents
@@ -27,13 +27,20 @@
27
27
 
28
28
  ## DESCRIPTION
29
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).
30
+ The ruby-jss project provides a Ruby module called JSS, which is used for accessing the REST API of
31
+ the JAMF Software Server (JSS), the core of Jamf Pro, an enterprise-level management tool for Apple
32
+ devices from [JAMF Software, LLC](http://www.jamf.com/). It is available as a
33
+ [rubygem](https://rubygems.org/gems/ruby-jss), and the
34
+ [source is on github](https://github.com/PixarAnimationStudios/ruby-jss).
31
35
 
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)
36
+ The module abstracts API resources as Ruby objects, and provides methods for interacting with those
37
+ resources. It also provides some features that aren't a part of the API itself, but come with other
38
+ Jamf-related tools, such as uploading .pkg and .dmg {JSS::Package} data to the master distribution
39
+ point, and the installation of {JSS::Package} objects on client machines. (See [BEYOND THE API](#beyond-the-api)
33
40
 
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.
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.
37
44
 
38
45
  We've implemented the things we need in our environment, and as our needs grow, we'll add more.
39
46
  Hopefully others will find it useful, and add more to it as well.
@@ -46,33 +53,31 @@ Hopefully others will find it useful, and add more to it as well.
46
53
  ```ruby
47
54
  require 'jss'
48
55
 
49
- JSS::API.connect(
50
- :user => jss_user,
51
- :pw => jss_user_pw,
52
- :server => jss_server_hostname
53
- )
56
+ # Connect to the API
57
+ JSS::API.connect user: jss_user, pw: jss_user_pw, server: jss_server_hostname
54
58
 
55
- # get an array of data about all JSS::Package objects in the JSS:
56
- JSS::Package.all
59
+ # get an array of basic data about all JSS::Package objects in the JSS:
60
+ pkgs = JSS::Package.all
57
61
 
58
62
  # get an array of names of all JSS::Package objects in the JSS:
59
- JSS::Package.all_names
63
+ pkg_names = JSS::Package.all_names
60
64
 
61
- # Get a static computer group
62
- mg = JSS::ComputerGroup.new :name => "Macs of interest"
65
+ # Get a static computer group. This creates a new Ruby object
66
+ # representing the existing JSS computer group.
67
+ mg = JSS::ComputerGroup.fetch name: "Macs of interest"
63
68
 
64
69
  # Add a computer to the group
65
70
  mg.add_member "pricklepants"
66
71
 
67
- # save my changes
68
- mg.update
72
+ # save changes back to the JSS, mg.update works also
73
+ mg.save
69
74
 
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'
75
+ # Create a new network segment to store in the JSS.
76
+ # This makes a new Ruby Object that doesn't yet exist in the JSS.
77
+ ns = JSS::NetworkSegment.make(
78
+ name: 'Private Class C',
79
+ starting_address: '192.168.0.0',
80
+ ending_address: '192.168.0.255'
76
81
  )
77
82
 
78
83
  # Associate this network segment with a specific building,
@@ -83,8 +88,8 @@ ns.building = "Main Office"
83
88
  # which must exist in the JSS, and be listed in JSS::SoftwareUpdateServer.all_names
84
89
  ns.swu_server = "Main SWU Server"
85
90
 
86
- # Create the new network segment in the JSS
87
- ns.create
91
+ # save the new network segment in the JSS, ns.create works as well
92
+ ns.save
88
93
  ```
89
94
 
90
95
  ## USAGE
@@ -94,23 +99,24 @@ ns.create
94
99
  Before you can work with JSS Objects via the API, you have to connect to it.
95
100
 
96
101
  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:
102
+ connected. To remedy that, use JSS::API.connect, passing it values for the connection. In this example, those values are stored
103
+ in the local variables jss_user, jss_user_pw, and jss_server_hostname, and others are left as default.
98
104
 
99
105
  ```ruby
100
- JSS::API.connect :user => jss_user, :pw => jss_user_pw, :server => jss_server_hostname
106
+ JSS::API.connect user: jss_user, pw: jss_user_pw, server: jss_server_hostname
101
107
  ```
102
108
 
103
- Make sure the user has privileges in the JSS to do things with API Objects.
109
+ Make sure the user has privileges in the JSS to do things with desired Objects.
104
110
 
105
111
  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.
112
+ 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
113
 
108
- Also see {JSS::Configuration}, and the CONFIGURATION section below, for how to store
114
+ Also see {JSS::Configuration}, and the [CONFIGURATION](#configuration) section below, for how to store
109
115
  server connection parameters in a simple config file.
110
116
 
111
117
  ### Working with JSS Objects (a.k.a REST Resources)
112
118
 
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.
119
+ 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. See below for the level of implementation of each class.
114
120
 
115
121
  --------
116
122
 
@@ -136,32 +142,29 @@ Some Classes provide other ways to list objects, depending on the data available
136
142
 
137
143
  #### Retrieving Objects
138
144
 
139
- To retrieve a single object call the object's constructor (.new) and provide either :name or :id or :data.
145
+ To retrieve a single object call the class's constructor .fetch method and provide a name:, id:, or other valid
146
+ lookup attribute.
140
147
 
141
- * :name or :id will be looked up via the API
142
148
 
143
149
  ```ruby
144
- a_dept = JSS::Department.new :name => "Payroll" # => #<JSS::Department:0x10b4c0818...
150
+ a_dept = JSS::Department.fetch name: "Payroll" # => #<JSS::Department:0x10b4c0818...
145
151
  ```
146
152
 
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
+ 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.
153
154
 
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
+ *NOTE*: A class's '.fetch' method is now the preferred method to use for retrieving existing objects. The '.new' method still works as before, but is
156
+ deprecated for object retrieval and doing so may raise errors in the future. See below for using .make to create new objects in the JSS.
155
157
 
156
158
  --------
157
159
 
158
160
  #### Creating Objects
159
161
 
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.
162
+ Some Objects can be created anew in the JSS via ruby. To do so, first make a Ruby object using the class's .make method and providinga unique :name:, e.g.
161
163
 
162
164
  ```ruby
163
- new_pkg = JSS::Package.new :id => :new, :name => "transmogrifier-2.3-1.pkg"
165
+ new_pkg = JSS::Package.make name: "transmogrifier-2.3-1.pkg"
164
166
  ```
167
+ *NOTE*: some classes require more data than just a :name when created with .create.
165
168
 
166
169
  Then set the attributes of the new object as needed
167
170
 
@@ -171,13 +174,13 @@ new_pkg.category = "CoolTools"
171
174
  # etc..
172
175
  ```
173
176
 
174
- Then use the #create method to create it in the JSS.
177
+ Then use the #create method to create it in the JSS. The #save method is an alias of #create
175
178
 
176
179
  ```ruby
177
- new_pkg.create # => 453 # the id number of the object just created
180
+ new_pkg.create # returns 453, the id number of the object just created
178
181
  ```
179
182
 
180
- *NOTE* some subclasses require more data than just a :name when instantiating with :id => :new.
183
+ *NOTE*: A class's '.make' method is now the preferred method to use for creating new objects. The '.new id: :new' method still works as before, but is deprecated for object creation and doing so may raise errors in the future.
181
184
 
182
185
  --------
183
186
 
@@ -186,14 +189,14 @@ new_pkg.create # => 453 # the id number of the object just created
186
189
  Some objects can be modified in the JSS.
187
190
 
188
191
  ```ruby
189
- existing_script = JSS::Script.new :id => 321
192
+ existing_script = JSS::Script.fetch id: 321
190
193
  existing_script.name = "transmogrifier-2.3-1.post-install"
191
194
  ```
192
195
 
193
196
  After changing any attributes, use the #update method (also aliased to #save) to push the changes to the JSS.
194
197
 
195
198
  ```ruby
196
- existing_script.update # or existing_script.save => true # the update was successful
199
+ existing_script.update # => returns the id number of the object just saved
197
200
  ```
198
201
 
199
202
  --------
@@ -203,7 +206,7 @@ existing_script.update # or existing_script.save => true # the update was succe
203
206
  To delete an object, just call its #delete method
204
207
 
205
208
  ```ruby
206
- existing_script = JSS::Script.new :id => 321
209
+ existing_script = JSS::Script.fetch id: 321
207
210
  existing_script.delete # => true # the delete was successful
208
211
  ```
209
212
 
@@ -225,6 +228,7 @@ See each Class's documentation for details.
225
228
  * {JSS::ComputerExtensionAttribute}
226
229
  * {JSS::ComputerGroup}
227
230
  * {JSS::Department}
231
+ * {JSS::MobileDeviceApplication}
228
232
  * {JSS::MobileDeviceExtensionAttribute}
229
233
  * {JSS::MobileDeviceGroup}
230
234
  * {JSS::NetworkSegment}
@@ -278,6 +282,7 @@ These must be created and edited via the JSS WebApp
278
282
  * {JSS::DistributionPoint}
279
283
  * {JSS::LDAPServer}
280
284
  * {JSS::NetBootServer}
285
+ * {JSS::RestrictedSoftware}
281
286
  * {JSS::SoftwareUpdateServer}
282
287
 
283
288
  ### Deletable
@@ -335,15 +340,15 @@ Here's an example of how to use a password stored in a file:
335
340
 
336
341
  ```ruby
337
342
  password = File.read "/path/to/secure/password/file" # read the password from a file
338
- JSS::API.connect :pw => password # other arguments used from the config settings
343
+ JSS::API.connect pw: password # other arguments used from the config settings
339
344
  ```
340
345
 
341
346
  And here's an example of how to read a password from a web server and use it.
342
347
 
343
348
  ```ruby
344
349
  require 'open-uri'
345
- password = open('http://server.org.org/path/to/password').read
346
- JSS::API.connect :pw => password # other arguments used from the config settings
350
+ password = open('https://server.org.org/path/to/password').read
351
+ JSS::API.connect pw: password # other arguments used from the config settings
347
352
  ```
348
353
 
349
354
  ## BEYOND THE API
@@ -372,10 +377,9 @@ While the Casper API provides access to object data in the JSS, this gem tries t
372
377
 
373
378
  the JSS gem was written for:
374
379
 
375
- * Mac OS X 10.8 and higher
380
+ * Mac OS X 10.9 or higher
381
+ * Ruby 2.0 or higher
376
382
  * Casper Suite version 9.4 or higher
377
- * Casper 9.4 - 9.6 require Ruby 1.8.7 and higher
378
- * Casper >= 9.61 require Ruby 1.9.3 and higher
379
383
 
380
384
  It also requires these gems, which will be installed automatically if you install JSS with `gem install jss`
381
385
 
@@ -393,46 +397,22 @@ It also requires these gems, which will be installed automatically if you instal
393
397
 
394
398
  NOTE: You may need to install XCode, and it's CLI tools, in order to install the required gems.
395
399
 
396
- In general, you can install the JSS Gem with this command:
400
+ In general, you can install ruby-jss with this command:
397
401
 
398
402
  `gem install ruby-jss`
399
403
 
400
- 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.
401
-
402
- `gem install json -v 1.6.5`
403
-
404
- `gem install mime-types -v 1.25.1`
405
-
406
- `gem install rest-client -v 1.6.8`
407
-
408
404
 
409
405
  ## HELP
410
406
 
407
+ Full documentation is available at [rubydoc.info](http://www.rubydoc.info/gems/ruby-jss/)
408
+
411
409
  [Email the developer](mailto:ruby-jss@pixar.com)
412
410
 
413
411
  [Macadmins Slack Channel](https://macadmins.slack.com/messages/#jss-api/)
414
412
 
415
413
  ## LICENSE
416
414
 
417
- Copyright 2016 Pixar
418
-
419
- Licensed under the Apache License, Version 2.0 (the "Apache License")
420
- with the following modification; you may not use this file except in
421
- compliance with the Apache License and the following modification to it:
422
-
423
- Section 6. Trademarks. is deleted and replaced with:
424
-
425
- 6\. Trademarks. This License does not grant permission to use the trade
426
- names, trademarks, service marks, or product names of the Licensor
427
- and its affiliates, except as required to comply with Section 4(c) of
428
- the License and to reproduce the content of the NOTICE file.
429
-
430
- You may obtain a copy of the Apache License at
431
-
432
- http://www.apache.org/licenses/LICENSE-2.0
415
+ Copyright 2017 Pixar
433
416
 
434
- Unless required by applicable law or agreed to in writing, software
435
- distributed under the Apache License with the above modification is
436
- distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
437
- KIND, either express or implied. See the Apache License for the specific
438
- language governing permissions and limitations under the Apache License.
417
+ Licensed under the Apache License, Version 2.0 (the "Apache License") with
418
+ modifications. See LICENSE.txt for details
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/ruby
2
+
3
+ ### Copyright 2017 Pixar
4
+
5
+ ###
6
+ ### Licensed under the Apache License, Version 2.0 (the "Apache License")
7
+ ### with the following modification; you may not use this file except in
8
+ ### compliance with the Apache License and the following modification to it:
9
+ ### Section 6. Trademarks. is deleted and replaced with:
10
+ ###
11
+ ### 6. Trademarks. This License does not grant permission to use the trade
12
+ ### names, trademarks, service marks, or product names of the Licensor
13
+ ### and its affiliates, except as required to comply with Section 4(c) of
14
+ ### the License and to reproduce the content of the NOTICE file.
15
+ ###
16
+ ### You may obtain a copy of the Apache License at
17
+ ###
18
+ ### http://www.apache.org/licenses/LICENSE-2.0
19
+ ###
20
+ ### Unless required by applicable law or agreed to in writing, software
21
+ ### distributed under the Apache License with the above modification is
22
+ ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
+ ### KIND, either express or implied. See the Apache License for the specific
24
+ ### language governing permissions and limitations under the Apache License.
25
+
26
+ # == Synopsis
27
+ # Run the jamfHelper program as a detached background process, optionally
28
+ # writing its output to a file, and optionally running it as the console user
29
+ # (if this script is being run by root).
30
+ #
31
+ # WARNING: You shouldn't run this command directly as a launchd job. Rather
32
+ # you should write a small script that runs this command, and use launchd
33
+ # to run that.
34
+ #
35
+ #
36
+ # == Usage
37
+ # jamfHelperBackgrounder <options> | -help
38
+ #
39
+ #
40
+ # == Author
41
+ # Chris Lasell <chrisl@pixar.com>
42
+ #
43
+ # == Copyright
44
+ # Copyright (c) 2017 Pixar Animation Studios
45
+ ##############################
46
+
47
+ require 'ruby-jss'
48
+
49
+ # The app object
50
+ class App
51
+
52
+ WIN_TYPE_PARAM = '-windowType'.freeze
53
+ CONS_USER_PARAM = '-consoleUser'.freeze
54
+ OUTPUT_FILE_PARAM = '-outputFile'.freeze
55
+
56
+ # Set up
57
+ #
58
+ def initialize(args)
59
+ if args.include? '-help'
60
+ @help = true
61
+ return
62
+ end
63
+
64
+ if args.include? CONS_USER_PARAM
65
+ args.delete CONS_USER_PARAM
66
+ @as_user = JSS::Client.console_user
67
+ else
68
+
69
+ wintype_idx = args.index { |a| a == WIN_TYPE_PARAM }
70
+ raise 'missing option: -windowType' unless wintype_idx
71
+ args.delete_at wintype_idx
72
+ @window_type = args.delete_at(wintype_idx).to_sym
73
+
74
+ if args.include? OUTPUT_FILE_PARAM
75
+ outfile_idx = args.index { |a| a == OUTPUT_FILE_PARAM }
76
+ args.delete_at outfile_idx
77
+ @outfile = args.delete_at outfile_idx
78
+ end
79
+
80
+ end # if args.include? AS_USER_PARAM...else...
81
+
82
+ @arg_string = ''
83
+ args.each { |a| @arg_string << " #{Shellwords.escape a}" }
84
+ end # init
85
+
86
+ # Do the thing. Win the points.
87
+ #
88
+ # @return [void]
89
+ #
90
+ def run
91
+ if @help
92
+ show_help
93
+ return
94
+ end
95
+
96
+ if @as_user
97
+ raise 'Only root can do things as another user' unless JSS.superuser?
98
+ cmd = ['su', '-l', @as_user, '-c', "#{Shellwords.escape __FILE__} #{@arg_string}"]
99
+ exec(*cmd)
100
+ end
101
+
102
+ JSS::Client.jamf_helper @window_type, arg_string: @arg_string, abandon_process: true, output_file: @outfile
103
+ end # run
104
+
105
+ # Spew helpful info to output
106
+ #
107
+ # @return [void]
108
+ #
109
+ def show_help
110
+ puts <<-ENDHELP
111
+ This command runs the jamfHelper command as a detached background process.
112
+ This means that you use this command in a policy (via script, usually) and the
113
+ Policy execution will continue, and exit properly, even while the jamfHelper window
114
+ is still open.
115
+
116
+ This is important because future Jamf checkins will not happen if an earlier checkin
117
+ policy is waiting for a jamfHelper window to close.
118
+
119
+ This command takes all the same commandline options as jamfHelper, plus these:
120
+
121
+ -outputFile <path> Write the numeric output from jamfHelper to the file
122
+ at <path>. The path must be writable by the user
123
+ running jamfHelper (see below).
124
+ This file can be examined later to determine what
125
+ the user clicked.
126
+
127
+ -consoleUser Run the jamfHelper process as the current console (GUI)
128
+ user. This is needed from most policies and other code
129
+ running as root, in order to show the window in the
130
+ current console user's UI. If no one is logged into the
131
+ console, nothing happens.
132
+ This can only be used by the root user.
133
+
134
+ -help Show this help.
135
+
136
+ WARNING: You shouldn't run this command directly as a launchd job. Rather
137
+ you should write a small script that runs this command, and use launchd
138
+ to run that.
139
+ ENDHELP
140
+ end # show help
141
+
142
+ end # app
143
+
144
+ ##############################
145
+ # create the app and go
146
+
147
+ app = App.new(ARGV)
148
+ app.run