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
@@ -61,9 +61,9 @@ module Jamf
61
61
  OBJECT_MODEL = {
62
62
 
63
63
  # @!attribute id
64
- # @return [Integer]
64
+ # @return [String]
65
65
  id: {
66
- class: :integer,
66
+ class: :j_id,
67
67
  identifier: :primary,
68
68
  readonly: true
69
69
  },
@@ -76,15 +76,15 @@ module Jamf
76
76
  },
77
77
 
78
78
  # @!attribute supervisionIdentityId
79
- # @return [Integer]
79
+ # @return [String]
80
80
  supervisionIdentityId: {
81
- class: :integer
81
+ class: :j_id
82
82
  },
83
83
 
84
84
  # @!attribute siteId
85
- # @return [Integer]
85
+ # @return [String]
86
86
  siteId: {
87
- class: :integer
87
+ class: :j_id
88
88
  },
89
89
 
90
90
  # @!attribute serverName
@@ -293,14 +293,14 @@ module Jamf
293
293
 
294
294
  # disown one or more serial numbers from a given DeviceEnrollment instance
295
295
  #
296
- # @param sns[Array<String>] One or more serial numbers to disown
296
+ # @param sns[String, Array<String>] One or more serial numbers to disown
297
297
  #
298
298
  # @param from_instance [Integer, String] the id or name of the instance
299
299
  # from which to disown the serial numbers
300
300
  #
301
301
  # @param cnx[Jamf::Connection] The API connection to use
302
302
  #
303
- # @return [void]
303
+ # @return [Hash] The SNs as keys and 'SUCESS' or 'FAILED' as values
304
304
  #
305
305
  def self.disown(*sns, from_instance:, cnx: Jamf.cnx)
306
306
  instance_id = valid_id from_instance, cnx: cnx
@@ -311,14 +311,14 @@ module Jamf
311
311
  data = { devices: sns }
312
312
  disown_rsrc = "#{self.class::RSRC_VERSION}/#{self.class::RSRC_PATH}/#{instance_id}/#{DISOWN_RSRC}"
313
313
 
314
- cnx.post(disown_rsrc, data)
314
+ cnx.post(disown_rsrc, data)[:devices]
315
315
  end
316
316
 
317
317
  # Private Class Methods
318
318
  ###############################################
319
319
 
320
320
  # Private, used by the .devices class method
321
- def self.fetch_devices(instance_ident, refresh, cnx)
321
+ def self.fetch_devices(instance_ident = nil, refresh, cnx)
322
322
  if instance_ident
323
323
  instance_id = valid_id instance_ident, cnx: cnx
324
324
  raise Jamf::NoSuchItemError, "No DeviceEnrollment instance matches '#{instance_ident}'" unless instance_id
@@ -51,9 +51,11 @@ module Jamf
51
51
  # Constants
52
52
  #####################################
53
53
 
54
- RSRC_VERSION = 'v1'.freeze
54
+ RSRC_VERSION = 'v2'.freeze
55
55
 
56
- RSRC_PATH = 'inventory-preload'.freeze
56
+ RSRC_PATH = 'inventory-preload/records'.freeze
57
+
58
+ CHANGE_LOG_RSRC = "#{RSRC_VERSION}/inventory-preload/history".freeze
57
59
 
58
60
  DEVICE_TYPE_COMPUTER = 'Computer'.freeze
59
61
  DEVICE_TYPE_MOBILE_DEV = 'Mobile Device'.freeze
@@ -77,7 +79,7 @@ module Jamf
77
79
  # @!attribute [r] id
78
80
  # @return [Integer]
79
81
  id: {
80
- class: :integer,
82
+ class: :j_id,
81
83
  identifier: :primary,
82
84
  readonly: true
83
85
  },
@@ -219,6 +221,12 @@ module Jamf
219
221
  class: :string
220
222
  },
221
223
 
224
+ # @!attribute vendor
225
+ # @return [String]
226
+ vendor: {
227
+ class: :string
228
+ },
229
+
222
230
  # @!attribute extensionAttributes
223
231
  # @return [Jamf::InventoryPreloadExtensionAttribute]
224
232
  extensionAttributes: {
@@ -37,7 +37,7 @@ module Jamf
37
37
  # Constants
38
38
  #####################################
39
39
 
40
- RSRC_VERSION = 'v1'.freeze
40
+ RSRC_VERSION = 'v2'.freeze
41
41
 
42
42
  RSRC_PATH = 'mobile-device-prestages'.freeze
43
43
 
@@ -53,21 +53,21 @@ module Jamf
53
53
  class: Jamf::MobileDevicePrestageSkipSetupItems
54
54
  },
55
55
 
56
- # @!attribute isAllowPairing
56
+ # @!attribute allowPairing
57
57
  # @return [Boolean]
58
- isAllowPairing: {
58
+ allowPairing: {
59
59
  class: :boolean
60
60
  },
61
61
 
62
- # @!attribute isMultiUser
62
+ # @!attribute multiUser
63
63
  # @return [Boolean]
64
- isMultiUser: {
64
+ multiUser: {
65
65
  class: :boolean
66
66
  },
67
67
 
68
- # @!attribute isSupervised
68
+ # @!attribute supervised
69
69
  # @return [Boolean]
70
- isSupervised: {
70
+ supervised: {
71
71
  class: :boolean
72
72
  },
73
73
 
@@ -79,33 +79,35 @@ module Jamf
79
79
 
80
80
  # @!attribute isAutoAdvanceSetup
81
81
  # @return [Boolean]
82
- isAutoAdvanceSetup: {
82
+ autoAdvanceSetup: {
83
83
  class: :boolean
84
84
  },
85
85
 
86
- # @!attribute isConfigureDeviceBeforeSetupAssistant
86
+ # @!attribute configureDeviceBeforeSetupAssistant
87
87
  # @return [Boolean]
88
- isConfigureDeviceBeforeSetupAssistant: {
88
+ configureDeviceBeforeSetupAssistant: {
89
89
  class: :boolean
90
90
  },
91
91
 
92
- # @!attribute language
93
- # @return [String]
94
- language: {
95
- class: :string
96
- },
97
-
98
- # @!attribute region
99
- # @return [String]
100
- region: {
101
- class: :string
102
- },
103
-
104
92
  # @!attribute names
105
93
  # @return [Jamf::MobileDevicePrestageNames]
106
94
  names: {
107
95
  class: Jamf::MobileDevicePrestageNames
96
+ },
97
+
98
+ # @!attribute sendTimezone
99
+ # @return [Boolean]
100
+ sendTimezone: {
101
+ class: :boolean
102
+ },
103
+
104
+ # @!attribute timezone
105
+ # @return [String]
106
+ timezone: {
107
+ class: :string
108
108
  }
109
+
110
+
109
111
  ).freeze
110
112
 
111
113
  parse_object_model
@@ -41,9 +41,8 @@ module Jamf
41
41
  # Constants
42
42
  #####################################
43
43
 
44
- RSRC_PATH = 'scripts'.freeze
45
-
46
44
  RSRC_VERSION = 'v1'.freeze
45
+ RSRC_PATH = 'scripts'.freeze
47
46
 
48
47
  PRIORITY_BEFORE = 'BEFORE'.freeze
49
48
  PRIORITY_AFTER = 'AFTER'.freeze
@@ -64,35 +63,40 @@ module Jamf
64
63
  # @!attribute [r] id
65
64
  # @return [Integer]
66
65
  id: {
67
- class: :integer,
66
+ class: :j_id,
68
67
  identifier: :primary,
69
- readonly: true
68
+ readonly: true,
69
+ filter_key: true
70
70
  },
71
71
 
72
72
  # @!attribute name
73
73
  # @return [String]
74
74
  name: {
75
75
  class: :string,
76
- identifier: true
76
+ identifier: true,
77
+ filter_key: true
77
78
  },
78
79
 
79
80
  # @!attribute info
80
81
  # @return [String]
81
82
  info: {
82
- class: :string
83
+ class: :string,
84
+ filter_key: true
83
85
  },
84
86
 
85
87
  # @!attribute notes
86
88
  # @return [String]
87
89
  notes: {
88
- class: :string
90
+ class: :string,
91
+ filter_key: true
89
92
  },
90
93
 
91
94
  # @!attribute priority
92
95
  # @return [String]
93
96
  priority: {
94
97
  class: :string,
95
- enum: Jamf::Script::PRIORTIES
98
+ enum: Jamf::Script::PRIORTIES,
99
+ filter_key: true
96
100
  },
97
101
 
98
102
  # TODO: Jamf should standardize object references
@@ -101,19 +105,22 @@ module Jamf
101
105
  # @!attribute categoryId
102
106
  # @return [Integer]
103
107
  categoryId: {
104
- class: :integer
108
+ class: :j_id,
109
+ filter_key: true
105
110
  },
106
111
 
107
112
  # @!attribute categoryName
108
113
  # @return [String]
109
114
  categoryName: {
110
- class: :string
115
+ class: :string,
116
+ filter_key: true
111
117
  },
112
118
 
113
119
  # @!attribute osRequirements
114
120
  # @return [String]
115
121
  osRequirements: {
116
- class: :string
122
+ class: :string,
123
+ filter_key: true
117
124
  },
118
125
 
119
126
  # @!attribute scriptContents
@@ -121,68 +128,97 @@ module Jamf
121
128
  scriptContents: {
122
129
  class: :string,
123
130
  validate: :script_contents,
124
- aliases: %i[code]
131
+ aliases: %i[code],
132
+ filter_key: true
125
133
  },
126
134
 
127
135
  # @!attribute parameter4
128
136
  # @return [String]
129
137
  parameter4: {
130
- class: :string
138
+ class: :string,
139
+ filter_key: true
131
140
  },
132
141
 
133
142
  # @!attribute parameter5
134
143
  # @return [String]
135
144
  parameter5: {
136
- class: :string
145
+ class: :string,
146
+ filter_key: true
137
147
  },
138
148
 
139
149
  # @!attribute parameter6
140
150
  # @return [String]
141
151
  parameter6: {
142
- class: :string
152
+ class: :string,
153
+ filter_key: true
143
154
  },
144
155
 
145
156
  # @!attribute parameter7
146
157
  # @return [String]
147
158
  parameter7: {
148
- class: :string
159
+ class: :string,
160
+ filter_key: true
149
161
  },
150
162
 
151
163
  # @!attribute parameter8
152
164
  # @return [String]
153
165
  parameter8: {
154
- class: :string
166
+ class: :string,
167
+ filter_key: true
155
168
  },
156
169
 
157
170
  # @!attribute parameter9
158
171
  # @return [String]
159
172
  parameter9: {
160
- class: :string
173
+ class: :string,
174
+ filter_key: true
161
175
  },
162
176
 
163
177
  # @!attribute parameter10
164
178
  # @return [String]
165
179
  parameter10: {
166
- class: :string
180
+ class: :string,
181
+ filter_key: true
167
182
  },
168
183
 
169
184
  # @!attribute parameter11
170
185
  # @return [String]
171
186
  parameter11: {
172
- class: :string
187
+ class: :string,
188
+ filter_key: true
173
189
  }
174
190
  }.freeze
175
191
 
176
192
  parse_object_model
177
193
 
178
-
179
194
  # Class Methods
180
195
  ##################################
181
196
 
182
- def self.scriptContents(scr_ident, cnx: Jamf.cnx)
183
- id = valid_id scr_ident
184
- raise Jamf::NoSuchItemError, "No script matches '#{scr_ident}'" unless id
185
- cnx.download "#{RSRC_VERSION}/#{RSRC_PATH}/#{id}/download"
197
+ # Retrieve a script's code without instantiating
198
+ #
199
+ # Specify an ident key, either id: or name: and the
200
+ # value for that ident
201
+ # e.g. `download id: 123` or `download name: 'myscript'`
202
+ #
203
+ # @param cnx [Jamf::Connection] The connection to use, default: Jamf.cnx
204
+ #
205
+ # @return [String] The code of the desired script
206
+ #
207
+ def self.download(cnx: Jamf.cnx, **ident_and_val)
208
+ ident, value = ident_and_val.first
209
+ if ident == :id
210
+ begin
211
+ return cnx.download "#{rsrc_path}/#{value}/download"
212
+ rescue => e
213
+ raise Jamf::NoSuchItemError, "No script with #{ident} = #{value}" if e.httpStatus == 404
214
+
215
+ raise e
216
+ end # begin
217
+ end # if
218
+ id = raw_data(cnx: cnx, **ident_and_val)&.dig(:id)
219
+ raise Jamf::NoSuchItemError, "No script with #{ident} = #{value}" unless id
220
+
221
+ cnx.download "#{rsrc_path}/#{id}/download"
186
222
  end
187
223
 
188
224
  end # class
@@ -32,6 +32,9 @@ module Jamf
32
32
  #
33
33
  class AppStoreCountryCodes < Jamf::SingletonResource
34
34
 
35
+ # Mix-Ins
36
+ #####################################
37
+
35
38
  extend Jamf::Immutable
36
39
 
37
40
  # Constants
@@ -48,7 +51,8 @@ module Jamf
48
51
  countryCodes: {
49
52
  class: Jamf::Country,
50
53
  multi: true,
51
- read_only: true
54
+ read_only: true,
55
+ aliases: [:list]
52
56
  }
53
57
 
54
58
  }.freeze # end OBJECT_MODEL
@@ -58,6 +62,12 @@ module Jamf
58
62
  # Class Methods
59
63
  #####################################
60
64
 
65
+ # @return [Array<Jamf::Country>] all the Countries available
66
+ #
67
+ def self.list(refresh = false, cnx: Jamf.cnx)
68
+ fetch(refresh, cnx: cnx).countryCodes
69
+ end
70
+
61
71
  # Class level wrapper for #names
62
72
  def self.names(refresh = false, cnx: Jamf.cnx)
63
73
  fetch(refresh, cnx: cnx).names
@@ -93,22 +103,22 @@ module Jamf
93
103
 
94
104
  # @return [Array<String>] the available country names
95
105
  def names
96
- @names ||= countryCodes.map{ |country| country.name }
106
+ @names ||= countryCodes.map(&:name)
97
107
  end
98
108
 
99
109
  # @return [Array<String>] the available country codes
100
110
  def codes
101
- @codes ||= countryCodes.map{ |country| country.code }
111
+ @codes ||= countryCodes.map(&:code)
102
112
  end
103
113
 
104
114
  # @return [Hash] name => code
105
115
  def codes_by_name
106
- @codes_by_name ||= countryCodes.map{ |country| [country.name, country.code] }.to_h
116
+ @codes_by_name ||= countryCodes.map { |country| [country.name, country.code] }.to_h
107
117
  end
108
118
 
109
119
  # @return [Hash] code => name
110
120
  def names_by_code
111
- @names_by_code ||= countryCodes.map{ |country| [country.code, country.name] }.to_h
121
+ @names_by_code ||= countryCodes.map { |country| [country.code, country.name] }.to_h
112
122
  end
113
123
 
114
124
  # return a country code from its name, case-insensitive
@@ -40,7 +40,7 @@ module Jamf
40
40
 
41
41
  UPDATABLE = true
42
42
 
43
- RSRC_VERSION = 'v1'.freeze
43
+ RSRC_VERSION = 'v2'.freeze
44
44
 
45
45
  RSRC_PATH = 'check-in'.freeze
46
46
 
@@ -54,79 +54,79 @@ module Jamf
54
54
 
55
55
  # @!attribute isCreateHooks
56
56
  # @return [Boolean]
57
- isCreateHooks: {
57
+ createHooks: {
58
58
  class: :boolean
59
59
  },
60
60
 
61
61
  # @!attribute isHookLog
62
62
  # @return [Boolean]
63
- isHookLog: {
63
+ hookLog: {
64
64
  class: :boolean
65
65
  },
66
66
 
67
67
  # @!attribute isHookPolicies
68
68
  # @return [Boolean]
69
- isHookPolicies: {
69
+ hookPolicies: {
70
70
  class: :boolean
71
71
  },
72
72
 
73
73
  # @!attribute isHookHideRestore
74
74
  # @return [Boolean]
75
- isHookHideRestore: {
75
+ hookHideRestore: {
76
76
  class: :boolean
77
77
  },
78
78
 
79
79
  # @!attribute isHookMCX
80
80
  # @return [Boolean]
81
- isHookMCX: {
81
+ hookMcx: {
82
82
  class: :boolean
83
83
  },
84
84
 
85
85
  # @!attribute isBackgroundHooks
86
86
  # @return [Boolean]
87
- isBackgroundHooks: {
87
+ backgroundHooks: {
88
88
  class: :boolean
89
89
  },
90
90
 
91
91
  # @!attribute isHookDisplayStatus
92
92
  # @return [Boolean]
93
- isHookDisplayStatus: {
93
+ hookDisplayStatus: {
94
94
  class: :boolean
95
95
  },
96
96
 
97
97
  # @!attribute isCreateStartupScript
98
98
  # @return [Boolean]
99
- isCreateStartupScript: {
99
+ createStartupScript: {
100
100
  class: :boolean
101
101
  },
102
102
 
103
103
  # @!attribute isStartupLog
104
104
  # @return [Boolean]
105
- isStartupLog: {
105
+ startupLog: {
106
106
  class: :boolean
107
107
  },
108
108
 
109
109
  # @!attribute isStartupPolicies
110
110
  # @return [Boolean]
111
- isStartupPolicies: {
111
+ startupPolicies: {
112
112
  class: :boolean
113
113
  },
114
114
 
115
115
  # @!attribute isStartupSSH
116
116
  # @return [Boolean]
117
- isStartupSSH: {
117
+ startupSsh: {
118
118
  class: :boolean
119
119
  },
120
120
 
121
121
  # @!attribute isStartupMCX
122
122
  # @return [Boolean]
123
- isStartupMCX: {
123
+ startupMcx: {
124
124
  class: :boolean
125
125
  },
126
126
 
127
127
  # @!attribute isEnableLocalConfigurationProfiles
128
128
  # @return [Boolean]
129
- isEnableLocalConfigurationProfiles: {
129
+ enableLocalConfigurationProfiles: {
130
130
  class: :boolean
131
131
  }
132
132