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.
- checksums.yaml +4 -4
- data/CHANGES.md +29 -22
- data/README.md +66 -86
- data/bin/jamfHelperBackgrounder +148 -0
- data/bin/netseg-update +0 -1
- data/lib/jss.rb +20 -9
- data/lib/jss/api_connection.rb +369 -295
- data/lib/jss/api_object.rb +651 -418
- data/lib/jss/api_object/account.rb +69 -77
- data/lib/jss/api_object/advanced_search.rb +201 -236
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +42 -42
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +33 -43
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +33 -43
- data/lib/jss/api_object/building.rb +39 -52
- data/lib/jss/api_object/categorizable.rb +221 -0
- data/lib/jss/api_object/category.rb +81 -89
- data/lib/jss/api_object/computer.rb +486 -525
- data/lib/jss/api_object/computer_invitation.rb +73 -86
- data/lib/jss/api_object/criteriable.rb +6 -7
- data/lib/jss/api_object/ebook.rb +21 -0
- data/lib/jss/api_object/extendable.rb +6 -8
- data/lib/jss/api_object/group.rb +0 -3
- data/lib/jss/api_object/locatable.rb +19 -20
- data/lib/jss/api_object/mac_application.rb +21 -0
- data/lib/jss/api_object/mobile_device.rb +30 -21
- data/lib/jss/api_object/mobile_device_application.rb +447 -0
- data/lib/jss/api_object/mobile_device_configuration_profile.rb +21 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +0 -3
- data/lib/jss/api_object/package.rb +21 -34
- data/lib/jss/api_object/peripheral.rb +16 -18
- data/lib/jss/api_object/policy.rb +5 -83
- data/lib/jss/api_object/purchasable.rb +11 -13
- data/lib/jss/api_object/scopable.rb +11 -12
- data/lib/jss/api_object/script.rb +3 -17
- data/lib/jss/api_object/self_servable.rb +419 -205
- data/lib/jss/api_object/self_servable/icon.rb +179 -0
- data/lib/jss/api_object/updatable.rb +35 -34
- data/lib/jss/api_object/uploadable.rb +72 -70
- data/lib/jss/api_object/user.rb +6 -7
- data/lib/jss/api_object/vppable.rb +117 -0
- data/lib/jss/client.rb +264 -225
- data/lib/jss/db_connection.rb +7 -5
- data/lib/jss/exceptions.rb +50 -42
- data/lib/jss/ruby_extensions.rb +8 -7
- data/lib/jss/ruby_extensions/object.rb +19 -0
- data/lib/jss/utility.rb +82 -40
- data/lib/jss/version.rb +1 -1
- metadata +37 -68
- data/bin/jss-webhook-server +0 -3
- data/lib/jss/webhooks.rb +0 -53
- data/lib/jss/webhooks/README.md +0 -269
- data/lib/jss/webhooks/configuration.rb +0 -213
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation-executable +0 -91
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation.rb +0 -45
- data/lib/jss/webhooks/data/sample_jsons/ComputerAdded.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerCheckIn.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerInventoryCompleted.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerPolicyFinished.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/ComputerPushCapabilityChanged.json +0 -27
- data/lib/jss/webhooks/data/sample_jsons/JSSShutdown.json +0 -14
- data/lib/jss/webhooks/data/sample_jsons/JSSStartup.json +0 -14
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCheckIn.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCommandCompleted.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceEnrolled.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDevicePushSent.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceUnEnrolled.json +0 -26
- data/lib/jss/webhooks/data/sample_jsons/PatchSoftwareTitleUpdated.json +0 -14
- data/lib/jss/webhooks/data/sample_jsons/PushSent.json +0 -11
- data/lib/jss/webhooks/data/sample_jsons/RestAPIOperation.json +0 -15
- data/lib/jss/webhooks/data/sample_jsons/SCEPChallenge.json +0 -10
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupComputerMembershipChange.json +0 -13
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +0 -13
- data/lib/jss/webhooks/event.rb +0 -139
- data/lib/jss/webhooks/event/computer_added.rb +0 -38
- data/lib/jss/webhooks/event/computer_check_in.rb +0 -38
- data/lib/jss/webhooks/event/computer_inventory_completed.rb +0 -38
- data/lib/jss/webhooks/event/computer_policy_finished.rb +0 -38
- data/lib/jss/webhooks/event/computer_push_capability_changed.rb +0 -38
- data/lib/jss/webhooks/event/handlers.rb +0 -192
- data/lib/jss/webhooks/event/jss_shutdown.rb +0 -38
- data/lib/jss/webhooks/event/jss_startup.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_check_in.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_command_completed.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_enrolled.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_push_sent.rb +0 -38
- data/lib/jss/webhooks/event/mobile_device_unenrolled.rb +0 -38
- data/lib/jss/webhooks/event/patch_software_title_updated.rb +0 -38
- data/lib/jss/webhooks/event/push_sent.rb +0 -38
- data/lib/jss/webhooks/event/rest_api_operation.rb +0 -38
- data/lib/jss/webhooks/event/scep_challenge.rb +0 -38
- data/lib/jss/webhooks/event/smart_group_computer_membership_change.rb +0 -38
- data/lib/jss/webhooks/event/smart_group_mobile_device_membership_change.rb +0 -38
- data/lib/jss/webhooks/event/webhook.rb +0 -40
- data/lib/jss/webhooks/event_objects.rb +0 -112
- data/lib/jss/webhooks/event_objects/computer.rb +0 -49
- data/lib/jss/webhooks/event_objects/jss.rb +0 -36
- data/lib/jss/webhooks/event_objects/mobile_device.rb +0 -48
- data/lib/jss/webhooks/event_objects/patch_software_title_update.rb +0 -38
- data/lib/jss/webhooks/event_objects/push.rb +0 -33
- data/lib/jss/webhooks/event_objects/rest_api_operation.rb +0 -37
- data/lib/jss/webhooks/event_objects/scep_challenge.rb +0 -32
- data/lib/jss/webhooks/event_objects/smart_group.rb +0 -35
- data/lib/jss/webhooks/server_app.rb +0 -37
- data/lib/jss/webhooks/server_app/routes.rb +0 -27
- data/lib/jss/webhooks/server_app/routes/handle_webhook_event.rb +0 -39
- data/lib/jss/webhooks/server_app/routes/home.rb +0 -37
- data/lib/jss/webhooks/server_app/self_signed_cert.rb +0 -65
- data/lib/jss/webhooks/server_app/server.rb +0 -60
- 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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
|
32
|
+
# Module Methods
|
38
33
|
#####################################
|
39
|
-
|
34
|
+
|
35
|
+
# Classes
|
40
36
|
#####################################
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
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
|
-
|
65
|
-
RSRC_BASE =
|
66
|
-
|
67
|
-
|
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
|
-
|
71
|
-
|
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
|
-
|
75
|
-
VALID_DATA_KEYS = [:priority]
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
84
|
+
|
85
|
+
# The Default Priority
|
84
86
|
DEFAULT_PRIORITY = 5
|
85
|
-
|
86
|
-
|
87
|
-
### Attributes
|
87
|
+
|
88
|
+
# Attributes
|
88
89
|
#####################################
|
89
|
-
|
90
|
-
|
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
|
-
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
-
|
151
|
+
# @return [Array<String>] all computer serial numbers in the jss
|
160
152
|
def self.all_serial_numbers(refresh = false)
|
161
|
-
|
153
|
+
all(refresh).map { |i| i[:serial_number] }
|
162
154
|
end
|
163
155
|
|
164
|
-
|
156
|
+
# @return [Array<String>] all computer mac_addresses in the jss
|
165
157
|
def self.all_mac_addresses(refresh = false)
|
166
|
-
|
158
|
+
all(refresh).map { |i| i[:mac_address] }
|
167
159
|
end
|
168
160
|
|
169
|
-
|
161
|
+
# @return [Array<String>] all computer udids in the jss
|
170
162
|
def self.all_udids(refresh = false)
|
171
|
-
|
163
|
+
all(refresh).map { |i| i[:udid] }
|
172
164
|
end
|
173
165
|
|
174
|
-
|
166
|
+
# @return [Array<Hash>] all managed computers in the jss
|
175
167
|
def self.all_managed(refresh = false)
|
176
|
-
|
168
|
+
all(refresh).select { |d| d[:managed] }
|
177
169
|
end
|
178
170
|
|
179
|
-
|
171
|
+
# @return [Array<Hash>] all unmanaged computers in the jss
|
180
172
|
def self.all_unmanaged(refresh = false)
|
181
|
-
|
173
|
+
all(refresh).select { |d| !(d[:managed]) }
|
182
174
|
end
|
183
175
|
|
184
|
-
|
176
|
+
# @return [Array<Hash>] all laptop computers in the jss
|
185
177
|
def self.all_laptops(refresh = false)
|
186
|
-
|
178
|
+
all(refresh).select { |d| d[:model] =~ /book/i }
|
187
179
|
end
|
188
180
|
|
189
|
-
|
181
|
+
# @return [Array<Hash>] all macbooks in the jss
|
190
182
|
def self.all_macbooks(refresh = false)
|
191
|
-
|
183
|
+
all(refresh).select { |d| d[:model] =~ /^macbook\d/i }
|
192
184
|
end
|
193
185
|
|
194
|
-
|
186
|
+
# @return [Array<Hash>] all macbookpros in the jss
|
195
187
|
def self.all_macbookpros(refresh = false)
|
196
|
-
|
188
|
+
all(refresh).select { |d| d[:model] =~ /^macbookpro\d/i }
|
197
189
|
end
|
198
190
|
|
199
|
-
|
191
|
+
# @return [Array<Hash>] all macbookairs in the jss
|
200
192
|
def self.all_macbookairs(refresh = false)
|
201
|
-
|
193
|
+
all(refresh).select { |d| d[:model] =~ /^macbookair\d/i }
|
202
194
|
end
|
203
195
|
|
204
|
-
|
196
|
+
# @return [Array<Hash>] all xserves in the jss
|
205
197
|
def self.all_xserves(refresh = false)
|
206
|
-
|
198
|
+
all(refresh).select { |d| d[:model] =~ /serve/i }
|
207
199
|
end
|
208
200
|
|
209
|
-
|
201
|
+
# @return [Array<Hash>] all desktop macs in the jss
|
210
202
|
def self.all_desktops(refresh = false)
|
211
|
-
|
203
|
+
all(refresh).select { |d| d[:model] !~ /serve|book/i }
|
212
204
|
end
|
213
205
|
|
214
|
-
|
206
|
+
# @return [Array<Hash>] all imacs in the jss
|
215
207
|
def self.all_imacs(refresh = false)
|
216
|
-
|
208
|
+
all(refresh).select { |d| d[:model] =~ /^imac/i }
|
217
209
|
end
|
218
210
|
|
219
|
-
|
211
|
+
# @return [Array<Hash>] all mac minis in the jss
|
220
212
|
def self.all_minis(refresh = false)
|
221
|
-
|
213
|
+
all(refresh).select { |d| d[:model] =~ /^macmini/i }
|
222
214
|
end
|
223
215
|
|
224
|
-
|
216
|
+
# @return [Array<Hash>] all macpros in the jss
|
225
217
|
def self.all_macpros(refresh = false)
|
226
|
-
|
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
|
-
|
268
|
-
RSRC_BASE =
|
255
|
+
# The base for REST resources of this class
|
256
|
+
RSRC_BASE = 'computers'.freeze
|
269
257
|
|
270
|
-
|
271
|
-
LIST_RSRC = "#{RSRC_BASE}/subset/basic"
|
258
|
+
# The (temporary?) list-resource
|
259
|
+
LIST_RSRC = "#{RSRC_BASE}/subset/basic".freeze
|
272
260
|
|
273
|
-
|
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
|
-
|
277
|
-
|
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
|
-
|
281
|
-
|
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
|
-
|
275
|
+
# This class lets us seach for computers
|
284
276
|
SEARCH_CLASS = JSS::AdvancedComputerSearch
|
285
277
|
|
286
|
-
|
278
|
+
# This is the class for relevant Extension Attributes
|
287
279
|
EXT_ATTRIB_CLASS = JSS::ComputerExtensionAttribute
|
288
280
|
|
289
|
-
|
290
|
-
BOOT_FLAG =
|
281
|
+
# Boot partitions are noted with the string "(Boot Partition)" at the end
|
282
|
+
BOOT_FLAG = ' (Boot Partition)'.freeze
|
291
283
|
|
292
|
-
|
293
|
-
UPLOAD_TYPES = { :
|
284
|
+
# file uploads can send attachments to the JSS using :computers as the sub-resource.
|
285
|
+
UPLOAD_TYPES = { attachment: :computers }.freeze
|
294
286
|
|
295
|
-
|
296
|
-
|
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
|
-
:
|
299
|
-
:
|
300
|
-
:
|
301
|
-
:
|
302
|
-
:
|
303
|
-
:
|
304
|
-
:
|
305
|
-
:
|
306
|
-
:
|
307
|
-
:
|
308
|
-
:
|
309
|
-
:
|
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
|
-
|
317
|
-
|
318
|
-
|
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
|
-
|
311
|
+
# @return [String] the secondary mac address
|
321
312
|
attr_reader :alt_mac_address
|
322
313
|
|
323
|
-
|
314
|
+
# @return [String] the asset tag
|
324
315
|
attr_reader :asset_tag
|
325
316
|
|
326
|
-
|
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
|
-
|
323
|
+
# @return [Time] when was it added to the JSS
|
334
324
|
attr_reader :initial_entry_date
|
335
325
|
|
336
|
-
|
326
|
+
# @return [IPAddr] the last known IP address
|
337
327
|
attr_reader :ip_address
|
338
328
|
|
339
|
-
|
329
|
+
# @return [String] the version of the jamf binary
|
340
330
|
attr_reader :jamf_version
|
341
331
|
|
342
|
-
|
332
|
+
# @return [Time] the last contact time
|
343
333
|
attr_reader :last_contact_time
|
344
334
|
|
345
|
-
|
335
|
+
# @return [String] the primary macaddress
|
346
336
|
attr_reader :mac_address
|
347
337
|
|
348
|
-
|
338
|
+
# @return [Boolean] is this machine "managed" by Casper?
|
349
339
|
attr_reader :managed
|
350
340
|
|
351
|
-
|
341
|
+
# @return [String] the name of the management account
|
352
342
|
attr_reader :management_username
|
353
343
|
|
354
|
-
|
344
|
+
# @return [Boolean] doesit support MDM?
|
355
345
|
attr_reader :mdm_capable
|
356
346
|
|
357
|
-
|
347
|
+
# @return [String] the name of the netboot server for this machine
|
358
348
|
attr_reader :netboot_server
|
359
349
|
|
360
|
-
|
350
|
+
# @return [String] what kind of computer?
|
361
351
|
attr_reader :platform
|
362
352
|
|
363
|
-
|
353
|
+
# @return [Time] the last recon time
|
364
354
|
attr_reader :report_date
|
365
355
|
|
366
|
-
|
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
|
-
|
362
|
+
# @return [String] the name of the Software Update Server assigned to this machine.
|
374
363
|
attr_reader :sus
|
375
364
|
|
376
|
-
|
365
|
+
# @return [String] the UDID of the computer
|
377
366
|
attr_reader :udid
|
378
367
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
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
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
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
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
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
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
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
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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
|
-
|
596
|
-
|
597
|
-
|
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
|
-
|
605
|
-
###
|
577
|
+
# @return [Boolean] is FileVault2 enabled?
|
578
|
+
#
|
606
579
|
def filevault2_enabled?
|
607
|
-
boot_drive[:partition][:filevault2_status] !=
|
580
|
+
boot_drive[:partition][:filevault2_status] != 'Not Encrypted'
|
608
581
|
end
|
609
582
|
|
610
|
-
|
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
|
-
|
618
|
-
|
590
|
+
# @return [Array<Hash>] each storage device
|
591
|
+
#
|
619
592
|
def drives
|
620
593
|
@hardware[:storage]
|
621
594
|
end
|
622
595
|
|
623
|
-
|
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] ==
|
627
|
-
|
599
|
+
drives.each { |d| return d if d[:partition][:type] == 'boot' }
|
600
|
+
nil
|
628
601
|
end
|
629
602
|
|
630
|
-
|
631
|
-
|
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
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
def licensed_sw
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
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
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
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=
|
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=
|
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=
|
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=
|
689
|
+
#
|
690
|
+
def ip_address=(new_val)
|
718
691
|
return nil if @ip_address == new_val
|
719
692
|
new_val.strip!
|
720
|
-
|
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
|
-
|
728
|
-
|
729
|
-
|
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
|
-
|
739
|
-
|
740
|
-
|
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
|
-
#
|
785
|
-
#
|
786
|
-
#
|
787
|
-
#
|
788
|
-
#
|
789
|
-
#
|
790
|
-
#
|
791
|
-
#
|
792
|
-
# alias
|
793
|
-
#
|
794
|
-
#
|
795
|
-
#
|
796
|
-
#
|
797
|
-
#
|
798
|
-
#
|
799
|
-
#
|
800
|
-
#
|
801
|
-
# alias
|
802
|
-
#
|
803
|
-
#
|
804
|
-
#
|
805
|
-
#
|
806
|
-
#
|
807
|
-
#
|
808
|
-
#
|
809
|
-
#
|
810
|
-
# alias
|
811
|
-
|
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
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
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
|
-
|
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
|