ruby-jss 1.2.4a3 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +180 -1
- data/README.md +4 -2
- 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 +2 -1
- data/lib/jamf/api/abstract_classes/advanced_search.rb +1 -1
- data/lib/jamf/api/abstract_classes/collection_resource.rb +54 -38
- data/lib/jamf/api/abstract_classes/generic_reference.rb +1 -1
- data/lib/jamf/api/abstract_classes/json_object.rb +16 -10
- data/lib/jamf/api/abstract_classes/prestage.rb +111 -35
- 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 +166 -69
- 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 +87 -16
- 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 +6 -4
- 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 +5 -3
- 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 +3 -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 +3 -3
- 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 +2 -1
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +110 -18
- 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 +119 -0
- 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 +59 -4
- 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 +6 -8
- 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 -3
- 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 +107 -42
- 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 +16 -4
@@ -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
|
@@ -0,0 +1,90 @@
|
|
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 for containing the different types of DirectoryBindings stored within the JSS
|
29
|
+
module DirectoryBindingType
|
30
|
+
|
31
|
+
# Module Variables
|
32
|
+
#####################################
|
33
|
+
|
34
|
+
# Module Methods
|
35
|
+
#####################################
|
36
|
+
def should_update
|
37
|
+
@need_to_update = true
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_type_settings(settings)
|
41
|
+
@type_settings = settings
|
42
|
+
@type_settings.container = self
|
43
|
+
end
|
44
|
+
|
45
|
+
# Classes
|
46
|
+
#####################################
|
47
|
+
|
48
|
+
# A generic binding type class that sets common variables, methods, and constructors
|
49
|
+
# for all the different directory binding types.
|
50
|
+
#
|
51
|
+
# @author Tyler Morgan
|
52
|
+
class DirectoryBindingType
|
53
|
+
# Mix-Ins
|
54
|
+
#####################################
|
55
|
+
|
56
|
+
# Class Methods
|
57
|
+
#####################################
|
58
|
+
|
59
|
+
# Class Constants
|
60
|
+
#####################################
|
61
|
+
|
62
|
+
# The different network protocols supported.
|
63
|
+
NETWORK_PROTOCOL = {
|
64
|
+
afp: "AFP",
|
65
|
+
smb: "SMB"
|
66
|
+
}.freeze
|
67
|
+
|
68
|
+
|
69
|
+
# The different home folder types.
|
70
|
+
HOME_FOLDER_TYPE = {
|
71
|
+
network: "Network",
|
72
|
+
local: "Local",
|
73
|
+
either: "Either",
|
74
|
+
mobile: "Mobile"
|
75
|
+
}.freeze
|
76
|
+
|
77
|
+
# Attributes
|
78
|
+
#####################################
|
79
|
+
|
80
|
+
# This is used to properly handle updating the containing object.
|
81
|
+
attr_accessor :container
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
require "jss/api_object/directory_binding_type/active_directory"
|
87
|
+
require "jss/api_object/directory_binding_type/open_directory"
|
88
|
+
require "jss/api_object/directory_binding_type/admitmac"
|
89
|
+
require "jss/api_object/directory_binding_type/centrify"
|
90
|
+
require "jss/api_object/directory_binding_type/powerbroker_identity_services"
|