ruby-jss 1.4.1 → 1.5.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.

Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +38 -0
  3. data/lib/jamf.rb +10 -3
  4. data/lib/jamf/api/abstract_classes/collection_resource.rb +329 -150
  5. data/lib/jamf/api/abstract_classes/generic_reference.rb +9 -1
  6. data/lib/jamf/api/abstract_classes/json_object.rb +106 -82
  7. data/lib/jamf/api/abstract_classes/prestage.rb +54 -29
  8. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +21 -0
  9. data/lib/jamf/api/abstract_classes/resource.rb +4 -4
  10. data/lib/jamf/api/abstract_classes/singleton_resource.rb +1 -1
  11. data/lib/jamf/api/connection.rb +13 -9
  12. data/lib/jamf/api/connection/api_error.rb +8 -8
  13. data/lib/jamf/api/connection/token.rb +16 -15
  14. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +14 -1
  15. data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
  16. data/lib/jamf/api/json_objects/device_enrollment_device_sync_state.rb +81 -0
  17. data/lib/jamf/api/json_objects/locale.rb +59 -0
  18. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
  19. data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
  20. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
  21. data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
  22. data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
  23. data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
  24. data/lib/jamf/api/mixins/change_log.rb +201 -51
  25. data/lib/jamf/api/mixins/filterable.rb +51 -0
  26. data/lib/jamf/api/mixins/pageable.rb +208 -0
  27. data/lib/jamf/api/mixins/sortable.rb +59 -0
  28. data/lib/jamf/api/resources/collection_resources/building.rb +19 -8
  29. data/lib/jamf/api/resources/collection_resources/category.rb +5 -3
  30. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +11 -4
  31. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +10 -10
  32. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
  33. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +24 -22
  34. data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
  35. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
  36. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +14 -14
  37. data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
  38. data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
  39. data/lib/jamf/validate.rb +63 -24
  40. data/lib/jamf/version.rb +1 -1
  41. data/lib/jss.rb +2 -1
  42. data/lib/jss/api_connection.rb +110 -370
  43. data/lib/jss/api_object.rb +3 -19
  44. data/lib/jss/api_object/categorizable.rb +1 -1
  45. data/lib/jss/api_object/configuration_profile.rb +34 -3
  46. data/lib/jss/api_object/directory_binding_type.rb +66 -60
  47. data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
  48. data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
  49. data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
  50. data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
  51. data/lib/jss/api_object/distribution_point.rb +2 -2
  52. data/lib/jss/api_object/dock_item.rb +102 -96
  53. data/lib/jss/api_object/extendable.rb +1 -1
  54. data/lib/jss/api_object/group.rb +33 -2
  55. data/lib/jss/api_object/network_segment.rb +43 -12
  56. data/lib/jss/api_object/patch_source.rb +10 -9
  57. data/lib/jss/api_object/printer.rb +10 -4
  58. data/lib/jss/api_object/scopable.rb +10 -15
  59. data/lib/jss/exceptions.rb +3 -0
  60. data/lib/jss/server.rb +15 -0
  61. data/lib/jss/version.rb +1 -1
  62. metadata +37 -22
@@ -0,0 +1,155 @@
1
+ # Copyright 2020 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
+ # The Module
27
+ module Jamf
28
+
29
+ # Classes
30
+ #####################################
31
+
32
+ # A list of known timezones
33
+ class Locales < Jamf::SingletonResource
34
+
35
+ # Mix-Ins
36
+ #####################################
37
+
38
+ extend Jamf::Immutable
39
+
40
+ # Constants
41
+ #####################################
42
+
43
+ RSRC_VERSION = 'v1'.freeze
44
+
45
+ RSRC_PATH = 'locales'.freeze
46
+
47
+ OBJECT_MODEL = {
48
+
49
+ # @!attribute checkInFrequency
50
+ # @return [integer]
51
+ locales: {
52
+ class: Jamf::Locale,
53
+ multi: true,
54
+ read_only: true,
55
+ aliases: [:list]
56
+ }
57
+
58
+ }.freeze # end OBJECT_MODEL
59
+
60
+ parse_object_model
61
+
62
+ # TEMP? until this endpoint is brought up to standards
63
+ # the data from the API is a raw Array, but it should be a
64
+ # Hash containing an array.
65
+ def initialize(data, cnx: Jamf.cnx)
66
+ data = { locales: data }
67
+ super data, cnx: cnx
68
+ end
69
+
70
+ # Class Methods
71
+ #####################################
72
+
73
+ # @return [Array<Jamf::Locale>] all the locales available
74
+ #
75
+ def self.list(refresh = false, cnx: Jamf.cnx)
76
+ fetch(refresh, cnx: cnx).locales
77
+ end
78
+
79
+ # Class level wrapper for #descriptions
80
+ def self.descriptions(refresh = false, cnx: Jamf.cnx)
81
+ fetch(refresh, cnx: cnx).descriptions
82
+ end
83
+ # how to alias a class method
84
+ singleton_class.send(:alias_method, :names, :descriptions)
85
+
86
+ # Class level wrapper for #identifiers
87
+ def self.identifiers(refresh = false, cnx: Jamf.cnx)
88
+ fetch(refresh, cnx: cnx).identifiers
89
+ end
90
+ singleton_class.send(:alias_method, :ids, :identifiers)
91
+
92
+ # Class level wrapper for #ids_by_desc
93
+ def self.ids_by_desc(refresh = false, cnx: Jamf.cnx)
94
+ fetch(refresh, cnx: cnx).ids_by_desc
95
+ end
96
+
97
+ # Class level wrapper for #descs_by_id
98
+ def self.descs_by_id(refresh = false, cnx: Jamf.cnx)
99
+ fetch(refresh, cnx: cnx).descs_by_id
100
+ end
101
+
102
+ # Class level wrapper for #id_for_desc
103
+ def self.id_for_desc(desc, refresh = false, cnx: Jamf.cnx)
104
+ fetch(refresh, cnx: cnx).id_for_desc desc
105
+ end
106
+
107
+ # Class level wrapper for #desc_for_id
108
+ def self.desc_for_id(id, refresh = false, cnx: Jamf.cnx)
109
+ fetch(refresh, cnx: cnx).desc_for_id id
110
+ end
111
+
112
+ # Instance Methods
113
+ #####################################
114
+
115
+ # @return [Array<String>] the available descriptions
116
+ def descriptions
117
+ @descriptions ||= locales.map(&:description)
118
+ end
119
+ alias names descriptions
120
+
121
+ # @return [Array<String>] the available identifiers
122
+ def identifiers
123
+ @identifiers ||= locales.map(&:identifier)
124
+ end
125
+ alias ids identifiers
126
+
127
+ # @return [Hash] name => code
128
+ def ids_by_desc
129
+ @ids_by_desc ||= locales.map { |l| [l.description, l.identifier] }.to_h
130
+ end
131
+
132
+ # @return [Hash] code => name
133
+ def descs_by_id
134
+ @descs_by_id ||= locales.map { |l| [l.identifier, l.description] }.to_h
135
+ end
136
+
137
+ # return an identifier from its description, case-insensitive
138
+ # @param desc[String] the description of a locale
139
+ # @return [String]
140
+ def id_for_desc(desc)
141
+ desc = descriptions.select { |n| n.casecmp? desc }.first
142
+ ids_by_desc[desc]
143
+ end
144
+
145
+ # return a description from its identifier, case-insensitive
146
+ # @param name[String] the identifier of a local
147
+ # @return [String]
148
+ def desc_for_id(id)
149
+ id = identifiers.select { |n| n.casecmp? id }.first
150
+ descs_by_id[id]
151
+ end
152
+
153
+ end # class
154
+
155
+ end # module
@@ -0,0 +1,213 @@
1
+ # Copyright 2020 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
+ # The Module
27
+ module Jamf
28
+
29
+ # Classes
30
+ #####################################
31
+
32
+ # A list of known timezones
33
+ class TimeZones < Jamf::SingletonResource
34
+
35
+ # Mix-Ins
36
+ #####################################
37
+
38
+ extend Jamf::Immutable
39
+
40
+ # Constants
41
+ #####################################
42
+
43
+ RSRC_VERSION = 'v1'.freeze
44
+
45
+ RSRC_PATH = 'time-zones'.freeze
46
+
47
+ OBJECT_MODEL = {
48
+
49
+ # @!attribute checkInFrequency
50
+ # @return [integer]
51
+ timeZones: {
52
+ class: Jamf::TimeZone,
53
+ multi: true,
54
+ read_only: true,
55
+ aliases: [:list]
56
+ }
57
+
58
+ }.freeze # end OBJECT_MODEL
59
+
60
+ parse_object_model
61
+
62
+ # TEMP? until this endpoint is brought up to standards
63
+ # the data from the API is a raw Array, but it should be a
64
+ # Hash containing an array.
65
+ def initialize(data, cnx: Jamf.cnx)
66
+ data = { timeZones: data }
67
+ super data, cnx: cnx
68
+ end
69
+
70
+
71
+
72
+ # Class Methods
73
+ #####################################
74
+
75
+ # @return [Array<Jamf::TimeZone>] all the zomes available
76
+ #
77
+ def self.list(refresh = false, cnx: Jamf.cnx)
78
+ fetch(refresh, cnx: cnx).timeZones
79
+ end
80
+
81
+ # Class level wrapper for #displayNames
82
+ def self.displayNames(refresh = false, cnx: Jamf.cnx)
83
+ fetch(refresh, cnx: cnx).displayNames
84
+ end
85
+ singleton_class.send(:alias_method, :names, :displayNames)
86
+
87
+ # Class level wrapper for #zoneIds
88
+ def self.zoneIds(refresh = false, cnx: Jamf.cnx)
89
+ fetch(refresh, cnx: cnx).zoneIds
90
+ end
91
+ singleton_class.send(:alias_method, :ids, :zoneIds)
92
+
93
+ # Class level wrapper for #regions
94
+ def self.regions(refresh = false, cnx: Jamf.cnx)
95
+ fetch(refresh, cnx: cnx).regions
96
+ end
97
+
98
+ # Class level wrapper for #ids_by_name
99
+ def self.ids_by_name(refresh = false, cnx: Jamf.cnx)
100
+ fetch(refresh, cnx: cnx).ids_by_name
101
+ end
102
+
103
+ # Class level wrapper for #names_by_id
104
+ def self.names_by_id(refresh = false, cnx: Jamf.cnx)
105
+ fetch(refresh, cnx: cnx).names_by_id
106
+ end
107
+
108
+ # Class level wrapper for #regions_by_id
109
+ def self.regions_by_id(refresh = false, cnx: Jamf.cnx)
110
+ fetch(refresh, cnx: cnx).regions_by_id
111
+ end
112
+
113
+ # Class level wrapper for #regions_by_name
114
+ def self.regions_by_name(refresh = false, cnx: Jamf.cnx)
115
+ fetch(refresh, cnx: cnx).regions_by_name
116
+ end
117
+
118
+ # Class level wrapper for #id_for_name
119
+ def self.id_for_name(name, refresh = false, cnx: Jamf.cnx)
120
+ fetch(refresh, cnx: cnx).id_for_name name
121
+ end
122
+
123
+ # Class level wrapper for #name_for_id
124
+ def self.name_for_id(id, refresh = false, cnx: Jamf.cnx)
125
+ fetch(refresh, cnx: cnx).name_for_id id
126
+ end
127
+
128
+ # Class level wrapper for #region_for_name
129
+ def self.region_for_name(name, refresh = false, cnx: Jamf.cnx)
130
+ fetch(refresh, cnx: cnx).region_for_name name
131
+ end
132
+
133
+ # Class level wrapper for #name_for_id
134
+ def self.region_for_id(id, refresh = false, cnx: Jamf.cnx)
135
+ fetch(refresh, cnx: cnx).region_for_id id
136
+ end
137
+
138
+
139
+ # Instance Methods
140
+ #####################################
141
+
142
+ # @return [Array<String>] the available zone names
143
+ def displayNames
144
+ @names ||= timeZones.map(&:displayName)
145
+ end
146
+ alias names displayNames
147
+
148
+ # @return [Array<String>] the available zone ids
149
+ def zoneIds
150
+ @ids ||= timeZones.map(&:zoneId)
151
+ end
152
+ alias ids zoneIds
153
+
154
+ # @return [Array<String>] the available zone regions
155
+ def regions
156
+ @regions ||= timeZones.map(&:region).uniq
157
+ end
158
+
159
+ # @return [Hash] name => id
160
+ def ids_by_name
161
+ @ids_by_name ||= timeZones.map { |tz| [tz.displayName, tz.zoneId] }.to_h
162
+ end
163
+
164
+ # @return [Hash] id => name
165
+ def names_by_id
166
+ @names_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.displayName] }.to_h
167
+ end
168
+
169
+ # @return [Hash] id => region
170
+ def regions_by_id
171
+ @regions_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.region] }.to_h
172
+ end
173
+
174
+ # @return [Hash] name => region
175
+ def regions_by_name
176
+ @regions_by_name ||= timeZones.map { |tz| [tz.displayName, tz.region] }.to_h
177
+ end
178
+
179
+ # return a zone id from its name, case-insensitive
180
+ # @param name[String] the name of a zone
181
+ # @return [String]
182
+ def id_for_name(name)
183
+ name = names.select { |n| n.casecmp? name }.first
184
+ ids_by_name[name]
185
+ end
186
+
187
+ # return a zone name from its id, case-insensitive
188
+ # @param name[String] the name of a zone
189
+ # @return [String]
190
+ def name_for_id(id)
191
+ id = ids.select { |n| n.casecmp? id }.first
192
+ names_by_id[id]
193
+ end
194
+
195
+ # return a zone name from its id, case-insensitive
196
+ # @param name[String] the name of a zone
197
+ # @return [String]
198
+ def region_for_name(name)
199
+ name = names.select { |n| n.casecmp? name }.first
200
+ regions_by_name[name]
201
+ end
202
+
203
+ # return a zones from its id, case-insensitive
204
+ # @param name[String] the name of a zone
205
+ # @return [String]
206
+ def region_for_id(id)
207
+ id = ids.select { |n| n.casecmp? id }.first
208
+ regions_by_id[id]
209
+ end
210
+
211
+ end # class
212
+
213
+ end # module
@@ -37,7 +37,7 @@ module Jamf
37
37
  module Validate
38
38
 
39
39
  # The regular expression that matches a valid MAC address.
40
- MAC_ADDR_RE = /^[a-f0-9]{2}(:[a-f0-9]{2}){5}$/i
40
+ MAC_ADDR_RE = /^[a-f0-9]{2}(:[a-f0-9]{2}){5}$/i.freeze
41
41
 
42
42
  # Validate the format and content of a MAC address
43
43
  #
@@ -50,6 +50,7 @@ module Jamf
50
50
  def self.mac_address(val, msg = nil)
51
51
  msg ||= "Not a valid MAC address: '#{val}'"
52
52
  raise Jamf::InvalidDataError, msg unless val =~ MAC_ADDR_RE
53
+
53
54
  val
54
55
  end
55
56
 
@@ -68,10 +69,11 @@ module Jamf
68
69
  ok = false unless parts.size == 4
69
70
  parts.each { |p| ok = false unless p.j_integer? && p.to_i < 256 && p.to_i >= 0 }
70
71
  raise Jamf::InvalidDataError, msg unless ok
72
+
71
73
  val
72
74
  end
73
75
 
74
- # Does a give JSONObject class have a given JSON attribute?
76
+ # Does a given JSONObject class have a given JSON attribute?
75
77
  #
76
78
  # @param klass [<JSONObject] A class descended from JSONObject
77
79
  #
@@ -83,9 +85,24 @@ module Jamf
83
85
  raise "#{klass} is not a descendent of JSONObject" unless klass < Jamf::JSONObject
84
86
 
85
87
  raise Jamf::NoSuchItemError, "No attribute #{attr_name} for class #{klass}" unless klass::OBJECT_MODEL.key? attrib
88
+
86
89
  attr_name
87
90
  end
88
91
 
92
+ # Does a value exist in a given enum array?
93
+ #
94
+ # @param klass [<JSONObject] A class descended from JSONObject
95
+ #
96
+ # @param attr_name [Symbol] The attribute to validate
97
+ #
98
+ # @return [Symbol] The valid attribute
99
+ #
100
+ def self.in_enum(val, enum)
101
+ raise Jamf::InvalidDataError, "Value must be one of: #{enum.join ', '}" unless enum.include? val
102
+
103
+ val
104
+ end
105
+
89
106
  # Validate that a value doesn't already exist for a given identifier of
90
107
  # a given CollectionResource class
91
108
  #
@@ -116,14 +133,12 @@ module Jamf
116
133
  raise Jamf::AlreadyExistsError, msg
117
134
  end
118
135
 
136
+ TRUE_FALSE = [true, false].freeze
137
+
119
138
  # Confirm that the given value is a boolean value, accepting
120
- # Strings and Symbols, returning real booleans as needed
121
- #
122
- # Accepted True values: true, 'true', :true, 'yes', :yes
123
- #
124
- # Accepted False values: false, 'false', :false, 'no', :no
125
- #
126
- # all Strings and Symbols are case insensitive
139
+ # strings and symbols and returning real booleans as needed
140
+ # Accepts: true, false, 'true', 'false', 'yes', 'no', 't','f', 'y', or 'n'
141
+ # as strings or symbols, case insensitive
127
142
  #
128
143
  # @param val [Boolean,String,Symbol] The value to validate
129
144
  #
@@ -131,14 +146,36 @@ module Jamf
131
146
  #
132
147
  # @return [Boolean] the valid boolean
133
148
  #
134
- def self.boolean(val, msg = nil)
135
- msg ||= 'Value must be boolean true or false'
136
- return true if val.to_s =~ /^(true|yes)$/i
137
- return false if val.to_s =~ /^(false|no)$/i
149
+ def self.boolean(val, msg = 'Value must be true or false, or equivalent string or symbol')
150
+ return val if TRUE_FALSE.include? val
151
+ return true if val.to_s =~ /^(t(rue)?|y(es)?)$/i
152
+ return false if val.to_s =~ /^(f(alse)?|no?)$/i
138
153
 
139
154
  raise Jamf::InvalidDataError, msg
140
155
  end
141
156
 
157
+ # Confirm that a value provided is an integer or a string version
158
+ # of an integer, and return the string version
159
+ #
160
+ # The JPAPI specs say that all IDs are integers in strings
161
+ # tho, the endpoints are still implementing that in different versions.
162
+ #
163
+ # @param val[Object] the value to validate
164
+ #
165
+ # @param msg[String] A custom error message when the value is invalid
166
+ #
167
+ # @return [String] the valid integer-in-a-string
168
+ #
169
+ def self.j_id(val, msg = 'Value must be an Integer or an Integer in a String, e.g. "42"')
170
+ case val
171
+ when Integer
172
+ return val.to_s
173
+ when String
174
+ return val if val.j_integer?
175
+ end
176
+ raise Jamf::InvalidDataError, msg
177
+ end
178
+
142
179
  # Confirm that a value is an Integer or a String representation of an
143
180
  # Integer. Return the integer, or raise an error
144
181
  #
@@ -148,10 +185,10 @@ module Jamf
148
185
  #
149
186
  # @return [Integer] the valid integer
150
187
  #
151
- def self.integer(val, msg = nil)
152
- msg ||= 'Value must be an Integer'
188
+ def self.integer(val, msg = 'Value must be an Integer')
153
189
  val = val.to_i if val.is_a?(String) && val.j_integer?
154
190
  raise Jamf::InvalidDataError, msg unless val.is_a? Integer
191
+
155
192
  val
156
193
  end
157
194
 
@@ -164,10 +201,10 @@ module Jamf
164
201
  #
165
202
  # @return [Float] the valid float
166
203
  #
167
- def self.float(val, msg = nil)
168
- msg ||= 'Value must be a Floating Point number'
204
+ def self.float(val, msg = 'Value must be a Floating Point number')
169
205
  val = val.to_f if val.is_a?(String) && val.j_float?
170
- raise Jamf::InvalidDataError, msg unless val.is_a? Flot
206
+ raise Jamf::InvalidDataError, msg unless val.is_a? Float
207
+
171
208
  val
172
209
  end
173
210
 
@@ -180,11 +217,12 @@ module Jamf
180
217
  #
181
218
  # @return [String] the valid String
182
219
  #
183
- def self.string(val, msg = nil)
184
- msg ||= 'Value must be a String'
220
+ def self.string(val, msg = 'Value must be a String')
185
221
  return Jamf::BLANK if val.nil?
222
+
186
223
  val = val.to_s if val.is_a? Symbol
187
224
  raise Jamf::InvalidDataError, msg unless val.is_a? String
225
+
188
226
  val
189
227
  end
190
228
 
@@ -197,10 +235,10 @@ module Jamf
197
235
  #
198
236
  # @return [String] the valid non-empty string
199
237
  #
200
- def self.non_empty_string(val, msg = nil)
201
- msg ||= 'value must be a non-empty String'
238
+ def self.non_empty_string(val, msg = 'value must be a non-empty String')
202
239
  val = val.to_s if val.is_a? Symbol
203
240
  raise Jamf::InvalidDataError, msg unless val.is_a?(String) && !val.empty?
241
+
204
242
  val
205
243
  end
206
244
 
@@ -214,11 +252,12 @@ module Jamf
214
252
  #
215
253
  # @return [String] the validated string
216
254
  #
217
- def self.script_contents(val, msg = nil)
218
- msg ||= "value must be a String starting with '#!'"
255
+ def self.script_contents(val, msg = "value must be a String starting with '#!'")
219
256
  raise Jamf::InvalidDataError, msg unless val.is_a?(String) && val.start_with?(SCRIPT_SHEBANG)
257
+
220
258
  val
221
259
  end
260
+
222
261
  end # module validate
223
262
 
224
263
  end # module JSS