ruby-jss 1.3.3 → 1.4.1
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 +47 -0
- data/lib/jamf/api/connection.rb +1 -1
- data/lib/jamf/api/connection/token.rb +21 -1
- data/lib/jamf/api/resources/collection_resources/department.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +3 -3
- data/lib/jamf/version.rb +1 -1
- data/lib/jss/api_object.rb +7 -1
- data/lib/jss/api_object/advanced_search.rb +27 -26
- data/lib/jss/api_object/app_store_country_codes.rb +298 -0
- data/lib/jss/api_object/ebook.rb +1 -2
- data/lib/jss/api_object/extension_attribute.rb +4 -3
- data/lib/jss/api_object/mac_application.rb +107 -8
- data/lib/jss/api_object/policy.rb +112 -3
- data/lib/jss/api_object/scopable/scope.rb +366 -51
- data/lib/jss/api_object/self_servable.rb +17 -9
- data/lib/jss/api_object/uploadable.rb +1 -1
- data/lib/jss/api_object/user.rb +42 -1
- data/lib/jss/api_object/vpp_account.rb +209 -0
- data/lib/jss/api_object/vppable.rb +169 -13
- data/lib/jss/validate.rb +53 -10
- data/lib/jss/version.rb +1 -1
- metadata +4 -2
data/lib/jss/validate.rb
CHANGED
@@ -111,8 +111,8 @@ module JSS
|
|
111
111
|
|
112
112
|
# Confirm that the given value is a boolean value, accepting
|
113
113
|
# strings and symbols and returning real booleans as needed
|
114
|
-
# Accepts: true, false, 'true', 'false',
|
115
|
-
#
|
114
|
+
# Accepts: true, false, 'true', 'false', 'yes', 'no', 't','f', 'y', or 'n'
|
115
|
+
# as strings or symbols, case insensitive
|
116
116
|
#
|
117
117
|
# TODO: use this throughout ruby-jss
|
118
118
|
#
|
@@ -123,11 +123,11 @@ module JSS
|
|
123
123
|
# @return [Boolean] the valid boolean
|
124
124
|
#
|
125
125
|
def self.boolean(bool, msg = nil)
|
126
|
-
msg ||= 'Value must be boolean true or false'
|
127
126
|
return bool if JSS::TRUE_FALSE.include? bool
|
128
|
-
return true if bool.to_s =~ /^(
|
129
|
-
return false if bool.to_s =~ /^(
|
127
|
+
return true if bool.to_s =~ /^(t(rue)?|y(es)?)$/i
|
128
|
+
return false if bool.to_s =~ /^(f(alse)?|no?)$/i
|
130
129
|
|
130
|
+
msg ||= 'Value must be boolean true or false, or an equivalent string or symbol'
|
131
131
|
raise JSS::InvalidDataError, msg
|
132
132
|
end
|
133
133
|
|
@@ -176,10 +176,10 @@ module JSS
|
|
176
176
|
# @return [String] the valid uuid string
|
177
177
|
#
|
178
178
|
def self.uuid(val, msg = nil)
|
179
|
-
|
180
|
-
raise JSS::InvalidDataError, msg unless val.is_a?(String) && val =~ UUID_RE
|
179
|
+
return val if val.is_a?(String) && val =~ UUID_RE
|
181
180
|
|
182
|
-
|
181
|
+
msg ||= 'value must be valid uuid'
|
182
|
+
raise JSS::InvalidDataError, msg
|
183
183
|
end
|
184
184
|
|
185
185
|
# validate that the given value is an integer in the JSS::IBeacon::MAJOR_MINOR_RANGE
|
@@ -191,13 +191,56 @@ module JSS
|
|
191
191
|
# @return [String] the valid integer
|
192
192
|
#
|
193
193
|
def self.ibeacon_major_minor(val, msg = nil)
|
194
|
-
msg ||= "value must be an integer in the range #{JSS::IBeacon::MAJOR_MINOR_RANGE}"
|
195
194
|
val = val.to_i if val.is_a?(String) && val.jss_integer?
|
196
195
|
ok = val.is_a? Integer
|
197
196
|
ok = JSS::IBeacon::MAJOR_MINOR_RANGE.include? val if ok
|
197
|
+
return val if ok
|
198
|
+
|
199
|
+
msg ||= "value must be an integer in the range #{JSS::IBeacon::MAJOR_MINOR_RANGE}"
|
198
200
|
raise JSS::InvalidDataError, msg unless ok
|
201
|
+
end
|
199
202
|
|
200
|
-
|
203
|
+
# validate a country name or code from JSS::APP_STORE_COUNTRY_CODES
|
204
|
+
# returning the validated code, or raising an error
|
205
|
+
#
|
206
|
+
# @param country[String] The country name or code
|
207
|
+
#
|
208
|
+
# @param msg[String] A custom error message when the value is invalid
|
209
|
+
#
|
210
|
+
# @return [String] the valid two-letter country code
|
211
|
+
#
|
212
|
+
def self.app_store_country_code(country, msg = nil)
|
213
|
+
country = country.to_s.upcase
|
214
|
+
return country if JSS::APP_STORE_COUNTRY_CODES.value? country
|
215
|
+
|
216
|
+
JSS::APP_STORE_COUNTRY_CODES.each do |name, code|
|
217
|
+
return code if name.upcase == country
|
218
|
+
end
|
219
|
+
|
220
|
+
msg ||= 'Unknown country name or code. See JSS::APP_STORE_COUNTRY_CODES or JSS.country_code_match(str)'
|
221
|
+
raise JSS::InvalidDataError, msg
|
222
|
+
end
|
223
|
+
|
224
|
+
# validate an email address - must match the RegEx /^\S+@\S+\.\S+$/
|
225
|
+
# i.e.:
|
226
|
+
# 1 or more non-whitespace chars, followed by
|
227
|
+
# an @ character, followed by
|
228
|
+
# 1 or more non-whitespace chars, followed by
|
229
|
+
# a dot, followed by
|
230
|
+
# 1 or more non-whitespace chars
|
231
|
+
#
|
232
|
+
# @param email[String] The email address
|
233
|
+
#
|
234
|
+
# @param msg[String] A custom error message when the value is invalid
|
235
|
+
#
|
236
|
+
# @return [String] the validly formatted email address
|
237
|
+
#
|
238
|
+
def self.email_address(email, msg = nil)
|
239
|
+
msg ||= "'#{email}' is not formatted as a valid email address"
|
240
|
+
email = email.to_s
|
241
|
+
return email if email =~ /^\S+@\S+\.\S+$/
|
242
|
+
|
243
|
+
raise JSS::InvalidDataError, msg
|
201
244
|
end
|
202
245
|
|
203
246
|
end # module validate
|
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.
|
4
|
+
version: 1.4.1
|
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-
|
12
|
+
date: 2020-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plist
|
@@ -264,6 +264,7 @@ files:
|
|
264
264
|
- lib/jss/api_object/advanced_search/advanced_computer_search.rb
|
265
265
|
- lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb
|
266
266
|
- lib/jss/api_object/advanced_search/advanced_user_search.rb
|
267
|
+
- lib/jss/api_object/app_store_country_codes.rb
|
267
268
|
- lib/jss/api_object/building.rb
|
268
269
|
- lib/jss/api_object/categorizable.rb
|
269
270
|
- lib/jss/api_object/category.rb
|
@@ -346,6 +347,7 @@ files:
|
|
346
347
|
- lib/jss/api_object/updatable.rb
|
347
348
|
- lib/jss/api_object/uploadable.rb
|
348
349
|
- lib/jss/api_object/user.rb
|
350
|
+
- lib/jss/api_object/vpp_account.rb
|
349
351
|
- lib/jss/api_object/vppable.rb
|
350
352
|
- lib/jss/api_object/webhook.rb
|
351
353
|
- lib/jss/client.rb
|