ruby-jss 1.2.10 → 1.5.2
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.
- checksums.yaml +4 -4
- data/CHANGES.md +208 -1
- data/lib/jamf.rb +18 -16
- data/lib/jamf/api/base_classes/collection_resource.rb +613 -0
- data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +110 -102
- data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +56 -31
- data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +10 -6
- data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +4 -3
- data/lib/jamf/api/connection.rb +20 -12
- data/lib/jamf/api/connection/api_error.rb +8 -8
- data/lib/jamf/api/connection/token.rb +36 -15
- data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
- data/lib/jamf/api/json_objects/{location.rb → device_enrollment_device_sync_state.rb} +27 -41
- data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
- data/lib/jamf/api/json_objects/{attachment.rb → locale.rb} +14 -23
- data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
- data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
- data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
- data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
- data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
- data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
- data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
- data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
- data/lib/jamf/api/mixins/change_log.rb +201 -51
- data/lib/jamf/api/{resources/collection_resources/extension_attribute.rb → mixins/filterable.rb} +20 -14
- data/lib/jamf/api/mixins/pageable.rb +208 -0
- data/lib/jamf/api/{json_objects/installed_application.rb → mixins/sortable.rb} +33 -33
- data/lib/jamf/api/resources/collection_resources/building.rb +16 -9
- data/lib/jamf/api/resources/collection_resources/category.rb +5 -4
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +12 -5
- data/lib/jamf/api/resources/collection_resources/department.rb +1 -3
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +13 -13
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
- data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +25 -23
- data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
- data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
- data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
- data/lib/jamf/configuration.rb +7 -9
- data/lib/jamf/ruby_extensions.rb +1 -0
- data/lib/jamf/ruby_extensions/array.rb +1 -1
- data/lib/jamf/ruby_extensions/array/utils.rb +3 -3
- data/lib/jamf/{api/resources/collection_resources/computer.rb → ruby_extensions/dig.rb} +22 -19
- data/lib/jamf/validate.rb +63 -24
- data/lib/jamf/version.rb +1 -1
- data/lib/jss.rb +4 -1
- data/lib/jss/api_connection.rb +111 -433
- data/lib/jss/api_object.rb +16 -13
- 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/categorizable.rb +1 -1
- data/lib/jss/api_object/computer.rb +13 -0
- data/lib/jss/api_object/configuration_profile.rb +60 -4
- data/lib/jss/api_object/directory_binding.rb +273 -0
- data/lib/jss/api_object/directory_binding_type.rb +96 -0
- data/lib/jss/api_object/directory_binding_type/active_directory.rb +539 -0
- data/lib/jss/api_object/directory_binding_type/admitmac.rb +594 -0
- data/lib/jss/api_object/directory_binding_type/centrify.rb +226 -0
- data/lib/jss/api_object/directory_binding_type/open_directory.rb +178 -0
- data/lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb +73 -0
- data/lib/jss/api_object/disk_encryption_configurations.rb +114 -0
- data/lib/jss/api_object/distribution_point.rb +97 -37
- data/lib/jss/api_object/dock_item.rb +143 -0
- data/lib/jss/api_object/ebook.rb +1 -2
- data/lib/jss/api_object/extendable.rb +1 -1
- data/lib/jss/api_object/extension_attribute.rb +4 -3
- data/lib/jss/api_object/group.rb +33 -2
- data/lib/jss/api_object/mac_application.rb +107 -8
- data/lib/jss/api_object/mobile_device_application.rb +12 -0
- data/lib/jss/api_object/network_segment.rb +195 -70
- data/lib/jss/api_object/package.rb +105 -40
- data/lib/jss/api_object/patch_source.rb +10 -9
- data/lib/jss/api_object/policy.rb +596 -32
- data/lib/jss/api_object/printer.rb +446 -0
- data/lib/jss/api_object/scopable.rb +10 -15
- data/lib/jss/api_object/scopable/scope.rb +371 -55
- 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/composer.rb +1 -1
- data/lib/jss/exceptions.rb +3 -0
- data/lib/jss/server.rb +15 -0
- data/lib/jss/utility.rb +143 -52
- data/lib/jss/validate.rb +53 -10
- data/lib/jss/version.rb +1 -1
- metadata +56 -61
- data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
- data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
- data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
- data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
- data/lib/jamf/api/json_objects/android_details.rb +0 -139
- data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
- data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
- data/lib/jamf/api/json_objects/criterion.rb +0 -152
- data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
- data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
- data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
- data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
- data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
- data/lib/jamf/api/json_objects/ios_details.rb +0 -244
- data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
- data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
- data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
- data/lib/jamf/api/mixins/locatable.rb +0 -124
- data/lib/jamf/api/mixins/referable.rb +0 -92
- data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
- data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
- data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
- data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
- data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
- data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
- data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
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.5.2
|
|
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-12-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: plist
|
|
@@ -46,39 +46,45 @@ dependencies:
|
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: 2.9.12
|
|
48
48
|
- !ruby/object:Gem::Dependency
|
|
49
|
-
name:
|
|
49
|
+
name: faraday
|
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
55
|
-
- - "
|
|
54
|
+
version: 1.0.0
|
|
55
|
+
- - "<="
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
|
-
version:
|
|
57
|
+
version: 1.0.1
|
|
58
58
|
type: :runtime
|
|
59
59
|
prerelease: false
|
|
60
60
|
version_requirements: !ruby/object:Gem::Requirement
|
|
61
61
|
requirements:
|
|
62
62
|
- - ">="
|
|
63
63
|
- !ruby/object:Gem::Version
|
|
64
|
-
version:
|
|
65
|
-
- - "
|
|
64
|
+
version: 1.0.0
|
|
65
|
+
- - "<="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version:
|
|
67
|
+
version: 1.0.1
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
|
-
name:
|
|
69
|
+
name: faraday_middleware
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
|
-
- - "
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 1.0.0
|
|
75
|
+
- - "<="
|
|
73
76
|
- !ruby/object:Gem::Version
|
|
74
|
-
version:
|
|
77
|
+
version: 1.0.1
|
|
75
78
|
type: :runtime
|
|
76
79
|
prerelease: false
|
|
77
80
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
81
|
requirements:
|
|
79
|
-
- - "
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: 1.0.0
|
|
85
|
+
- - "<="
|
|
80
86
|
- !ruby/object:Gem::Version
|
|
81
|
-
version:
|
|
87
|
+
version: 1.0.1
|
|
82
88
|
- !ruby/object:Gem::Dependency
|
|
83
89
|
name: immutable-struct
|
|
84
90
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,11 +126,13 @@ dependencies:
|
|
|
120
126
|
- !ruby/object:Gem::Version
|
|
121
127
|
version: '1.1'
|
|
122
128
|
description: |2
|
|
123
|
-
The ruby-jss gem provides
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
The ruby-jss gem provides native ruby access to the REST APIs of Jamf Pro,
|
|
130
|
+
an enterprise/education tool for managing Apple devices, from jamf.com.
|
|
131
|
+
The JSS module provides access to the 'Classic' API, while the Jamf module
|
|
132
|
+
provides access to the more modern 'Jamf Pro' API. Jamf Pro objects are
|
|
133
|
+
implemented as classes and, within each module, can interact with each other.
|
|
134
|
+
The underlying data transfer using JSON or XML is handled automatically
|
|
135
|
+
under the hood to allow simpler, intuitive automation of Jamf-related Tasks.
|
|
128
136
|
email: ruby-jss@pixar.com
|
|
129
137
|
executables:
|
|
130
138
|
- cgrouper
|
|
@@ -147,82 +155,56 @@ files:
|
|
|
147
155
|
- bin/netseg-update
|
|
148
156
|
- data/ruby-jss.conf.example
|
|
149
157
|
- lib/jamf.rb
|
|
150
|
-
- lib/jamf/api/abstract_classes/advanced_search.rb
|
|
151
|
-
- lib/jamf/api/abstract_classes/collection_resource.rb
|
|
152
|
-
- lib/jamf/api/abstract_classes/generic_reference.rb
|
|
153
|
-
- lib/jamf/api/abstract_classes/json_object.rb
|
|
154
|
-
- lib/jamf/api/abstract_classes/prestage.rb
|
|
155
|
-
- lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb
|
|
156
|
-
- lib/jamf/api/abstract_classes/resource.rb
|
|
157
|
-
- lib/jamf/api/abstract_classes/singleton_resource.rb
|
|
158
158
|
- lib/jamf/api/attribute_classes/ip_address.rb
|
|
159
159
|
- lib/jamf/api/attribute_classes/timestamp.rb
|
|
160
|
+
- lib/jamf/api/base_classes/collection_resource.rb
|
|
161
|
+
- lib/jamf/api/base_classes/json_object.rb
|
|
162
|
+
- lib/jamf/api/base_classes/prestage.rb
|
|
163
|
+
- lib/jamf/api/base_classes/resource.rb
|
|
164
|
+
- lib/jamf/api/base_classes/singleton_resource.rb
|
|
160
165
|
- lib/jamf/api/connection.rb
|
|
161
166
|
- lib/jamf/api/connection/api_error.rb
|
|
162
167
|
- lib/jamf/api/connection/api_error_styleguide.rb
|
|
163
168
|
- lib/jamf/api/connection/token.rb
|
|
164
|
-
- lib/jamf/api/json_objects/account_prefs.rb
|
|
165
|
-
- lib/jamf/api/json_objects/android_details.rb
|
|
166
|
-
- lib/jamf/api/json_objects/appletv_details.rb
|
|
167
|
-
- lib/jamf/api/json_objects/attachment.rb
|
|
168
|
-
- lib/jamf/api/json_objects/cellular_network.rb
|
|
169
169
|
- lib/jamf/api/json_objects/change_log_entry.rb
|
|
170
|
-
- lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb
|
|
171
170
|
- lib/jamf/api/json_objects/country.rb
|
|
172
|
-
- lib/jamf/api/json_objects/criterion.rb
|
|
173
171
|
- lib/jamf/api/json_objects/device_enrollment_device.rb
|
|
172
|
+
- lib/jamf/api/json_objects/device_enrollment_device_sync_state.rb
|
|
174
173
|
- lib/jamf/api/json_objects/device_enrollment_sync_status.rb
|
|
175
|
-
- lib/jamf/api/json_objects/extension_attribute_value.rb
|
|
176
|
-
- lib/jamf/api/json_objects/installed_application.rb
|
|
177
|
-
- lib/jamf/api/json_objects/installed_certificate.rb
|
|
178
|
-
- lib/jamf/api/json_objects/installed_configuration_profile.rb
|
|
179
|
-
- lib/jamf/api/json_objects/installed_ebook.rb
|
|
180
|
-
- lib/jamf/api/json_objects/installed_provisioning_profile.rb
|
|
181
174
|
- lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb
|
|
182
|
-
- lib/jamf/api/json_objects/
|
|
183
|
-
- lib/jamf/api/json_objects/location.rb
|
|
175
|
+
- lib/jamf/api/json_objects/locale.rb
|
|
184
176
|
- lib/jamf/api/json_objects/md_prestage_name.rb
|
|
185
177
|
- lib/jamf/api/json_objects/md_prestage_names.rb
|
|
186
178
|
- lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb
|
|
187
|
-
- lib/jamf/api/json_objects/mobile_device_details.rb
|
|
188
|
-
- lib/jamf/api/json_objects/mobile_device_security.rb
|
|
189
179
|
- lib/jamf/api/json_objects/prestage_assignment.rb
|
|
190
180
|
- lib/jamf/api/json_objects/prestage_location.rb
|
|
191
181
|
- lib/jamf/api/json_objects/prestage_purchasing_data.rb
|
|
192
182
|
- lib/jamf/api/json_objects/prestage_scope.rb
|
|
193
183
|
- lib/jamf/api/json_objects/prestage_sync_status.rb
|
|
194
|
-
- lib/jamf/api/json_objects/
|
|
195
|
-
- lib/jamf/api/mixins/
|
|
184
|
+
- lib/jamf/api/json_objects/time_zone.rb
|
|
185
|
+
- lib/jamf/api/mixins/base_class.rb
|
|
196
186
|
- lib/jamf/api/mixins/bulk_deletable.rb
|
|
197
187
|
- lib/jamf/api/mixins/change_log.rb
|
|
198
188
|
- lib/jamf/api/mixins/extendable.rb
|
|
189
|
+
- lib/jamf/api/mixins/filterable.rb
|
|
199
190
|
- lib/jamf/api/mixins/immutable.rb
|
|
200
|
-
- lib/jamf/api/mixins/locatable.rb
|
|
201
191
|
- lib/jamf/api/mixins/lockable.rb
|
|
202
|
-
- lib/jamf/api/mixins/
|
|
192
|
+
- lib/jamf/api/mixins/pageable.rb
|
|
203
193
|
- lib/jamf/api/mixins/searchable.rb
|
|
194
|
+
- lib/jamf/api/mixins/sortable.rb
|
|
204
195
|
- lib/jamf/api/mixins/uncreatable.rb
|
|
205
196
|
- lib/jamf/api/mixins/undeletable.rb
|
|
206
|
-
- lib/jamf/api/resources/collection_resources/account.rb
|
|
207
|
-
- lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb
|
|
208
|
-
- lib/jamf/api/resources/collection_resources/advanced_user_search.rb
|
|
209
197
|
- lib/jamf/api/resources/collection_resources/building.rb
|
|
210
198
|
- lib/jamf/api/resources/collection_resources/category.rb
|
|
211
|
-
- lib/jamf/api/resources/collection_resources/computer.rb
|
|
212
199
|
- lib/jamf/api/resources/collection_resources/computer_prestage.rb
|
|
213
200
|
- lib/jamf/api/resources/collection_resources/department.rb
|
|
214
201
|
- lib/jamf/api/resources/collection_resources/device_enrollment.rb
|
|
215
|
-
- lib/jamf/api/resources/collection_resources/extension_attribute.rb
|
|
216
202
|
- lib/jamf/api/resources/collection_resources/inventory_preload_record.rb
|
|
217
|
-
- lib/jamf/api/resources/collection_resources/mobile_device.rb
|
|
218
203
|
- lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb
|
|
219
204
|
- lib/jamf/api/resources/collection_resources/script.rb
|
|
220
|
-
- lib/jamf/api/resources/collection_resources/site.rb
|
|
221
|
-
- lib/jamf/api/resources/collection_resources/time_zone.rb
|
|
222
205
|
- lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb
|
|
223
|
-
- lib/jamf/api/resources/singleton_resources/
|
|
224
|
-
- lib/jamf/api/resources/singleton_resources/
|
|
225
|
-
- lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb
|
|
206
|
+
- lib/jamf/api/resources/singleton_resources/locales.rb
|
|
207
|
+
- lib/jamf/api/resources/singleton_resources/time_zones.rb
|
|
226
208
|
- lib/jamf/client.rb
|
|
227
209
|
- lib/jamf/client/jamf_binary.rb
|
|
228
210
|
- lib/jamf/client/jamf_helper.rb
|
|
@@ -235,6 +217,7 @@ files:
|
|
|
235
217
|
- lib/jamf/ruby_extensions/array.rb
|
|
236
218
|
- lib/jamf/ruby_extensions/array/predicates.rb
|
|
237
219
|
- lib/jamf/ruby_extensions/array/utils.rb
|
|
220
|
+
- lib/jamf/ruby_extensions/dig.rb
|
|
238
221
|
- lib/jamf/ruby_extensions/filetest.rb
|
|
239
222
|
- lib/jamf/ruby_extensions/filetest/predicates.rb
|
|
240
223
|
- lib/jamf/ruby_extensions/hash.rb
|
|
@@ -263,6 +246,7 @@ files:
|
|
|
263
246
|
- lib/jss/api_object/advanced_search/advanced_computer_search.rb
|
|
264
247
|
- lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb
|
|
265
248
|
- lib/jss/api_object/advanced_search/advanced_user_search.rb
|
|
249
|
+
- lib/jss/api_object/app_store_country_codes.rb
|
|
266
250
|
- lib/jss/api_object/building.rb
|
|
267
251
|
- lib/jss/api_object/categorizable.rb
|
|
268
252
|
- lib/jss/api_object/category.rb
|
|
@@ -277,7 +261,16 @@ files:
|
|
|
277
261
|
- lib/jss/api_object/criteriable/criteria.rb
|
|
278
262
|
- lib/jss/api_object/criteriable/criterion.rb
|
|
279
263
|
- lib/jss/api_object/department.rb
|
|
264
|
+
- lib/jss/api_object/directory_binding.rb
|
|
265
|
+
- lib/jss/api_object/directory_binding_type.rb
|
|
266
|
+
- lib/jss/api_object/directory_binding_type/active_directory.rb
|
|
267
|
+
- lib/jss/api_object/directory_binding_type/admitmac.rb
|
|
268
|
+
- lib/jss/api_object/directory_binding_type/centrify.rb
|
|
269
|
+
- lib/jss/api_object/directory_binding_type/open_directory.rb
|
|
270
|
+
- lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb
|
|
271
|
+
- lib/jss/api_object/disk_encryption_configurations.rb
|
|
280
272
|
- lib/jss/api_object/distribution_point.rb
|
|
273
|
+
- lib/jss/api_object/dock_item.rb
|
|
281
274
|
- lib/jss/api_object/ebook.rb
|
|
282
275
|
- lib/jss/api_object/extendable.rb
|
|
283
276
|
- lib/jss/api_object/extension_attribute.rb
|
|
@@ -321,6 +314,7 @@ files:
|
|
|
321
314
|
- lib/jss/api_object/peripheral.rb
|
|
322
315
|
- lib/jss/api_object/peripheral_type.rb
|
|
323
316
|
- lib/jss/api_object/policy.rb
|
|
317
|
+
- lib/jss/api_object/printer.rb
|
|
324
318
|
- lib/jss/api_object/purchasable.rb
|
|
325
319
|
- lib/jss/api_object/removable_macaddr.rb
|
|
326
320
|
- lib/jss/api_object/restricted_software.rb
|
|
@@ -335,6 +329,7 @@ files:
|
|
|
335
329
|
- lib/jss/api_object/updatable.rb
|
|
336
330
|
- lib/jss/api_object/uploadable.rb
|
|
337
331
|
- lib/jss/api_object/user.rb
|
|
332
|
+
- lib/jss/api_object/vpp_account.rb
|
|
338
333
|
- lib/jss/api_object/vppable.rb
|
|
339
334
|
- lib/jss/api_object/webhook.rb
|
|
340
335
|
- lib/jss/client.rb
|
|
@@ -394,7 +389,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
394
389
|
requirements:
|
|
395
390
|
- - ">="
|
|
396
391
|
- !ruby/object:Gem::Version
|
|
397
|
-
version: 2.
|
|
392
|
+
version: 2.3.0
|
|
398
393
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
394
|
requirements:
|
|
400
395
|
- - ">="
|
|
@@ -404,5 +399,5 @@ requirements: []
|
|
|
404
399
|
rubygems_version: 3.0.3
|
|
405
400
|
signing_key:
|
|
406
401
|
specification_version: 4
|
|
407
|
-
summary: A Ruby interface to the Jamf Pro REST
|
|
402
|
+
summary: A Ruby interface to the Jamf Pro REST APIs
|
|
408
403
|
test_files: []
|
|
@@ -1,86 +0,0 @@
|
|
|
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 building defined in the JSS
|
|
33
|
-
class AdvancedSearch < Jamf::CollectionResource
|
|
34
|
-
|
|
35
|
-
extend Jamf::Abstract
|
|
36
|
-
|
|
37
|
-
# Constants
|
|
38
|
-
#####################################
|
|
39
|
-
|
|
40
|
-
# Object Model / Attributes
|
|
41
|
-
# See APIObject class documentation for details
|
|
42
|
-
# of how the OBJECT_MODEL hash works.
|
|
43
|
-
#####################################
|
|
44
|
-
OBJECT_MODEL = {
|
|
45
|
-
|
|
46
|
-
# @!attribute [r] id
|
|
47
|
-
# @return [Integer]
|
|
48
|
-
id: {
|
|
49
|
-
class: :integer,
|
|
50
|
-
identifier: :primary,
|
|
51
|
-
readonly: true
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
# @!attribute name
|
|
55
|
-
# @return [String]
|
|
56
|
-
name: {
|
|
57
|
-
class: :string,
|
|
58
|
-
identifier: true
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
# @!attribute criteria
|
|
62
|
-
# @return [Array<Jamf::Criterion>]
|
|
63
|
-
criteria: {
|
|
64
|
-
class: Jamf::Criterion,
|
|
65
|
-
multi: true,
|
|
66
|
-
required: true
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
# @!attribute displayFields
|
|
70
|
-
# @return [Array<String>]
|
|
71
|
-
displayFields: {
|
|
72
|
-
class: :string,
|
|
73
|
-
multi: true
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
# @!attribute site
|
|
77
|
-
# @return [Jamf::Site::Reference]
|
|
78
|
-
site: {
|
|
79
|
-
class: Jamf::Site::Reference
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}.freeze
|
|
83
|
-
|
|
84
|
-
end # class
|
|
85
|
-
|
|
86
|
-
end # module
|
|
@@ -1,433 +0,0 @@
|
|
|
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
|
-
# A Collection Resource in Jamf Pro
|
|
30
|
-
#
|
|
31
|
-
# See {Jamf::Resource} for general info about API resources.
|
|
32
|
-
#
|
|
33
|
-
# Collection resources have more than one resource within them, and those
|
|
34
|
-
# can (usually) be created and deleted as well as fetched and updated.
|
|
35
|
-
# The entire collection (or a part of it) can also be fetched as an Array.
|
|
36
|
-
# When the whole collection is fetched, the result is cached for future use.
|
|
37
|
-
#
|
|
38
|
-
# # Subclassing
|
|
39
|
-
#
|
|
40
|
-
# ## Creatability, & Deletability
|
|
41
|
-
#
|
|
42
|
-
# Sometimes the API doesn't support creation of new members of the collection.
|
|
43
|
-
# If that's the case, just extend the subclass with Jamf::UnCreatable
|
|
44
|
-
# and the '.create' class method will raise an error.
|
|
45
|
-
#
|
|
46
|
-
# Similarly for deletion of members: if the API doesn't have a way to delete
|
|
47
|
-
# them, extend the subclass with Jamf::UnDeletable
|
|
48
|
-
#
|
|
49
|
-
# See also Jamf::JSONObject, which talks about extending subclasses
|
|
50
|
-
# with Jamf::Immutable
|
|
51
|
-
#
|
|
52
|
-
# ## Bulk Deletion
|
|
53
|
-
#
|
|
54
|
-
# Some collection resources have a resource for bulk deletion, passing in
|
|
55
|
-
# a JSON array of ids to delete.
|
|
56
|
-
#
|
|
57
|
-
# If so, just define a BULK_DELETE_RSRC, and the .delete class method
|
|
58
|
-
# will use it, rather than making multiple calls to delete individual
|
|
59
|
-
# items. See Jamf::Category::BULK_DELETE_RSRC for an example
|
|
60
|
-
#
|
|
61
|
-
# @abstract
|
|
62
|
-
#
|
|
63
|
-
class CollectionResource < Jamf::Resource
|
|
64
|
-
|
|
65
|
-
extend Jamf::Abstract
|
|
66
|
-
include Comparable
|
|
67
|
-
|
|
68
|
-
# Public Class Methods
|
|
69
|
-
#####################################
|
|
70
|
-
|
|
71
|
-
# @return [Array<Symbol>] the attribute names that are marked as identifiers
|
|
72
|
-
#
|
|
73
|
-
def self.identifiers
|
|
74
|
-
self::OBJECT_MODEL.select { |_attr, deets| deets[:identifier] }.keys
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# The Collection members Array for this class, retrieved from
|
|
78
|
-
# the RSRC_PATH as Parsed JSON, but not instantiated into instances
|
|
79
|
-
# unless instantiate: is truthy.
|
|
80
|
-
#
|
|
81
|
-
# E.g. for {Jamf::Settings::Building}, this would be the Array of Hashes
|
|
82
|
-
# returned by GETing the resource .../settings/obj/building
|
|
83
|
-
#
|
|
84
|
-
# This Array is cached in the {Jamf::Connection} instance used to
|
|
85
|
-
# retrieve it, and future calls to .all will return the cached Array
|
|
86
|
-
# unless refresh is truthy.
|
|
87
|
-
#
|
|
88
|
-
# TODO: Investigate https://www.rubydoc.info/github/mloughran/api_cache
|
|
89
|
-
#
|
|
90
|
-
# @param refresh[Boolean] re-read the data from the API?
|
|
91
|
-
#
|
|
92
|
-
# @param cnx[Jamf::Connection] an API connection to use for the query.
|
|
93
|
-
# Defaults to the corrently active connection. See {Jamf::Connection}
|
|
94
|
-
#
|
|
95
|
-
# @param instantiate[Boolean] The Array contains instances of this class
|
|
96
|
-
# rather than the JSON Hashes from the API.
|
|
97
|
-
#
|
|
98
|
-
# @return [Array<Object>] An Array of all objects of this class in the JSS.
|
|
99
|
-
#
|
|
100
|
-
def self.all(refresh = false, cnx: Jamf.cnx, instantiate: false)
|
|
101
|
-
validate_not_abstract
|
|
102
|
-
cnx.collection_cache[self] = nil if refresh
|
|
103
|
-
if cnx.collection_cache[self]
|
|
104
|
-
return cnx.collection_cache[self] unless instantiate
|
|
105
|
-
|
|
106
|
-
return cnx.collection_cache[self].map { |m| new m }
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# TODO: make sure all collection resources use this format
|
|
110
|
-
# for paging. Also -ask Jamf about a url that returns
|
|
111
|
-
# ALL objects in one query, regardless of number.
|
|
112
|
-
page = 0
|
|
113
|
-
raw = cnx.get "#{rsrc_path}?page=#{page}&size=1000000&sort=id%3Aasc"
|
|
114
|
-
results = raw[:results]
|
|
115
|
-
|
|
116
|
-
until results.size >= raw[:totalCount]
|
|
117
|
-
page += 1
|
|
118
|
-
raw = cnx.get "#{rsrc_path}?page=#{page}&size=1000000&sort=id%3Aasc"
|
|
119
|
-
results += raw[:results]
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
cnx.collection_cache[self] = results
|
|
124
|
-
|
|
125
|
-
return cnx.collection_cache[self] unless instantiate
|
|
126
|
-
|
|
127
|
-
cnx.collection_cache[self].map { |m| new m }
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
# An array of the ids for all collection members. According to the
|
|
131
|
-
# specs ALL collection resources must have an ID, which is used in the
|
|
132
|
-
# resource path.
|
|
133
|
-
#
|
|
134
|
-
# @param refresh (see .all)
|
|
135
|
-
#
|
|
136
|
-
# @param cnx (see .all)
|
|
137
|
-
#
|
|
138
|
-
# @return [Array<Integer>]
|
|
139
|
-
#
|
|
140
|
-
def self.all_ids(refresh = false, cnx: Jamf.cnx)
|
|
141
|
-
all(refresh, cnx: cnx).map { |m| m[:id] }
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# rubocop:disable Naming/UncommunicativeMethodParamName
|
|
145
|
-
|
|
146
|
-
# A Hash of all members of this collection where the keys are some
|
|
147
|
-
# identifier and values are any other attribute.
|
|
148
|
-
#
|
|
149
|
-
# @param ident [Symbol] An identifier of this Class, used as the key
|
|
150
|
-
# for the mapping Hash. Aliases are acceptable, e.g. :sn for :serialNumber
|
|
151
|
-
#
|
|
152
|
-
# @param to [Symbol] The attribute to which the ident will be mapped.
|
|
153
|
-
# Aliases are acceptable, e.g. :name for :displayName
|
|
154
|
-
#
|
|
155
|
-
# @param refresh (see .all)
|
|
156
|
-
#
|
|
157
|
-
# @param cnx (see .all)
|
|
158
|
-
#
|
|
159
|
-
# @return [Hash {Symbol: Object}] A Hash of identifier mapped to attribute
|
|
160
|
-
#
|
|
161
|
-
def self.map_all(ident, to:, cnx: Jamf.cnx, refresh: false)
|
|
162
|
-
real_ident = attr_key_for_alias ident
|
|
163
|
-
raise Jamf::InvalidDataError, "No identifier #{ident} for class #{self}" unless
|
|
164
|
-
identifiers.include? real_ident
|
|
165
|
-
|
|
166
|
-
real_to = attr_key_for_alias to
|
|
167
|
-
raise Jamf::NoSuchItemError, "No attribute #{to} for class #{self}" unless self::OBJECT_MODEL.key? real_to
|
|
168
|
-
|
|
169
|
-
ident = real_ident
|
|
170
|
-
to = real_to
|
|
171
|
-
list = all refresh, cnx: cnx
|
|
172
|
-
to_class = self::OBJECT_MODEL[to][:class]
|
|
173
|
-
mapped = list.map do |i|
|
|
174
|
-
[
|
|
175
|
-
i[ident],
|
|
176
|
-
to_class.is_a?(Symbol) ? i[to] : to_class.new(i[to])
|
|
177
|
-
]
|
|
178
|
-
end # do i
|
|
179
|
-
mapped.to_h
|
|
180
|
-
end
|
|
181
|
-
# rubocop:enable Naming/UncommunicativeMethodParamName
|
|
182
|
-
|
|
183
|
-
# Given any identfier value for this collection, return the id of the
|
|
184
|
-
# object that has such an identifier.
|
|
185
|
-
#
|
|
186
|
-
# Return nil if there's no match for the given value.
|
|
187
|
-
#
|
|
188
|
-
# If you know the value is a certain identifier, e.g. a serialNumber,
|
|
189
|
-
# then you can specify the identifier for a faster search:
|
|
190
|
-
#
|
|
191
|
-
# valid_id serialNumber: 'AB12DE34' # => Int or nil
|
|
192
|
-
#
|
|
193
|
-
# If you don't know wich identifier you have, just pass the value and
|
|
194
|
-
# all identifiers are searched
|
|
195
|
-
#
|
|
196
|
-
# valid_id 'AB12DE34' # => Int or nil
|
|
197
|
-
# valid_id 'SomeComputerName' # => Int or nil
|
|
198
|
-
#
|
|
199
|
-
# When the value is a string, the seach is case-insensitive
|
|
200
|
-
#
|
|
201
|
-
# TODO: When 'Searchability' is more dialed in via the searchable
|
|
202
|
-
# mixin, which implements enpoints like 'POST /v1/search-mobile-devices'
|
|
203
|
-
# then use that before using the 'all' list.
|
|
204
|
-
#
|
|
205
|
-
# @param value [Object] A value to search for as an identifier.
|
|
206
|
-
#
|
|
207
|
-
# @param refresh[Boolean] Reload the list data from the API
|
|
208
|
-
#
|
|
209
|
-
# @param ident: [Symbol] Restrict the search to this identifier.
|
|
210
|
-
# E.g. if :serialNumber, then the value must be
|
|
211
|
-
# a known serial number, it is not checked against other identifiers
|
|
212
|
-
#
|
|
213
|
-
# @param cnx: (see .all)
|
|
214
|
-
#
|
|
215
|
-
# @return [Object, nil] the primary identifier of the matching object,
|
|
216
|
-
# or nil if it doesn't exist
|
|
217
|
-
#
|
|
218
|
-
def self.valid_id(value = nil, refresh: true, cnx: Jamf.cnx, **ident_hash)
|
|
219
|
-
unless ident_hash.empty?
|
|
220
|
-
ident, value = ident_hash.first
|
|
221
|
-
return id_from_other_ident ident, value, refresh, cnx: cnx
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
# check the id itself first
|
|
225
|
-
return value if all_ids(refresh, cnx: cnx).include? value
|
|
226
|
-
|
|
227
|
-
idents = identifiers - [:id]
|
|
228
|
-
val_is_str = value.is_a? String
|
|
229
|
-
|
|
230
|
-
idents.each do |ident|
|
|
231
|
-
match = all(refresh, cnx: cnx).select do |m|
|
|
232
|
-
val_is_str ? m[ident].to_s.casecmp?(value) : m[ident] == value
|
|
233
|
-
end.first
|
|
234
|
-
return match[:id] if match
|
|
235
|
-
end # identifiers.each do |ident|
|
|
236
|
-
|
|
237
|
-
nil
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
# Bu default, subclasses are creatable, i.e. new instances can be created
|
|
241
|
-
# with .create, and added to the JSS with .save
|
|
242
|
-
# If a subclass is NOT creatble for any reason, just add
|
|
243
|
-
# extend Jamf::UnCreatable
|
|
244
|
-
# and this method will return false
|
|
245
|
-
#
|
|
246
|
-
# @return [Boolean]
|
|
247
|
-
def self.creatable?
|
|
248
|
-
true
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
# Make a new thing to be added to the API
|
|
252
|
-
def self.create(**params)
|
|
253
|
-
validate_not_abstract
|
|
254
|
-
raise Jamf::UnsupportedError, "#{self}'s are not currently creatable via the API" unless creatable?
|
|
255
|
-
|
|
256
|
-
cnx = params.delete :cnx
|
|
257
|
-
cnx ||= Jamf.cnx
|
|
258
|
-
|
|
259
|
-
params.delete :id # no such animal when .creating
|
|
260
|
-
|
|
261
|
-
params.keys.each do |param|
|
|
262
|
-
raise ArgumentError, "Unknown parameter: #{param}" unless self::OBJECT_MODEL.key? param
|
|
263
|
-
|
|
264
|
-
params[param] = validate_attr param, params[param], cnx: cnx
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
params[:creating_from_create] = true
|
|
268
|
-
new params, cnx: cnx
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
# Retrieve a member of a CollectionResource from the API
|
|
272
|
-
#
|
|
273
|
-
# To create new members to be added to the JSS, use
|
|
274
|
-
# {Jamf::CollectionResource.create}
|
|
275
|
-
#
|
|
276
|
-
# If you know the specific identifier attribute you're looking up, e.g.
|
|
277
|
-
# :id or :name or :udid, (or an aliase thereof) then you can specify it like
|
|
278
|
-
# `.fetch name: 'somename'`, or `.fetch udid: 'someudid'`
|
|
279
|
-
#
|
|
280
|
-
# If you don't know if (or don't want to type it) you can just use
|
|
281
|
-
# `.fetch 'somename'`, or `.fetch 'someudid'` and all identifiers will be
|
|
282
|
-
# searched for a match.
|
|
283
|
-
#
|
|
284
|
-
# @param ident_value[Object] A value for any identifier for this subclass.
|
|
285
|
-
# All identifier attributes will be searched for a match.
|
|
286
|
-
#
|
|
287
|
-
# @param cnx[Jamf::Connection] the connection to use to fetch the object
|
|
288
|
-
#
|
|
289
|
-
# @param ident_hash[Hash] an identifier attribute key and a search value
|
|
290
|
-
#
|
|
291
|
-
# @return [CollectionResource] The ruby-instance of a Jamf object
|
|
292
|
-
#
|
|
293
|
-
def self.fetch(ident_value = nil, cnx: Jamf.cnx, **ident_hash)
|
|
294
|
-
validate_not_abstract
|
|
295
|
-
|
|
296
|
-
id =
|
|
297
|
-
if ident_value == :random
|
|
298
|
-
all_ids.sample
|
|
299
|
-
elsif ident_value
|
|
300
|
-
valid_id ident_value, cnx: cnx
|
|
301
|
-
elsif ident_hash.empty?
|
|
302
|
-
nil
|
|
303
|
-
else
|
|
304
|
-
ident, lookup_value = ident_hash.first
|
|
305
|
-
valid_id ident => lookup_value, cnx: cnx
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
raise Jamf::NoSuchItemError, "No matching #{self}" unless id
|
|
309
|
-
|
|
310
|
-
data = cnx.get "#{rsrc_path}/#{id}"
|
|
311
|
-
new data, cnx: cnx
|
|
312
|
-
end # fetch
|
|
313
|
-
|
|
314
|
-
# By default, CollectionResource subclass instances are deletable.
|
|
315
|
-
# If not, just extend the subclass with Jamf::UnDeletable, and this
|
|
316
|
-
# will return false, and .delete & #delete will raise errors
|
|
317
|
-
def self.deletable?
|
|
318
|
-
true
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
# Delete one or more objects by identifier
|
|
322
|
-
# Any valid identifier for the class can be used (id, name, udid, etc)
|
|
323
|
-
# Identifiers can be provided as an array or as separate parameters
|
|
324
|
-
#
|
|
325
|
-
# e.g. .delete [1,3, 34, 4]
|
|
326
|
-
# or .delete 'myComputer', 'that-computer', 'OtherComputer'
|
|
327
|
-
#
|
|
328
|
-
# @param idents[Array<integer>, Integer]
|
|
329
|
-
#
|
|
330
|
-
# @param cnx[Jamf::Connection]
|
|
331
|
-
#
|
|
332
|
-
# @return [Array] the identifiers that were not found, so couldn't be deleted
|
|
333
|
-
#
|
|
334
|
-
def self.delete(*idents, cnx: Jamf.cnx)
|
|
335
|
-
raise Jamf::UnsupportedError, "Deleting #{self} objects is not currently supported" unless deletable?
|
|
336
|
-
|
|
337
|
-
idents.flatten!
|
|
338
|
-
no_valid_ids = []
|
|
339
|
-
|
|
340
|
-
idents.map do |ident|
|
|
341
|
-
id = valid_id ident
|
|
342
|
-
no_valid_ids << ident unless id
|
|
343
|
-
id
|
|
344
|
-
end
|
|
345
|
-
idents.compact!
|
|
346
|
-
|
|
347
|
-
# TODO: some rsrcs have a 'bulk delete' version...
|
|
348
|
-
idents.each { |id| cnx.delete "#{rsrc_path}/#{id}" }
|
|
349
|
-
|
|
350
|
-
no_valid_ids
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
# Private Class Methods
|
|
354
|
-
#####################################
|
|
355
|
-
|
|
356
|
-
# TODO: better pluralizing?
|
|
357
|
-
#
|
|
358
|
-
def self.create_list_methods(attr_name, attr_def)
|
|
359
|
-
list_method_name = "all_#{attr_name}s"
|
|
360
|
-
|
|
361
|
-
define_singleton_method(list_method_name) do |refresh = false, cnx: Jamf.cnx|
|
|
362
|
-
all_list = all(refresh, cnx: cnx)
|
|
363
|
-
if attr_def[:class].is_a? Symbol
|
|
364
|
-
all_list.map { |i| i[attr_name] }.uniq
|
|
365
|
-
else
|
|
366
|
-
all_list.map { |i| attr_def[:class].new i[attr_name] }
|
|
367
|
-
end
|
|
368
|
-
end # define_singleton_method
|
|
369
|
-
|
|
370
|
-
return unless attr_def[:aliases]
|
|
371
|
-
|
|
372
|
-
# aliases - TODO: is there a more elegant way?
|
|
373
|
-
attr_def[:aliases].each do |a|
|
|
374
|
-
define_singleton_method("all_#{a}s") do |refresh = false, cnx: Jamf.cnx|
|
|
375
|
-
send list_method_name, refresh, cnx: cnx
|
|
376
|
-
end # define_singleton_method
|
|
377
|
-
end # each alias
|
|
378
|
-
end # create_list_methods
|
|
379
|
-
private_class_method :create_list_methods
|
|
380
|
-
|
|
381
|
-
# Given an indentier attr. key, and a value,
|
|
382
|
-
# return the id where that ident has that value, or nil
|
|
383
|
-
#
|
|
384
|
-
def self.id_from_other_ident(ident, value, refresh = true, cnx: Jamf.cnx)
|
|
385
|
-
raise ArgumentError, "Unknown identifier '#{ident}' for #{self}" unless identifiers.include? ident
|
|
386
|
-
|
|
387
|
-
# check the id itself first
|
|
388
|
-
return value if ident == :id && all_ids(refresh, cnx: cnx).include?(value)
|
|
389
|
-
|
|
390
|
-
# all ident values => ids
|
|
391
|
-
ident_map = map_all(ident, to: :id, cnx: cnx, refresh: refresh)
|
|
392
|
-
|
|
393
|
-
# case-insensitivity for string values
|
|
394
|
-
value = ident_map.keys.j_ci_fetch(value) if value.is_a? String
|
|
395
|
-
|
|
396
|
-
ident_map[value]
|
|
397
|
-
end
|
|
398
|
-
private_class_method :id_from_other_ident
|
|
399
|
-
|
|
400
|
-
# Instance Methods
|
|
401
|
-
#####################################
|
|
402
|
-
|
|
403
|
-
def exist?
|
|
404
|
-
!@id.nil?
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
def rsrc_path
|
|
408
|
-
return unless exist?
|
|
409
|
-
"#{self.class.rsrc_path}/#{@id}"
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
def delete
|
|
413
|
-
raise Jamf::UnsupportedError, "Deleting #{self} objects is not currently supported" unless self.class.deletable?
|
|
414
|
-
@cnx.delete rsrc_path
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
# Two collection resource objects are the same if their id's are the same
|
|
418
|
-
def <=>(other)
|
|
419
|
-
id <=> other.id
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
# Private Instance Methods
|
|
423
|
-
############################################
|
|
424
|
-
private
|
|
425
|
-
|
|
426
|
-
def create_in_jamf
|
|
427
|
-
result = @cnx.post self.class.rsrc_path, to_jamf
|
|
428
|
-
@id = result[:id]
|
|
429
|
-
end
|
|
430
|
-
|
|
431
|
-
end # class CollectionResource
|
|
432
|
-
|
|
433
|
-
end # module JAMF
|