ruby-jss 0.10.1 → 0.10.2a4

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.

@@ -1,141 +1,122 @@
1
- ### Copyright 2017 Pixar
2
-
3
- ###
4
- ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
- ### with the following modification; you may not use this file except in
6
- ### compliance with the Apache License and the following modification to it:
7
- ### Section 6. Trademarks. is deleted and replaced with:
8
- ###
9
- ### 6. Trademarks. This License does not grant permission to use the trade
10
- ### names, trademarks, service marks, or product names of the Licensor
11
- ### and its affiliates, except as required to comply with Section 4(c) of
12
- ### the License and to reproduce the content of the NOTICE file.
13
- ###
14
- ### You may obtain a copy of the Apache License at
15
- ###
16
- ### http://www.apache.org/licenses/LICENSE-2.0
17
- ###
18
- ### Unless required by applicable law or agreed to in writing, software
19
- ### distributed under the Apache License with the above modification is
20
- ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
- ### KIND, either express or implied. See the Apache License for the specific
22
- ### language governing permissions and limitations under the Apache License.
23
- ###
24
- ###
25
-
26
- ###
1
+ # Copyright 2017 Pixar
2
+
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
5
+ # with the following modification; you may not use this file except in
6
+ # compliance with the Apache License and the following modification to it:
7
+ # Section 6. Trademarks. is deleted and replaced with:
8
+ #
9
+ # 6. Trademarks. This License does not grant permission to use the trade
10
+ # names, trademarks, service marks, or product names of the Licensor
11
+ # and its affiliates, except as required to comply with Section 4(c) of
12
+ # the License and to reproduce the content of the NOTICE file.
13
+ #
14
+ # You may obtain a copy of the Apache License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the Apache License with the above modification is
20
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
+ # KIND, either express or implied. See the Apache License for the specific
22
+ # language governing permissions and limitations under the Apache License.
23
+ #
24
+ #
25
+
26
+ #
27
27
  module JSS
28
28
 
29
- #####################################
30
- ### Module Variables
31
- #####################################
32
-
33
- #####################################
34
- ### Module Methods
35
- #####################################
36
-
37
- #####################################
38
- ### Classes
39
- #####################################
40
-
41
- ###
42
- ### An OS X Configuration Profile in the JSS.
43
- ###
44
- ### Note that the profile payloads and the profile UUID cannot be edited or updated with this via this class.
45
- ### Use the web UI.
46
- ###
47
- ### @see JSS::APIObject
48
- ###
29
+ # Classes
30
+ ###################################
31
+
32
+ # An OS X Configuration Profile in the JSS.
33
+ #
34
+ # Note that the profile payloads and the profile UUID cannot be edited or updated with this via this class.
35
+ # Use the web UI.
36
+ #
37
+ # @see JSS::APIObject
38
+ #
49
39
  class OSXConfigurationProfile < JSS::APIObject
50
40
 
51
- #####################################
52
- ### Mix-Ins
53
- #####################################
41
+ # Mix-Ins
42
+ ###################################
54
43
  include JSS::Updatable
55
44
  include JSS::Scopable
56
45
  include JSS::SelfServable
46
+ include JSS::Categorizable
47
+ include JSS::Sitable
57
48
 
58
- #####################################
59
- ### Class Variables
60
- #####################################
61
-
62
- #####################################
63
- ### Class Methods
64
- #####################################
49
+ # Class Constants
50
+ ###################################
65
51
 
66
- #####################################
67
- ### Class Constants
68
- #####################################
52
+ # The base for REST resources of this class
53
+ RSRC_BASE = 'osxconfigurationprofiles'.freeze
69
54
 
70
- ### The base for REST resources of this class
71
- RSRC_BASE = "osxconfigurationprofiles"
72
-
73
- ### the hash key used for the JSON list output of all objects in the JSS
55
+ # the hash key used for the JSON list output of all objects in the JSS
74
56
  RSRC_LIST_KEY = :os_x_configuration_profiles
75
57
 
76
- ### The hash key used for the JSON object output.
77
- ### It's also used in various error messages
58
+ # The hash key used for the JSON object output.
59
+ # It's also used in various error messages
78
60
  RSRC_OBJECT_KEY = :os_x_configuration_profile
79
61
 
80
- ### these keys, as well as :id and :name, are present in valid API JSON data for this class
81
- VALID_DATA_KEYS = [:distribution_method, :scope, :redeploy_on_update]
62
+ # these keys, as well as :id and :name, are present in valid API JSON data for this class
63
+ VALID_DATA_KEYS = %i[distribution_method scope redeploy_on_update].freeze
82
64
 
83
- ### Our scopes deal with computers
65
+ # Our scopes deal with computers
84
66
  SCOPE_TARGET_KEY = :computers
85
67
 
86
- ### Our SelfService happens on OSX
68
+ # Our SelfService happens on OSX
87
69
  SELF_SERVICE_TARGET = :osx
88
70
 
89
- ### Our SelfService deploys profiles
71
+ # Our SelfService deploys profiles
90
72
  SELF_SERVICE_PAYLOAD = :profile
91
73
 
92
- ### The possible values for the :distribution_method
93
- DISTRIBUTION_METHODS = ["Install Automatically", "Make Available in Self Service"]
74
+ # The possible values for the :distribution_method
75
+ DISTRIBUTION_METHODS = ['Install Automatically', 'Make Available in Self Service'].freeze
94
76
 
95
- SELF_SERVICE_DIST_METHOD = "Make Available in Self Service"
77
+ SELF_SERVICE_DIST_METHOD = 'Make Available in Self Service'.freeze
96
78
 
97
- ### The possible values for :level
98
- LEVELS = ["user", "computer"]
79
+ # The possible values for :level
80
+ LEVELS = %w[user computer].freeze
99
81
 
100
82
  # the object type for this object in
101
83
  # the object history table.
102
84
  # See {APIObject#add_object_history_entry}
103
85
  OBJECT_HISTORY_OBJECT_TYPE = 4
104
86
 
105
- #####################################
106
- ### Attributes
107
- #####################################
87
+ # Where is the Site data in the API JSON?
88
+ SITE_SUBSET = :general
89
+
90
+ # Attributes
91
+ ###################################
108
92
 
109
- ### @return [String] the description of this profile
93
+ # @return [String] the description of this profile
110
94
  attr_reader :description
111
95
 
112
- ### @return [String] the distribution_method of this profile
96
+ # @return [String] the distribution_method of this profile
113
97
  attr_reader :distribution_method
114
98
 
115
- ### @return [Boolean] can the user remove this profile
99
+ # @return [Boolean] can the user remove this profile
116
100
  attr_reader :user_removable
117
101
 
118
- ### @return [String] the level (user/computer) of this profile
102
+ # @return [String] the level (user/computer) of this profile
119
103
  attr_reader :level
120
104
 
121
- ### @return [String] the uuid of this profile. NOT Updatable
105
+ # @return [String] the uuid of this profile. NOT Updatable
122
106
  attr_reader :uuid
123
107
 
124
- ### @return [Boolean] Should this profile be redeployed when an inventory update happens?
108
+ # @return [Boolean] Should this profile be redeployed when an inventory update happens?
125
109
  attr_reader :redeploy_on_update
126
110
 
127
- ### @return [String] the plist containing the payloads for this profile. NOT Updatable
111
+ # @return [String] the plist containing the payloads for this profile. NOT Updatable
128
112
  attr_reader :payloads
129
113
 
130
- #####################################
131
- ### Constructor
132
- #####################################
133
-
134
- ###
135
- ### See JSS::APIObject#initialize
136
- ###
137
- def initialize (args = {})
114
+ # Constructor
115
+ ###################################
138
116
 
117
+ # See JSS::APIObject#initialize
118
+ #
119
+ def initialize(args = {})
139
120
  super
140
121
 
141
122
  @description = @main_subset[:description]
@@ -147,100 +128,82 @@ module JSS
147
128
  @payloads = @main_subset[:payloads]
148
129
  end
149
130
 
150
- #####################################
151
- ### Public Instance Methods
152
- #####################################
131
+ # Public Instance Methods
132
+ ###################################
153
133
 
154
- ###
155
- ### @param new_val[String] the new discription
156
- ###
157
- ### @return [void]
158
- ###
159
- def description= (new_val)
134
+ # @param new_val[String] the new discription
135
+ #
136
+ # @return [void]
137
+ #
138
+ def description=(new_val)
160
139
  return nil if @self_service_description == new_val
161
140
  @description = new_val.strip!
162
141
  @need_to_update = true
163
- end
164
-
142
+ end # @param new_val[String] how should this be distributed to clients?
165
143
 
166
- ###
167
- ### @param new_val[String] how should this be distributed to clients?
168
- ###
169
- ### @return [void]
170
- ###
171
- def distribution_method= (new_val)
144
+ #
145
+ # @return [void]
146
+ #
147
+ def distribution_method=(new_val)
172
148
  return nil if @distribution_method == new_val
173
149
  raise JSS::InvalidDataError, "New value must be one of '#{DISTRIBUTION_METHODS.join("' '")}'" unless DISTRIBUTION_METHODS.include? new_val
174
150
  @distribution_method = new_val
175
151
  @need_to_update = true
176
152
  end
177
153
 
178
- ###
179
- ### @param new_val[Boolean] should the user be able to remove this?
180
- ###
181
- ### @return [void]
182
- ###
183
- def user_removable= (new_val)
154
+ # @param new_val[Boolean] should the user be able to remove this?
155
+ #
156
+ # @return [void]
157
+ #
158
+ def user_removable=(new_val)
184
159
  return nil if @self_service_feature_on_main_page == new_val
185
160
  raise JSS::InvalidDataError, "Distribution method must be '#{SELF_SERVICE_DIST_METHOD}' to let the user remove it." unless in_self_service?
186
- raise JSS::InvalidDataError, "New value must be true or false" unless JSS::TRUE_FALSE.include? new_val
161
+ raise JSS::InvalidDataError, 'New value must be true or false' unless JSS::TRUE_FALSE.include? new_val
187
162
  @user_removable = new_val
188
163
  @need_to_update = true
189
164
  end
190
165
 
191
- ###
192
- ### @param new_val[String] the new level for this profile (user/computer)
193
- ###
194
- ### @return [void]
195
- ###
196
- def level= (new_val)
166
+ # @param new_val[String] the new level for this profile (user/computer)
167
+ #
168
+ # @return [void]
169
+ #
170
+ def level=(new_val)
197
171
  return nil if @level == new_val
198
172
  raise JSS::InvalidDataError, "New value must be one of '#{LEVELS.join("' '")}'" unless LEVELS.include? new_val
199
173
  @level = new_val
200
174
  @need_to_update = true
201
- end
202
-
175
+ end # @return [Boolean] is this profile available in Self Service?
203
176
 
204
- ###
205
- ### @return [Boolean] is this profile available in Self Service?
206
- ###
177
+ #
207
178
  def in_self_service?
208
179
  @distribution_method == SELF_SERVICE_DIST_METHOD
209
- end
210
-
180
+ end # @return [Boolean] is this profile removable by the user?
211
181
 
212
- ###
213
- ### @return [Boolean] is this profile removable by the user?
214
- ###
182
+ #
215
183
  def user_removable?
216
184
  @user_removable
217
- end
218
-
185
+ end # @return [Hash] The payload plist parsed into a Ruby hash
219
186
 
220
- ###
221
- ### @return [Hash] The payload plist parsed into a Ruby hash
222
- ###
187
+ #
223
188
  def parsed_payloads
224
189
  Plist.parse_xml @payloads
225
190
  end
226
191
 
227
- ###
228
- ### @return [Array<Hash>] the individual payloads from the payload Plist
229
- ###
192
+ # @return [Array<Hash>] the individual payloads from the payload Plist
193
+ #
230
194
  def payload_content
231
195
  parsed_payloads['PayloadContent']
232
196
  end
233
197
 
234
- ###
235
- ### @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
236
- ###
198
+ # @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
199
+ #
237
200
  def payload_types
238
- payload_content.map{|p| p['PayloadType'] }
201
+ payload_content.map { |p| p['PayloadType'] }
239
202
  end
240
203
 
241
- #####################################
242
- ### Private Instance Methods
243
- #####################################
204
+ ###################################
205
+ # Private Instance Methods
206
+ ###################################
244
207
  private
245
208
 
246
209
  def rest_xml
@@ -255,9 +218,10 @@ module JSS
255
218
  gen.add_element('redeploy_on_update').text = @redeploy_on_update
256
219
 
257
220
  obj << @scope.scope_xml
258
- obj << self_service_xml
259
-
260
- return doc.to_s
221
+ add_self_service_xml doc
222
+ add_category_to_xml doc
223
+ add_site_to_xml doc
224
+ doc.to_s
261
225
  end
262
226
 
263
227
  end # class OSXConfigurationProfile
@@ -0,0 +1,38 @@
1
+ ### Copyright 2017 Pixar
2
+
3
+ ###
4
+ ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
+ ### with the following modification; you may not use this file except in
6
+ ### compliance with the Apache License and the following modification to it:
7
+ ### Section 6. Trademarks. is deleted and replaced with:
8
+ ###
9
+ ### 6. Trademarks. This License does not grant permission to use the trade
10
+ ### names, trademarks, service marks, or product names of the Licensor
11
+ ### and its affiliates, except as required to comply with Section 4(c) of
12
+ ### the License and to reproduce the content of the NOTICE file.
13
+ ###
14
+ ### You may obtain a copy of the Apache License at
15
+ ###
16
+ ### http://www.apache.org/licenses/LICENSE-2.0
17
+ ###
18
+ ### Unless required by applicable law or agreed to in writing, software
19
+ ### distributed under the Apache License with the above modification is
20
+ ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
+ ### KIND, either express or implied. See the Apache License for the specific
22
+ ### language governing permissions and limitations under the Apache License.
23
+ ###
24
+ ###
25
+
26
+ ###
27
+ module JSS
28
+
29
+ # This is a stub - Patch data in the API is still borked.
30
+ # Waiting for fixes from Jamf.
31
+ #
32
+ # @see JSS::APIObject
33
+ #
34
+ class Patch < JSS::APIObject
35
+
36
+ end # class Patch
37
+
38
+ end # module JSS
@@ -0,0 +1,38 @@
1
+ ### Copyright 2017 Pixar
2
+
3
+ ###
4
+ ### Licensed under the Apache License, Version 2.0 (the "Apache License")
5
+ ### with the following modification; you may not use this file except in
6
+ ### compliance with the Apache License and the following modification to it:
7
+ ### Section 6. Trademarks. is deleted and replaced with:
8
+ ###
9
+ ### 6. Trademarks. This License does not grant permission to use the trade
10
+ ### names, trademarks, service marks, or product names of the Licensor
11
+ ### and its affiliates, except as required to comply with Section 4(c) of
12
+ ### the License and to reproduce the content of the NOTICE file.
13
+ ###
14
+ ### You may obtain a copy of the Apache License at
15
+ ###
16
+ ### http://www.apache.org/licenses/LICENSE-2.0
17
+ ###
18
+ ### Unless required by applicable law or agreed to in writing, software
19
+ ### distributed under the Apache License with the above modification is
20
+ ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
+ ### KIND, either express or implied. See the Apache License for the specific
22
+ ### language governing permissions and limitations under the Apache License.
23
+ ###
24
+ ###
25
+
26
+ ###
27
+ module JSS
28
+
29
+ # This is a stub - Patch Policy data in the API is still borked.
30
+ # Waiting for fixes from Jamf.
31
+ #
32
+ # @see JSS::APIObject
33
+ #
34
+ class PatchPolicy < JSS::APIObject
35
+
36
+ end # class PatchPolicy
37
+
38
+ end # module JSS
@@ -51,16 +51,10 @@ module JSS
51
51
 
52
52
  include JSS::Creatable
53
53
  include JSS::Updatable
54
-
55
- ### periphs have a purchasing subset
56
54
  include JSS::Purchasable
57
-
58
- ### periphs have a location subset, which will be
59
- ### stored in primary attributes.
60
55
  include JSS::Locatable
61
-
62
- ### periphs can take uploaded files.
63
56
  include JSS::Uploadable
57
+ include JSS::Sitable
64
58
 
65
59
  #####################################
66
60
  ### Class Methods
@@ -88,6 +82,9 @@ module JSS
88
82
  # See {APIObject#add_object_history_entry}
89
83
  OBJECT_HISTORY_OBJECT_TYPE = 8
90
84
 
85
+ # Where is the Site data in the API JSON?
86
+ SITE_SUBSET = :general
87
+
91
88
  #####################################
92
89
  ### Class Variables
93
90
  #####################################
@@ -316,6 +313,7 @@ module JSS
316
313
  if has_purchasing?
317
314
  periph << purchasing_xml
318
315
  end
316
+ add_site_to_xml doc
319
317
 
320
318
  return doc.to_s
321
319
  end # rest xml
@@ -77,6 +77,7 @@ module JSS
77
77
  include JSS::Uploadable
78
78
  include JSS::SelfServable
79
79
  include JSS::Categorizable
80
+ include JSS::Sitable
80
81
 
81
82
  #####################################
82
83
  ### Class Methods
@@ -249,6 +250,9 @@ module JSS
249
250
  # See {APIObject#add_object_history_entry}
250
251
  OBJECT_HISTORY_OBJECT_TYPE = 3
251
252
 
253
+ # Where is the Site data in the API JSON?
254
+ SITE_SUBSET = :general
255
+
252
256
  ######################
253
257
  ### Attributes
254
258
  ######################
@@ -1360,6 +1364,7 @@ module JSS
1360
1364
  end
1361
1365
 
1362
1366
  add_self_service_xml doc
1367
+ add_site_xml doc
1363
1368
 
1364
1369
  doc.to_s
1365
1370
  end
@@ -11,6 +11,7 @@ module JSS
11
11
  include JSS::Updatable
12
12
  include JSS::Creatable
13
13
  include JSS::Scopable
14
+ include JSS::Sitable
14
15
 
15
16
  # Class Constants
16
17
  #####################################
@@ -36,6 +37,9 @@ module JSS
36
37
  # See {APIObject#add_object_history_entry}
37
38
  OBJECT_HISTORY_OBJECT_TYPE = 5
38
39
 
40
+ # Where is the Site data in the API JSON?
41
+ SITE_SUBSET = :general
42
+
39
43
  # Attributes
40
44
  #####################################
41
45
 
@@ -162,6 +166,7 @@ module JSS
162
166
  site.add_element('name').text = @site
163
167
 
164
168
  obj << @scope.scope_xml
169
+ add_self_service_xml doc
165
170
  doc.to_s
166
171
  end # rest_xml
167
172