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
@@ -0,0 +1,221 @@
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
+ # Module Variables
30
+ #####################################
31
+
32
+ # Module Methods
33
+ #####################################
34
+
35
+ # Classes
36
+ #####################################
37
+
38
+ # A mix-in module that centralizes the code for handling objects which can be
39
+ # assigned a 'category' in the JSS.
40
+ #
41
+ # Objects in the JSS present category data in two different ways:
42
+ #
43
+ # 1) An 'old' style, where the top-level Hash of the API data contains a
44
+ # :category which contains a String, being the category name.
45
+ #
46
+ # 2) A 'new' style, where the top-level :general Hash contains a :category key
47
+ # which is a Hash with a :name and :id key.
48
+ #
49
+ # This module can detect and handle either type.
50
+ #
51
+ # Classes mixing in this module MUST:
52
+ #
53
+ # - call {#add_category_to_xml(xmldoc)} from their #rest_xml method if they are
54
+ # {Updatable} or {Creatable}
55
+ #
56
+ module Categorizable
57
+
58
+ # Module Constants
59
+ #####################################
60
+
61
+ CATEGORIZABLE = true
62
+
63
+ # When no category has been assigned, this is the 'name' and id used
64
+ NO_CATEGORY_NAME = 'No category assigned'.freeze
65
+ NO_CATEGORY_ID = -1
66
+
67
+ # Setting the category to any of these values will unset the category
68
+ NON_CATEGORIES = [
69
+ nil,
70
+ '',
71
+ 0,
72
+ NO_CATEGORY_NAME,
73
+ NO_CATEGORY_ID
74
+ ].freeze
75
+
76
+ # These classes use old-style categories in their data.
77
+ OLD_STYLE_CATEGORY_CLASSES = [
78
+ JSS::Script,
79
+ JSS::Package
80
+ ].freeze
81
+
82
+ # Mixed-in Public Instance Methods
83
+ #####################################
84
+
85
+ # The name of the category for this object.
86
+ # For backward compatibility, this is aliased to just
87
+ # 'category'
88
+ #
89
+ # @return [String] The name of the category for this object.
90
+ #
91
+ def category_name
92
+ @category_name
93
+ end # cat name
94
+ alias category category_name
95
+
96
+ # The id of the category for this object.
97
+ #
98
+ # @return [Integer] The id of the category for this object.
99
+ #
100
+ def category_id
101
+ @category_id
102
+ end # cat id
103
+
104
+ # The JSS::Category instance for this object's category
105
+ #
106
+ # @return [JSS::Category] The JSS::Category instance for this object's category
107
+ #
108
+ def category_object
109
+ return nil unless category_assigned?
110
+ JSS::Category.new id: @category_id
111
+ end # cat obj
112
+
113
+ # Does this object have a category assigned?
114
+ #
115
+ # @return [Boolean] Does this object have a category assigned?
116
+ #
117
+ def category_assigned?
118
+ !@category_name.nil?
119
+ end # cat assigned?
120
+ alias categorized? category_assigned?
121
+
122
+ # Change the category of this object.
123
+ # Any of the NON_CATEGORIES values will
124
+ # unset the category
125
+ #
126
+ # @param new_cat[Integer, String] The new category
127
+ #
128
+ # @return [void]
129
+ #
130
+ def category=(new_cat)
131
+ return nil unless updatable? || creatable?
132
+
133
+ # unset the category? Use nil or an empty string
134
+ if NON_CATEGORIES.include? new_cat
135
+ unset_category
136
+ return
137
+ end
138
+
139
+ new_name, new_id = evaluate_new_category(new_cat)
140
+
141
+ # no change, go home.
142
+ return nil if new_name == @category_name
143
+
144
+ raise JSS::NoSuchItemError, "Category '#{new_cat}' is not known to the JSS" unless JSS::Category.all_names(:ref).include? new_name
145
+
146
+ @category_name = new_name
147
+ @category_id = new_id
148
+ @need_to_update = true
149
+ end # category =
150
+
151
+ # Given a category name or id, return the name and id
152
+ #
153
+ # @param new_cat[String, Integer] The name or id of a possible category
154
+ #
155
+ # @return [Array<String, Integer>] The matching name and id, which may be nil.
156
+ #
157
+ def evaluate_new_category(new_cat)
158
+ # if we were given anything but a string, assume it was an id.
159
+ if new_cat.is_a? String
160
+ new_name = new_cat
161
+ new_id = JSS::Category.category_id_from_name new_cat
162
+ else
163
+ new_id = new_cat
164
+ new_name = JSS::Category.map_all_ids_to(:name)[new_id]
165
+ end
166
+ [new_name, new_id]
167
+ end
168
+
169
+ # Set the category to nothing
170
+ #
171
+ # @return [void]
172
+ #
173
+ def unset_category
174
+ # no change, go home
175
+ return nil if @category_name.nil?
176
+ @category_name = nil
177
+ @category_id = nil
178
+ @need_to_update = true
179
+ end # unset category
180
+
181
+ # Mixed-in Private Instance Methods
182
+ #####################################
183
+ private
184
+
185
+ # Parse the category data from any incoming API data
186
+ #
187
+ # @return [void] description_of_returned_object
188
+ #
189
+ def parse_category
190
+ if @init_data[:category]
191
+ @category_name = @init_data[:category]
192
+ @category_id = JSS::Category.category_id_from_name @category_name
193
+ elsif @init_data[:general][:category]
194
+ @category_name = @init_data[:general][:category][:name]
195
+ @category_id = @init_data[:general][:category][:id]
196
+ end
197
+ @category_data_style = OLD_STYLE_CATEGORY_CLASSES.include?(self.class) ? :old : :new
198
+ @category_name = nil if @category_name.to_s.casecmp(NO_CATEGORY_NAME).zero?
199
+ @category_id = nil if @category_id == NO_CATEGORY_ID
200
+ end # parse category
201
+
202
+ # Add the category to the XML for POSTing or PUTting to the API.
203
+ #
204
+ # @param xmldoc[REXML::Document] The in-construction XML document
205
+ #
206
+ # @return [void]
207
+ #
208
+ def add_category_to_xml(xmldoc)
209
+ root = xmldoc.root
210
+ if @category_data_style == :old
211
+ root.add_element('category').text = @category_name.to_s
212
+ else
213
+ gen_elem = root.elements['general'] ? root.elements['general'] : root.add_element('general')
214
+ cat_elem = gen_elem.add_element 'category'
215
+ cat_elem.add_element('name').text = @category_name.to_s
216
+ end
217
+ end # add_category_to_xml
218
+
219
+ end # module categorizable
220
+
221
+ end # module
@@ -1,148 +1,140 @@
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
  ###
27
27
  module JSS
28
-
29
- #####################################
30
- ### Module Variables
31
- #####################################
32
28
 
29
+ # Module Variables
33
30
  #####################################
34
- ### Module Methods
35
- #####################################
36
-
37
-
31
+
32
+ # Module Methods
38
33
  #####################################
39
- ### Classes
34
+
35
+ # Classes
40
36
  #####################################
41
-
42
- ###
43
- ### A Category in the JSS.
44
- ###
45
- ###
46
- ### @see JSS::APIObject
47
- ###
37
+
38
+ # A Category in the JSS.
39
+ #
40
+ #
41
+ # @see JSS::APIObject
42
+ #
48
43
  class Category < JSS::APIObject
49
-
50
- #####################################
51
- ### Mix-Ins
44
+
45
+ # Mix-Ins
52
46
  #####################################
53
47
  include JSS::Creatable
54
48
  include JSS::Updatable
55
-
56
- #####################################
57
- ### Class Methods
58
- #####################################
59
-
49
+
50
+ # Class Methods
60
51
  #####################################
61
- ### Class Constants
52
+
53
+ def self.category_id_from_name(name)
54
+ return nil if name.nil?
55
+ return nil if name.casecmp(JSS::Category::NO_CATEGORY_NAME).zero?
56
+ JSS::Category.map_all_ids_to(:name).invert[name]
57
+ end # self cat id from name
58
+
59
+ # Class Constants
62
60
  #####################################
63
-
64
- ### The base for REST resources of this class
65
- RSRC_BASE = "categories"
66
-
67
- ### the hash key used for the JSON list output of all objects in the JSS
61
+
62
+ # The base for REST resources of this class
63
+ RSRC_BASE = 'categories'.freeze
64
+
65
+ # the hash key used for the JSON list output of all objects in the JSS
68
66
  RSRC_LIST_KEY = :categories
69
-
70
- ### The hash key used for the JSON object output.
71
- ### It's also used in various error messages
67
+
68
+ # The hash key used for the JSON object output.
69
+ # It's also used in various error messages
72
70
  RSRC_OBJECT_KEY = :category
73
-
74
- ### these keys, as well as :id and :name, are present in valid API JSON data for this class
75
- VALID_DATA_KEYS = [:priority]
76
-
77
- ### The Default category
78
- DEFAULT_CATEGORY = "Unknown"
79
-
80
- ### The range of possible priorities
71
+
72
+ # these keys, as well as :id and :name, are present in valid API JSON data for this class
73
+ VALID_DATA_KEYS = [:priority].freeze
74
+
75
+ # When no category has been assigned, this is the 'name' and id used
76
+ NO_CATEGORY_NAME = JSS::Categorizable::NO_CATEGORY_NAME
77
+ NO_CATEGORY_ID = JSS::Categorizable::NO_CATEGORY_ID
78
+
79
+ # The Default category
80
+ DEFAULT_CATEGORY = NO_CATEGORY_NAME
81
+
82
+ # The range of possible priorities
81
83
  POSSIBLE_PRIORITIES = 1..20
82
-
83
- ### The Default Priority
84
+
85
+ # The Default Priority
84
86
  DEFAULT_PRIORITY = 5
85
-
86
- #####################################
87
- ### Attributes
87
+
88
+ # Attributes
88
89
  #####################################
89
-
90
- ### @return [Integer] the SelfService priority for this category
90
+
91
+ # @return [Integer] the SelfService priority for this category
91
92
  attr_reader :priority
92
-
93
- #####################################
94
- ### Constructor
93
+
94
+ # Constructor
95
95
  #####################################
96
-
97
- ###
98
- ### See JSS::APIObject#initialize
99
- ###
96
+
97
+ # See JSS::APIObject#initialize
98
+ #
100
99
  def initialize(args = {})
101
100
  super
102
101
  @priority = @init_data[:priority] || DEFAULT_PRIORITY
103
-
104
102
  end
105
-
106
-
107
- #####################################
108
- ### Public Instance Methods
103
+
104
+ # Public Instance Methods
109
105
  #####################################
110
-
111
-
112
- ###
113
- ### Change the Priority
114
- ###
115
- ### @param new_val[Integer] the new priority, must be in the range POSSIBLE_PRIORITIES
116
- ###
117
- ### @return [void]
118
- ###
119
- def priority= (new_val = @priority)
106
+
107
+ # Change the Priority
108
+ #
109
+ # @param new_val[Integer] the new priority, must be in the range POSSIBLE_PRIORITIES
110
+ #
111
+ # @return [void]
112
+ #
113
+ def priority=(new_val = @priority)
120
114
  return nil if new_val == @priority
121
115
  raise JSS::InvalidDataError, "priority must be an integer between #{POSSIBLE_PRIORITIES.first} and #{POSSIBLE_PRIORITIES.last} (inclusive)" unless POSSIBLE_PRIORITIES.include? new_val
122
116
  @priority = new_val
123
117
  @need_to_update = true
124
118
  end
125
-
126
-
127
- #####################################
128
- ### Private Instance Methods
119
+
120
+ # Private Instance Methods
129
121
  #####################################
130
122
  private
131
123
 
132
- ###
133
- ### Return a String with the XML Resource
134
- ### for submitting creation or changes to the JSS via
135
- ### the API via the Creatable or Updatable modules
136
- ###
137
- ### Most classes will redefine this method.
138
- ###
124
+ # Return a String with the XML Resource
125
+ # for submitting creation or changes to the JSS via
126
+ # the API via the Creatable or Updatable modules
127
+ #
128
+ # Most classes will redefine this method.
129
+ #
139
130
  def rest_xml
140
131
  doc = REXML::Document.new APIConnection::XML_HEADER
141
132
  tmpl = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
142
133
  tmpl.add_element('name').text = @name
143
134
  tmpl.add_element('priority').text = @priority
144
- return doc.to_s
135
+ doc.to_s
145
136
  end
137
+
146
138
  end # class category
147
-
139
+
148
140
  end # module
@@ -26,94 +26,88 @@
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
- ###
43
- ### This class represents a Computer in the JSS.
44
- ###
45
- ### ===Adding Computers to the JSS
46
- ###
47
- ### This class cannot be used to add new Computers to the JSS. Please use other
48
- ### Casper methods (like the Recon App or QuickAdd package)
49
- ###
50
- ### ---
51
- ### ===Editing values
52
- ###
53
- ### Any data that arrives in the JSS via an "inventory update"
54
- ### (a.k.a. 'recon') cannot be modified through this class, or the API.
55
- ###
56
- ### Data that can be modified are:
57
- ### * Management Account (see #set_management_to)
58
- ### * asset_tag
59
- ### * barcodes 1 and 2
60
- ### * ip_address
61
- ### * udid
62
- ### * mac_addresses
63
- ### * location data via the Locatable module
64
- ### * purchasing data via the Purchasable module
65
- ### * Extension Attribute values via the Extendable module
66
- ### Note: as with other 'recon' generated values, Ext. Attrs.
67
- ### populated by scripts cannot be modified via the API.
68
- ### (the change would be overwritten the next time the machine
69
- ### did a recon)
70
- ###
71
- ### After making any changes, you must call #update to send those
72
- ### changes to the server.
73
- ###
74
- ### ---
75
- ### ===MDM Commands
76
- ###
77
- ### ==== MDM Commands are Not Yet Supported!
78
- ### *Hopefully they will be soon*
79
- ###
80
- ### The following methods will be used to send an APNS command to the computer represented by an
81
- ### instance of JSS::Computer, equivalent to clicking one of the buttons on
82
- ### the Management Commands section of the Management tab of the Computer details page in the JSS UI.
83
- ###
84
- ### The methods supported will be:
85
- ### - #blank_push (aliases blank, noop, send_blank_push)
86
- ### - #device_lock (aliases lock, lock_device)
87
- ### - #erase_device (aliases wipe)
88
- ###
89
- ### To send an MDM command without making an instance, use the class method {.send_mdm_command}
90
- ###
91
- ### Each returns true if the command as sent.
92
- ###
93
- ### ---
94
- ### ===Other Methods
95
- ###
96
- ### - {#set_management_to} change the management acct and passwd for this computer, aliased to #make_managed
97
- ### - requires calling #update to push changes to the server
98
- ### - {#make_unmanaged} an shortcut method for {#set_management_to}(nil)
99
- ### - requires calling #update to push changes to the server
100
- ### - {#apps} a shortcut to {#software} [:applications]
101
- ### - {#licensed_sw} a shortcut to {#software} [:licensed_software]
102
- ### - {#computer_groups} a shortcut to {#groups_accounts} [:computer_group_memberships]
103
- ### - {#local_accounts} a shortcut to {#groups_accounts} [:local_accounts]
104
- ### - {#drives} a shortcut to {#hardware} [:storage]
105
- ### - {#printers} a shortcut to {#hardware} [:mapped_printers]
106
- ###
107
- ### @see APIObject
108
- ### @see Locatable
109
- ### @see Purchasable
110
- ### @see Matchable
111
- ### @see FileUpload
112
- ###
113
- class Computer < JSS::APIObject
114
37
 
115
- #####################################
116
- ### MixIns
38
+ # This class represents a Computer in the JSS.
39
+ #
40
+ # ===Adding Computers to the JSS
41
+ #
42
+ # This class cannot be used to add new Computers to the JSS. Please use other
43
+ # Casper methods (like the Recon App or QuickAdd package)
44
+ #
45
+ # ---
46
+ # ===Editing values
47
+ #
48
+ # Any data that arrives in the JSS via an "inventory update"
49
+ # (a.k.a. 'recon') cannot be modified through this class, or the API.
50
+ #
51
+ # Data that can be modified are:
52
+ # * Management Account (see #set_management_to)
53
+ # * asset_tag
54
+ # * barcodes 1 and 2
55
+ # * ip_address
56
+ # * udid
57
+ # * mac_addresses
58
+ # * location data via the Locatable module
59
+ # * purchasing data via the Purchasable module
60
+ # * Extension Attribute values via the Extendable module
61
+ # Note: as with other 'recon' generated values, Ext. Attrs.
62
+ # populated by scripts cannot be modified via the API.
63
+ # (the change would be overwritten the next time the machine
64
+ # did a recon)
65
+ #
66
+ # After making any changes, you must call #update to send those
67
+ # changes to the server.
68
+ #
69
+ # ---
70
+ # === MDM Commands
71
+ #
72
+ # ==== MDM Commands are Not Yet Supported!
73
+ # *Hopefully they will be soon*
74
+ #
75
+ # The following methods will be used to send an APNS command to the computer represented by an
76
+ # instance of JSS::Computer, equivalent to clicking one of the buttons on
77
+ # the Management Commands section of the Management tab of the Computer details page in the JSS UI.
78
+ #
79
+ # The methods supported will be:
80
+ # - #blank_push (aliases blank, noop, send_blank_push)
81
+ # - #device_lock (aliases lock, lock_device)
82
+ # - #erase_device (aliases wipe)
83
+ #
84
+ # To send an MDM command without making an instance, use the class method {.send_mdm_command}
85
+ #
86
+ # Each returns true if the command as sent.
87
+ #
88
+ # ---
89
+ # ===Other Methods
90
+ #
91
+ # - {#set_management_to} change the management acct and passwd for this computer, aliased to #make_managed
92
+ # - requires calling #update to push changes to the server
93
+ # - {#make_unmanaged} an shortcut method for {#set_management_to}(nil)
94
+ # - requires calling #update to push changes to the server
95
+ # - {#apps} a shortcut to {#software} [:applications]
96
+ # - {#licensed_sw} a shortcut to {#software} [:licensed_software]
97
+ # - {#computer_groups} a shortcut to {#groups_accounts} [:computer_group_memberships]
98
+ # - {#local_accounts} a shortcut to {#groups_accounts} [:local_accounts]
99
+ # - {#drives} a shortcut to {#hardware} [:storage]
100
+ # - {#printers} a shortcut to {#hardware} [:mapped_printers]
101
+ #
102
+ # @see APIObject
103
+ # @see Locatable
104
+ # @see Purchasable
105
+ # @see Matchable
106
+ # @see FileUpload
107
+ #
108
+ class Computer < JSS::APIObject
109
+
110
+ # MixIns
117
111
  #####################################
118
112
 
119
113
  include JSS::Updatable
@@ -124,430 +118,417 @@ module JSS
124
118
 
125
119
  extend JSS::Matchable
126
120
 
127
- #####################################
128
- ### Class Variables
121
+ # Class Variables
129
122
  #####################################
130
123
 
131
124
  @@all_computers = nil
132
125
 
133
- #####################################
134
- ### Class Methods
126
+ # Class Methods
135
127
  #####################################
136
128
 
137
- ### A larger set of info about the computers in the JSS.
138
- ###
139
- ### Casper 9.4 introduced the API Resource /computers/subset/basic
140
- ### that returns an array of hashes with more data than just /computers/
141
- ### (which was just :name and :id). Similar to /mobildevices/, this new
142
- ### list includes :udid, :serial_number, and :mac_address, as well as :model,
143
- ### :managed, :building, :department, :username, and :report_date
144
- ###
145
- ### Because this requires a different, unusual, resource path, we're completely re-defining
146
- ### {APIObject.all} for JSS::Computer. Hopefully some day the original /computers/
147
- ### resource will be updated to return this data.
148
- ###
149
- ### @param refresh[Boolean] should the data be re-queried from the API?
150
- ###
151
- ### @return [Array<Hash{:name=>String, :id=> Integer}>]
152
- ###
129
+ # A larger set of info about the computers in the JSS.
130
+ #
131
+ # Casper 9.4 introduced the API Resource /computers/subset/basic
132
+ # that returns an array of hashes with more data than just /computers/
133
+ # (which was just :name and :id). Similar to /mobildevices/, this new
134
+ # list includes :udid, :serial_number, and :mac_address, as well as :model,
135
+ # :managed, :building, :department, :username, and :report_date
136
+ #
137
+ # Because this requires a different, unusual, resource path, we're completely re-defining
138
+ # {APIObject.all} for JSS::Computer. Hopefully some day the original /computers/
139
+ # resource will be updated to return this data.
140
+ #
141
+ # @param refresh[Boolean] should the data be re-queried from the API?
142
+ #
143
+ # @return [Array<Hash{:name=>String, :id=> Integer}>]
144
+ #
153
145
  def self.all(refresh = false)
154
146
  @@all_computers = nil if refresh
155
147
  return @@all_computers if @@all_computers
156
148
  @@all_computers = JSS::API.get_rsrc(self::LIST_RSRC)[self::RSRC_LIST_KEY]
157
149
  end
158
150
 
159
- ### @return [Array<String>] all computer serial numbers in the jss
151
+ # @return [Array<String>] all computer serial numbers in the jss
160
152
  def self.all_serial_numbers(refresh = false)
161
- self.all(refresh).map{|i| i[:serial_number]}
153
+ all(refresh).map { |i| i[:serial_number] }
162
154
  end
163
155
 
164
- ### @return [Array<String>] all computer mac_addresses in the jss
156
+ # @return [Array<String>] all computer mac_addresses in the jss
165
157
  def self.all_mac_addresses(refresh = false)
166
- self.all(refresh).map{|i| i[:mac_address]}
158
+ all(refresh).map { |i| i[:mac_address] }
167
159
  end
168
160
 
169
- ### @return [Array<String>] all computer udids in the jss
161
+ # @return [Array<String>] all computer udids in the jss
170
162
  def self.all_udids(refresh = false)
171
- self.all(refresh).map{|i| i[:udid]}
163
+ all(refresh).map { |i| i[:udid] }
172
164
  end
173
165
 
174
- ### @return [Array<Hash>] all managed computers in the jss
166
+ # @return [Array<Hash>] all managed computers in the jss
175
167
  def self.all_managed(refresh = false)
176
- self.all(refresh).select{|d| d[:managed] }
168
+ all(refresh).select { |d| d[:managed] }
177
169
  end
178
170
 
179
- ### @return [Array<Hash>] all unmanaged computers in the jss
171
+ # @return [Array<Hash>] all unmanaged computers in the jss
180
172
  def self.all_unmanaged(refresh = false)
181
- self.all(refresh).select{|d| not d[:managed] }
173
+ all(refresh).select { |d| !(d[:managed]) }
182
174
  end
183
175
 
184
- ### @return [Array<Hash>] all laptop computers in the jss
176
+ # @return [Array<Hash>] all laptop computers in the jss
185
177
  def self.all_laptops(refresh = false)
186
- self.all(refresh).select{|d| d[:model] =~ /book/i }
178
+ all(refresh).select { |d| d[:model] =~ /book/i }
187
179
  end
188
180
 
189
- ### @return [Array<Hash>] all macbooks in the jss
181
+ # @return [Array<Hash>] all macbooks in the jss
190
182
  def self.all_macbooks(refresh = false)
191
- self.all(refresh).select{|d| d[:model] =~ /^macbook\d/i }
183
+ all(refresh).select { |d| d[:model] =~ /^macbook\d/i }
192
184
  end
193
185
 
194
- ### @return [Array<Hash>] all macbookpros in the jss
186
+ # @return [Array<Hash>] all macbookpros in the jss
195
187
  def self.all_macbookpros(refresh = false)
196
- self.all(refresh).select{|d| d[:model] =~ /^macbookpro\d/i }
188
+ all(refresh).select { |d| d[:model] =~ /^macbookpro\d/i }
197
189
  end
198
190
 
199
- ### @return [Array<Hash>] all macbookairs in the jss
191
+ # @return [Array<Hash>] all macbookairs in the jss
200
192
  def self.all_macbookairs(refresh = false)
201
- self.all(refresh).select{|d| d[:model] =~ /^macbookair\d/i }
193
+ all(refresh).select { |d| d[:model] =~ /^macbookair\d/i }
202
194
  end
203
195
 
204
- ### @return [Array<Hash>] all xserves in the jss
196
+ # @return [Array<Hash>] all xserves in the jss
205
197
  def self.all_xserves(refresh = false)
206
- self.all(refresh).select{|d| d[:model] =~ /serve/i }
198
+ all(refresh).select { |d| d[:model] =~ /serve/i }
207
199
  end
208
200
 
209
- ### @return [Array<Hash>] all desktop macs in the jss
201
+ # @return [Array<Hash>] all desktop macs in the jss
210
202
  def self.all_desktops(refresh = false)
211
- self.all(refresh).select{|d| d[:model] !~ /serve|book/i }
203
+ all(refresh).select { |d| d[:model] !~ /serve|book/i }
212
204
  end
213
205
 
214
- ### @return [Array<Hash>] all imacs in the jss
206
+ # @return [Array<Hash>] all imacs in the jss
215
207
  def self.all_imacs(refresh = false)
216
- self.all(refresh).select{|d| d[:model] =~ /^imac/i }
208
+ all(refresh).select { |d| d[:model] =~ /^imac/i }
217
209
  end
218
210
 
219
- ### @return [Array<Hash>] all mac minis in the jss
211
+ # @return [Array<Hash>] all mac minis in the jss
220
212
  def self.all_minis(refresh = false)
221
- self.all(refresh).select{|d| d[:model] =~ /^macmini/i }
213
+ all(refresh).select { |d| d[:model] =~ /^macmini/i }
222
214
  end
223
215
 
224
- ### @return [Array<Hash>] all macpros in the jss
216
+ # @return [Array<Hash>] all macpros in the jss
225
217
  def self.all_macpros(refresh = false)
226
- self.all(refresh).select{|d| d[:model] =~ /^macpro/i }
227
- end
228
-
229
- ###
230
- ### Send an MDM command to a managed computer by id or name
231
- ###
232
- ### @param computer[String,Integer] the name or id of the computer to recieve the command
233
- ### @param command[Symbol] the command to send, one of the keys of COMPUTER_MDM_COMMANDS
234
- ###
235
- ### @return [true] if the command was sent
236
- ###
237
-
238
- # Not functional until I get more docs from JAMF
239
- #
240
- # def self.send_mdm_command(computer,command)
241
- #
242
- # raise JSS::NoSuchItemError, "Unknown command '#{command}'" unless COMPUTER_MDM_COMMANDS.keys.include? command
243
- #
244
- # command_xml ="#{JSS::APIConnection::XML_HEADER}<computer><command>#{COMPUTER_MDM_COMMANDS[command]}</command></computer>"
245
- # the_id = nil
246
- #
247
- # if computer.to_s =~ /^\d+$/
248
- # the_id = computer
249
- # else
250
- # the_id = self.map_all_ids_to(:name).invert[computer]
251
- # end
252
- #
253
- # if the_id
254
- # response = JSS::API.put_rsrc("#{RSRC_BASE}/id/#{the_id}", command_xml)
255
- # response =~ %r{<notification_sent>(.+)</notification_sent>}
256
- # return ($1 and $1 == "true")
257
- # end
258
- # raise JSS::UnmanagedError, "Cannot send command to unknown/unmanaged computer '#{computer}'"
259
- # end
260
-
218
+ all(refresh).select { |d| d[:model] =~ /^macpro/i }
219
+ end
261
220
 
221
+ # Send an MDM command to a managed computer by id or name
222
+ #
223
+ # @param computer[String,Integer] the name or id of the computer to recieve the command
224
+ # @param command[Symbol] the command to send, one of the keys of COMPUTER_MDM_COMMANDS
225
+ #
226
+ # @return [true] if the command was sent
227
+ #
228
+
229
+ # Not functional until I get more docs from JAMF
230
+ #
231
+ # def self.send_mdm_command(computer,command)
232
+ #
233
+ # raise JSS::NoSuchItemError, "Unknown command '#{command}'" unless COMPUTER_MDM_COMMANDS.keys.include? command
234
+ #
235
+ # command_xml ="#{JSS::APIConnection::XML_HEADER}<computer><command>#{COMPUTER_MDM_COMMANDS[command]}</command></computer>"
236
+ # the_id = nil
237
+ #
238
+ # if computer.to_s =~ /^\d+$/
239
+ # the_id = computer
240
+ # else
241
+ # the_id = self.map_all_ids_to(:name).invert[computer]
242
+ # end
243
+ #
244
+ # if the_id
245
+ # response = JSS::API.put_rsrc("#{RSRC_BASE}/id/#{the_id}", command_xml)
246
+ # response =~ %r{<notification_sent>(.+)</notification_sent>}
247
+ # return ($1 and $1 == "true")
248
+ # end
249
+ # raise JSS::UnmanagedError, "Cannot send command to unknown/unmanaged computer '#{computer}'"
250
+ # end
251
+
252
+ # Class Constants
262
253
  #####################################
263
- ### Class Constants
264
- #####################################
265
-
266
254
 
267
- ### The base for REST resources of this class
268
- RSRC_BASE = "computers"
255
+ # The base for REST resources of this class
256
+ RSRC_BASE = 'computers'.freeze
269
257
 
270
- ### The (temporary?) list-resource
271
- LIST_RSRC = "#{RSRC_BASE}/subset/basic"
258
+ # The (temporary?) list-resource
259
+ LIST_RSRC = "#{RSRC_BASE}/subset/basic".freeze
272
260
 
273
- ### the hash key used for the JSON list output of all objects in the JSS
261
+ # the hash key used for the JSON list output of all objects in the JSS
274
262
  RSRC_LIST_KEY = :computers
275
263
 
276
- ### The hash key used for the JSON object output.
277
- ### It's also used in various error messages
264
+ # The hash key used for the JSON object output.
265
+ # It's also used in various error messages
278
266
  RSRC_OBJECT_KEY = :computer
279
267
 
280
- ### these keys, as well as :id and :name, are present in valid API JSON data for this class
281
- VALID_DATA_KEYS = [:sus, :distribution_point, :alt_mac_address ]
268
+ # these keys, as well as :id and :name, are present in valid API JSON data for this class
269
+ # DEPRECATED, with be removed in a future release.
270
+ VALID_DATA_KEYS = [:sus, :distribution_point, :alt_mac_address].freeze
271
+
272
+ # these keys, as well as :id and :name, can be used to look up objects of this class in the JSS
273
+ OTHER_LOOKUP_KEYS = [:udid, :serialnumber, :mac_address].freeze
282
274
 
283
- ### This class lets us seach for computers
275
+ # This class lets us seach for computers
284
276
  SEARCH_CLASS = JSS::AdvancedComputerSearch
285
277
 
286
- ### This is the class for relevant Extension Attributes
278
+ # This is the class for relevant Extension Attributes
287
279
  EXT_ATTRIB_CLASS = JSS::ComputerExtensionAttribute
288
280
 
289
- ### Boot partitions are noted with the string "(Boot Partition)" at the end
290
- BOOT_FLAG = " (Boot Partition)"
281
+ # Boot partitions are noted with the string "(Boot Partition)" at the end
282
+ BOOT_FLAG = ' (Boot Partition)'.freeze
291
283
 
292
- ### file uploads can send attachments to the JSS using :computers as the sub-resource.
293
- UPLOAD_TYPES = { :attachment => :computers}
284
+ # file uploads can send attachments to the JSS using :computers as the sub-resource.
285
+ UPLOAD_TYPES = { attachment: :computers }.freeze
294
286
 
295
- ### A mapping of Symbols available to the send_mdm_command class method, to
296
- ### the String commands actuallly sent via the API.
287
+ # A mapping of Symbols available to the send_mdm_command class method, to
288
+ # the String commands actuallly sent via the API.
297
289
  COMPUTER_MDM_COMMANDS = {
298
- :blank_push => "BlankPush",
299
- :send_blank_push => "BlankPush",
300
- :blank => "BlankPush",
301
- :noop => "BlankPush",
302
- :device_lock => "DeviceLock",
303
- :lock => "DeviceLock",
304
- :lock_device => "DeviceLock",
305
- :erase_device => "EraseDevice",
306
- :erase => "EraseDevice",
307
- :wipe => "EraseDevice",
308
- :unmanage_device => "UnmanageDevice",
309
- :unmanage => "UnmanageDevice"
310
- }
311
-
312
- #####################################
313
- ### Attributes
290
+ blank_push: 'BlankPush',
291
+ send_blank_push: 'BlankPush',
292
+ blank: 'BlankPush',
293
+ noop: 'BlankPush',
294
+ device_lock: 'DeviceLock',
295
+ lock: 'DeviceLock',
296
+ lock_device: 'DeviceLock',
297
+ erase_device: 'EraseDevice',
298
+ erase: 'EraseDevice',
299
+ wipe: 'EraseDevice',
300
+ unmanage_device: 'UnmanageDevice',
301
+ unmanage: 'UnmanageDevice'
302
+ }.freeze
303
+
304
+ # Attributes
314
305
  #####################################
315
306
 
316
- ### The values returned in the General, Location, and Purchasing subsets are stored as direct attributes
317
- ### Location and Purchasing are defined in the Locatable and Purchasable mixin modules.
318
- ### Here's General, in alphabetical order
307
+ # The values returned in the General, Location, and Purchasing subsets are stored as direct attributes
308
+ # Location and Purchasing are defined in the Locatable and Purchasable mixin modules.
309
+ # Here's General, in alphabetical order
319
310
 
320
- ### @return [String] the secondary mac address
311
+ # @return [String] the secondary mac address
321
312
  attr_reader :alt_mac_address
322
313
 
323
- ### @return [String] the asset tag
314
+ # @return [String] the asset tag
324
315
  attr_reader :asset_tag
325
316
 
326
- ### @return [String] the barcodes
317
+ # @return [String] the barcodes
327
318
  attr_reader :barcode_1, :barcode_2
328
319
 
329
-
330
- ### @return [String] The name of the distribution point for this computer
320
+ # @return [String] The name of the distribution point for this computer
331
321
  attr_reader :distribution_point
332
322
 
333
- ### @return [Time] when was it added to the JSS
323
+ # @return [Time] when was it added to the JSS
334
324
  attr_reader :initial_entry_date
335
325
 
336
- ### @return [IPAddr] the last known IP address
326
+ # @return [IPAddr] the last known IP address
337
327
  attr_reader :ip_address
338
328
 
339
- ### @return [String] the version of the jamf binary
329
+ # @return [String] the version of the jamf binary
340
330
  attr_reader :jamf_version
341
331
 
342
- ### @return [Time] the last contact time
332
+ # @return [Time] the last contact time
343
333
  attr_reader :last_contact_time
344
334
 
345
- ### @return [String] the primary macaddress
335
+ # @return [String] the primary macaddress
346
336
  attr_reader :mac_address
347
337
 
348
- ### @return [Boolean] is this machine "managed" by Casper?
338
+ # @return [Boolean] is this machine "managed" by Casper?
349
339
  attr_reader :managed
350
340
 
351
- ### @return [String] the name of the management account
341
+ # @return [String] the name of the management account
352
342
  attr_reader :management_username
353
343
 
354
- ### @return [Boolean] doesit support MDM?
344
+ # @return [Boolean] doesit support MDM?
355
345
  attr_reader :mdm_capable
356
346
 
357
- ### @return [String] the name of the netboot server for this machine
347
+ # @return [String] the name of the netboot server for this machine
358
348
  attr_reader :netboot_server
359
349
 
360
- ### @return [String] what kind of computer?
350
+ # @return [String] what kind of computer?
361
351
  attr_reader :platform
362
352
 
363
- ### @return [Time] the last recon time
353
+ # @return [Time] the last recon time
364
354
  attr_reader :report_date
365
355
 
366
- ### @return [String] the serial number
356
+ # @return [String] the serial number
367
357
  attr_reader :serial_number
368
358
 
369
-
370
- ### @return [Hash] the :name and :id of the site for this machine
359
+ # @return [Hash] the :name and :id of the site for this machine
371
360
  attr_reader :site
372
361
 
373
- ### @return [String] the name of the Software Update Server assigned to this machine.
362
+ # @return [String] the name of the Software Update Server assigned to this machine.
374
363
  attr_reader :sus
375
364
 
376
- ### @return [String] the UDID of the computer
365
+ # @return [String] the UDID of the computer
377
366
  attr_reader :udid
378
367
 
379
-
380
- ############
381
- ### The remaining subsets each go into an attribute of their own.
382
- ###
383
-
384
- ### @return [Array<Hash>]
385
- ###
386
- ### A Hash for each ConfigurationProfile on the computer
387
- ###
388
- ### The Hash keys are:
389
- ### * :id => the ConfigurationProfile id in the JSS
390
- ### * :name => the username to whom this user-level profile has been applied (if it's a user-level profile)
391
- ### * :uuid => the ConfigurationProfile uuid
392
- ###
368
+ # The remaining subsets each go into an attribute of their own.
369
+ #
370
+
371
+ # @return [Array<Hash>]
372
+ #
373
+ # A Hash for each ConfigurationProfile on the computer
374
+ #
375
+ # The Hash keys are:
376
+ # * :id => the ConfigurationProfile id in the JSS
377
+ # * :name => the username to whom this user-level profile has been applied (if it's a user-level profile)
378
+ # * :uuid => the ConfigurationProfile uuid
379
+ #
393
380
  attr_reader :configuration_profiles
394
381
 
395
- ### @return [Hash]
396
- ###
397
- ### Info about the local accts and ComputerGroups to which this machine beloings
398
- ###
399
- ### The Hash keys are:
400
- ### * :computer_group_memberships => An Array of names of ComputerGroups to which this computer belongs
401
- ### * :local_accounts => An Array of Hashes for each local user acct on this computer. Each hash has these keys:
402
- ### * :name => String, the login name of the acct
403
- ### * :realname => the real name of the acct
404
- ### * :uid => String, the uid of the acct
405
- ### * :home => String, the path to the home folder
406
- ### * :home_size => String, the size of the homedir as a string like "53245MB"
407
- ### * :home_size_mb => Integer, the size of the homedir as an integer like 53245
408
- ### * :administrator => Boolean
409
- ### * :filevault_enabled => Boolean
410
- ###
382
+ # @return [Hash]
383
+ #
384
+ # Info about the local accts and ComputerGroups to which this machine beloings
385
+ #
386
+ # The Hash keys are:
387
+ # * :computer_group_memberships => An Array of names of ComputerGroups to which this computer belongs
388
+ # * :local_accounts => An Array of Hashes for each local user acct on this computer. Each hash has these keys:
389
+ # * :name => String, the login name of the acct
390
+ # * :realname => the real name of the acct
391
+ # * :uid => String, the uid of the acct
392
+ # * :home => String, the path to the home folder
393
+ # * :home_size => String, the size of the homedir as a string like "53245MB"
394
+ # * :home_size_mb => Integer, the size of the homedir as an integer like 53245
395
+ # * :administrator => Boolean
396
+ # * :filevault_enabled => Boolean
397
+ #
411
398
  attr_reader :groups_accounts
412
399
 
413
- ### @return [Hash]
414
- ###
415
- ### A Hash with info about the hardware of this cmoputer.
416
- ###
417
- ### These are the keys & sample data
418
- ### * :number_processors=>2,
419
- ### * :processor_speed_mhz=>2530,
420
- ### * :make=>"Apple",
421
- ### * :cache_size=>3072,
422
- ### * :processor_type=>"Intel Core i5",
423
- ### * :total_ram_mb=>8192,
424
- ### * :model=>"15-inch MacBook Pro (Mid 2010)",
425
- ### * :available_ram_slots=>0,
426
- ### * :processor_architecture=>"i386",
427
- ### * :bus_speed_mhz=>0,
428
- ### * :total_ram=>8192,
429
- ### * :os_name=>"Mac OS X",
430
- ### * :optical_drive=>"HL-DT-ST DVDRW GS23N",
431
- ### * :model_identifier=>"MacBookPro6,2",
432
- ### * :cache_size_kb=>3072,
433
- ### * :boot_rom=>"MBP61.0057.B0F",
434
- ### * :os_version=>"10.9.3",
435
- ### * :mapped_printers=> An Array of Hashes, one per printer, with these keys
436
- ### * :name => the name of the printer
437
- ### * :location => the location of the printer
438
- ### * :type => the printer model
439
- ### * :uri => the uri to reach the printer on the network
440
- ### * :nic_speed=>"10/100/1000",
441
- ### * :processor_speed=>2530,
442
- ### * :active_directory_status=>"Not Bound",
443
- ### * :bus_speed=>0,
444
- ### * :os_build=>"13D65",
445
- ### * :smc_version=>"1.58f17",
446
- ### * :service_pack=>"",
447
- ### * :battery_capacity=>87
448
- ### * :storage=> An Array of Hashes, one per Drive, with these keys
449
- ### * :smart_status=>"Verified",
450
- ### * :connection_type=>"NO",
451
- ### * :model=>"M4-CT256M4SSD2",
452
- ### * :revision=>"040H",
453
- ### * :serial_number=>"00000000130709JH7GhhC",
454
- ### * :size=>262205,
455
- ### * :disk=>"disk0",
456
- ### * :drive_capacity_mb=>262205}],
457
- ### * :partition=> A Hash with these keys
458
- ### * :filevault2_status=>"Encrypted",
459
- ### * :type=>"boot",
460
- ### * :filevault2_percent=>100,
461
- ### * :partition_capacity_mb=>38014,
462
- ### * :lvgUUID=>"C4883AF5-3E58-4F76-A56C-094D4CEC7E9F",
463
- ### * :percentage_full=>61,
464
- ### * :lvUUID=>"745A262E-AEA6-4608-8A3A-6CDC225B4DE6",
465
- ### * :filevault_status=>"Encrypted",
466
- ### * :size=>38014,
467
- ### * :pvUUID=>"C38051CF-5066-442F-A442-1035060ED462",
468
- ### * :name=>"KimDrive40 (Boot Partition)",
469
- ### * :filevault_percent=>100
470
- ###
400
+ # @return [Hash]
401
+ #
402
+ # A Hash with info about the hardware of this cmoputer.
403
+ #
404
+ # These are the keys & sample data
405
+ # * :number_processors=>2,
406
+ # * :processor_speed_mhz=>2530,
407
+ # * :make=>"Apple",
408
+ # * :cache_size=>3072,
409
+ # * :processor_type=>"Intel Core i5",
410
+ # * :total_ram_mb=>8192,
411
+ # * :model=>"15-inch MacBook Pro (Mid 2010)",
412
+ # * :available_ram_slots=>0,
413
+ # * :processor_architecture=>"i386",
414
+ # * :bus_speed_mhz=>0,
415
+ # * :total_ram=>8192,
416
+ # * :os_name=>"Mac OS X",
417
+ # * :optical_drive=>"HL-DT-ST DVDRW GS23N",
418
+ # * :model_identifier=>"MacBookPro6,2",
419
+ # * :cache_size_kb=>3072,
420
+ # * :boot_rom=>"MBP61.0057.B0F",
421
+ # * :os_version=>"10.9.3",
422
+ # * :mapped_printers=> An Array of Hashes, one per printer, with these keys
423
+ # * :name => the name of the printer
424
+ # * :location => the location of the printer
425
+ # * :type => the printer model
426
+ # * :uri => the uri to reach the printer on the network
427
+ # * :nic_speed=>"10/100/1000",
428
+ # * :processor_speed=>2530,
429
+ # * :active_directory_status=>"Not Bound",
430
+ # * :bus_speed=>0,
431
+ # * :os_build=>"13D65",
432
+ # * :smc_version=>"1.58f17",
433
+ # * :service_pack=>"",
434
+ # * :battery_capacity=>87
435
+ # * :storage=> An Array of Hashes, one per Drive, with these keys
436
+ # * :smart_status=>"Verified",
437
+ # * :connection_type=>"NO",
438
+ # * :model=>"M4-CT256M4SSD2",
439
+ # * :revision=>"040H",
440
+ # * :serial_number=>"00000000130709JH7GhhC",
441
+ # * :size=>262205,
442
+ # * :disk=>"disk0",
443
+ # * :drive_capacity_mb=>262205}],
444
+ # * :partition=> A Hash with these keys
445
+ # * :filevault2_status=>"Encrypted",
446
+ # * :type=>"boot",
447
+ # * :filevault2_percent=>100,
448
+ # * :partition_capacity_mb=>38014,
449
+ # * :lvgUUID=>"C4883AF5-3E58-4F76-A56C-094D4CEC7E9F",
450
+ # * :percentage_full=>61,
451
+ # * :lvUUID=>"745A262E-AEA6-4608-8A3A-6CDC225B4DE6",
452
+ # * :filevault_status=>"Encrypted",
453
+ # * :size=>38014,
454
+ # * :pvUUID=>"C38051CF-5066-442F-A442-1035060ED462",
455
+ # * :name=>"KimDrive40 (Boot Partition)",
456
+ # * :filevault_percent=>100
457
+ #
471
458
  attr_reader :hardware
472
459
 
473
- ### DEPRECATED
474
- ### attr_reader :iphones
475
-
476
- ### @return [Array<Hash>]
477
- ###
478
- ### A Hash per peripheral
479
- ###
480
- ### Each hash has these keys & sample data:
481
- ### * :id=>286,
482
- ### * :type=>"Display",
483
- ### * :field_0=>"HP",
484
- ### * :field_1=>"HP LP2480zx",
485
- ### * :field_2=>"DreamColor",
486
- ### * :field_3=>"3CM10800F4",
487
- ### * :field_4=>"",
488
- ### * :field_5=>""
489
- ### * :field_6=>"",
490
- ### * :bar_code_1=>"",
491
- ### * :bar_code_2=>"",
492
- ### * :purchasing=> A hash with these keys:
493
- ### * :warranty_expires_utc=>"",
494
- ### * :is_leased=>false,
495
- ### * :po_date=>"",
496
- ### * :lease_expires=>"",
497
- ### * :po_number=>"",
498
- ### * :po_date_epoch=>0,
499
- ### * :lease_expires_epoch=>0,
500
- ### * :vendor=>"",
501
- ### * :attachments=>[],
502
- ### * :po_date_utc=>"",
503
- ### * :lease_expires_utc=>"",
504
- ### * :applecare_id=>"",
505
- ### * :warranty_expires=>"",
506
- ### * :life_expectancy=>0,
507
- ### * :purchase_price=>"",
508
- ### * :warranty_expires_epoch=>0,
509
- ### * :is_purchased=>true,
510
- ### * :purchasing_contact=>"",
511
- ### * :purchasing_account=>""
512
- ###
460
+ # @return [Array<Hash>]
461
+ #
462
+ # A Hash per peripheral
463
+ #
464
+ # Each hash has these keys & sample data:
465
+ # * :id=>286,
466
+ # * :type=>"Display",
467
+ # * :field_0=>"HP",
468
+ # * :field_1=>"HP LP2480zx",
469
+ # * :field_2=>"DreamColor",
470
+ # * :field_3=>"3CM10800F4",
471
+ # * :field_4=>"",
472
+ # * :field_5=>""
473
+ # * :field_6=>"",
474
+ # * :bar_code_1=>"",
475
+ # * :bar_code_2=>"",
476
+ # * :purchasing=> A hash with these keys:
477
+ # * :warranty_expires_utc=>"",
478
+ # * :is_leased=>false,
479
+ # * :po_date=>"",
480
+ # * :lease_expires=>"",
481
+ # * :po_number=>"",
482
+ # * :po_date_epoch=>0,
483
+ # * :lease_expires_epoch=>0,
484
+ # * :vendor=>"",
485
+ # * :attachments=>[],
486
+ # * :po_date_utc=>"",
487
+ # * :lease_expires_utc=>"",
488
+ # * :applecare_id=>"",
489
+ # * :warranty_expires=>"",
490
+ # * :life_expectancy=>0,
491
+ # * :purchase_price=>"",
492
+ # * :warranty_expires_epoch=>0,
493
+ # * :is_purchased=>true,
494
+ # * :purchasing_contact=>"",
495
+ # * :purchasing_account=>""
496
+ #
513
497
  attr_reader :peripherals
514
498
 
515
- ### @return [Hash]
516
- ###
517
- ### A Hash of software data
518
- ###
519
- ### The Hash has these keys:
520
- ### * :running_services => An Array of services running on the computer (if gathered) TODO - is each item a hash?
521
- ### * :installed_by_casper => An Array of Package names unstalled on this computer by Casper
522
- ### * :fonts => An Array of fonts on this computer (if gathered) TODO - is each item a hash?
523
- ### * :installed_by_installer_swu => An Array of pkg IDs for pkgs installed by SoftwareUpdate or the Apple Installer
524
- ### * :applications => An Array of Hashes, one per Application on the computer, with these keys:
525
- ### * :path => String, the path to the app
526
- ### * :name => String, the name of the app, including the .app suffix
527
- ### * :version => String, the version of the app at that path.
528
- ### * :cached_by_casper => An Array of Casper Package names cached on the machine, awaiting installation
529
- ### * :available_software_updates => An Array of available SoftwareUpdate (if gathered) TODO - is each item a hash?
530
- ### * :plugins => An Array of plugins installed on the machine (if gathered) TODO - is each item a hash?
531
- ### * :available_updates => A Hash - Deprecated?
532
- ### * :licensed_software => An Array, the names of Licenced Software (as defined in Casper) on this machine
533
- ### * :unix_executables => DEPRECATED
534
- ###
499
+ # @return [Hash]
500
+ #
501
+ # A Hash of software data
502
+ #
503
+ # The Hash has these keys:
504
+ # * :running_services => An Array of services running on the computer (if gathered) TODO - is each item a hash?
505
+ # * :installed_by_casper => An Array of Package names unstalled on this computer by Casper
506
+ # * :fonts => An Array of fonts on this computer (if gathered) TODO - is each item a hash?
507
+ # * :installed_by_installer_swu => An Array of pkg IDs for pkgs installed by SoftwareUpdate or the Apple Installer
508
+ # * :applications => An Array of Hashes, one per Application on the computer, with these keys:
509
+ # * :path => String, the path to the app
510
+ # * :name => String, the name of the app, including the .app suffix
511
+ # * :version => String, the version of the app at that path.
512
+ # * :cached_by_casper => An Array of Casper Package names cached on the machine, awaiting installation
513
+ # * :available_software_updates => An Array of available SoftwareUpdate (if gathered) TODO - is each item a hash?
514
+ # * :plugins => An Array of plugins installed on the machine (if gathered) TODO - is each item a hash?
515
+ # * :available_updates => A Hash - Deprecated?
516
+ # * :licensed_software => An Array, the names of Licenced Software (as defined in Casper) on this machine
517
+ # * :unix_executables => DEPRECATED
518
+ #
535
519
  attr_reader :software
536
520
 
521
+ # Constructor
537
522
  #####################################
538
- ### Instance Methods
539
- #####################################
540
-
541
- ###
542
- ### @param (see APIObject#initialize)
543
- ###
544
- ### As well as :id and :name, computers can be queried using :udid, :serialnumber, and :mac_address
545
- ###
546
- def initialize (args = {})
547
523
 
524
+ # @param (see APIObject#initialize)
525
+ #
526
+ # As well as :id and :name, computers can be queried using :udid, :serialnumber, and :mac_address
527
+ #
528
+ def initialize(args = {})
548
529
  super args, [:udid, :serialnumber, :mac_address]
549
530
 
550
- ### now we have raw @init_data with something in it, so fill out the instance vars
531
+ # now we have raw @init_data with something in it, so fill out the instance vars
551
532
  @alt_mac_address = @init_data[:general][:alt_mac_address]
552
533
  @asset_tag = @init_data[:general][:asset_tag]
553
534
  @barcode_1 = @init_data[:general][:barcode_1]
@@ -565,14 +546,10 @@ module JSS
565
546
  @platform = @init_data[:general][:platform]
566
547
  @report_date = JSS.epoch_to_time @init_data[:general][:report_date_epoch]
567
548
  @serial_number = @init_data[:general][:serial_number]
568
- @site = JSS::APIObject.get_name( @init_data[:general][:site])
549
+ @site = JSS::APIObject.get_name(@init_data[:general][:site])
569
550
  @sus = @init_data[:general][:sus]
570
551
  @udid = @init_data[:general][:udid]
571
552
 
572
- parse_location
573
- parse_purchasing
574
- parse_ext_attrs
575
-
576
553
  @configuration_profiles = @init_data[:configuration_profiles]
577
554
  @extension_attributes = @init_data[:extension_attributes]
578
555
  @groups_accounts = @init_data[:groups_accounts]
@@ -581,87 +558,84 @@ module JSS
581
558
  @software = @init_data[:software]
582
559
 
583
560
  @management_password = nil
584
-
585
561
  end # initialize
586
562
 
587
- ###
588
- ### @return [Array] the JSS groups to which thismachine belongs (smart and static)
589
- ###
563
+ # @return [Array] the JSS groups to which thismachine belongs (smart and static)
564
+ #
590
565
  def computer_groups
591
566
  @groups_accounts[:computer_group_memberships]
592
567
  end
593
568
 
594
- ###
595
- ### @return [Array<Hash>] all the local accts on the machine.
596
- ###
597
- ### Each item has keys :name, :realname, :uid, :home, :home_size, :administrator, :filevault_enabled
598
- ###
569
+ # @return [Array<Hash>] all the local accts on the machine.
570
+ #
571
+ # Each item has keys :name, :realname, :uid, :home, :home_size, :administrator, :filevault_enabled
572
+ #
599
573
  def local_accounts
600
574
  @groups_accounts[:local_accounts]
601
575
  end
602
576
 
603
-
604
- ### @return [Boolean] is FileVault2 enabled?
605
- ###
577
+ # @return [Boolean] is FileVault2 enabled?
578
+ #
606
579
  def filevault2_enabled?
607
- boot_drive[:partition][:filevault2_status] != "Not Encrypted"
580
+ boot_drive[:partition][:filevault2_status] != 'Not Encrypted'
608
581
  end
609
582
 
610
- ### @return [Array<Hash>] The local_accounts Array that have Legacy FV enabled
611
- ###
583
+ # @return [Array<Hash>] The local_accounts Array that have Legacy FV enabled
584
+ #
612
585
  def filevault1_accounts
613
586
  return [] if filevault2_enabled?
614
- local_accounts.select{ |a| a[:filevault_enabled] }
587
+ local_accounts.select { |a| a[:filevault_enabled] }
615
588
  end
616
589
 
617
- ### @return [Array<Hash>] each storage device
618
- ###
590
+ # @return [Array<Hash>] each storage device
591
+ #
619
592
  def drives
620
593
  @hardware[:storage]
621
594
  end
622
595
 
623
- ### @return [Hash, nil] The hardware[:storage] hash of the boot drive
624
- ###
596
+ # @return [Hash, nil] The hardware[:storage] hash of the boot drive
597
+ #
625
598
  def boot_drive
626
- drives.each{ |d| return d if d[:partition][:type] == "boot" }
627
- return nil
599
+ drives.each { |d| return d if d[:partition][:type] == 'boot' }
600
+ nil
628
601
  end
629
602
 
630
- ### @return [Array<Hash>] each printer on this computer
631
- ### Keys are :name, :uri, :type, :location
632
- ###
603
+ # @return [Array<Hash>] each printer on this computer
604
+ # Keys are :name, :uri, :type, :location
605
+ #
633
606
  def printers
634
607
  @hardware[:mapped_printers]
635
608
  end
636
609
 
637
- ###
638
- ### @return [Array<Hash>] all apps installed on this machine.
639
- ### Hash keys are :name, :path, and :version
640
- ###
641
- def apps ; @software[:applications] ; end
642
-
643
- ###
644
- ### @return [Array<String>] the JSS-defined "licensed software" titles
645
- ### installed on this machine.
646
- ###
647
- def licensed_sw ; @software[:licensed_software] ; end
648
-
649
- ###
650
- ### Set or unset management acct and password for this computer
651
- ###
652
- ### @param name[String] the name of the management acct.
653
- ###
654
- ### @param password[String] the password of the management acct
655
- ###
656
- ### @return [void]
657
- ###
658
- ### The changes will need to be pushed to the server with #update
659
- ### before they take effect.
660
- ###
661
- ### CAUTION: this does nothing to confirm the name and password
662
- ### will work on the machine!
663
- ###
664
- def set_management_to (name, password)
610
+ # @return [Array<Hash>] all apps installed on this machine.
611
+ # Hash keys are :name, :path, and :version
612
+ #
613
+ def apps
614
+ @software[:applications]
615
+ end
616
+
617
+ # @return [Array<String>] the JSS-defined "licensed software" titles
618
+ # installed on this machine.
619
+ #
620
+ def licensed_sw
621
+ @software[:licensed_software]
622
+ end
623
+
624
+ # Set or unset management acct and password for this computer
625
+ #
626
+ # @param name[String] the name of the management acct.
627
+ #
628
+ # @param password[String] the password of the management acct
629
+ #
630
+ # @return [void]
631
+ #
632
+ # The changes will need to be pushed to the server with #update
633
+ # before they take effect.
634
+ #
635
+ # CAUTION: this does nothing to confirm the name and password
636
+ # will work on the machine!
637
+ #
638
+ def set_management_to(name, password)
665
639
  password = nil unless name
666
640
  @management_username = name
667
641
  @management_password = password
@@ -669,17 +643,16 @@ module JSS
669
643
  @need_to_update = true
670
644
  end
671
645
 
672
- ###
673
- ### Make the machine unmanaged.
674
- ###
675
- ### The same as
676
- ### #set_management_to nil, nil
677
- ### followed by
678
- ### JSS::Computer.send_mdm_command @id, :unmanage_device
679
- ### which currently isn't working
680
- ###
681
- ### @return [void]
682
- ###
646
+ # Make the machine unmanaged.
647
+ #
648
+ # The same as
649
+ # #set_management_to nil, nil
650
+ # followed by
651
+ # JSS::Computer.send_mdm_command @id, :unmanage_device
652
+ # which currently isn't working
653
+ #
654
+ # @return [void]
655
+ #
683
656
  def make_unmanaged
684
657
  return nil unless managed?
685
658
  set_management_to(nil, nil)
@@ -689,56 +662,54 @@ module JSS
689
662
  end
690
663
  end
691
664
 
692
- ###
693
- def asset_tag= (new_val)
665
+ #
666
+ def asset_tag=(new_val)
694
667
  return nil if @asset_tag == new_val
695
668
  new_val.strip!
696
669
  @asset_tag = new_val
697
670
  @need_to_update = true
698
671
  end
699
672
 
700
- ###
701
- def barcode_1= (new_val)
673
+ #
674
+ def barcode_1=(new_val)
702
675
  return nil if @barcode_1 == new_val
703
676
  new_val.strip!
704
677
  @barcode_1 = new_val
705
678
  @need_to_update = true
706
679
  end
707
680
 
708
- ###
709
- def barcode_2= (new_val)
681
+ #
682
+ def barcode_2=(new_val)
710
683
  return nil if @barcode_2 == new_val
711
684
  new_val.strip!
712
685
  @barcode_2 = new_val
713
686
  @need_to_update = true
714
687
  end
715
688
 
716
- ###
717
- def ip_address= (new_val)
689
+ #
690
+ def ip_address=(new_val)
718
691
  return nil if @ip_address == new_val
719
692
  new_val.strip!
720
- ### this raises an error if its an invalid IP address
693
+ # this raises an error if its an invalid IP address
721
694
  IPAddr.new new_val
722
695
  @ip_address = new_val
723
696
  @need_to_update = true
724
697
  end
725
698
 
726
- ###
727
- ### Send changes to the API
728
- ###
729
- ### @return [void]
730
- ###
699
+ # Send changes to the API
700
+ #
701
+ # @return [void]
702
+ #
731
703
  def update
732
704
  id = super
733
705
  @management_password = nil
734
706
  id
735
707
  end
736
708
 
737
- ###
738
- ### Delete this computer from the JSS
739
- ###
740
- ### @return [void]
741
- ###
709
+ # Delete this computer from the JSS
710
+ #
711
+ # @return [void]
712
+ #
742
713
  def delete
743
714
  super
744
715
  @alt_mac_address = nil
@@ -778,40 +749,38 @@ module JSS
778
749
  @peripherals = nil
779
750
  @purchasing = nil
780
751
  @software = nil
781
- end #delete
782
-
783
-
784
- # Not Functional until I get more docs from JAMF
785
- #
786
- # ###
787
- # ### Send a blank_push MDM command
788
- # ###
789
- # def blank_push
790
- # self.class.send_mdm_command @id, :blank_push
791
- # end
792
- # alias noop blank_push
793
- # alias send_blank_push blank_push
794
- #
795
- # ###
796
- # ### Send a device_lock MDM command
797
- # ###
798
- # def device_lock
799
- # self.class.send_mdm_command @id, :device_lock
800
- # end
801
- # alias lock device_lock
802
- # alias lock_device device_lock
803
- #
804
- # ###
805
- # ### Send an erase_device MDM command
806
- # ###
807
- # def erase_device
808
- # self.class.send_mdm_command @id, :erase_device
809
- # end
810
- # alias erase erase_device
811
- # alias wipe erase_device
812
-
813
-
814
- ### aliases
752
+ end # delete
753
+
754
+ # Not Functional until I get more docs from JAMF
755
+ #
756
+ # #
757
+ # # Send a blank_push MDM command
758
+ # #
759
+ # def blank_push
760
+ # self.class.send_mdm_command @id, :blank_push
761
+ # end
762
+ # alias noop blank_push
763
+ # alias send_blank_push blank_push
764
+ #
765
+ # #
766
+ # # Send a device_lock MDM command
767
+ # #
768
+ # def device_lock
769
+ # self.class.send_mdm_command @id, :device_lock
770
+ # end
771
+ # alias lock device_lock
772
+ # alias lock_device device_lock
773
+ #
774
+ # #
775
+ # # Send an erase_device MDM command
776
+ # #
777
+ # def erase_device
778
+ # self.class.send_mdm_command @id, :erase_device
779
+ # end
780
+ # alias erase erase_device
781
+ # alias wipe erase_device
782
+
783
+ # aliases
815
784
  alias alt_macaddress alt_mac_address
816
785
  alias bar_code_1 barcode_1
817
786
  alias bar_code_2 barcode_2
@@ -824,23 +793,17 @@ module JSS
824
793
  alias accts local_accounts
825
794
  alias make_managed set_management_to
826
795
 
827
-
828
-
829
-
830
-
831
- ##############################
832
- ### private methods
796
+ # private methods
833
797
  ##############################
834
798
  private
835
799
 
836
- ###
837
- ### Return a String with the XML Resource
838
- ### for submitting changes to the JSS via
839
- ### the API
840
- ###
841
- ### For Computers, only some items can be changed via the API
842
- ### In particular, any data gatherd by a Recon cannot be changed
843
- ###
800
+ # Return a String with the XML Resource
801
+ # for submitting changes to the JSS via
802
+ # the API
803
+ #
804
+ # For Computers, only some items can be changed via the API
805
+ # In particular, any data gatherd by a Recon cannot be changed
806
+ #
844
807
  def rest_xml
845
808
  doc = REXML::Document.new APIConnection::XML_HEADER
846
809
  computer = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
@@ -862,15 +825,13 @@ module JSS
862
825
 
863
826
  computer << ext_attr_xml
864
827
 
865
- if has_location?
866
- computer << location_xml
867
- end
868
- if has_purchasing?
869
- computer << purchasing_xml
870
- end
828
+ computer << location_xml if has_location?
871
829
 
872
- return doc.to_s
830
+ computer << purchasing_xml if has_purchasing?
831
+
832
+ doc.to_s
873
833
  end
874
834
 
875
835
  end # class Computer
836
+
876
837
  end # module