ruby-jss 1.4.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +95 -0
  3. data/THANKS.md +3 -2
  4. data/lib/jamf.rb +18 -17
  5. data/lib/jamf/api/base_classes/collection_resource.rb +613 -0
  6. data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +109 -101
  7. data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +55 -30
  8. data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +10 -6
  9. data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +4 -3
  10. data/lib/jamf/api/connection.rb +13 -9
  11. data/lib/jamf/api/connection/api_error.rb +8 -8
  12. data/lib/jamf/api/connection/token.rb +16 -15
  13. data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
  14. data/lib/jamf/api/json_objects/{location.rb → device_enrollment_device_sync_state.rb} +27 -41
  15. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
  16. data/lib/jamf/api/json_objects/{attachment.rb → locale.rb} +14 -23
  17. data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
  18. data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
  19. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
  20. data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
  21. data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
  22. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
  23. data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
  24. data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
  25. data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
  26. data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
  27. data/lib/jamf/api/mixins/change_log.rb +201 -51
  28. data/lib/jamf/api/{resources/collection_resources/computer.rb → mixins/filterable.rb} +19 -17
  29. data/lib/jamf/api/mixins/pageable.rb +208 -0
  30. data/lib/jamf/api/{json_objects/installed_application.rb → mixins/sortable.rb} +33 -33
  31. data/lib/jamf/api/resources/collection_resources/building.rb +16 -9
  32. data/lib/jamf/api/resources/collection_resources/category.rb +5 -4
  33. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +12 -5
  34. data/lib/jamf/api/resources/collection_resources/department.rb +0 -2
  35. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +10 -10
  36. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
  37. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +25 -23
  38. data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
  39. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
  40. data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
  41. data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
  42. data/lib/jamf/client.rb +3 -3
  43. data/lib/jamf/client/management_action.rb +2 -3
  44. data/lib/jamf/composer.rb +2 -2
  45. data/lib/jamf/utility.rb +35 -7
  46. data/lib/jamf/validate.rb +63 -24
  47. data/lib/jamf/version.rb +1 -1
  48. data/lib/jss.rb +2 -2
  49. data/lib/jss/api_connection.rb +114 -406
  50. data/lib/jss/api_object.rb +3 -19
  51. data/lib/jss/api_object/categorizable.rb +1 -1
  52. data/lib/jss/api_object/computer.rb +13 -0
  53. data/lib/jss/api_object/configuration_profile.rb +61 -5
  54. data/lib/jss/api_object/directory_binding_type.rb +66 -60
  55. data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
  56. data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
  57. data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
  58. data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
  59. data/lib/jss/api_object/distribution_point.rb +2 -2
  60. data/lib/jss/api_object/dock_item.rb +102 -96
  61. data/lib/jss/api_object/extendable.rb +1 -1
  62. data/lib/jss/api_object/group.rb +33 -2
  63. data/lib/jss/api_object/network_segment.rb +45 -13
  64. data/lib/jss/api_object/patch_source.rb +10 -9
  65. data/lib/jss/api_object/policy.rb +155 -25
  66. data/lib/jss/api_object/printer.rb +10 -4
  67. data/lib/jss/api_object/scopable.rb +10 -15
  68. data/lib/jss/api_object/scopable/scope.rb +31 -30
  69. data/lib/jss/api_object/script.rb +242 -352
  70. data/lib/jss/api_object/user.rb +1 -1
  71. data/lib/jss/client/management_action.rb +1 -2
  72. data/lib/jss/composer.rb +2 -2
  73. data/lib/jss/exceptions.rb +3 -0
  74. data/lib/jss/server.rb +15 -0
  75. data/lib/jss/utility.rb +213 -45
  76. data/lib/jss/version.rb +1 -1
  77. metadata +46 -64
  78. data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
  79. data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
  80. data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
  81. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
  82. data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
  83. data/lib/jamf/api/json_objects/android_details.rb +0 -139
  84. data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
  85. data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
  86. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
  87. data/lib/jamf/api/json_objects/criterion.rb +0 -152
  88. data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
  89. data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
  90. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
  91. data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
  92. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
  93. data/lib/jamf/api/json_objects/ios_details.rb +0 -244
  94. data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
  95. data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
  96. data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
  97. data/lib/jamf/api/mixins/locatable.rb +0 -124
  98. data/lib/jamf/api/mixins/referable.rb +0 -92
  99. data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
  100. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
  101. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
  102. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +0 -45
  103. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
  104. data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
  105. data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
  106. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
  107. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -35,7 +35,7 @@ module Jamf
35
35
  # Constants
36
36
  #####################################
37
37
 
38
- RSRC_VERSION = 'v1'.freeze
38
+ RSRC_VERSION = 'v2'.freeze
39
39
 
40
40
  RSRC_PATH = 'computer-prestages'.freeze
41
41
 
@@ -48,28 +48,35 @@ module Jamf
48
48
  # @!attribute skipSetupItems
49
49
  # @return [Jamf::ComputerPrestageSkipSetupItems]
50
50
  skipSetupItems: {
51
- class: Jamf::ComputerPrestageSkipSetupItems
51
+ class: :hash
52
52
  },
53
53
 
54
54
  # @!attribute isInstallProfilesDuringSetup
55
55
  # @return [Boolean]
56
- isInstallProfilesDuringSetup: {
56
+ installProfilesDuringSetup: {
57
57
  class: :boolean
58
58
  },
59
59
 
60
60
  # @!attribute prestageInstalledProfileIds
61
61
  # @return [Array<Integer>]
62
62
  prestageInstalledProfileIds: {
63
- class: :integer,
63
+ class: :j_id,
64
64
  multi: true
65
65
  },
66
66
 
67
67
  # @!attribute customPackageIds
68
68
  # @return [Array<Integer>]
69
69
  customPackageIds: {
70
- class: :integer,
70
+ class: :j_id,
71
71
  multi: true
72
+ },
73
+
74
+ # @!attribute customPackageDistributionPointId
75
+ # @return [String]
76
+ customPackageDistributionPointId: {
77
+ class: :j_id
72
78
  }
79
+
73
80
  ).freeze
74
81
 
75
82
  parse_object_model
@@ -36,7 +36,6 @@ module Jamf
36
36
  #####################################
37
37
 
38
38
  include Jamf::ChangeLog
39
- include Jamf::Referable
40
39
 
41
40
  # Constants
42
41
  #####################################
@@ -74,7 +73,6 @@ module Jamf
74
73
 
75
74
  parse_object_model
76
75
 
77
-
78
76
  end # class
79
77
 
80
78
  end # module
@@ -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
 
@@ -50,24 +50,24 @@ module Jamf
50
50
  # @!attribute skipSetupItems
51
51
  # @return [Jamf::ComputerPrestageSkipSetupItems]
52
52
  skipSetupItems: {
53
- class: Jamf::MobileDevicePrestageSkipSetupItems
53
+ class: :hash
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