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
@@ -26,127 +26,116 @@
26
26
  ###
27
27
  module JSS
28
28
 
29
- #####################################
30
- ### Module Constants
29
+ # Module Constants
31
30
  #####################################
32
31
 
33
- #####################################
34
- ### Module Variables
32
+ # Module Variables
35
33
  #####################################
36
34
 
35
+ # Module Methods
37
36
  #####################################
38
- ### Module Methods
39
- #####################################
40
-
41
- ###
42
- ### This class represents a Computer Invitation in the JSS.
43
- ###
44
- ### ===Adding Computer Invitations to the JSS
45
- ###
46
- ### This class is meant only to generate and hold the response of creating
47
- ### an invitation.
48
- ###
49
- ### @see APIObject
50
- ### @see Creatable
51
- ###
52
37
 
38
+ # This class represents a Computer Invitation in the JSS.
39
+ #
40
+ # ===Adding Computer Invitations to the JSS
41
+ #
42
+ # This class is meant only to generate and hold the response of creating
43
+ # an invitation.
44
+ #
45
+ # @see APIObject
46
+ # @see Creatable
47
+ #
53
48
  class ComputerInvitation < JSS::APIObject
54
49
 
55
- #####################################
56
- ### MixIns
50
+ # MixIns
57
51
  #####################################
58
52
 
59
53
  include JSS::Creatable
60
54
 
61
- #####################################
62
- ### Class Variables
55
+ # Class Variables
63
56
  #####################################
64
57
 
65
- #####################################
66
- ### Class Methods
58
+ # Class Methods
67
59
  #####################################
68
60
 
69
- #####################################
70
- ### Class Constants
61
+ # Class Constants
71
62
  #####################################
72
63
 
73
- ### The base for REST resources of this class
74
- RSRC_BASE = "computerinvitations"
64
+ # The base for REST resources of this class
65
+ RSRC_BASE = 'computerinvitations'.freeze
75
66
 
76
- ### the hash key used for the JSON list output of all objects in the JSS
67
+ # the hash key used for the JSON list output of all objects in the JSS
77
68
  RSRC_LIST_KEY = :computer_invitations
78
69
 
79
- ### The hash key used for the JSON object output.
80
- ### It's also used in various error messages
70
+ # The hash key used for the JSON object output.
71
+ # It's also used in various error messages
81
72
  RSRC_OBJECT_KEY = :computer_invitation
82
73
 
83
- ### these keys, as well as :id and :name, are present in valid API JSON data for this class
84
- VALID_DATA_KEYS = [:invitation]
74
+ # these keys, as well as :id and :name, are present in valid API JSON data for this class
75
+ VALID_DATA_KEYS = [:invitation].freeze
85
76
 
86
- #####################################
87
- ### Attributes
77
+ # Attributes
88
78
  #####################################
89
79
 
90
- ### The values returned in the General, Location, and Purchasing subsets are stored as direct attributes
91
- ### Location and Purchasing are defined in the Locatable and Purchasable mixin modules.
92
- ### Here's General, in alphabetical order
80
+ # The values returned in the General, Location, and Purchasing subsets are stored as direct attributes
81
+ # Location and Purchasing are defined in the Locatable and Purchasable mixin modules.
82
+ # Here's General, in alphabetical order
93
83
 
94
- ### @return [String] the invitation name
84
+ # @return [String] the invitation name
95
85
  attr_reader :name
96
86
 
97
- ### @return [String] the invitation type
98
- ###
99
- ### Valid values are: URL and EMAIL. Will default to DEFAULT.
87
+ # @return [String] the invitation type
88
+ #
89
+ # Valid values are: URL and EMAIL. Will default to DEFAULT.
100
90
  attr_accessor :invitation_type
101
91
 
102
- ### @return [String] whether or not to create the account if required
103
- ###
104
- ### "true" or "false" are valid values.
92
+ # @return [String] whether or not to create the account if required
93
+ #
94
+ # "true" or "false" are valid values.
105
95
  attr_accessor :create_account_if_does_not_exist
106
96
 
107
- ### @return [String]
108
- ###
109
- ### Time since epoch that the invitation will expire at.
110
- ###
111
- ### Note: defaults to "Unlimited", so only set if it should expire.
97
+ # @return [String]
98
+ #
99
+ # Time since epoch that the invitation will expire at.
100
+ #
101
+ # Note: defaults to "Unlimited", so only set if it should expire.
112
102
  attr_accessor :expiration_date_epoch
113
103
 
114
- ### @return [String]
115
- ###
116
- ### The username of the ssh user to be created.
117
- ###
118
- ### REQUIRED for valid setup.
104
+ # @return [String]
105
+ #
106
+ # The username of the ssh user to be created.
107
+ #
108
+ # REQUIRED for valid setup.
119
109
  attr_accessor :ssh_username
120
110
 
121
- ### @return [String]
122
- ###
123
- ### The whether or not to hide the ssh user.
111
+ # @return [String]
112
+ #
113
+ # The whether or not to hide the ssh user.
124
114
  attr_accessor :hide_account
125
115
 
126
- ### @return [String]
127
- ###
128
- ### The invitation_status.
116
+ # @return [String]
117
+ #
118
+ # The invitation_status.
129
119
  attr_accessor :invitation_status
130
120
 
131
- ### @return [String]
132
- ###
133
- ### Whether the invitation can be used multiple times (boolean).
121
+ # @return [String]
122
+ #
123
+ # Whether the invitation can be used multiple times (boolean).
134
124
  attr_accessor :multiple_uses_allowed
135
125
 
136
- #####################################
137
- ### Public Instance Methods
126
+ # Public Instance Methods
138
127
  #####################################
139
128
 
140
- ###
141
- ### @see APIObject#initialize
142
- ###
129
+ # @see APIObject#initialize
130
+ #
143
131
  def initialize(args = {
144
132
  id: :new,
145
- name: "some_new_name",
146
- ssh_username: "casper_remote",
147
- hide_account: "true" } )
133
+ name: 'some_new_name',
134
+ ssh_username: 'casper_remote',
135
+ hide_account: 'true'
136
+ })
148
137
 
149
- super args, []
138
+ super args
150
139
 
151
140
  @name = @init_data[:invitation]
152
141
  @invitation_type = @init_data[:invitation_type]
@@ -158,15 +147,13 @@ module JSS
158
147
  @multiple_uses_allowed = @init_data[:multiple_uses_allowed] || args[:multiple_uses_allowed]
159
148
  end
160
149
 
161
- #####################################
162
- ### Public Class Methods
150
+ # Public Class Methods
163
151
  #####################################
164
152
 
165
- ###
166
- ### Needed to support creation of new Computer Invitations to set their name.
167
- ###
168
- ### @return [JSS::ComputerInvitation]
169
- ###
153
+ # Needed to support creation of new Computer Invitations to set their name.
154
+ #
155
+ # @return [JSS::ComputerInvitation]
156
+ #
170
157
  def create
171
158
  new_invitation_id = super
172
159
 
@@ -181,14 +168,12 @@ module JSS
181
168
  @multiple_uses_allowed = jss_me.multiple_uses_allowed
182
169
  end
183
170
 
184
- #####################################
185
- ### Private Instance Methods
171
+ # Private Instance Methods
186
172
  #####################################
187
173
  private
188
174
 
189
- ###
190
- ### Sets invitation expiration 4 hours after request.
191
- ###
175
+ # Sets invitation expiration 4 hours after request.
176
+ #
192
177
  def rest_xml
193
178
  doc = REXML::Document.new APIConnection::XML_HEADER
194
179
  obj = doc.add_element RSRC_OBJECT_KEY.to_s
@@ -201,7 +186,9 @@ module JSS
201
186
  obj.add_element('hide_account').text = hide_account
202
187
  obj.add_element('invitation_status').text = invitation_status
203
188
  obj.add_element('multiple_uses_allowed').text = multiple_uses_allowed
204
- return doc.to_s
189
+ doc.to_s
205
190
  end
191
+
206
192
  end
193
+
207
194
  end
@@ -1,26 +1,26 @@
1
1
  ### Copyright 2017 Pixar
2
2
 
3
- ###
3
+ ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
5
  ### with the following modification; you may not use this file except in
6
6
  ### compliance with the Apache License and the following modification to it:
7
7
  ### Section 6. Trademarks. is deleted and replaced with:
8
- ###
8
+ ###
9
9
  ### 6. Trademarks. This License does not grant permission to use the trade
10
10
  ### names, trademarks, service marks, or product names of the Licensor
11
11
  ### and its affiliates, except as required to comply with Section 4(c) of
12
12
  ### the License and to reproduce the content of the NOTICE file.
13
- ###
13
+ ###
14
14
  ### You may obtain a copy of the Apache License at
15
- ###
15
+ ###
16
16
  ### http://www.apache.org/licenses/LICENSE-2.0
17
- ###
17
+ ###
18
18
  ### Unless required by applicable law or agreed to in writing, software
19
19
  ### distributed under the Apache License with the above modification is
20
20
  ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
21
  ### KIND, either express or implied. See the Apache License for the specific
22
22
  ### language governing permissions and limitations under the Apache License.
23
- ###
23
+ ###
24
24
  ###
25
25
 
26
26
  ###
@@ -68,7 +68,6 @@ module JSS
68
68
  ### inform the subclass instance that it has changed and needs an #update
69
69
  ###
70
70
  ### Classes mixing in this module *must*
71
- ### * call #parse_criteria during initialization.
72
71
  ### * If they are Updatable or Creatable, they must insert
73
72
  ### self.criteria.rest_xml into their own xml output.
74
73
  ###
@@ -0,0 +1,21 @@
1
+ # This is just a stub for now.
2
+
3
+ #
4
+ module JSS
5
+
6
+ #
7
+ class EBook < APIObject
8
+
9
+ ### The base for REST resources of this class
10
+ RSRC_BASE = 'ebooks'.freeze
11
+
12
+ ### the hash key used for the JSON list output of all objects in the JSS
13
+ RSRC_LIST_KEY = :ebooks
14
+
15
+ ### The hash key used for the JSON object output.
16
+ ### It's also used in various error messages
17
+ RSRC_OBJECT_KEY = :ebook
18
+
19
+ end
20
+
21
+ end
@@ -1,26 +1,26 @@
1
1
  ### Copyright 2017 Pixar
2
2
 
3
- ###
3
+ ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
5
  ### with the following modification; you may not use this file except in
6
6
  ### compliance with the Apache License and the following modification to it:
7
7
  ### Section 6. Trademarks. is deleted and replaced with:
8
- ###
8
+ ###
9
9
  ### 6. Trademarks. This License does not grant permission to use the trade
10
10
  ### names, trademarks, service marks, or product names of the Licensor
11
11
  ### and its affiliates, except as required to comply with Section 4(c) of
12
12
  ### the License and to reproduce the content of the NOTICE file.
13
- ###
13
+ ###
14
14
  ### You may obtain a copy of the Apache License at
15
- ###
15
+ ###
16
16
  ### http://www.apache.org/licenses/LICENSE-2.0
17
- ###
17
+ ###
18
18
  ### Unless required by applicable law or agreed to in writing, software
19
19
  ### distributed under the Apache License with the above modification is
20
20
  ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
21
  ### KIND, either express or implied. See the Apache License for the specific
22
22
  ### language governing permissions and limitations under the Apache License.
23
- ###
23
+ ###
24
24
  ###
25
25
 
26
26
  ###
@@ -61,8 +61,6 @@ module JSS
61
61
  ### For Example, {JSS::Computer} sets this:
62
62
  ### EXT_ATTRIB_CLASS = JSS::ComputerExtensionAttribute
63
63
  ###
64
- ### During initialization those classes must call {#parse_ext_attrs} to populate the @extension_attributes
65
- ### attribute from @init_data.
66
64
  ###
67
65
  ### Parsing also populates @ext_attrs which is a Hash of name => value for each EA.
68
66
  ###
@@ -155,8 +155,6 @@ module JSS
155
155
 
156
156
  @site = JSS::APIObject.get_name(@init_data[:site])
157
157
 
158
- parse_criteria
159
-
160
158
  end #init
161
159
 
162
160
  #####################################
@@ -378,4 +376,3 @@ end # module JSS
378
376
  require "jss/api_object/group/computer_group"
379
377
  require "jss/api_object/group/mobile_device_group"
380
378
  require "jss/api_object/group/user_group"
381
-
@@ -1,26 +1,26 @@
1
1
  ### Copyright 2017 Pixar
2
2
 
3
- ###
3
+ ###
4
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
5
  ### with the following modification; you may not use this file except in
6
6
  ### compliance with the Apache License and the following modification to it:
7
7
  ### Section 6. Trademarks. is deleted and replaced with:
8
- ###
8
+ ###
9
9
  ### 6. Trademarks. This License does not grant permission to use the trade
10
10
  ### names, trademarks, service marks, or product names of the Licensor
11
11
  ### and its affiliates, except as required to comply with Section 4(c) of
12
12
  ### the License and to reproduce the content of the NOTICE file.
13
- ###
13
+ ###
14
14
  ### You may obtain a copy of the Apache License at
15
- ###
15
+ ###
16
16
  ### http://www.apache.org/licenses/LICENSE-2.0
17
- ###
17
+ ###
18
18
  ### Unless required by applicable law or agreed to in writing, software
19
19
  ### distributed under the Apache License with the above modification is
20
20
  ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
21
  ### KIND, either express or implied. See the Apache License for the specific
22
22
  ### language governing permissions and limitations under the Apache License.
23
- ###
23
+ ###
24
24
  ###
25
25
 
26
26
  ###
@@ -52,8 +52,7 @@ module JSS
52
52
  ### - :username => String
53
53
  ###
54
54
  ### Including this module in an {APIObject} subclass will give it attributes
55
- ### matching those keys, which are populated by calling {#parse_location} in the
56
- ### subclass's constructor after calling super.
55
+ ### matching those keys.
57
56
  ###
58
57
  ### If the subclass is creatable or updatable, calling {#location_xml} returns
59
58
  ### a REXML element representing the location subset, to be included with the
@@ -70,13 +69,13 @@ module JSS
70
69
  #####################################
71
70
  ### Variables
72
71
  #####################################
73
-
74
-
72
+
73
+
75
74
  #####################################
76
75
  ### Attribtues
77
76
  #####################################
78
77
 
79
- ###
78
+ ###
80
79
  ### Objects with a Location subset have those values stored as
81
80
  ### primary attributes here, not in a single Hash attribute
82
81
  ### as the other subsets
@@ -104,7 +103,7 @@ module JSS
104
103
 
105
104
  ### @return [String]
106
105
  attr_reader :username
107
-
106
+
108
107
 
109
108
  #####################################
110
109
  ### Mixed-in Instance Methods
@@ -130,12 +129,12 @@ module JSS
130
129
  @username = @init_data[:location][:username]
131
130
  end
132
131
 
133
-
132
+
134
133
  ###
135
134
  ### All the location data in a Hash, as it comes from the API.
136
135
  ###
137
136
  ### The reason it isn't stored this way is to prevent editing of the hash directly.
138
- ###
137
+ ###
139
138
  ### @return [Hash<String>] the location data
140
139
  ###
141
140
  def location
@@ -150,8 +149,8 @@ module JSS
150
149
  :username => @username
151
150
  }
152
151
  end
153
-
154
-
152
+
153
+
155
154
  ###
156
155
  ###
157
156
  ### Setters
@@ -254,12 +253,12 @@ module JSS
254
253
  @room = ''
255
254
  @need_to_update = true
256
255
  end
257
-
258
-
256
+
257
+
259
258
  ### aliases
260
259
  alias user username
261
-
262
-
260
+
261
+
263
262
  ###
264
263
  ### @api private
265
264
  ###