ruby-jss 1.2.9 → 1.2.10
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 +14 -0
- data/lib/jss/api_object/computer.rb +5 -1
- data/lib/jss/api_object/extendable.rb +67 -31
- data/lib/jss/api_object/mobile_device.rb +3 -0
- data/lib/jss/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0734256ff4d9e553418ff9e0189e85cbb455751e682af0278dfff3f85f9a6070
|
4
|
+
data.tar.gz: 40fde852a9d6f4cc22a804b0240038bdb17d319e1d51edaa8c974ad50d05861d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 721bc4ef63c7c1114a66bb772a609c4589879977e65922eb008dacf478ea17cc09a78e367e4a8297b46139b9d08f5d16fa6ffa7e0516af6c7ccc571ab37e39da
|
7
|
+
data.tar.gz: 0d8788ff29178d488fc11da8fa4c77c3ca5b40c8a770979cc7bf11bb8ab727f43315e2632ed74c8ae9685d79142e2536e1239624c236ba218fc2de5c70adddd4
|
data/CHANGES.md
CHANGED
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## \[1.2.10] - 2020-04-25
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Computer#reported_ip_address. This value is collected in newer versions of Jamf Pro. While the #ip_address is the client's IP address from the Jamf Server's perspective, the #reported_ip_address is the IP from the client's perspective, which may be different on a NATted network like a home network.
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- MobileDevice#upload now works like Computer#upload
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Validation of Ext. Attribute values is improved, namely for EAs with integer values, integer-strings like "12" are accepted and converted to real integers as needed.
|
20
|
+
|
7
21
|
## \[1.2.9] - 2020-04-13
|
8
22
|
|
9
23
|
### Fixed
|
@@ -529,9 +529,12 @@ module JSS
|
|
529
529
|
# @return [Time] when was it added to the JSS
|
530
530
|
attr_reader :initial_entry_date
|
531
531
|
|
532
|
-
# @return [IPAddr] the last known IP address
|
532
|
+
# @return [IPAddr] the last known IP address from the server's perspective
|
533
533
|
attr_reader :ip_address
|
534
534
|
|
535
|
+
# @return [IPAddr] the last known IP address from the client's perspecive
|
536
|
+
attr_reader :reported_ip_address
|
537
|
+
|
535
538
|
# @return [Boolean]
|
536
539
|
attr_reader :itunes_store_account_is_active
|
537
540
|
|
@@ -784,6 +787,7 @@ module JSS
|
|
784
787
|
@initial_entry_date = JSS.epoch_to_time @init_data[:general][:initial_entry_date_epoch]
|
785
788
|
@last_enrolled = JSS.epoch_to_time @init_data[:general][:last_enrolled_date_epoch]
|
786
789
|
@ip_address = @init_data[:general][:ip_address]
|
790
|
+
@reported_ip_address = @init_data[:general][:last_reported_ip]
|
787
791
|
@itunes_store_account_is_active = @init_data[:general][:itunes_store_account_is_active]
|
788
792
|
@jamf_version = @init_data[:general][:jamf_version]
|
789
793
|
@last_contact_time = JSS.epoch_to_time @init_data[:general][:last_contact_time_epoch]
|
@@ -180,34 +180,21 @@ module JSS
|
|
180
180
|
#
|
181
181
|
# @return [void]
|
182
182
|
#
|
183
|
-
def set_ext_attr(
|
184
|
-
raise ArgumentError, "Unknown Extension Attribute Name: '#{
|
183
|
+
def set_ext_attr(ea_name, value, validate_popup_choice: true, refresh: false)
|
184
|
+
raise ArgumentError, "Unknown Extension Attribute Name: '#{ea_name}'" unless ea_types.key? ea_name
|
185
185
|
|
186
|
-
value
|
187
|
-
validate_popup_value(name, value, refresh) if validate_popup_choice
|
188
|
-
|
189
|
-
value =
|
190
|
-
case ea_types[name]
|
191
|
-
when JSS::ExtensionAttribute::DATA_TYPE_DATE # date
|
192
|
-
JSS.parse_datetime(value).to_s
|
193
|
-
when *JSS::ExtensionAttribute::NUMERIC_TYPES # integer
|
194
|
-
if value.is_a? Integer
|
195
|
-
value
|
196
|
-
elsif value.to_s.jss_integer?
|
197
|
-
value.to_s.to_i
|
198
|
-
else
|
199
|
-
raise JSS::InvalidDataError, "The value for #{name} must be an integer"
|
200
|
-
end # if
|
201
|
-
else # string
|
202
|
-
value.to_s
|
203
|
-
end # case
|
186
|
+
value = validate_ea_value(ea_name, value, validate_popup_choice, refresh)
|
204
187
|
|
205
188
|
# update this ea hash in the @extension_attributes array
|
206
|
-
@extension_attributes.
|
189
|
+
ea_hash = @extension_attributes.find { |ea| ea[:name] == ea_name }
|
190
|
+
|
191
|
+
raise JSS::NoSuchItemError, "#{self.class} '#{name}'(id #{id}) does not know about ExtAttr '#{ea_name}'. Please re-fetch and try again." unless ea_hash
|
192
|
+
|
193
|
+
ea_hash[:value] = value
|
207
194
|
|
208
195
|
# update the shortcut hash too
|
209
|
-
@ext_attrs[
|
210
|
-
@changed_eas <<
|
196
|
+
@ext_attrs[ea_name] = value if @ext_attrs
|
197
|
+
@changed_eas << ea_name
|
211
198
|
@need_to_update = true
|
212
199
|
end
|
213
200
|
|
@@ -251,22 +238,71 @@ module JSS
|
|
251
238
|
eaxml
|
252
239
|
end
|
253
240
|
|
254
|
-
#
|
255
|
-
|
256
|
-
|
257
|
-
|
241
|
+
# is the value being passed to set_ext_attr valid?
|
242
|
+
# Converts values as needed (e.g. strings to integers or Times)
|
243
|
+
#
|
244
|
+
# If the EA is defined to hold a string, any value is accepted and
|
245
|
+
# converted with #to_s
|
246
|
+
#
|
247
|
+
# Note: All EAs can be blank
|
248
|
+
#
|
249
|
+
# @param name[String] the name of the extension attribute to set
|
250
|
+
#
|
251
|
+
# @param value[String,Time,Integer] the new value for the extension
|
252
|
+
# attribute for this user
|
253
|
+
#
|
254
|
+
# @param validate_popup_choice[Boolean] validate the new value against the E.A. definition.
|
255
|
+
# Defaults to true.
|
256
|
+
#
|
257
|
+
# @param refresh[Boolean] Re-read the ext. attrib definition from the API,
|
258
|
+
# for popup validation.
|
259
|
+
#
|
260
|
+
# @return [Object] the possibly modified valid value
|
261
|
+
#
|
262
|
+
def validate_ea_value(ea_name, value, validate_popup_choice, refresh)
|
263
|
+
return JSS::BLANK if value.to_s == JSS::BLANK
|
264
|
+
|
265
|
+
value =
|
266
|
+
case ea_types[ea_name]
|
267
|
+
when JSS::ExtensionAttribute::DATA_TYPE_DATE
|
268
|
+
JSS.parse_datetime(value).to_s
|
269
|
+
when *JSS::ExtensionAttribute::NUMERIC_TYPES
|
270
|
+
validate_integer_ea_value ea_name, value
|
271
|
+
else
|
272
|
+
value.to_s
|
273
|
+
end # case
|
274
|
+
|
275
|
+
validate_popup_value(ea_name, value, refresh) if validate_popup_choice
|
276
|
+
|
277
|
+
value
|
278
|
+
end
|
279
|
+
|
280
|
+
# raise error if the value isn't an integer
|
281
|
+
def validate_integer_ea_value(ea_name, value)
|
282
|
+
if value.is_a? Integer
|
283
|
+
value
|
284
|
+
elsif value.to_s.jss_integer?
|
285
|
+
value.to_s.to_i
|
286
|
+
else
|
287
|
+
raise JSS::InvalidDataError, "The value for #{ea_name} must be an integer"
|
288
|
+
end # if
|
289
|
+
end
|
258
290
|
|
291
|
+
# Raise an error if the named EA has a popup menu,
|
292
|
+
# but the provided value isn't one of the menu items
|
293
|
+
#
|
294
|
+
def validate_popup_value(ea_name, value, refresh)
|
259
295
|
# get the ea def. instance from the api cache, or the api
|
260
296
|
api.ext_attr_definition_cache[self.class] ||= {}
|
261
|
-
api.ext_attr_definition_cache[self.class][
|
262
|
-
api.ext_attr_definition_cache[self.class][
|
297
|
+
api.ext_attr_definition_cache[self.class][ea_name] = nil if refresh
|
298
|
+
api.ext_attr_definition_cache[self.class][ea_name] ||= self.class::EXT_ATTRIB_CLASS.fetch name: ea_name, api: api
|
263
299
|
|
264
|
-
ea_def = api.ext_attr_definition_cache[self.class][
|
300
|
+
ea_def = api.ext_attr_definition_cache[self.class][ea_name]
|
265
301
|
return unless ea_def.from_popup_menu?
|
266
302
|
|
267
303
|
return if ea_def.popup_choices.include? value.to_s
|
268
304
|
|
269
|
-
raise JSS::UnsupportedError, "The value for #{
|
305
|
+
raise JSS::UnsupportedError, "The value for #{ea_name} must be one of: '#{ea_def.popup_choices.join("' '")}'"
|
270
306
|
end
|
271
307
|
|
272
308
|
end # module extendable
|
@@ -132,6 +132,9 @@ module JSS
|
|
132
132
|
|
133
133
|
NON_UNIQUE_NAMES = true
|
134
134
|
|
135
|
+
# file uploads can send attachments to the JSS using :mobiledevices as the sub-resource.
|
136
|
+
UPLOAD_TYPES = { attachment: :mobiledevices }.freeze
|
137
|
+
|
135
138
|
# This class lets us seach for computers
|
136
139
|
SEARCH_CLASS = JSS::AdvancedMobileDeviceSearch
|
137
140
|
|
data/lib/jss/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-04-
|
12
|
+
date: 2020-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plist
|