ruby-jss 1.2.6 → 1.4.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.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +189 -1
  3. data/README.md +1 -1
  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 +1 -1
  9. data/lib/jamf/api/abstract_classes/advanced_search.rb +1 -1
  10. data/lib/jamf/api/abstract_classes/collection_resource.rb +17 -9
  11. data/lib/jamf/api/abstract_classes/generic_reference.rb +1 -1
  12. data/lib/jamf/api/abstract_classes/json_object.rb +2 -2
  13. data/lib/jamf/api/abstract_classes/prestage.rb +2 -2
  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 +9 -5
  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 +22 -2
  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 +1 -1
  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 +1 -1
  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 +1 -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 +1 -1
  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 -2
  73. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +4 -4
  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 +1 -1
  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 +1 -1
  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 +1 -1
  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 +8 -10
  92. data/lib/jamf/exceptions.rb +1 -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 -4
  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 +3 -1
  119. data/lib/jss/api_connection.rb +3 -30
  120. data/lib/jss/api_object.rb +23 -4
  121. data/lib/jss/api_object/account.rb +1 -1
  122. data/lib/jss/api_object/advanced_search.rb +28 -27
  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/app_store_country_codes.rb +298 -0
  127. data/lib/jss/api_object/building.rb +1 -1
  128. data/lib/jss/api_object/categorizable.rb +1 -1
  129. data/lib/jss/api_object/category.rb +1 -1
  130. data/lib/jss/api_object/computer.rb +12 -6
  131. data/lib/jss/api_object/computer/application_installs.rb +1 -1
  132. data/lib/jss/api_object/computer_invitation.rb +1 -1
  133. data/lib/jss/api_object/configuration_profile.rb +4 -2
  134. data/lib/jss/api_object/configuration_profile/mobile_device_configuration_profile.rb +1 -1
  135. data/lib/jss/api_object/configuration_profile/osx_configuration_profile.rb +1 -1
  136. data/lib/jss/api_object/creatable.rb +1 -1
  137. data/lib/jss/api_object/criteriable.rb +1 -1
  138. data/lib/jss/api_object/criteriable/criteria.rb +1 -1
  139. data/lib/jss/api_object/criteriable/criterion.rb +1 -1
  140. data/lib/jss/api_object/department.rb +1 -1
  141. data/lib/jss/api_object/directory_binding.rb +273 -0
  142. data/lib/jss/api_object/directory_binding_type.rb +90 -0
  143. data/lib/jss/api_object/directory_binding_type/active_directory.rb +502 -0
  144. data/lib/jss/api_object/directory_binding_type/admitmac.rb +525 -0
  145. data/lib/jss/api_object/directory_binding_type/centrify.rb +212 -0
  146. data/lib/jss/api_object/directory_binding_type/open_directory.rb +178 -0
  147. data/lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb +73 -0
  148. data/lib/jss/api_object/disk_encryption_configurations.rb +114 -0
  149. data/lib/jss/api_object/distribution_point.rb +96 -36
  150. data/lib/jss/api_object/dock_item.rb +137 -0
  151. data/lib/jss/api_object/ebook.rb +2 -3
  152. data/lib/jss/api_object/extendable.rb +67 -28
  153. data/lib/jss/api_object/extension_attribute.rb +5 -4
  154. data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +1 -1
  155. data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +1 -1
  156. data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +1 -1
  157. data/lib/jss/api_object/group.rb +1 -1
  158. data/lib/jss/api_object/group/computer_group.rb +1 -1
  159. data/lib/jss/api_object/group/mobile_device_group.rb +1 -1
  160. data/lib/jss/api_object/group/user_group.rb +1 -1
  161. data/lib/jss/api_object/ibeacon.rb +1 -1
  162. data/lib/jss/api_object/ldap_server.rb +1 -1
  163. data/lib/jss/api_object/locatable.rb +1 -1
  164. data/lib/jss/api_object/mac_application.rb +108 -9
  165. data/lib/jss/api_object/management_history.rb +1 -1
  166. data/lib/jss/api_object/management_history/audit_event.rb +1 -1
  167. data/lib/jss/api_object/management_history/casper_imaging_log.rb +1 -1
  168. data/lib/jss/api_object/management_history/casper_remote_log.rb +1 -1
  169. data/lib/jss/api_object/management_history/computer_usage_log.rb +1 -1
  170. data/lib/jss/api_object/management_history/ebook.rb +1 -1
  171. data/lib/jss/api_object/management_history/hashlike.rb +1 -1
  172. data/lib/jss/api_object/management_history/mac_app_store_app.rb +1 -1
  173. data/lib/jss/api_object/management_history/mdm_command.rb +1 -1
  174. data/lib/jss/api_object/management_history/mobile_device_app.rb +1 -1
  175. data/lib/jss/api_object/management_history/policy_log.rb +1 -1
  176. data/lib/jss/api_object/management_history/screen_sharing_log.rb +1 -1
  177. data/lib/jss/api_object/management_history/user_location_change.rb +1 -1
  178. data/lib/jss/api_object/matchable.rb +1 -1
  179. data/lib/jss/api_object/mdm.rb +1 -1
  180. data/lib/jss/api_object/mobile_device.rb +12 -6
  181. data/lib/jss/api_object/mobile_device_application.rb +13 -1
  182. data/lib/jss/api_object/netboot_server.rb +1 -1
  183. data/lib/jss/api_object/network_segment.rb +153 -59
  184. data/lib/jss/api_object/package.rb +106 -41
  185. data/lib/jss/api_object/patch_policy.rb +1 -1
  186. data/lib/jss/api_object/patch_source.rb +1 -1
  187. data/lib/jss/api_object/patch_source/patch_external_source.rb +1 -1
  188. data/lib/jss/api_object/patch_source/patch_internal_source.rb +1 -1
  189. data/lib/jss/api_object/patch_title.rb +1 -1
  190. data/lib/jss/api_object/patch_title/version.rb +1 -1
  191. data/lib/jss/api_object/peripheral.rb +1 -1
  192. data/lib/jss/api_object/peripheral_type.rb +1 -1
  193. data/lib/jss/api_object/policy.rb +492 -8
  194. data/lib/jss/api_object/printer.rb +440 -0
  195. data/lib/jss/api_object/purchasable.rb +1 -1
  196. data/lib/jss/api_object/removable_macaddr.rb +1 -1
  197. data/lib/jss/api_object/restricted_software.rb +1 -1
  198. data/lib/jss/api_object/scopable.rb +1 -1
  199. data/lib/jss/api_object/scopable/scope.rb +387 -72
  200. data/lib/jss/api_object/script.rb +1 -1
  201. data/lib/jss/api_object/self_servable.rb +24 -16
  202. data/lib/jss/api_object/self_servable/icon.rb +1 -1
  203. data/lib/jss/api_object/sitable.rb +1 -1
  204. data/lib/jss/api_object/site.rb +1 -1
  205. data/lib/jss/api_object/software_update_server.rb +1 -1
  206. data/lib/jss/api_object/updatable.rb +1 -1
  207. data/lib/jss/api_object/uploadable.rb +2 -2
  208. data/lib/jss/api_object/user.rb +43 -2
  209. data/lib/jss/api_object/vpp_account.rb +209 -0
  210. data/lib/jss/api_object/vppable.rb +170 -14
  211. data/lib/jss/api_object/webhook.rb +1 -1
  212. data/lib/jss/client.rb +1 -1
  213. data/lib/jss/client/jamf_binary.rb +1 -1
  214. data/lib/jss/client/jamf_helper.rb +1 -1
  215. data/lib/jss/client/management_action.rb +1 -1
  216. data/lib/jss/compatibility.rb +1 -1
  217. data/lib/jss/composer.rb +2 -2
  218. data/lib/jss/configuration.rb +1 -1
  219. data/lib/jss/db_connection.rb +1 -1
  220. data/lib/jss/exceptions.rb +1 -1
  221. data/lib/jss/ruby_extensions.rb +1 -1
  222. data/lib/jss/ruby_extensions/array.rb +1 -1
  223. data/lib/jss/ruby_extensions/filetest.rb +1 -1
  224. data/lib/jss/ruby_extensions/hash.rb +1 -1
  225. data/lib/jss/ruby_extensions/ipaddr.rb +1 -1
  226. data/lib/jss/ruby_extensions/pathname.rb +1 -1
  227. data/lib/jss/ruby_extensions/string.rb +1 -1
  228. data/lib/jss/ruby_extensions/string/backports.rb +1 -1
  229. data/lib/jss/ruby_extensions/string/conversions.rb +1 -1
  230. data/lib/jss/ruby_extensions/string/predicates.rb +14 -4
  231. data/lib/jss/ruby_extensions/time.rb +1 -1
  232. data/lib/jss/server.rb +1 -1
  233. data/lib/jss/utility.rb +9 -23
  234. data/lib/jss/validate.rb +54 -11
  235. data/lib/jss/version.rb +2 -2
  236. data/lib/jss/xml_workaround.rb +1 -1
  237. data/lib/ruby-jss.rb +1 -1
  238. data/test/bin/runtests +1 -1
  239. data/test/lib/testhelper.rb +1 -1
  240. data/test/lib/testhelper/auth.rb +1 -1
  241. data/test/lib/testhelper/patch_mgmt.rb +1 -1
  242. data/test/specs/api_connection_spec.rb +1 -1
  243. data/test/specs/patch01_source_spec.rb +1 -1
  244. data/test/specs/patch02_internal_source_spec.rb +1 -1
  245. data/test/specs/patch03_external_source_spec.rb +1 -1
  246. data/test/specs/patch04_titles_spec.rb +1 -1
  247. data/test/specs/patch05_policies_spec.rb +1 -1
  248. data/test/specs/patch06_cleanup_spec.rb +1 -1
  249. data/test/specs/policy_spec.rb +1 -1
  250. metadata +15 -2
@@ -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")
@@ -27,6 +27,6 @@
27
27
  module Jamf
28
28
 
29
29
  ### The version of the Jamf module
30
- VERSION = '0.0.1'.freeze
30
+ VERSION = '0.0.3'.freeze
31
31
 
32
32
  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")
data/lib/jss.rb CHANGED
@@ -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")
@@ -197,7 +197,9 @@ module JSS
197
197
  class DistributionPoint < JSS::APIObject; end
198
198
  class EBook < JSS::APIObject; end
199
199
  class IBeacon < JSS::APIObject; end
200
+ class DockItem < JSS::APIObject; end
200
201
  class LDAPServer < JSS::APIObject; end
202
+ class DirectoryBinding < JSS::APIObject; end
201
203
  class MacApplication < JSS::APIObject; end
202
204
  class MobileDevice < JSS::APIObject; end
203
205
  class MobileDeviceApplication < JSS::APIObject; end
@@ -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
@@ -896,22 +896,7 @@ module JSS
896
896
  # @return [JSS::DistributionPoint]
897
897
  #
898
898
  def master_distribution_point(refresh = false)
899
- @master_distribution_point = nil if refresh
900
- return @master_distribution_point if @master_distribution_point
901
-
902
- JSS::DistributionPoint.all_ids.each do |dp_id|
903
- dp = JSS::DistributionPoint.fetch id: dp_id, api: self
904
- if dp.master?
905
- @master_distribution_point = dp
906
- break
907
- end
908
- end
909
-
910
- return @master_distribution_point if @master_distribution_point
911
-
912
- # If we're here, the Cloud DP might be master, but there's no
913
- # access to it in the API :/
914
- raise JSS::NoSuchItemError, 'No Master Distribtion Point defined. It could be the Cloud Dist Point, which is not available in the classic API'
899
+ JSS::DistributionPoint.master_distribution_point refresh, api: self
915
900
  end
916
901
 
917
902
  # Get the DistributionPoint instance for the machine running
@@ -923,19 +908,7 @@ module JSS
923
908
  # @return [JSS::DistributionPoint]
924
909
  #
925
910
  def my_distribution_point(refresh = false)
926
- @my_distribution_point = nil if refresh
927
- return @my_distribution_point if @my_distribution_point
928
-
929
- my_net_seg_id = my_network_segments[0]
930
-
931
- if my_net_seg_id
932
- my_net_seg = JSS::NetworkSegment.fetch(id: my_net_seg_id, api: self)
933
- my_dp_name = my_net_seg.distribution_point
934
- @my_distribution_point = JSS::DistributionPoint.fetch(name: my_dp_name) if my_dp_name
935
- end # if my_net_seg_id
936
-
937
- @my_distribution_point ||= master_distribution_point refresh
938
- @my_distribution_point
911
+ JSS::DistributionPoint.my_distribution_point refresh, api: self
939
912
  end
940
913
 
941
914
  # @deprecated
@@ -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")
@@ -1222,8 +1222,16 @@ module JSS
1222
1222
  # @return [void]
1223
1223
  #
1224
1224
  def delete
1225
- return nil unless @in_jss
1226
- @api.delete_rsrc @rest_rsrc
1225
+ return unless @in_jss
1226
+ begin
1227
+ @api.delete_rsrc @rest_rsrc
1228
+ rescue RestClient::NotFound, RestClient::ResourceNotFound
1229
+ # over slow connections (?) or more likely
1230
+ # split-tunnel VPN connections, sometimes the thing gets deleted
1231
+ # the call gets a 404 anyway
1232
+ nil
1233
+ end
1234
+
1227
1235
  @rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name.to_s}"
1228
1236
  @id = nil
1229
1237
  @in_jss = false
@@ -1350,7 +1358,10 @@ module JSS
1350
1358
  #
1351
1359
  def ppx
1352
1360
  return nil unless creatable? || updatable?
1353
- REXML::Document.new(rest_xml).write $stdout, 2
1361
+
1362
+ formatter = REXML::Formatters::Pretty.new(2)
1363
+ formatter.compact = true
1364
+ formatter.write(REXML::Document.new(rest_xml), $stdout)
1354
1365
  puts
1355
1366
  end
1356
1367
 
@@ -1655,9 +1666,13 @@ require 'jss/api_object/category'
1655
1666
  require 'jss/api_object/computer'
1656
1667
  require 'jss/api_object/computer_invitation'
1657
1668
  require 'jss/api_object/department'
1669
+ require 'jss/api_object/disk_encryption_configurations'
1670
+ require "jss/api_object/directory_binding_type"
1671
+ require 'jss/api_object/directory_binding'
1658
1672
  require 'jss/api_object/distribution_point'
1659
1673
  require 'jss/api_object/ebook'
1660
1674
  require 'jss/api_object/ibeacon'
1675
+ require 'jss/api_object/dock_item'
1661
1676
  require 'jss/api_object/ldap_server'
1662
1677
  require 'jss/api_object/mac_application'
1663
1678
  require 'jss/api_object/mobile_device'
@@ -1677,5 +1692,9 @@ require 'jss/api_object/site'
1677
1692
  require 'jss/api_object/software_update_server'
1678
1693
  require 'jss/api_object/user'
1679
1694
  require 'jss/api_object/webhook'
1695
+ require 'jss/api_object/printer'
1696
+
1697
+ ### Other
1698
+ require 'jss/api_object/app_store_country_codes'
1680
1699
 
1681
1700
  JSS::APIObject.define_identifier_list_methods
@@ -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")
@@ -62,6 +62,7 @@ module JSS
62
62
  include JSS::Criteriable
63
63
  include JSS::Sitable
64
64
 
65
+
65
66
  # Class Constants
66
67
  #####################################
67
68
 
@@ -85,6 +86,22 @@ module JSS
85
86
  #
86
87
  attr_reader :search_results
87
88
 
89
+ # @return [Array<String>] the fields to be returned with the search results
90
+ #
91
+ # The API delivers these as an array of Hashes,
92
+ # where each hash has only one key, :name => the name of the fields/ExtAttrib
93
+ # to display. It should probably not have the underlying Hashes, and just
94
+ # be an array of names. This class converts it to just an Array of field names
95
+ # (Strings) for internal use.
96
+ #
97
+ # These fields are returned in the @search_results
98
+ # data along with :id, :name, and other unique identifiers
99
+ # for each found item. In that data, their names have colons removed, abd
100
+ # spaces and dashes converted to underscores, and they are
101
+ # symbolized. See attribute result_display_keys
102
+ #
103
+ attr_reader :display_fields
104
+
88
105
  # @return [Array<Symbol>]
89
106
  #
90
107
  # The search result Hash keys for the {#display_fields} of the search
@@ -95,8 +112,9 @@ module JSS
95
112
  # methods are for.
96
113
  #
97
114
  # However, when those names come back as the Hash Keys of the {#search_results}
98
- # they (inconsistently) have spaces and/or dashes converted to underscores, and,
99
- # the JSON module converts the keys to Symbols, so they don't match the {#display_fields}.
115
+ # they (inconsistently) have spaces and/or dashes converted to underscores,
116
+ # and colons are removed. The JSON module then converts the keys to Symbols,
117
+ # so they don't match the {#display_fields}.
100
118
  #
101
119
  # For example, the display field "Last Check-in" might come back as any of these Symbols:
102
120
  # - :"Last Check-in"
@@ -147,13 +165,13 @@ module JSS
147
165
  # make sure each hash of the search results
148
166
  # has a key matching a standard key.
149
167
  #
150
- @search_results.each do |hash|
151
- hash.keys.each do |key|
152
- std_key = key.to_s.gsub(/ |-/, '_').to_sym
153
- next if hash[std_key]
154
- hash[std_key] = hash[key]
155
- end
156
- end
168
+ # @search_results.each do |hash|
169
+ # hash.keys.each do |key|
170
+ # std_key = key.to_s.gsub(':', '').gsub(/ |-/, '_').to_sym
171
+ # next if hash[std_key]
172
+ # hash[std_key] = hash[key]
173
+ # end
174
+ # end
157
175
  end # init
158
176
 
159
177
  # Public Instance Methods
@@ -231,23 +249,6 @@ module JSS
231
249
  end
232
250
  end
233
251
 
234
- # @return [Array<String>] the fields to be returned with the search results
235
- #
236
- # The API delivers these as an array of Hashes,
237
- # where each hash has only one key, :name => the name of the fields/ExtAttrib
238
- # to display. It should probably not have the underlying Hashes, and just
239
- # be an array of names. This class converts it to just an Array of field names
240
- # (Strings) for internal use.
241
- #
242
- # These fields are returned in the @search_results
243
- # data along with :id, :name, and other unique identifiers
244
- # for each found item. In that data, their names have
245
- # spaces and dashes converted to underscores, and they are
246
- # symbolized.
247
- #
248
- #
249
- attr_reader :display_fields
250
-
251
252
  # Set the list of fields to be retrieved with the
252
253
  # search results.
253
254
  #
@@ -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")
@@ -0,0 +1,298 @@
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
+ ###
27
+ module JSS
28
+
29
+ # Return the names and codes containing a given string
30
+ # (case insentitive).
31
+ #
32
+ # @param str [String] the string to look for, must be >=2 chars long
33
+ #
34
+ # @return [Hash] the country names => codes that contain the string.
35
+ #
36
+ def self.country_code_match(str)
37
+ raise ArgumentError, 'Match string must be at least 2 characters long' if str.size < 2
38
+
39
+ str = str.to_s.upcase
40
+ APP_STORE_COUNTRY_CODES.select { |n, c| n.upcase.include?(str) || c.include?(str) }
41
+ end
42
+
43
+ # The official names and two-letter codes for countries known to the App Store.
44
+ # These were retrieved from the Jamf Pro API endpoint in August 2020.
45
+ # They should be updated regularly. To do so using the Jamf Module, just
46
+ # replace this Hash with the one you get from:
47
+ # Jamf::AppStoreCountryCodes.codes_by_name
48
+ #
49
+ APP_STORE_COUNTRY_CODES = {
50
+ 'Afghanistan' => 'AF',
51
+ 'Aland Islands' => 'AX',
52
+ 'Albania' => 'AL',
53
+ 'Algeria' => 'DZ',
54
+ 'American Samoa' => 'AS',
55
+ 'Andorra' => 'AD',
56
+ 'Angola' => 'AO',
57
+ 'Anguilla' => 'AI',
58
+ 'Antarctica' => 'AQ',
59
+ 'Antigua and Barbuda' => 'AG',
60
+ 'Argentina' => 'AR',
61
+ 'Armenia' => 'AM',
62
+ 'Aruba' => 'AW',
63
+ 'Australia' => 'AU',
64
+ 'Austria' => 'AT',
65
+ 'Azerbaijan' => 'AZ',
66
+ 'Bahamas' => 'BS',
67
+ 'Bahrain' => 'BH',
68
+ 'Bangladesh' => 'BD',
69
+ 'Barbados' => 'BB',
70
+ 'Belarus' => 'BY',
71
+ 'Belgium' => 'BE',
72
+ 'Belize' => 'BZ',
73
+ 'Benin' => 'BJ',
74
+ 'Bermuda' => 'BM',
75
+ 'Bhutan' => 'BT',
76
+ 'Bolivia, Plurinational State of' => 'BO',
77
+ 'Bosnia and Herzegovina' => 'BA',
78
+ 'Botswana' => 'BW',
79
+ 'Bouvet Island' => 'BV',
80
+ 'Brazil' => 'BR',
81
+ 'British Indian Ocean Territory' => 'IO',
82
+ 'Brunei Darussalam' => 'BN',
83
+ 'Bulgaria' => 'BG',
84
+ 'Burkina Faso' => 'BF',
85
+ 'Burundi' => 'BI',
86
+ 'Cambodia' => 'KH',
87
+ 'Cameroon' => 'CM',
88
+ 'Canada' => 'CA',
89
+ 'Cape Verde' => 'CV',
90
+ 'Cayman Islands' => 'KY',
91
+ 'Central African Republic' => 'CF',
92
+ 'Chad' => 'TD',
93
+ 'Chile' => 'CL',
94
+ 'China' => 'CN',
95
+ 'Christmas Island' => 'CX',
96
+ 'Cocos (Keeling) Islands' => 'CC',
97
+ 'Colombia' => 'CO',
98
+ 'Comoros' => 'KM',
99
+ 'Congo' => 'CG',
100
+ 'Congo, the Democratic Republic of the' => 'CD',
101
+ 'Cook Islands' => 'CK',
102
+ 'Costa Rica' => 'CR',
103
+ "Cote d'Ivoire" => 'CI',
104
+ 'Croatia' => 'HR',
105
+ 'Cuba' => 'CU',
106
+ 'Cyprus' => 'CY',
107
+ 'Czech Republic' => 'CZ',
108
+ 'Denmark' => 'DK',
109
+ 'Djibouti' => 'DJ',
110
+ 'Dominica' => 'DM',
111
+ 'Dominican Republic' => 'DO',
112
+ 'Ecuador' => 'EC',
113
+ 'Egypt' => 'EG',
114
+ 'El Salvador' => 'SV',
115
+ 'Equatorial Guinea' => 'GQ',
116
+ 'Eritrea' => 'ER',
117
+ 'Estonia' => 'EE',
118
+ 'Ethiopia' => 'ET',
119
+ 'Falkland Islands (Malvinas)' => 'FK',
120
+ 'Faroe Islands' => 'FO',
121
+ 'Fiji' => 'FJ',
122
+ 'Finland' => 'FI',
123
+ 'France' => 'FR',
124
+ 'French Guiana' => 'GF',
125
+ 'French Polynesia' => 'PF',
126
+ 'French Southern Territories' => 'TF',
127
+ 'Gabon' => 'GA',
128
+ 'Gambia' => 'GM',
129
+ 'Georgia' => 'GE',
130
+ 'Germany' => 'DE',
131
+ 'Ghana' => 'GH',
132
+ 'Gibraltar' => 'GI',
133
+ 'Greece' => 'GR',
134
+ 'Greenland' => 'GL',
135
+ 'Grenada' => 'GD',
136
+ 'Guadeloupe' => 'GP',
137
+ 'Guam' => 'GU',
138
+ 'Guatemala' => 'GT',
139
+ 'Guernsey' => 'GG',
140
+ 'Guinea' => 'GN',
141
+ 'Guinea-Bissau' => 'GW',
142
+ 'Guyana' => 'GY',
143
+ 'Haiti' => 'HT',
144
+ 'Heard Island and McDonald Islands' => 'HM',
145
+ 'Holy See (Vatican City State)' => 'VA',
146
+ 'Honduras' => 'HN',
147
+ 'Hong Kong' => 'HK',
148
+ 'Hungary' => 'HU',
149
+ 'Iceland' => 'IS',
150
+ 'India' => 'IN',
151
+ 'Indonesia' => 'ID',
152
+ 'Iran, Islamic Republic of' => 'IR',
153
+ 'Iraq' => 'IQ',
154
+ 'Ireland' => 'IE',
155
+ 'Isle of Man' => 'IM',
156
+ 'Israel' => 'IL',
157
+ 'Italy' => 'IT',
158
+ 'Jamaica' => 'JM',
159
+ 'Japan' => 'JP',
160
+ 'Jersey' => 'JE',
161
+ 'Jordan' => 'JO',
162
+ 'Kazakhstan' => 'KZ',
163
+ 'Kenya' => 'KE',
164
+ 'Kiribati' => 'KI',
165
+ "Korea, Democratic People's Republic of" => 'KP',
166
+ 'Korea, Republic of' => 'KR',
167
+ 'Kuwait' => 'KW',
168
+ 'Kyrgyzstan' => 'KG',
169
+ "Lao People's Democratic Republic" => 'LA',
170
+ 'Latvia' => 'LV',
171
+ 'Lebanon' => 'LB',
172
+ 'Lesotho' => 'LS',
173
+ 'Liberia' => 'LR',
174
+ 'Libyan Arab Jamahiriya' => 'LY',
175
+ 'Liechtenstein' => 'LI',
176
+ 'Lithuania' => 'LT',
177
+ 'Luxembourg' => 'LU',
178
+ 'Macao' => 'MO',
179
+ 'Macedonia, the former Yugoslav Republic of' => 'MK',
180
+ 'Madagascar' => 'MG',
181
+ 'Malawi' => 'MW',
182
+ 'Malaysia' => 'MY',
183
+ 'Maldives' => 'MV',
184
+ 'Mali' => 'ML',
185
+ 'Malta' => 'MT',
186
+ 'Marshall Islands' => 'MH',
187
+ 'Martinique' => 'MQ',
188
+ 'Mauritania' => 'MR',
189
+ 'Mauritius' => 'MU',
190
+ 'Mayotte' => 'YT',
191
+ 'Mexico' => 'MX',
192
+ 'Micronesia, Federated States of' => 'FM',
193
+ 'Moldova, Republic of' => 'MD',
194
+ 'Monaco' => 'MC',
195
+ 'Mongolia' => 'MN',
196
+ 'Montenegro' => 'ME',
197
+ 'Montserrat' => 'MS',
198
+ 'Morocco' => 'MA',
199
+ 'Mozambique' => 'MZ',
200
+ 'Myanmar' => 'MM',
201
+ 'Namibia' => 'NA',
202
+ 'Nauru' => 'NR',
203
+ 'Nepal' => 'NP',
204
+ 'Netherlands' => 'NL',
205
+ 'Netherlands Antilles' => 'AN',
206
+ 'New Caledonia' => 'NC',
207
+ 'New Zealand' => 'NZ',
208
+ 'Nicaragua' => 'NI',
209
+ 'Niger' => 'NE',
210
+ 'Nigeria' => 'NG',
211
+ 'Niue' => 'NU',
212
+ 'Norfolk Island' => 'NF',
213
+ 'Northern Mariana Islands' => 'MP',
214
+ 'Norway' => 'NO',
215
+ 'Oman' => 'OM',
216
+ 'Pakistan' => 'PK',
217
+ 'Palau' => 'PW',
218
+ 'Palestinian Territory, Occupied' => 'PS',
219
+ 'Panama' => 'PA',
220
+ 'Papua New Guinea' => 'PG',
221
+ 'Paraguay' => 'PY',
222
+ 'Peru' => 'PE',
223
+ 'Philippines' => 'PH',
224
+ 'Pitcairn' => 'PN',
225
+ 'Poland' => 'PL',
226
+ 'Portugal' => 'PT',
227
+ 'Puerto Rico' => 'PR',
228
+ 'Qatar' => 'QA',
229
+ 'Reunion' => 'RE',
230
+ 'Romania' => 'RO',
231
+ 'Russian Federation' => 'RU',
232
+ 'Rwanda' => 'RW',
233
+ 'Saint Barthelemy' => 'BL',
234
+ 'Saint Helena, Ascension and Tristan da Cunha' => 'SH',
235
+ 'Saint Kitts and Nevis' => 'KN',
236
+ 'Saint Lucia' => 'LC',
237
+ 'Saint Martin (French part)' => 'MF',
238
+ 'Saint Pierre and Miquelon' => 'PM',
239
+ 'Saint Vincent and the Grenadines' => 'VC',
240
+ 'Samoa' => 'WS',
241
+ 'San Marino' => 'SM',
242
+ 'Sao Tome and Principe' => 'ST',
243
+ 'Saudi Arabia' => 'SA',
244
+ 'Senegal' => 'SN',
245
+ 'Serbia' => 'RS',
246
+ 'Seychelles' => 'SC',
247
+ 'Sierra Leone' => 'SL',
248
+ 'Singapore' => 'SG',
249
+ 'Slovakia' => 'SK',
250
+ 'Slovenia' => 'SI',
251
+ 'Solomon Islands' => 'SB',
252
+ 'Somalia' => 'SO',
253
+ 'South Africa' => 'ZA',
254
+ 'South Georgia and the South Sandwich Islands' => 'GS',
255
+ 'Spain' => 'ES',
256
+ 'Sri Lanka' => 'LK',
257
+ 'Sudan' => 'SD',
258
+ 'Suriname' => 'SR',
259
+ 'Svalbard and Jan Mayen' => 'SJ',
260
+ 'Swaziland' => 'SZ',
261
+ 'Sweden' => 'SE',
262
+ 'Switzerland' => 'CH',
263
+ 'Syrian Arab Republic' => 'SY',
264
+ 'Taiwan, Province of China' => 'TW',
265
+ 'Tajikistan' => 'TJ',
266
+ 'Tanzania, United Republic of' => 'TZ',
267
+ 'Thailand' => 'TH',
268
+ 'Timor-Leste' => 'TL',
269
+ 'Togo' => 'TG',
270
+ 'Tokelau' => 'TK',
271
+ 'Tonga' => 'TO',
272
+ 'Trinidad and Tobago' => 'TT',
273
+ 'Tunisia' => 'TN',
274
+ 'Turkey' => 'TR',
275
+ 'Turkmenistan' => 'TM',
276
+ 'Turks and Caicos Islands' => 'TC',
277
+ 'Tuvalu' => 'TV',
278
+ 'Uganda' => 'UG',
279
+ 'Ukraine' => 'UA',
280
+ 'United Arab Emirates' => 'AE',
281
+ 'United Kingdom' => 'GB',
282
+ 'United States' => 'US',
283
+ 'United States Minor Outlying Islands' => 'UM',
284
+ 'Uruguay' => 'UY',
285
+ 'Uzbekistan' => 'UZ',
286
+ 'Vanuatu' => 'VU',
287
+ 'Venezuela, Bolivarian Republic of' => 'VE',
288
+ 'Viet Nam' => 'VN',
289
+ 'Virgin Islands, British' => 'VG',
290
+ 'Virgin Islands, U.S.' => 'VI',
291
+ 'Wallis and Futuna' => 'WF',
292
+ 'Western Sahara' => 'EH',
293
+ 'Yemen' => 'YE',
294
+ 'Zambia' => 'ZM',
295
+ 'Zimbabwe' => 'ZW'
296
+ }.freeze
297
+
298
+ end # JSS