ruby-jss 1.2.4a4 → 1.3.3
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 +185 -1
- data/README.md +3 -1
- data/bin/cgrouper +1 -1
- data/bin/jamfHelperBackgrounder +1 -1
- data/bin/netseg-update +1 -1
- data/data/ruby-jss.conf.example +1 -1
- data/lib/jamf.rb +1 -1
- data/lib/jamf/api/abstract_classes/advanced_search.rb +1 -1
- data/lib/jamf/api/abstract_classes/collection_resource.rb +31 -26
- data/lib/jamf/api/abstract_classes/generic_reference.rb +1 -1
- data/lib/jamf/api/abstract_classes/json_object.rb +15 -5
- data/lib/jamf/api/abstract_classes/prestage.rb +2 -2
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +1 -1
- data/lib/jamf/api/abstract_classes/resource.rb +1 -1
- data/lib/jamf/api/abstract_classes/singleton_resource.rb +1 -1
- data/lib/jamf/api/attribute_classes/ip_address.rb +1 -1
- data/lib/jamf/api/attribute_classes/timestamp.rb +1 -1
- data/lib/jamf/api/connection.rb +106 -60
- data/lib/jamf/api/connection/api_error.rb +1 -1
- data/lib/jamf/api/connection/api_error_styleguide.rb +1 -1
- data/lib/jamf/api/connection/token.rb +80 -13
- data/lib/jamf/api/json_objects/account_prefs.rb +1 -1
- data/lib/jamf/api/json_objects/android_details.rb +1 -1
- data/lib/jamf/api/json_objects/appletv_details.rb +1 -1
- data/lib/jamf/api/json_objects/attachment.rb +1 -1
- data/lib/jamf/api/json_objects/cellular_network.rb +1 -1
- data/lib/jamf/api/json_objects/change_log_entry.rb +1 -1
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +1 -1
- data/lib/jamf/api/json_objects/country.rb +1 -1
- data/lib/jamf/api/json_objects/criterion.rb +1 -1
- data/lib/jamf/api/json_objects/device_enrollment_device.rb +1 -1
- data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
- data/lib/jamf/api/json_objects/extension_attribute_value.rb +1 -1
- data/lib/jamf/api/json_objects/installed_application.rb +1 -1
- data/lib/jamf/api/json_objects/installed_certificate.rb +1 -1
- data/lib/jamf/api/json_objects/installed_configuration_profile.rb +1 -1
- data/lib/jamf/api/json_objects/installed_ebook.rb +1 -1
- data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +1 -1
- data/lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb +1 -1
- data/lib/jamf/api/json_objects/ios_details.rb +1 -1
- data/lib/jamf/api/json_objects/location.rb +1 -1
- data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
- data/lib/jamf/api/json_objects/md_prestage_names.rb +1 -1
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +1 -1
- data/lib/jamf/api/json_objects/mobile_device_details.rb +1 -1
- data/lib/jamf/api/json_objects/mobile_device_security.rb +1 -1
- data/lib/jamf/api/json_objects/prestage_assignment.rb +1 -1
- data/lib/jamf/api/json_objects/prestage_location.rb +1 -1
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +1 -1
- data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
- data/lib/jamf/api/json_objects/prestage_sync_status.rb +1 -1
- data/lib/jamf/api/json_objects/purchasing_data.rb +1 -1
- data/lib/jamf/api/mixins/abstract.rb +1 -1
- data/lib/jamf/api/mixins/bulk_deletable.rb +1 -1
- data/lib/jamf/api/mixins/change_log.rb +1 -1
- data/lib/jamf/api/mixins/extendable.rb +1 -1
- data/lib/jamf/api/mixins/immutable.rb +1 -1
- data/lib/jamf/api/mixins/locatable.rb +1 -1
- data/lib/jamf/api/mixins/lockable.rb +1 -1
- data/lib/jamf/api/mixins/referable.rb +1 -1
- data/lib/jamf/api/mixins/searchable.rb +1 -1
- data/lib/jamf/api/mixins/uncreatable.rb +1 -1
- data/lib/jamf/api/mixins/undeletable.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/account.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/building.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/category.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/computer.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/department.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +9 -2
- data/lib/jamf/api/resources/collection_resources/mobile_device.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/script.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/site.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/time_zone.rb +1 -1
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +1 -1
- data/lib/jamf/api/resources/singleton_resources/authorization.rb +1 -1
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +1 -1
- data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +1 -1
- data/lib/jamf/client.rb +1 -1
- data/lib/jamf/client/jamf_binary.rb +1 -1
- data/lib/jamf/client/jamf_helper.rb +1 -1
- data/lib/jamf/client/management_action.rb +1 -1
- data/lib/jamf/compatibility.rb +1 -1
- data/lib/jamf/composer.rb +1 -1
- data/lib/jamf/configuration.rb +8 -10
- data/lib/jamf/exceptions.rb +6 -1
- data/lib/jamf/ruby_extensions.rb +2 -1
- data/lib/jamf/ruby_extensions/array.rb +2 -2
- data/lib/jamf/ruby_extensions/array/predicates.rb +1 -1
- data/lib/jamf/ruby_extensions/array/utils.rb +4 -4
- data/lib/jamf/ruby_extensions/dig.rb +52 -0
- data/lib/jamf/ruby_extensions/filetest.rb +1 -1
- data/lib/jamf/ruby_extensions/filetest/predicates.rb +1 -1
- data/lib/jamf/ruby_extensions/hash.rb +1 -1
- data/lib/jamf/ruby_extensions/hash/backports.rb +2 -2
- data/lib/jamf/ruby_extensions/ipaddr.rb +1 -1
- data/lib/jamf/ruby_extensions/ipaddr/utils.rb +1 -1
- data/lib/jamf/ruby_extensions/object.rb +1 -1
- data/lib/jamf/ruby_extensions/object/predicates.rb +1 -1
- data/lib/jamf/ruby_extensions/pathname.rb +1 -1
- data/lib/jamf/ruby_extensions/pathname/predicates.rb +1 -1
- data/lib/jamf/ruby_extensions/pathname/utils.rb +1 -1
- data/lib/jamf/ruby_extensions/string.rb +1 -1
- data/lib/jamf/ruby_extensions/string/backports.rb +1 -1
- data/lib/jamf/ruby_extensions/string/conversions.rb +1 -1
- data/lib/jamf/ruby_extensions/string/predicates.rb +14 -4
- data/lib/jamf/utility.rb +1 -1
- data/lib/jamf/validate.rb +1 -1
- data/lib/jamf/version.rb +2 -2
- data/lib/jpapi.rb +1 -1
- data/lib/jss-api.rb +1 -1
- data/lib/jss.rb +5 -2
- data/lib/jss/api_connection.rb +3 -30
- data/lib/jss/api_object.rb +16 -3
- data/lib/jss/api_object/account.rb +1 -1
- data/lib/jss/api_object/advanced_search.rb +1 -1
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +1 -1
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +1 -1
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +1 -1
- data/lib/jss/api_object/building.rb +1 -1
- data/lib/jss/api_object/categorizable.rb +1 -1
- data/lib/jss/api_object/category.rb +1 -1
- data/lib/jss/api_object/computer.rb +12 -6
- data/lib/jss/api_object/computer/application_installs.rb +1 -1
- data/lib/jss/api_object/computer_invitation.rb +1 -1
- data/lib/jss/api_object/configuration_profile.rb +4 -2
- data/lib/jss/api_object/configuration_profile/mobile_device_configuration_profile.rb +1 -1
- data/lib/jss/api_object/configuration_profile/osx_configuration_profile.rb +1 -1
- data/lib/jss/api_object/creatable.rb +1 -1
- data/lib/jss/api_object/criteriable.rb +10 -5
- data/lib/jss/api_object/criteriable/criteria.rb +26 -10
- data/lib/jss/api_object/criteriable/criterion.rb +1 -1
- data/lib/jss/api_object/department.rb +1 -1
- data/lib/jss/api_object/directory_binding.rb +273 -0
- data/lib/jss/api_object/directory_binding_type.rb +90 -0
- data/lib/jss/api_object/directory_binding_type/active_directory.rb +502 -0
- data/lib/jss/api_object/directory_binding_type/admitmac.rb +525 -0
- data/lib/jss/api_object/directory_binding_type/centrify.rb +212 -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 +96 -36
- data/lib/jss/api_object/dock_item.rb +137 -0
- data/lib/jss/api_object/ebook.rb +1 -1
- data/lib/jss/api_object/extendable.rb +67 -28
- data/lib/jss/api_object/extension_attribute.rb +1 -1
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +1 -1
- data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +1 -1
- data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +1 -1
- data/lib/jss/api_object/group.rb +1 -1
- data/lib/jss/api_object/group/computer_group.rb +1 -1
- data/lib/jss/api_object/group/mobile_device_group.rb +1 -1
- data/lib/jss/api_object/group/user_group.rb +1 -1
- data/lib/jss/api_object/ibeacon.rb +1 -1
- data/lib/jss/api_object/ldap_server.rb +1 -1
- data/lib/jss/api_object/locatable.rb +1 -1
- data/lib/jss/api_object/mac_application.rb +1 -1
- data/lib/jss/api_object/management_history.rb +23 -22
- data/lib/jss/api_object/management_history/audit_event.rb +1 -1
- data/lib/jss/api_object/management_history/casper_imaging_log.rb +1 -1
- data/lib/jss/api_object/management_history/casper_remote_log.rb +1 -1
- data/lib/jss/api_object/management_history/computer_usage_log.rb +1 -1
- data/lib/jss/api_object/management_history/ebook.rb +1 -1
- data/lib/jss/api_object/management_history/hashlike.rb +1 -1
- data/lib/jss/api_object/management_history/mac_app_store_app.rb +1 -1
- data/lib/jss/api_object/management_history/mdm_command.rb +1 -1
- data/lib/jss/api_object/management_history/mobile_device_app.rb +1 -1
- data/lib/jss/api_object/management_history/policy_log.rb +1 -1
- data/lib/jss/api_object/management_history/screen_sharing_log.rb +1 -1
- data/lib/jss/api_object/management_history/user_location_change.rb +1 -1
- data/lib/jss/api_object/matchable.rb +1 -1
- data/lib/jss/api_object/mdm.rb +1 -1
- data/lib/jss/api_object/mobile_device.rb +29 -6
- data/lib/jss/api_object/mobile_device_application.rb +13 -1
- data/lib/jss/api_object/netboot_server.rb +1 -1
- data/lib/jss/api_object/network_segment.rb +153 -59
- data/lib/jss/api_object/package.rb +106 -41
- data/lib/jss/api_object/patch_policy.rb +1 -1
- data/lib/jss/api_object/patch_source.rb +1 -1
- data/lib/jss/api_object/patch_source/patch_external_source.rb +1 -1
- data/lib/jss/api_object/patch_source/patch_internal_source.rb +1 -1
- data/lib/jss/api_object/patch_title.rb +1 -1
- data/lib/jss/api_object/patch_title/version.rb +1 -1
- data/lib/jss/api_object/peripheral.rb +1 -1
- data/lib/jss/api_object/peripheral_type.rb +1 -1
- data/lib/jss/api_object/policy.rb +380 -5
- data/lib/jss/api_object/printer.rb +440 -0
- data/lib/jss/api_object/purchasable.rb +1 -1
- data/lib/jss/api_object/removable_macaddr.rb +1 -1
- data/lib/jss/api_object/restricted_software.rb +1 -1
- data/lib/jss/api_object/scopable.rb +1 -1
- data/lib/jss/api_object/scopable/scope.rb +257 -37
- data/lib/jss/api_object/script.rb +1 -1
- data/lib/jss/api_object/self_servable.rb +7 -7
- data/lib/jss/api_object/self_servable/icon.rb +1 -1
- data/lib/jss/api_object/sitable.rb +6 -2
- data/lib/jss/api_object/site.rb +1 -1
- data/lib/jss/api_object/software_update_server.rb +1 -1
- data/lib/jss/api_object/updatable.rb +1 -1
- data/lib/jss/api_object/uploadable.rb +1 -1
- data/lib/jss/api_object/user.rb +5 -3
- data/lib/jss/api_object/vppable.rb +1 -1
- data/lib/jss/api_object/webhook.rb +1 -1
- data/lib/jss/client.rb +1 -1
- data/lib/jss/client/jamf_binary.rb +1 -1
- data/lib/jss/client/jamf_helper.rb +1 -1
- data/lib/jss/client/management_action.rb +1 -1
- data/lib/jss/compatibility.rb +1 -1
- data/lib/jss/composer.rb +2 -2
- data/lib/jss/configuration.rb +1 -1
- data/lib/jss/db_connection.rb +1 -1
- data/lib/jss/exceptions.rb +1 -1
- data/lib/jss/ruby_extensions.rb +1 -1
- data/lib/jss/ruby_extensions/array.rb +1 -1
- data/lib/jss/ruby_extensions/filetest.rb +1 -1
- data/lib/jss/ruby_extensions/hash.rb +1 -1
- data/lib/jss/ruby_extensions/ipaddr.rb +1 -1
- data/lib/jss/ruby_extensions/pathname.rb +1 -1
- data/lib/jss/ruby_extensions/string.rb +1 -1
- data/lib/jss/ruby_extensions/string/backports.rb +1 -1
- data/lib/jss/ruby_extensions/string/conversions.rb +1 -1
- data/lib/jss/ruby_extensions/string/predicates.rb +14 -4
- data/lib/jss/ruby_extensions/time.rb +1 -1
- data/lib/jss/server.rb +1 -1
- data/lib/jss/utility.rb +9 -23
- data/lib/jss/validate.rb +1 -1
- data/lib/jss/version.rb +2 -2
- data/lib/jss/xml_workaround.rb +1 -1
- data/lib/ruby-jss.rb +1 -1
- data/test/bin/runtests +1 -1
- data/test/lib/testhelper.rb +1 -1
- data/test/lib/testhelper/auth.rb +1 -1
- data/test/lib/testhelper/patch_mgmt.rb +1 -1
- data/test/specs/api_connection_spec.rb +1 -1
- data/test/specs/patch01_source_spec.rb +1 -1
- data/test/specs/patch02_internal_source_spec.rb +1 -1
- data/test/specs/patch03_external_source_spec.rb +1 -1
- data/test/specs/patch04_titles_spec.rb +1 -1
- data/test/specs/patch05_policies_spec.rb +1 -1
- data/test/specs/patch06_cleanup_spec.rb +1 -1
- data/test/specs/policy_spec.rb +1 -1
- metadata +15 -4
data/lib/jss/api_connection.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
### Copyright
|
|
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
|
-
|
|
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
|
-
|
|
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
|
data/lib/jss/api_object.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
### Copyright
|
|
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
|
|
1226
|
-
|
|
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
|
|
@@ -1655,9 +1663,13 @@ require 'jss/api_object/category'
|
|
|
1655
1663
|
require 'jss/api_object/computer'
|
|
1656
1664
|
require 'jss/api_object/computer_invitation'
|
|
1657
1665
|
require 'jss/api_object/department'
|
|
1666
|
+
require 'jss/api_object/disk_encryption_configurations'
|
|
1667
|
+
require "jss/api_object/directory_binding_type"
|
|
1668
|
+
require 'jss/api_object/directory_binding'
|
|
1658
1669
|
require 'jss/api_object/distribution_point'
|
|
1659
1670
|
require 'jss/api_object/ebook'
|
|
1660
1671
|
require 'jss/api_object/ibeacon'
|
|
1672
|
+
require 'jss/api_object/dock_item'
|
|
1661
1673
|
require 'jss/api_object/ldap_server'
|
|
1662
1674
|
require 'jss/api_object/mac_application'
|
|
1663
1675
|
require 'jss/api_object/mobile_device'
|
|
@@ -1677,5 +1689,6 @@ require 'jss/api_object/site'
|
|
|
1677
1689
|
require 'jss/api_object/software_update_server'
|
|
1678
1690
|
require 'jss/api_object/user'
|
|
1679
1691
|
require 'jss/api_object/webhook'
|
|
1692
|
+
require 'jss/api_object/printer'
|
|
1680
1693
|
|
|
1681
1694
|
JSS::APIObject.define_identifier_list_methods
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
### Copyright
|
|
1
|
+
### Copyright 2020 Pixar
|
|
2
2
|
|
|
3
3
|
###
|
|
4
4
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
@@ -529,9 +529,12 @@ module JSS
|
|
|
529
529
|
# @return [Time] when was it added to the JSS
|
|
530
530
|
attr_reader :initial_entry_date
|
|
531
531
|
|
|
532
|
-
# @return [IPAddr] the last known IP address
|
|
532
|
+
# @return [IPAddr] the last known IP address from the server's perspective
|
|
533
533
|
attr_reader :ip_address
|
|
534
534
|
|
|
535
|
+
# @return [IPAddr] the last known IP address from the client's perspecive
|
|
536
|
+
attr_reader :reported_ip_address
|
|
537
|
+
|
|
535
538
|
# @return [Boolean]
|
|
536
539
|
attr_reader :itunes_store_account_is_active
|
|
537
540
|
|
|
@@ -784,6 +787,7 @@ module JSS
|
|
|
784
787
|
@initial_entry_date = JSS.epoch_to_time @init_data[:general][:initial_entry_date_epoch]
|
|
785
788
|
@last_enrolled = JSS.epoch_to_time @init_data[:general][:last_enrolled_date_epoch]
|
|
786
789
|
@ip_address = @init_data[:general][:ip_address]
|
|
790
|
+
@reported_ip_address = @init_data[:general][:last_reported_ip]
|
|
787
791
|
@itunes_store_account_is_active = @init_data[:general][:itunes_store_account_is_active]
|
|
788
792
|
@jamf_version = @init_data[:general][:jamf_version]
|
|
789
793
|
@last_contact_time = JSS.epoch_to_time @init_data[:general][:last_contact_time_epoch]
|
|
@@ -1035,23 +1039,25 @@ module JSS
|
|
|
1035
1039
|
end
|
|
1036
1040
|
|
|
1037
1041
|
def asset_tag=(new_val)
|
|
1038
|
-
new_val =
|
|
1042
|
+
new_val = new_val.to_s.strip
|
|
1039
1043
|
return nil if @asset_tag.to_s == new_val
|
|
1040
|
-
|
|
1044
|
+
|
|
1041
1045
|
@asset_tag = new_val
|
|
1042
1046
|
@need_to_update = true
|
|
1043
1047
|
end
|
|
1044
1048
|
|
|
1045
1049
|
def barcode1=(new_val)
|
|
1050
|
+
new_val = new_val.strip
|
|
1046
1051
|
return nil if @barcode1 == new_val
|
|
1047
|
-
|
|
1052
|
+
|
|
1048
1053
|
@barcode1 = new_val
|
|
1049
1054
|
@need_to_update = true
|
|
1050
1055
|
end
|
|
1051
1056
|
|
|
1052
1057
|
def barcode2=(new_val)
|
|
1058
|
+
new_val = new_val.strip
|
|
1053
1059
|
return nil if @barcode2 == new_val
|
|
1054
|
-
|
|
1060
|
+
|
|
1055
1061
|
@barcode2 = new_val
|
|
1056
1062
|
@need_to_update = true
|
|
1057
1063
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2020 Pixar
|
|
2
2
|
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
@@ -105,8 +105,10 @@ module JSS
|
|
|
105
105
|
# @return [void]
|
|
106
106
|
#
|
|
107
107
|
def description=(new_val)
|
|
108
|
+
new_val = new_val.strip
|
|
108
109
|
return nil if @self_service_description == new_val
|
|
109
|
-
|
|
110
|
+
|
|
111
|
+
@description = new_val
|
|
110
112
|
@need_to_update = true
|
|
111
113
|
end # @param new_val[String] how should this be distributed to clients?
|
|
112
114
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2020 Pixar
|
|
2
2
|
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
@@ -152,21 +152,26 @@ module JSS
|
|
|
152
152
|
# @return [void]
|
|
153
153
|
#
|
|
154
154
|
def parse_criteria
|
|
155
|
-
@criteria =
|
|
156
|
-
@criteria.
|
|
155
|
+
@criteria = JSS::Criteriable::Criteria.new
|
|
156
|
+
@criteria.criteria = @init_data[:criteria].map { |c| JSS::Criteriable::Criterion.new c } if @init_data[:criteria]
|
|
157
|
+
|
|
158
|
+
@criteria.container = self
|
|
157
159
|
end
|
|
158
160
|
|
|
159
161
|
#
|
|
160
162
|
# Change the criteria, it must be a JSS::Criteriable::Criteria instance
|
|
161
163
|
#
|
|
162
|
-
# @param new_criteria[JSS::Criteriable::Criteria] the new criteria
|
|
164
|
+
# @param new_criteria[JSS::Criteriable::Criteria, nil] the new criteria. An
|
|
165
|
+
# empty criteria object is used if nil is passed.
|
|
163
166
|
#
|
|
164
167
|
# @return [void]
|
|
165
168
|
#
|
|
166
169
|
def criteria=(new_criteria)
|
|
170
|
+
new_criteria ||= JSS::Criteriable::Criteria.new
|
|
167
171
|
raise JSS::InvalidDataError, 'JSS::Criteriable::Criteria instance required' unless new_criteria.is_a?(JSS::Criteriable::Criteria)
|
|
172
|
+
|
|
168
173
|
@criteria = new_criteria
|
|
169
|
-
@criteria.container = self
|
|
174
|
+
@criteria.container = self unless new_criteria.nil?
|
|
170
175
|
@need_to_update = true
|
|
171
176
|
end
|
|
172
177
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
### Copyright
|
|
1
|
+
### Copyright 2020 Pixar
|
|
2
2
|
|
|
3
3
|
###
|
|
4
4
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
@@ -72,21 +72,18 @@ module JSS
|
|
|
72
72
|
attr_reader :criteria
|
|
73
73
|
|
|
74
74
|
### @return [JSS::APIObject subclass] a reference to the object containing these Criteria
|
|
75
|
-
|
|
75
|
+
attr_writer :container
|
|
76
76
|
|
|
77
77
|
###
|
|
78
78
|
### @param new_criteria[Array<JSS::Criteriable::Criterion>]
|
|
79
79
|
###
|
|
80
|
-
def initialize(new_criteria)
|
|
80
|
+
def initialize(new_criteria = [])
|
|
81
81
|
@criteria = []
|
|
82
|
+
|
|
83
|
+
# validates the param and fills @criteria
|
|
82
84
|
self.criteria = new_criteria
|
|
83
85
|
end # init
|
|
84
86
|
|
|
85
|
-
### set the object we belong to, so we can set its @should_update value
|
|
86
|
-
def container= (a_thing)
|
|
87
|
-
@container = a_thing
|
|
88
|
-
end
|
|
89
|
-
|
|
90
87
|
###
|
|
91
88
|
### Provide a whole new array of JSS::Criteriable::Criterion instances for this Criteria
|
|
92
89
|
###
|
|
@@ -94,7 +91,7 @@ module JSS
|
|
|
94
91
|
###
|
|
95
92
|
### @return [void]
|
|
96
93
|
###
|
|
97
|
-
def criteria=
|
|
94
|
+
def criteria=(new_criteria)
|
|
98
95
|
unless new_criteria.is_a?(Array) && new_criteria.reject { |c| c.is_a?(JSS::Criteriable::Criterion) }.empty?
|
|
99
96
|
raise JSS::InvalidDataError, 'Argument must be an Array of JSS::Criteriable::Criterion instances.'
|
|
100
97
|
end
|
|
@@ -104,6 +101,14 @@ module JSS
|
|
|
104
101
|
@container.should_update if @container
|
|
105
102
|
end
|
|
106
103
|
|
|
104
|
+
# Remove all criterion objects
|
|
105
|
+
#
|
|
106
|
+
# @return [void]
|
|
107
|
+
def clear
|
|
108
|
+
@criteria = []
|
|
109
|
+
@container.should_update if @container
|
|
110
|
+
end
|
|
111
|
+
|
|
107
112
|
###
|
|
108
113
|
### Add a new criterion to the end of the criteria
|
|
109
114
|
###
|
|
@@ -192,6 +197,18 @@ module JSS
|
|
|
192
197
|
@criteria.each_index { |ci| @criteria[ci].priority = ci }
|
|
193
198
|
end
|
|
194
199
|
|
|
200
|
+
# Remove the various cached data
|
|
201
|
+
# from the instance_variables used to create
|
|
202
|
+
# pretty-print (pp) output.
|
|
203
|
+
#
|
|
204
|
+
# @return [Array] the desired instance_variables
|
|
205
|
+
#
|
|
206
|
+
def pretty_print_instance_variables
|
|
207
|
+
vars = instance_variables.sort
|
|
208
|
+
vars.delete :@container
|
|
209
|
+
vars
|
|
210
|
+
end
|
|
211
|
+
|
|
195
212
|
###
|
|
196
213
|
### @return [REXML::Element] the xml element for the criteria
|
|
197
214
|
###
|
|
@@ -200,7 +217,6 @@ module JSS
|
|
|
200
217
|
### @api private
|
|
201
218
|
###
|
|
202
219
|
def rest_xml
|
|
203
|
-
raise JSS::MissingDataError, "Criteria can't be empty" if @criteria.empty?
|
|
204
220
|
cr = REXML::Element.new 'criteria'
|
|
205
221
|
@criteria.each { |c| cr << c.rest_xml }
|
|
206
222
|
cr
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
### Copyright 2019 Rixar
|
|
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
|
+
module JSS
|
|
27
|
+
|
|
28
|
+
# Module Variables
|
|
29
|
+
#####################################
|
|
30
|
+
|
|
31
|
+
# Module Methods
|
|
32
|
+
#####################################
|
|
33
|
+
|
|
34
|
+
# Classes
|
|
35
|
+
#####################################
|
|
36
|
+
|
|
37
|
+
# A Directory Binding object in the JSS
|
|
38
|
+
# These are rather complex objects, and contain settings specific to the directory object's type.
|
|
39
|
+
#
|
|
40
|
+
# @see JSS::APIObject
|
|
41
|
+
# @see JSS::DirectoryBindingType
|
|
42
|
+
# @note "JSS::DirectoryBinding.fetch name: 'BindingName'" seems to be returning a 500 error in my test evironment. Use "JSS::DirectoryBinding.fetch 'BindingName' instead."
|
|
43
|
+
#
|
|
44
|
+
class DirectoryBinding < JSS::APIObject
|
|
45
|
+
|
|
46
|
+
# Mix-Ins
|
|
47
|
+
#####################################
|
|
48
|
+
include JSS::Creatable
|
|
49
|
+
include JSS::Updatable
|
|
50
|
+
include JSS::DirectoryBindingType
|
|
51
|
+
|
|
52
|
+
# Class Methods
|
|
53
|
+
#####################################
|
|
54
|
+
|
|
55
|
+
# Class Constants
|
|
56
|
+
#####################################
|
|
57
|
+
|
|
58
|
+
#! You CAN update this
|
|
59
|
+
DIRECTORY_BINDING_TYPE = {
|
|
60
|
+
open_directory: "Open Directory",
|
|
61
|
+
active_directory: "Active Directory",
|
|
62
|
+
powerbroker_identity_services: "PowerBroker Identity Services",
|
|
63
|
+
admitmac: "ADmitMac",
|
|
64
|
+
centrify: "Centrify"
|
|
65
|
+
}.freeze
|
|
66
|
+
|
|
67
|
+
DIRECTORY_BINDING_TYPE_CLASSES = {
|
|
68
|
+
"Open Directory" => JSS::DirectoryBindingType::OpenDirectory,
|
|
69
|
+
"Active Directory" => JSS::DirectoryBindingType::ActiveDirectory,
|
|
70
|
+
"PowerBroker Identity Services" => JSS::DirectoryBindingType::PowerBroker,
|
|
71
|
+
"ADmitMac" => JSS::DirectoryBindingType::ADmitMac,
|
|
72
|
+
"Centrify" => JSS::DirectoryBindingType::Centrify
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# The base for REST resources of this class
|
|
76
|
+
RSRC_BASE = 'directorybindings'.freeze
|
|
77
|
+
|
|
78
|
+
# the hash key used for the JSON list output of all objects in the JSS
|
|
79
|
+
RSRC_LIST_KEY = :directory_bindings
|
|
80
|
+
|
|
81
|
+
# The hash key used for the JSON object output.
|
|
82
|
+
# It's also used in various error messages
|
|
83
|
+
RSRC_OBJECT_KEY = :directory_binding
|
|
84
|
+
|
|
85
|
+
# the object type for this object in
|
|
86
|
+
# the object history table.
|
|
87
|
+
# See {APIObject#add_object_history_entry}
|
|
88
|
+
# OBJECT_HISTORY_OBJECT_TYPE = 41
|
|
89
|
+
|
|
90
|
+
# Attributes
|
|
91
|
+
#####################################
|
|
92
|
+
attr_reader :id
|
|
93
|
+
attr_reader :name
|
|
94
|
+
attr_reader :priority
|
|
95
|
+
attr_reader :domain
|
|
96
|
+
attr_reader :username
|
|
97
|
+
attr_reader :password_sha256
|
|
98
|
+
attr_reader :computer_ou
|
|
99
|
+
attr_reader :type
|
|
100
|
+
attr_reader :type_settings
|
|
101
|
+
attr_reader :password
|
|
102
|
+
|
|
103
|
+
# Constructor
|
|
104
|
+
# @see JSS::APIObject.initialize
|
|
105
|
+
# @note When creating an object with specific properties use the
|
|
106
|
+
# objects name and then the settings.
|
|
107
|
+
# Ex: Creating an Active Directory object:
|
|
108
|
+
# JSS::DirectoryBinding.make name: "Example Binding", username: "BindingUser", password: "SuperMonkey123", computer_ou: "computers", active_directory: { multiple_domains: false }, domain: your.domain.server
|
|
109
|
+
#####################################
|
|
110
|
+
def initialize(args = {})
|
|
111
|
+
super args
|
|
112
|
+
|
|
113
|
+
if self.in_jss?
|
|
114
|
+
@priority = @init_data[:priority]
|
|
115
|
+
@domain = @init_data[:domain]
|
|
116
|
+
@username = @init_data[:username]
|
|
117
|
+
@password_sha256 = @init_data[:password_sha256]
|
|
118
|
+
@computer_ou = @init_data[:computer_ou]
|
|
119
|
+
@type = @init_data[:type]
|
|
120
|
+
|
|
121
|
+
class_key = DIRECTORY_BINDING_TYPE.select { |k,v| v == @type }.map { |k,v| k }.first
|
|
122
|
+
self.set_type_settings (DIRECTORY_BINDING_TYPE_CLASSES[@type.to_s].new @init_data[class_key])
|
|
123
|
+
else
|
|
124
|
+
# Build
|
|
125
|
+
raise JSS::MissingDataError, "domain must be provided." if @init_data[:domain].nil?
|
|
126
|
+
raise JSS::MissingDataError, "username must be provided." if @init_data[:username].nil?
|
|
127
|
+
raise JSS::MissingDataError, "computer_ou must be provided." if @init_data[:computer_ou].nil?
|
|
128
|
+
raise JSS::MissingDataError, "password must be provided when creating a DirectoryBinding object." if @init_data[:password].nil?
|
|
129
|
+
raise JSS::MissingDataError, "Type must be provided, one of \":#{DIRECTORY_BINDING_TYPE.keys.join(",:")}\"." if @init_data[:type].nil?
|
|
130
|
+
raise JSS::InvalidDataError, "Type must be one of \":#{DIRECTORY_BINDING_TYPE.keys.join(",:")}\"." unless DIRECTORY_BINDING_TYPE.keys.include? @init_data[:type]
|
|
131
|
+
raise JSS::InvalidDataError, "Priority must be between 1 and 10" if !@init_data[:priority].nil? && (@init_data[:priority] <= 1 || @init_data[:priority] >= 10)
|
|
132
|
+
|
|
133
|
+
@domain = @init_data[:domain]
|
|
134
|
+
@username = @init_data[:username]
|
|
135
|
+
@computer_ou = @init_data[:computer_ou]
|
|
136
|
+
@type = DIRECTORY_BINDING_TYPE[@init_data[:type]]
|
|
137
|
+
@password = @init_data[:password]
|
|
138
|
+
@priority = @init_data[:priority]
|
|
139
|
+
|
|
140
|
+
@priority = 1 if @priority.nil?
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class_key = DIRECTORY_BINDING_TYPE.select { |k,v| v == @type }.map { |k,v| k }.first
|
|
144
|
+
self.set_type_settings (DIRECTORY_BINDING_TYPE_CLASSES[@type.to_s].new @init_data[class_key])
|
|
145
|
+
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Public Instance Methods
|
|
151
|
+
#####################################
|
|
152
|
+
|
|
153
|
+
# The domain the device will be bound to.
|
|
154
|
+
#
|
|
155
|
+
# @author Tyler Morgan
|
|
156
|
+
#
|
|
157
|
+
# @param newvalue [String]
|
|
158
|
+
#
|
|
159
|
+
# @raise [JSS::InvalidDataError] If newvalue is not a String
|
|
160
|
+
#
|
|
161
|
+
# @return [void]
|
|
162
|
+
def domain=(newvalue)
|
|
163
|
+
raise JSS::InvalidDataError, "Domain must be a String" unless newvalue.is_a? String
|
|
164
|
+
|
|
165
|
+
@domain = newvalue.to_s
|
|
166
|
+
@need_to_update = true
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# The username used to attempt to bind the device to the domain.
|
|
171
|
+
#
|
|
172
|
+
# @author Tyler Morgan
|
|
173
|
+
#
|
|
174
|
+
# @param newvalue [String]
|
|
175
|
+
#
|
|
176
|
+
# @raise [JSS::InvalidDataError] If newvalue is not a String
|
|
177
|
+
#
|
|
178
|
+
# @return [void]
|
|
179
|
+
def username=(newvalue)
|
|
180
|
+
raise JSS::InvalidDataError, "Username must be a String" unless newvalue.is_a? String
|
|
181
|
+
|
|
182
|
+
@username = newvalue
|
|
183
|
+
@need_to_update = true
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# The priority the domain has over another one.
|
|
188
|
+
#
|
|
189
|
+
# @author Tyler Morgan
|
|
190
|
+
#
|
|
191
|
+
# @param newvalue [Integer]
|
|
192
|
+
#
|
|
193
|
+
# @raise [JSS::InvalidDataError] If newvalue is not an Integer
|
|
194
|
+
# @raise [JSS::InvalidDataError] If newvalue is not between 1 and 10
|
|
195
|
+
#
|
|
196
|
+
# @return [void]
|
|
197
|
+
def priority=(newvalue)
|
|
198
|
+
raise JSS::InvalidDataError, "Priority must be a Integer" unless newvalue.is_a? Integer
|
|
199
|
+
raise JSS::InvalidDataError, "Priority cannot exceed 10" unless newvalue <= 10
|
|
200
|
+
raise JSS::InvalidDataError, "Priority must be greater than 0" unless newvalue > 0
|
|
201
|
+
|
|
202
|
+
@priority = newvalue
|
|
203
|
+
@need_to_update = true
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
# The OU path the computer object is to be placed
|
|
208
|
+
#
|
|
209
|
+
# @author Tyler Morgan
|
|
210
|
+
#
|
|
211
|
+
# @param newvalue [String]
|
|
212
|
+
#
|
|
213
|
+
# @raise [JSS::InvalidDataError] If newvalue is not a String
|
|
214
|
+
#
|
|
215
|
+
# @return [void]
|
|
216
|
+
def computer_ou=(newvalue)
|
|
217
|
+
raise JSS::InvalidDataError, "Computer OU must be a String" unless newvalue.is_a? String
|
|
218
|
+
|
|
219
|
+
@computer_ou = newvalue
|
|
220
|
+
@need_to_update = true
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
# Sets the password used in conjunction with the username to attempt to bind
|
|
225
|
+
# the computer to the domain.
|
|
226
|
+
#
|
|
227
|
+
# @author Tyler Morgan
|
|
228
|
+
#
|
|
229
|
+
# @param newvalue [String]
|
|
230
|
+
#
|
|
231
|
+
# @raise [JSS::InvalidDataError] If newvalue is not a String
|
|
232
|
+
#
|
|
233
|
+
# @return [void]
|
|
234
|
+
def password=(newvalue)
|
|
235
|
+
raise JSS::InvalidDataError, "Password must be a string" unless newvalue.is_a? String
|
|
236
|
+
|
|
237
|
+
@password = newvalue
|
|
238
|
+
@need_to_update = true
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# private instance methods
|
|
242
|
+
######################
|
|
243
|
+
private
|
|
244
|
+
|
|
245
|
+
# the xml formated data for adding or updating this in the JSS
|
|
246
|
+
#
|
|
247
|
+
# This method constructs a properly formatted XML document to be handled by the Jamf Pro API
|
|
248
|
+
#
|
|
249
|
+
# @author Tyler Morgan
|
|
250
|
+
#
|
|
251
|
+
# @return [String]
|
|
252
|
+
def rest_xml
|
|
253
|
+
doc = REXML::Document.new APIConnection::XML_HEADER
|
|
254
|
+
ns = doc.add_element RSRC_OBJECT_KEY.to_s
|
|
255
|
+
ns.add_element('id').text = @id.to_s
|
|
256
|
+
ns.add_element('name').text = @name
|
|
257
|
+
ns.add_element('priority').text = @priority.to_s
|
|
258
|
+
ns.add_element('domain').text = @domain.to_s
|
|
259
|
+
ns.add_element('username').text = @username.to_s
|
|
260
|
+
ns.add_element('computer_ou').text = @computer_ou.to_s
|
|
261
|
+
ns.add_element('type').text = @type.to_s
|
|
262
|
+
if !@password.nil?
|
|
263
|
+
ns.add_element('password').text = @password.to_s
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
ns << @type_settings.type_setting_xml
|
|
267
|
+
|
|
268
|
+
return doc.to_s
|
|
269
|
+
end # rest_xml
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
end
|