ruby-jss 1.2.4a3 → 1.3.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.
Files changed (248) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +180 -1
  3. data/README.md +4 -2
  4. data/bin/cgrouper +1 -1
  5. data/bin/jamfHelperBackgrounder +1 -1
  6. data/bin/netseg-update +1 -1
  7. data/data/ruby-jss.conf.example +1 -1
  8. data/lib/jamf.rb +2 -1
  9. data/lib/jamf/api/abstract_classes/advanced_search.rb +1 -1
  10. data/lib/jamf/api/abstract_classes/collection_resource.rb +54 -38
  11. data/lib/jamf/api/abstract_classes/generic_reference.rb +1 -1
  12. data/lib/jamf/api/abstract_classes/json_object.rb +16 -10
  13. data/lib/jamf/api/abstract_classes/prestage.rb +111 -35
  14. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +1 -1
  15. data/lib/jamf/api/abstract_classes/resource.rb +1 -1
  16. data/lib/jamf/api/abstract_classes/singleton_resource.rb +1 -1
  17. data/lib/jamf/api/attribute_classes/ip_address.rb +1 -1
  18. data/lib/jamf/api/attribute_classes/timestamp.rb +1 -1
  19. data/lib/jamf/api/connection.rb +166 -69
  20. data/lib/jamf/api/connection/api_error.rb +1 -1
  21. data/lib/jamf/api/connection/api_error_styleguide.rb +1 -1
  22. data/lib/jamf/api/connection/token.rb +87 -16
  23. data/lib/jamf/api/json_objects/account_prefs.rb +1 -1
  24. data/lib/jamf/api/json_objects/android_details.rb +1 -1
  25. data/lib/jamf/api/json_objects/appletv_details.rb +1 -1
  26. data/lib/jamf/api/json_objects/attachment.rb +1 -1
  27. data/lib/jamf/api/json_objects/cellular_network.rb +1 -1
  28. data/lib/jamf/api/json_objects/change_log_entry.rb +1 -1
  29. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +1 -1
  30. data/lib/jamf/api/json_objects/country.rb +1 -1
  31. data/lib/jamf/api/json_objects/criterion.rb +1 -1
  32. data/lib/jamf/api/json_objects/device_enrollment_device.rb +6 -4
  33. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
  34. data/lib/jamf/api/json_objects/extension_attribute_value.rb +1 -1
  35. data/lib/jamf/api/json_objects/installed_application.rb +1 -1
  36. data/lib/jamf/api/json_objects/installed_certificate.rb +1 -1
  37. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +1 -1
  38. data/lib/jamf/api/json_objects/installed_ebook.rb +1 -1
  39. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +1 -1
  40. data/lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb +1 -1
  41. data/lib/jamf/api/json_objects/ios_details.rb +1 -1
  42. data/lib/jamf/api/json_objects/location.rb +1 -1
  43. data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
  44. data/lib/jamf/api/json_objects/md_prestage_names.rb +1 -1
  45. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +1 -1
  46. data/lib/jamf/api/json_objects/mobile_device_details.rb +1 -1
  47. data/lib/jamf/api/json_objects/mobile_device_security.rb +1 -1
  48. data/lib/jamf/api/json_objects/prestage_assignment.rb +5 -3
  49. data/lib/jamf/api/json_objects/prestage_location.rb +1 -1
  50. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +1 -1
  51. data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
  52. data/lib/jamf/api/json_objects/prestage_sync_status.rb +1 -1
  53. data/lib/jamf/api/json_objects/purchasing_data.rb +1 -1
  54. data/lib/jamf/api/mixins/abstract.rb +1 -1
  55. data/lib/jamf/api/mixins/bulk_deletable.rb +1 -1
  56. data/lib/jamf/api/mixins/change_log.rb +3 -1
  57. data/lib/jamf/api/mixins/extendable.rb +1 -1
  58. data/lib/jamf/api/mixins/immutable.rb +1 -1
  59. data/lib/jamf/api/mixins/locatable.rb +1 -1
  60. data/lib/jamf/api/mixins/lockable.rb +1 -1
  61. data/lib/jamf/api/mixins/referable.rb +1 -1
  62. data/lib/jamf/api/mixins/searchable.rb +3 -3
  63. data/lib/jamf/api/mixins/uncreatable.rb +1 -1
  64. data/lib/jamf/api/mixins/undeletable.rb +1 -1
  65. data/lib/jamf/api/resources/collection_resources/account.rb +1 -1
  66. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +1 -1
  67. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +1 -1
  68. data/lib/jamf/api/resources/collection_resources/building.rb +1 -1
  69. data/lib/jamf/api/resources/collection_resources/category.rb +1 -1
  70. data/lib/jamf/api/resources/collection_resources/computer.rb +1 -1
  71. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +1 -1
  72. data/lib/jamf/api/resources/collection_resources/department.rb +2 -1
  73. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +110 -18
  74. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +1 -1
  75. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +9 -2
  76. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +1 -1
  77. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +1 -1
  78. data/lib/jamf/api/resources/collection_resources/script.rb +1 -1
  79. data/lib/jamf/api/resources/collection_resources/site.rb +1 -1
  80. data/lib/jamf/api/resources/collection_resources/time_zone.rb +119 -0
  81. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +1 -1
  82. data/lib/jamf/api/resources/singleton_resources/authorization.rb +1 -1
  83. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +1 -1
  84. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +1 -1
  85. data/lib/jamf/client.rb +59 -4
  86. data/lib/jamf/client/jamf_binary.rb +1 -1
  87. data/lib/jamf/client/jamf_helper.rb +1 -1
  88. data/lib/jamf/client/management_action.rb +1 -1
  89. data/lib/jamf/compatibility.rb +1 -1
  90. data/lib/jamf/composer.rb +1 -1
  91. data/lib/jamf/configuration.rb +6 -8
  92. data/lib/jamf/exceptions.rb +6 -1
  93. data/lib/jamf/ruby_extensions.rb +2 -1
  94. data/lib/jamf/ruby_extensions/array.rb +2 -2
  95. data/lib/jamf/ruby_extensions/array/predicates.rb +1 -1
  96. data/lib/jamf/ruby_extensions/array/utils.rb +4 -3
  97. data/lib/jamf/ruby_extensions/dig.rb +52 -0
  98. data/lib/jamf/ruby_extensions/filetest.rb +1 -1
  99. data/lib/jamf/ruby_extensions/filetest/predicates.rb +1 -1
  100. data/lib/jamf/ruby_extensions/hash.rb +1 -1
  101. data/lib/jamf/ruby_extensions/hash/backports.rb +2 -2
  102. data/lib/jamf/ruby_extensions/ipaddr.rb +1 -1
  103. data/lib/jamf/ruby_extensions/ipaddr/utils.rb +1 -1
  104. data/lib/jamf/ruby_extensions/object.rb +1 -1
  105. data/lib/jamf/ruby_extensions/object/predicates.rb +1 -1
  106. data/lib/jamf/ruby_extensions/pathname.rb +1 -1
  107. data/lib/jamf/ruby_extensions/pathname/predicates.rb +1 -1
  108. data/lib/jamf/ruby_extensions/pathname/utils.rb +1 -1
  109. data/lib/jamf/ruby_extensions/string.rb +1 -1
  110. data/lib/jamf/ruby_extensions/string/backports.rb +1 -1
  111. data/lib/jamf/ruby_extensions/string/conversions.rb +1 -1
  112. data/lib/jamf/ruby_extensions/string/predicates.rb +14 -4
  113. data/lib/jamf/utility.rb +1 -1
  114. data/lib/jamf/validate.rb +1 -1
  115. data/lib/jamf/version.rb +2 -2
  116. data/lib/jpapi.rb +1 -1
  117. data/lib/jss-api.rb +1 -1
  118. data/lib/jss.rb +5 -2
  119. data/lib/jss/api_connection.rb +3 -30
  120. data/lib/jss/api_object.rb +16 -3
  121. data/lib/jss/api_object/account.rb +1 -1
  122. data/lib/jss/api_object/advanced_search.rb +1 -1
  123. data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +1 -1
  124. data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +1 -1
  125. data/lib/jss/api_object/advanced_search/advanced_user_search.rb +1 -1
  126. data/lib/jss/api_object/building.rb +1 -1
  127. data/lib/jss/api_object/categorizable.rb +1 -1
  128. data/lib/jss/api_object/category.rb +1 -1
  129. data/lib/jss/api_object/computer.rb +12 -6
  130. data/lib/jss/api_object/computer/application_installs.rb +1 -1
  131. data/lib/jss/api_object/computer_invitation.rb +1 -1
  132. data/lib/jss/api_object/configuration_profile.rb +4 -2
  133. data/lib/jss/api_object/configuration_profile/mobile_device_configuration_profile.rb +1 -1
  134. data/lib/jss/api_object/configuration_profile/osx_configuration_profile.rb +1 -1
  135. data/lib/jss/api_object/creatable.rb +1 -1
  136. data/lib/jss/api_object/criteriable.rb +10 -5
  137. data/lib/jss/api_object/criteriable/criteria.rb +26 -10
  138. data/lib/jss/api_object/criteriable/criterion.rb +1 -1
  139. data/lib/jss/api_object/department.rb +1 -1
  140. data/lib/jss/api_object/directory_binding.rb +273 -0
  141. data/lib/jss/api_object/directory_binding_type.rb +90 -0
  142. data/lib/jss/api_object/directory_binding_type/active_directory.rb +502 -0
  143. data/lib/jss/api_object/directory_binding_type/admitmac.rb +525 -0
  144. data/lib/jss/api_object/directory_binding_type/centrify.rb +212 -0
  145. data/lib/jss/api_object/directory_binding_type/open_directory.rb +178 -0
  146. data/lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb +73 -0
  147. data/lib/jss/api_object/disk_encryption_configurations.rb +114 -0
  148. data/lib/jss/api_object/distribution_point.rb +96 -36
  149. data/lib/jss/api_object/dock_item.rb +137 -0
  150. data/lib/jss/api_object/ebook.rb +1 -1
  151. data/lib/jss/api_object/extendable.rb +67 -28
  152. data/lib/jss/api_object/extension_attribute.rb +1 -1
  153. data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +1 -1
  154. data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +1 -1
  155. data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +1 -1
  156. data/lib/jss/api_object/group.rb +1 -1
  157. data/lib/jss/api_object/group/computer_group.rb +1 -1
  158. data/lib/jss/api_object/group/mobile_device_group.rb +1 -1
  159. data/lib/jss/api_object/group/user_group.rb +1 -1
  160. data/lib/jss/api_object/ibeacon.rb +1 -1
  161. data/lib/jss/api_object/ldap_server.rb +1 -1
  162. data/lib/jss/api_object/locatable.rb +1 -1
  163. data/lib/jss/api_object/mac_application.rb +1 -1
  164. data/lib/jss/api_object/management_history.rb +23 -22
  165. data/lib/jss/api_object/management_history/audit_event.rb +1 -1
  166. data/lib/jss/api_object/management_history/casper_imaging_log.rb +1 -1
  167. data/lib/jss/api_object/management_history/casper_remote_log.rb +1 -1
  168. data/lib/jss/api_object/management_history/computer_usage_log.rb +1 -1
  169. data/lib/jss/api_object/management_history/ebook.rb +1 -1
  170. data/lib/jss/api_object/management_history/hashlike.rb +1 -1
  171. data/lib/jss/api_object/management_history/mac_app_store_app.rb +1 -1
  172. data/lib/jss/api_object/management_history/mdm_command.rb +1 -1
  173. data/lib/jss/api_object/management_history/mobile_device_app.rb +1 -1
  174. data/lib/jss/api_object/management_history/policy_log.rb +1 -1
  175. data/lib/jss/api_object/management_history/screen_sharing_log.rb +1 -1
  176. data/lib/jss/api_object/management_history/user_location_change.rb +1 -1
  177. data/lib/jss/api_object/matchable.rb +1 -1
  178. data/lib/jss/api_object/mdm.rb +1 -1
  179. data/lib/jss/api_object/mobile_device.rb +29 -6
  180. data/lib/jss/api_object/mobile_device_application.rb +13 -1
  181. data/lib/jss/api_object/netboot_server.rb +1 -1
  182. data/lib/jss/api_object/network_segment.rb +153 -59
  183. data/lib/jss/api_object/package.rb +107 -42
  184. data/lib/jss/api_object/patch_policy.rb +1 -1
  185. data/lib/jss/api_object/patch_source.rb +1 -1
  186. data/lib/jss/api_object/patch_source/patch_external_source.rb +1 -1
  187. data/lib/jss/api_object/patch_source/patch_internal_source.rb +1 -1
  188. data/lib/jss/api_object/patch_title.rb +1 -1
  189. data/lib/jss/api_object/patch_title/version.rb +1 -1
  190. data/lib/jss/api_object/peripheral.rb +1 -1
  191. data/lib/jss/api_object/peripheral_type.rb +1 -1
  192. data/lib/jss/api_object/policy.rb +380 -5
  193. data/lib/jss/api_object/printer.rb +440 -0
  194. data/lib/jss/api_object/purchasable.rb +1 -1
  195. data/lib/jss/api_object/removable_macaddr.rb +1 -1
  196. data/lib/jss/api_object/restricted_software.rb +1 -1
  197. data/lib/jss/api_object/scopable.rb +1 -1
  198. data/lib/jss/api_object/scopable/scope.rb +257 -37
  199. data/lib/jss/api_object/script.rb +1 -1
  200. data/lib/jss/api_object/self_servable.rb +7 -7
  201. data/lib/jss/api_object/self_servable/icon.rb +1 -1
  202. data/lib/jss/api_object/sitable.rb +6 -2
  203. data/lib/jss/api_object/site.rb +1 -1
  204. data/lib/jss/api_object/software_update_server.rb +1 -1
  205. data/lib/jss/api_object/updatable.rb +1 -1
  206. data/lib/jss/api_object/uploadable.rb +1 -1
  207. data/lib/jss/api_object/user.rb +5 -3
  208. data/lib/jss/api_object/vppable.rb +1 -1
  209. data/lib/jss/api_object/webhook.rb +1 -1
  210. data/lib/jss/client.rb +1 -1
  211. data/lib/jss/client/jamf_binary.rb +1 -1
  212. data/lib/jss/client/jamf_helper.rb +1 -1
  213. data/lib/jss/client/management_action.rb +1 -1
  214. data/lib/jss/compatibility.rb +1 -1
  215. data/lib/jss/composer.rb +2 -2
  216. data/lib/jss/configuration.rb +1 -1
  217. data/lib/jss/db_connection.rb +1 -1
  218. data/lib/jss/exceptions.rb +1 -1
  219. data/lib/jss/ruby_extensions.rb +1 -1
  220. data/lib/jss/ruby_extensions/array.rb +1 -1
  221. data/lib/jss/ruby_extensions/filetest.rb +1 -1
  222. data/lib/jss/ruby_extensions/hash.rb +1 -1
  223. data/lib/jss/ruby_extensions/ipaddr.rb +1 -1
  224. data/lib/jss/ruby_extensions/pathname.rb +1 -1
  225. data/lib/jss/ruby_extensions/string.rb +1 -1
  226. data/lib/jss/ruby_extensions/string/backports.rb +1 -1
  227. data/lib/jss/ruby_extensions/string/conversions.rb +1 -1
  228. data/lib/jss/ruby_extensions/string/predicates.rb +14 -4
  229. data/lib/jss/ruby_extensions/time.rb +1 -1
  230. data/lib/jss/server.rb +1 -1
  231. data/lib/jss/utility.rb +9 -23
  232. data/lib/jss/validate.rb +1 -1
  233. data/lib/jss/version.rb +2 -2
  234. data/lib/jss/xml_workaround.rb +1 -1
  235. data/lib/ruby-jss.rb +1 -1
  236. data/test/bin/runtests +1 -1
  237. data/test/lib/testhelper.rb +1 -1
  238. data/test/lib/testhelper/auth.rb +1 -1
  239. data/test/lib/testhelper/patch_mgmt.rb +1 -1
  240. data/test/specs/api_connection_spec.rb +1 -1
  241. data/test/specs/patch01_source_spec.rb +1 -1
  242. data/test/specs/patch02_internal_source_spec.rb +1 -1
  243. data/test/specs/patch03_external_source_spec.rb +1 -1
  244. data/test/specs/patch04_titles_spec.rb +1 -1
  245. data/test/specs/patch05_policies_spec.rb +1 -1
  246. data/test/specs/patch06_cleanup_spec.rb +1 -1
  247. data/test/specs/policy_spec.rb +1 -1
  248. metadata +16 -4
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -60,6 +60,8 @@ module Jamf
60
60
  #
61
61
  module ChangeLog
62
62
 
63
+ # TODO: note can have a max length of 2500 characters.
64
+
63
65
  # The change and note history for this resource.
64
66
  #
65
67
  # The history is cached internally and only re-fetched when
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -161,7 +161,7 @@ module Jamf
161
161
  enum: SORT_DIRECTIONS
162
162
  }
163
163
  }.freeze
164
-
164
+ parse_object_model
165
165
  end # class Orderby
166
166
 
167
167
  class SeachParams < Jamf::JSONObject
@@ -194,7 +194,7 @@ module Jamf
194
194
  }
195
195
 
196
196
  }.freeze
197
-
197
+ parse_object_model
198
198
  end # class SearchParams
199
199
 
200
200
  end # module searchable
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
4
  # with the following modification; you may not use this file except in
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -71,6 +71,7 @@ module Jamf
71
71
  required: true
72
72
  }
73
73
  }.freeze
74
+
74
75
  parse_object_model
75
76
 
76
77
 
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -144,6 +144,8 @@ module Jamf
144
144
 
145
145
  LATEST_RSRC = 'latest'.freeze
146
146
 
147
+ DISOWN_RSRC = 'disown'.freeze
148
+
147
149
  TYPES = %i[computers mobiledevices].freeze
148
150
 
149
151
  COMPUTERS_RE = /mac/i.freeze
@@ -152,7 +154,12 @@ module Jamf
152
154
  #########################################
153
155
 
154
156
  # All devices associated by Apple with a given DeviceEnrollment instance
155
- # or all defined DeviceEnrollment instances
157
+ # or all defined DeviceEnrollment instances.
158
+ #
159
+ # This data is cached the first time it is read from the API, similarly to
160
+ # how CollectionResources are cached. To refresh the cache, pass
161
+ # a truthy value to the refresh: parameter, or use the Connection's
162
+ # .flushcache method
156
163
  #
157
164
  # @param instance_ident[Integer, String] the id or name of the
158
165
  # DeviceEnrollment instance for which to list the devices. If omitted,
@@ -161,17 +168,19 @@ module Jamf
161
168
  # @param type[Symbol] Either :computers or :mobiledevices, returns both if
162
169
  # not specified.
163
170
  #
171
+ # @param refresh [Boolean] re-read the data from the API?
172
+ #
164
173
  # @param cnx[Jamf::Connection] The API connection to use
165
174
  #
166
175
  # @return [Array<Jamf::DeviceEnrollmentDevice>] The devices associated with
167
- # the given, or all, instances
176
+ # the given DeviceEnrollment instance, or all instances
168
177
  #
169
- def self.devices(instance_ident = nil, type: nil, cnx: Jamf.cnx)
178
+ def self.devices(instance_ident = nil, type: nil, refresh: false, cnx: Jamf.cnx)
170
179
  if type
171
180
  raise ArgumentError, "Type must be one of: :#{TYPES.join ', :'}" unless TYPES.include? type
172
181
  end
173
182
 
174
- devs = fetch_devices(instance_ident, cnx)
183
+ devs = fetch_devices(instance_ident, refresh, cnx)
175
184
  return devs unless type
176
185
 
177
186
  if type == :computers
@@ -181,23 +190,33 @@ module Jamf
181
190
  end
182
191
  end
183
192
 
193
+ # The serial numbers assigned bu Apple to one, or all of your
194
+ # Device Enrollment instances
195
+ #
184
196
  # See .devices
197
+ #
185
198
  # @return [Array<String>] just the serial numbers for the devices
186
199
  #
187
- def self.device_sns(instance_ident = nil, type: nil, cnx: Jamf.cnx)
188
- devices(instance_ident, type: type, cnx: cnx).map(&:serialNumber)
200
+ def self.device_sns(instance_ident = nil, type: nil, refresh: false, cnx: Jamf.cnx)
201
+ devices(instance_ident, type: type, refresh: refresh, cnx: cnx).map(&:serialNumber)
189
202
  end
190
203
 
204
+ # Is the given serial number in one, or any, or your Device Enrollment
205
+ # instances?
206
+ #
191
207
  # See .devices
192
208
  #
209
+ # @param sn [String] the serialNumber to look for
210
+ #
193
211
  # @return [Boolean] is the given SN in a given DeviceEnrollment instance
194
212
  # or in DEP at all?
195
213
  #
196
- def self.include?(sn, instance_ident = nil, type: nil, cnx: Jamf.cnx)
197
- device_sns(instance_ident, type: type, cnx: cnx).j_ci_include? sn
214
+ def self.include?(sn, instance_ident = nil, type: nil, refresh: false, cnx: Jamf.cnx)
215
+ device_sns(instance_ident, type: type, refresh: refresh, cnx: cnx).j_ci_include? sn
198
216
  end
199
217
 
200
218
  # See .devices
219
+ #
201
220
  # Returns just those devices with the desired profileStatus, which must be
202
221
  # an item in DeviceEnrollmentDevice::PROFILE_STATUSES
203
222
  #
@@ -206,14 +225,54 @@ module Jamf
206
225
  # @return [Array<Jamf::DeviceEnrollmentDevice>] The devices with the desired
207
226
  # status, associated with the given, or all, instances
208
227
  #
209
- def self.devices_with_status(status, instance_ident = nil, type: nil, cnx: Jamf.cnx)
228
+ def self.devices_with_status(status, instance_ident = nil, type: nil, refresh: false, cnx: Jamf.cnx)
210
229
  unless Jamf::DeviceEnrollmentDevice::PROFILE_STATUSES.include? status
211
230
  raise ArgumentError, "profileStatus must be one of: '#{Jamf::DeviceEnrollmentDevice::PROFILE_STATUSES.join "', '"}'"
212
231
  end
213
232
 
214
- devices(instance_ident, type: type, cnx: cnx).select { |d| d.profileStatus == status }
233
+ devices(instance_ident, type: type, refresh: refresh, cnx: cnx).select { |d| d.profileStatus == status }
215
234
  end
216
235
 
236
+ # Fetch a single device from any defined DeviceEnrollment instance.
237
+ # The instance id containing the device is available in its
238
+ # .deviceEnrollmentProgramInstanceId attribute.
239
+ #
240
+ # @pararm sn [String] the serial number of the device
241
+ #
242
+ # @param instance_ident [String, Integer] the name or id of the instance
243
+ # in which to look for the sn. All instances are searched if omitted.
244
+ #
245
+ # @param refresh [Boolean] re-read the data from the API?
246
+ #
247
+ # @param cnx[Jamf::Connection] The API connection to use
248
+ #
249
+ # @return [Jamf::DeviceEnrollmentDevice] the device as known to DEP
250
+ #
251
+ def self.device(sn, instance_ident = nil, refresh: false, cnx: Jamf.cnx)
252
+ sn.upcase! # SNs from apple are always uppercase
253
+ devs = devices(instance_ident, refresh: refresh, cnx: cnx)
254
+ dev = devs.select { |d| d.serialNumber == sn }.first
255
+ return dev if dev
256
+
257
+ searched = instance_ident ? "DeviceEnrollment instance #{instance_ident}" : 'any DeviceEnrollment instance'
258
+ raise Jamf::NoSuchItemError, "No device with serialNumber '#{sn}' in #{searched}"
259
+ end
260
+
261
+ # The history of sync operations between Apple and a given DeviceEnrollment
262
+ # instanace, or all instances.
263
+ #
264
+ # @param instance_ident[Integer, String] the id or name of the
265
+ # DeviceEnrollment instance for which to get the history. If omitted,
266
+ # the history for all instances will be returned.
267
+ #
268
+ # @param latest [Boolean] show only the latest sync? Only valid when an
269
+ # instance_ident is provided.
270
+ #
271
+ # @param cnx[Jamf::Connection] The API connection to use
272
+ #
273
+ # @return [Jamf::DeviceEnrollmentSyncStatus] When latest = true, the latest
274
+ # sync status.
275
+ # @return [Array<Jamf::DeviceEnrollmentSyncStatus>] The known sync statuses.
217
276
  #
218
277
  def self.sync_history(instance_ident = nil, latest = false, cnx: Jamf.cnx)
219
278
  if instance_ident
@@ -232,31 +291,60 @@ module Jamf
232
291
  data.map! { |s| Jamf::DeviceEnrollmentSyncStatus.new s }
233
292
  end
234
293
 
294
+ # disown one or more serial numbers from a given DeviceEnrollment instance
295
+ #
296
+ # @param sns[Array<String>] One or more serial numbers to disown
297
+ #
298
+ # @param from_instance [Integer, String] the id or name of the instance
299
+ # from which to disown the serial numbers
300
+ #
301
+ # @param cnx[Jamf::Connection] The API connection to use
302
+ #
303
+ # @return [void]
304
+ #
305
+ def self.disown(*sns, from_instance:, cnx: Jamf.cnx)
306
+ instance_id = valid_id from_instance, cnx: cnx
307
+ raise Jamf::NoSuchItemError, "No DeviceEnrollment instance matches '#{instance}'" unless instance_id
308
+
309
+ sns.flatten!
310
+ sns.map!(&:to_s)
311
+ data = { devices: sns }
312
+ disown_rsrc = "#{self.class::RSRC_VERSION}/#{self.class::RSRC_PATH}/#{instance_id}/#{DISOWN_RSRC}"
313
+
314
+ cnx.post(disown_rsrc, data)
315
+ end
316
+
235
317
  # Private Class Methods
236
318
  ###############################################
237
319
 
238
320
  # Private, used by the .devices class method
239
- def self.fetch_devices(instance_ident, cnx)
321
+ def self.fetch_devices(instance_ident, refresh, cnx)
240
322
  if instance_ident
241
323
  instance_id = valid_id instance_ident, cnx: cnx
242
- raise Jamf::NoSuchItemError "No DeviceEnrollment instance matches '#{instance_ident}'" unless instance_id
324
+ raise Jamf::NoSuchItemError, "No DeviceEnrollment instance matches '#{instance_ident}'" unless instance_id
243
325
 
244
- devs = devices_for_instance_id instance_id, cnx
326
+ devs = devices_for_instance_id instance_id, refresh, cnx
245
327
  else
246
328
  devs = []
247
329
  all_ids.each do |id|
248
- devs += devices_for_instance_id id, cnx
330
+ devs += devices_for_instance_id id, refresh, cnx
249
331
  end
250
332
  end
251
333
  devs
252
334
  end
253
335
  private_class_method :fetch_devices
254
336
 
255
- # Private, used by the .devices class method
256
- def self.devices_for_instance_id(instance_id, cnx)
337
+ # Private, used by the .fetch_devices class method
338
+ def self.devices_for_instance_id(instance_id, refresh, cnx)
339
+ @device_cache ||= {}
340
+ @device_cache[cnx] ||= {}
341
+ @device_cache[cnx][instance_id] = nil if refresh
342
+ return @device_cache[cnx][instance_id] if @device_cache[cnx][instance_id]
343
+
257
344
  data = cnx.get("#{RSRC_VERSION}/#{RSRC_PATH}/#{instance_id}/#{DEVICES_RSRC}")[:results]
258
345
 
259
- data.map { |dev| Jamf::DeviceEnrollmentDevice.new dev }
346
+ data.map! { |dev| Jamf::DeviceEnrollmentDevice.new dev }
347
+ @device_cache[cnx][instance_id] = data
260
348
  end
261
349
  private_class_method :devices_for_instance_id
262
350
 
@@ -287,6 +375,10 @@ module Jamf
287
375
  sync_history :latest
288
376
  end
289
377
 
378
+ def disown(*sns)
379
+ self.class.disown sns, from_instance: @id, cnx: @cnx
380
+ end
381
+
290
382
  end # class
291
383
 
292
384
  end # module
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -224,7 +224,7 @@ module Jamf
224
224
  extensionAttributes: {
225
225
  class: Jamf::InventoryPreloadExtensionAttribute,
226
226
  multi: true,
227
- aliases: %i[ext_attrs eas]
227
+ aliases: %i[eas]
228
228
  }
229
229
 
230
230
  }.freeze
@@ -251,6 +251,13 @@ module Jamf
251
251
  extensionAttributes_delete_at idx if idx
252
252
  end
253
253
 
254
+ # a Hash of ea name => ea_value for all eas currently set.
255
+ def ext_attrs
256
+ eas = {}
257
+ extensionAttributes.each { |ea| eas[ea.name] = ea.value }
258
+ eas
259
+ end
260
+
254
261
  # clear all values for this record except id, serialNumber, and deviceType
255
262
  def clear
256
263
  OBJECT_MODEL.keys.each do |attr|
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Pixar
1
+ # Copyright 2020 Pixar
2
2
 
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "Apache License")