ruby-jss 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +23 -0
- data/lib/jss/api_connection.rb +20 -13
- data/lib/jss/api_object.rb +105 -1
- data/lib/jss/api_object/extension_attribute.rb +165 -68
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +176 -282
- data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +66 -171
- data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +51 -92
- data/lib/jss/api_object/management_history.rb +29 -0
- data/lib/jss/db_connection.rb +1 -0
- data/lib/jss/version.rb +1 -1
- metadata +4 -4
@@ -1,82 +1,56 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
### language governing permissions and limitations under the Apache License.
|
23
|
-
###
|
24
|
-
###
|
25
|
-
|
26
|
-
###
|
27
|
-
module JSS
|
28
|
-
|
29
|
-
#####################################
|
30
|
-
### Constants
|
31
|
-
#####################################
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
# with the following modification; you may not use this file except in
|
5
|
+
# compliance with the Apache License and the following modification to it:
|
6
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
#
|
8
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
# names, trademarks, service marks, or product names of the Licensor
|
10
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
# the License and to reproduce the content of the NOTICE file.
|
12
|
+
#
|
13
|
+
# You may obtain a copy of the Apache License at
|
14
|
+
#
|
15
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
#
|
17
|
+
# Unless required by applicable law or agreed to in writing, software
|
18
|
+
# distributed under the Apache License with the above modification is
|
19
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
# KIND, either express or implied. See the Apache License for the specific
|
21
|
+
# language governing permissions and limitations under the Apache License.
|
32
22
|
|
33
|
-
|
34
|
-
### Module Variables
|
35
|
-
#####################################
|
23
|
+
module JSS
|
36
24
|
|
37
|
-
|
38
|
-
### Module Methods
|
25
|
+
# Classes
|
39
26
|
#####################################
|
40
27
|
|
41
|
-
####################################
|
42
|
-
### Classes
|
43
|
-
#####################################
|
44
28
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
###
|
29
|
+
# An extension attribute as defined in the JSS
|
30
|
+
#
|
31
|
+
# @see JSS::ExtensionAttribute
|
32
|
+
#
|
33
|
+
# @see JSS::APIObject
|
34
|
+
#
|
52
35
|
class MobileDeviceExtensionAttribute < JSS::ExtensionAttribute
|
53
36
|
|
54
|
-
|
55
|
-
### Mix-Ins
|
56
|
-
#####################################
|
57
|
-
|
58
|
-
#####################################
|
59
|
-
### Class Methods
|
60
|
-
#####################################
|
61
|
-
|
62
|
-
#####################################
|
63
|
-
### Class Constants
|
37
|
+
# Class Constants
|
64
38
|
#####################################
|
65
39
|
|
66
|
-
|
40
|
+
# The base for REST resources of this class
|
67
41
|
RSRC_BASE = 'mobiledeviceextensionattributes'.freeze
|
68
42
|
|
69
|
-
|
43
|
+
# the hash key used for the JSON list output of all objects in the JSS
|
70
44
|
RSRC_LIST_KEY = :mobile_device_extension_attributes
|
71
45
|
|
72
|
-
|
73
|
-
|
46
|
+
# The hash key used for the JSON object output.
|
47
|
+
# It's also used in various error messages
|
74
48
|
RSRC_OBJECT_KEY = :mobile_device_extension_attribute
|
75
49
|
|
76
|
-
|
50
|
+
# these ext attribs are related to these kinds of objects
|
77
51
|
TARGET_CLASS = JSS::MobileDevice
|
78
52
|
|
79
|
-
|
53
|
+
# A criterion that will return all members of the TARGET_CLASS
|
80
54
|
ALL_TARGETS_CRITERION = JSS::Criteriable::Criterion.new(and_or: 'and', name: 'Last Inventory Update', search_type: 'after (yyyy-mm-dd)', value: '2003-01-01')
|
81
55
|
|
82
56
|
# the object type for this object in
|
@@ -84,101 +58,44 @@ module JSS
|
|
84
58
|
# See {APIObject#add_object_history_entry}
|
85
59
|
OBJECT_HISTORY_OBJECT_TYPE = 86
|
86
60
|
|
87
|
-
|
88
|
-
### Attributes
|
89
|
-
######################
|
90
|
-
|
91
|
-
### @return [String] the name of the LDAP attribute to use when the @input Type is "LDAP Attribute Mapping"
|
92
|
-
attr_reader :attribute_mapping
|
93
|
-
|
94
|
-
#####################################
|
95
|
-
### Constructor
|
96
|
-
#####################################
|
97
|
-
|
98
|
-
###
|
99
|
-
### See JSS::APIObject.initialize
|
100
|
-
###
|
101
|
-
def initialize(args = {})
|
102
|
-
super args
|
103
|
-
@attribute_mapping = @init_data[:input_type][:attribute_mapping] if @init_data[:input_type]
|
104
|
-
end # init
|
105
|
-
|
106
|
-
#####################################
|
107
|
-
### Public Instance Methods
|
61
|
+
# Public Instance Methods
|
108
62
|
#####################################
|
109
63
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
if @input_type == 'LDAP Attribute Mapping'
|
115
|
-
raise MissingDataError, "No attribute_mapping defined for 'LDAP Attribute Mapping' input_type." unless @attribute_mapping
|
116
|
-
end
|
117
|
-
super
|
118
|
-
end
|
64
|
+
# @see JSS::ExtensionAttribute#web_display=
|
65
|
+
#
|
66
|
+
def web_display=(new_val)
|
67
|
+
raise JSS::InvalidDataError, "Mobile Device Extension Attributes web_display cannot be '#{WEB_DISPLAY_CHOICE_OS}'" if new_val == WEB_DISPLAY_CHOICE_OS
|
119
68
|
|
120
|
-
###
|
121
|
-
### @see JSS::ExtensionAttribute#web_display=
|
122
|
-
###
|
123
|
-
def web_display= (new_val)
|
124
|
-
raise JSS::InvalidDataError, "web_display cannot be 'Operating System' for Mobile Device Extension Attributes." if new_val == 'Operating System'
|
125
69
|
super
|
126
70
|
end # end web_display
|
127
71
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
def input_type= (new_val)
|
133
|
-
raise JSS::InvalidDataError, "Mobile Device Extension Attribute input_type cannot be 'script'" if new_val == 'script'
|
72
|
+
# @see JSS::ExtensionAttribute#input_type=
|
73
|
+
#
|
74
|
+
def input_type=(new_val)
|
75
|
+
raise JSS::InvalidDataError, "Mobile Device Extension Attribute input_type cannot be '#{INPUT_TYPE_SCRIPT}'" if new_val == INPUT_TYPE_SCRIPT
|
134
76
|
|
135
77
|
super
|
136
|
-
|
137
|
-
if @input_type == 'LDAP Attribute Mapping'
|
138
|
-
@popup_choices = nil
|
139
|
-
else
|
140
|
-
@attribute_mapping = nil
|
141
|
-
end
|
142
78
|
end # end input_type
|
143
79
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
###
|
159
|
-
### Each hash contains these 2 keys:
|
160
|
-
### * :value - String, Integer, or Time, depending on @data_type
|
161
|
-
### * :timestamp - Time
|
162
|
-
###
|
163
|
-
### This method requires a MySQL database connection established via JSS::DB_CNX.connect
|
164
|
-
###
|
165
|
-
### @see JSS::DBConnection
|
166
|
-
###
|
167
|
-
### @param mobiledevice[Integer,String] the id or name of the MobileDevice.
|
168
|
-
###
|
169
|
-
### @return [Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>]
|
170
|
-
###
|
80
|
+
# Return an Array of Hashes showing the history of reported values for this EA on one MobileDevice.
|
81
|
+
#
|
82
|
+
# Each hash contains these 2 keys:
|
83
|
+
# * :value - String, Integer, or Time, depending on @data_type
|
84
|
+
# * :timestamp - Time
|
85
|
+
#
|
86
|
+
# This method requires a MySQL database connection established via JSS::DB_CNX.connect
|
87
|
+
#
|
88
|
+
# @see JSS::DBConnection
|
89
|
+
#
|
90
|
+
# @param mobiledevice[Integer,String] the id or name of the MobileDevice.
|
91
|
+
#
|
92
|
+
# @return [Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>]
|
93
|
+
#
|
171
94
|
def history(mobiledevice)
|
172
95
|
raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{RSRC_OBJECT_KEY}." unless @in_jss
|
173
96
|
raise JSS::InvalidConnectionError, "Database connection required for 'history' query." unless JSS::DB_CNX.connected?
|
174
97
|
|
175
|
-
mobile_device_id =
|
176
|
-
when *JSS::MobileDevice.all_ids(api: @api)
|
177
|
-
mobiledevice
|
178
|
-
when *JSS::MobileDevice.all_names(api: @api)
|
179
|
-
JSS::MobileDevice.map_all_ids_to(:name, api: @api).invert[mobiledevice]
|
180
|
-
end # case
|
181
|
-
|
98
|
+
mobile_device_id = JSS::MobileDevice.valid_id mobiledevice, api: @api
|
182
99
|
raise JSS::NoSuchItemError, "No MobileDevice found matching '#{mobiledevice}'" unless mobile_device_id
|
183
100
|
|
184
101
|
the_query = <<-END_Q
|
@@ -192,11 +109,12 @@ module JSS
|
|
192
109
|
qrez = JSS::DB_CNX.db.query the_query
|
193
110
|
history = []
|
194
111
|
qrez.each_hash do |entry|
|
195
|
-
value =
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
112
|
+
value =
|
113
|
+
case @data_type
|
114
|
+
when 'String' then entry['value']
|
115
|
+
when 'Integer' then entry['value'].to_i
|
116
|
+
when 'Date' then JSS.parse_datetime(entry['value'])
|
117
|
+
end # case
|
200
118
|
newhash = { value: value, timestamp: JSS.epoch_to_time(entry['timestamp_epoch']) }
|
201
119
|
history << newhash
|
202
120
|
end # each hash
|
@@ -204,29 +122,6 @@ module JSS
|
|
204
122
|
history
|
205
123
|
end # history
|
206
124
|
|
207
|
-
######################
|
208
|
-
### Private Instance Methods
|
209
|
-
#####################
|
210
|
-
|
211
|
-
private
|
212
|
-
|
213
|
-
###
|
214
|
-
### Return the REST XML for this item, with the current values,
|
215
|
-
### for saving or updating
|
216
|
-
###
|
217
|
-
def rest_xml
|
218
|
-
mdea = rest_rexml
|
219
|
-
if @input_type == 'LDAP Attribute Mapping'
|
220
|
-
it = mdea.elements["input_type"]
|
221
|
-
it.add_element('attribute_mapping').text = @attribute_mapping
|
222
|
-
end
|
223
|
-
|
224
|
-
doc = REXML::Document.new APIConnection::XML_HEADER
|
225
|
-
doc << mdea
|
226
|
-
|
227
|
-
doc.to_s
|
228
|
-
end # rest xml
|
229
|
-
|
230
125
|
end # class ExtAttrib
|
231
126
|
|
232
127
|
end # module
|
@@ -1,120 +1,79 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
### language governing permissions and limitations under the Apache License.
|
23
|
-
###
|
24
|
-
###
|
25
|
-
|
26
|
-
###
|
27
|
-
module JSS
|
28
|
-
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
# with the following modification; you may not use this file except in
|
5
|
+
# compliance with the Apache License and the following modification to it:
|
6
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
#
|
8
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
# names, trademarks, service marks, or product names of the Licensor
|
10
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
# the License and to reproduce the content of the NOTICE file.
|
12
|
+
#
|
13
|
+
# You may obtain a copy of the Apache License at
|
14
|
+
#
|
15
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
#
|
17
|
+
# Unless required by applicable law or agreed to in writing, software
|
18
|
+
# distributed under the Apache License with the above modification is
|
19
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
# KIND, either express or implied. See the Apache License for the specific
|
21
|
+
# language governing permissions and limitations under the Apache License.
|
29
22
|
|
23
|
+
module JSS
|
30
24
|
|
25
|
+
# Classes
|
31
26
|
#####################################
|
32
|
-
### Constants
|
33
|
-
#####################################
|
34
|
-
|
35
|
-
#####################################
|
36
|
-
### Module Variables
|
37
|
-
#####################################
|
38
|
-
|
39
|
-
#####################################
|
40
|
-
### Module Methods
|
41
|
-
#####################################
|
42
|
-
|
43
|
-
####################################
|
44
|
-
### Classes
|
45
|
-
#####################################
|
46
|
-
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
###
|
28
|
+
# A User extension attribute as defined in the JSS
|
29
|
+
#
|
30
|
+
# @see JSS::ExtensionAttribute
|
31
|
+
# @see JSS::APIObject
|
32
|
+
#
|
54
33
|
class UserExtensionAttribute < JSS::ExtensionAttribute
|
55
34
|
|
56
|
-
|
57
|
-
### Mix-Ins
|
58
|
-
#####################################
|
59
|
-
|
60
|
-
#####################################
|
61
|
-
### Class Methods
|
62
|
-
#####################################
|
63
|
-
|
64
|
-
#####################################
|
65
|
-
### Class Constants
|
35
|
+
# Class Constants
|
66
36
|
#####################################
|
67
37
|
|
68
|
-
|
69
|
-
RSRC_BASE =
|
38
|
+
# The base for REST resources of this class
|
39
|
+
RSRC_BASE = 'userextensionattributes'.freeze
|
70
40
|
|
71
|
-
|
41
|
+
# the hash key used for the JSON list output of all objects in the JSS
|
72
42
|
RSRC_LIST_KEY = :user_extension_attributes
|
73
43
|
|
74
|
-
|
75
|
-
|
44
|
+
# The hash key used for the JSON object output.
|
45
|
+
# It's also used in various error messages
|
76
46
|
RSRC_OBJECT_KEY = :user_extension_attribute
|
77
47
|
|
78
|
-
|
48
|
+
# these ext attribs are related to these kinds of objects
|
79
49
|
TARGET_CLASS = JSS::User
|
80
50
|
|
81
|
-
|
82
|
-
ALL_TARGETS_CRITERION = JSS::Criteriable::Criterion.new(:
|
51
|
+
# A criterion that will return all members of the TARGET_CLASS
|
52
|
+
ALL_TARGETS_CRITERION = JSS::Criteriable::Criterion.new(and_or: 'and', name: 'Username', search_type: 'like', value: '')
|
83
53
|
|
84
54
|
# the object type for this object in
|
85
55
|
# the object history table.
|
86
56
|
# See {APIObject#add_object_history_entry}
|
87
57
|
OBJECT_HISTORY_OBJECT_TYPE = 87
|
88
58
|
|
89
|
-
|
90
|
-
### Attributes
|
91
|
-
######################
|
92
|
-
|
93
|
-
#####################################
|
94
|
-
### Constructor
|
59
|
+
# Public Instance Methods
|
95
60
|
#####################################
|
96
61
|
|
97
|
-
|
98
|
-
|
99
|
-
|
62
|
+
# @see JSS::ExtensionAttribute#input_type=
|
63
|
+
#
|
64
|
+
def input_type=(new_val)
|
65
|
+
raise JSS::InvalidDataError, "User Extension Attribute input_type cannot be '#{INPUT_TYPE_SCRIPT}'" if new_val == INPUT_TYPE_SCRIPT
|
66
|
+
raise JSS::InvalidDataError, "User Extension Attribute input_type cannot be '#{INPUT_TYPE_LDAP}'" if new_val == INPUT_TYPE_LDAP
|
100
67
|
|
101
|
-
|
102
|
-
|
103
|
-
#####################
|
104
|
-
private
|
105
|
-
|
106
|
-
###
|
107
|
-
### Return the REST XML for this item, with the current values,
|
108
|
-
### for saving or updating
|
109
|
-
###
|
110
|
-
def rest_xml
|
111
|
-
uea = rest_rexml
|
112
|
-
doc = REXML::Document.new APIConnection::XML_HEADER
|
113
|
-
doc << uea
|
114
|
-
return doc.to_s
|
115
|
-
end # rest xml
|
68
|
+
super
|
69
|
+
end # end input_type
|
116
70
|
|
117
|
-
|
71
|
+
# @see JSS::ExtensionAttribute#web_display=
|
72
|
+
#
|
73
|
+
def web_display=(_new_val)
|
74
|
+
raise JSS::UnsupportedError, 'User Extension Attributes web_display cannot be set'
|
75
|
+
end
|
118
76
|
|
77
|
+
end # class ExtAttrib
|
119
78
|
|
120
79
|
end # module
|