ruby-jss 1.2.10 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +208 -1
  3. data/lib/jamf.rb +18 -16
  4. data/lib/jamf/api/base_classes/collection_resource.rb +613 -0
  5. data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +110 -102
  6. data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +56 -31
  7. data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +10 -6
  8. data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +4 -3
  9. data/lib/jamf/api/connection.rb +20 -12
  10. data/lib/jamf/api/connection/api_error.rb +8 -8
  11. data/lib/jamf/api/connection/token.rb +36 -15
  12. data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
  13. data/lib/jamf/api/json_objects/{location.rb → device_enrollment_device_sync_state.rb} +27 -41
  14. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
  15. data/lib/jamf/api/json_objects/{attachment.rb → locale.rb} +14 -23
  16. data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
  17. data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
  18. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
  19. data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
  20. data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
  21. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
  22. data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
  23. data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
  24. data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
  25. data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
  26. data/lib/jamf/api/mixins/change_log.rb +201 -51
  27. data/lib/jamf/api/{resources/collection_resources/extension_attribute.rb → mixins/filterable.rb} +20 -14
  28. data/lib/jamf/api/mixins/pageable.rb +208 -0
  29. data/lib/jamf/api/{json_objects/installed_application.rb → mixins/sortable.rb} +33 -33
  30. data/lib/jamf/api/resources/collection_resources/building.rb +16 -9
  31. data/lib/jamf/api/resources/collection_resources/category.rb +5 -4
  32. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +12 -5
  33. data/lib/jamf/api/resources/collection_resources/department.rb +1 -3
  34. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +13 -13
  35. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
  36. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +25 -23
  37. data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
  38. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
  39. data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
  40. data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
  41. data/lib/jamf/configuration.rb +7 -9
  42. data/lib/jamf/ruby_extensions.rb +1 -0
  43. data/lib/jamf/ruby_extensions/array.rb +1 -1
  44. data/lib/jamf/ruby_extensions/array/utils.rb +3 -3
  45. data/lib/jamf/{api/resources/collection_resources/computer.rb → ruby_extensions/dig.rb} +22 -19
  46. data/lib/jamf/validate.rb +63 -24
  47. data/lib/jamf/version.rb +1 -1
  48. data/lib/jss.rb +4 -1
  49. data/lib/jss/api_connection.rb +111 -433
  50. data/lib/jss/api_object.rb +16 -13
  51. data/lib/jss/api_object/advanced_search.rb +27 -26
  52. data/lib/jss/api_object/app_store_country_codes.rb +298 -0
  53. data/lib/jss/api_object/categorizable.rb +1 -1
  54. data/lib/jss/api_object/computer.rb +13 -0
  55. data/lib/jss/api_object/configuration_profile.rb +60 -4
  56. data/lib/jss/api_object/directory_binding.rb +273 -0
  57. data/lib/jss/api_object/directory_binding_type.rb +96 -0
  58. data/lib/jss/api_object/directory_binding_type/active_directory.rb +539 -0
  59. data/lib/jss/api_object/directory_binding_type/admitmac.rb +594 -0
  60. data/lib/jss/api_object/directory_binding_type/centrify.rb +226 -0
  61. data/lib/jss/api_object/directory_binding_type/open_directory.rb +178 -0
  62. data/lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb +73 -0
  63. data/lib/jss/api_object/disk_encryption_configurations.rb +114 -0
  64. data/lib/jss/api_object/distribution_point.rb +97 -37
  65. data/lib/jss/api_object/dock_item.rb +143 -0
  66. data/lib/jss/api_object/ebook.rb +1 -2
  67. data/lib/jss/api_object/extendable.rb +1 -1
  68. data/lib/jss/api_object/extension_attribute.rb +4 -3
  69. data/lib/jss/api_object/group.rb +33 -2
  70. data/lib/jss/api_object/mac_application.rb +107 -8
  71. data/lib/jss/api_object/mobile_device_application.rb +12 -0
  72. data/lib/jss/api_object/network_segment.rb +195 -70
  73. data/lib/jss/api_object/package.rb +105 -40
  74. data/lib/jss/api_object/patch_source.rb +10 -9
  75. data/lib/jss/api_object/policy.rb +596 -32
  76. data/lib/jss/api_object/printer.rb +446 -0
  77. data/lib/jss/api_object/scopable.rb +10 -15
  78. data/lib/jss/api_object/scopable/scope.rb +371 -55
  79. data/lib/jss/api_object/self_servable.rb +17 -9
  80. data/lib/jss/api_object/uploadable.rb +1 -1
  81. data/lib/jss/api_object/user.rb +42 -1
  82. data/lib/jss/api_object/vpp_account.rb +209 -0
  83. data/lib/jss/api_object/vppable.rb +169 -13
  84. data/lib/jss/composer.rb +1 -1
  85. data/lib/jss/exceptions.rb +3 -0
  86. data/lib/jss/server.rb +15 -0
  87. data/lib/jss/utility.rb +143 -52
  88. data/lib/jss/validate.rb +53 -10
  89. data/lib/jss/version.rb +1 -1
  90. metadata +56 -61
  91. data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
  92. data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
  93. data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
  94. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
  95. data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
  96. data/lib/jamf/api/json_objects/android_details.rb +0 -139
  97. data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
  98. data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
  99. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
  100. data/lib/jamf/api/json_objects/criterion.rb +0 -152
  101. data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
  102. data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
  103. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
  104. data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
  105. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
  106. data/lib/jamf/api/json_objects/ios_details.rb +0 -244
  107. data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
  108. data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
  109. data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
  110. data/lib/jamf/api/mixins/locatable.rb +0 -124
  111. data/lib/jamf/api/mixins/referable.rb +0 -92
  112. data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
  113. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
  114. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
  115. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
  116. data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
  117. data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
  118. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
  119. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -198,7 +198,7 @@ module JSS
198
198
 
199
199
  if cat.is_a? String
200
200
  @category_name = cat
201
- @category_id = JSS::Category.category_id_from_name @category_name
201
+ @category_id = JSS::Category.category_id_from_name @category_name, api: @api
202
202
  else
203
203
  @category_name = cat[:name]
204
204
  @category_id = cat[:id]
@@ -1046,6 +1046,19 @@ module JSS
1046
1046
  @need_to_update = true
1047
1047
  end
1048
1048
 
1049
+ # flush the logs for this computer in a given policy
1050
+ # @see JSS::Policy.flush_logs
1051
+ #
1052
+ def flush_policy_logs(policy, older_than: 0, period: :days)
1053
+ JSS::Policy.flush_logs(
1054
+ policy,
1055
+ older_than: older_than,
1056
+ period: period,
1057
+ computers: [@id],
1058
+ api: @api
1059
+ )
1060
+ end
1061
+
1049
1062
  def barcode1=(new_val)
1050
1063
  new_val = new_val.strip
1051
1064
  return nil if @barcode1 == new_val
@@ -23,7 +23,6 @@
23
23
  #
24
24
  #
25
25
 
26
- #
27
26
  module JSS
28
27
 
29
28
  # Classes
@@ -56,6 +55,11 @@ module JSS
56
55
  # which DISTRIBUTION_METHODS means we're in self service?
57
56
  SELF_SERVICE_DIST_METHOD = 'Make Available in Self Service'.freeze
58
57
 
58
+ # when a change is made, which in-scope machines should get
59
+ # the changed profile?
60
+ REDEPLOY_NEWLY_ASSIGNED = 'Newly Assigned'.freeze
61
+ REDEPLOY_ALL = 'All'.freeze
62
+
59
63
  # Our SelfService deploys profiles
60
64
  SELF_SERVICE_PAYLOAD = :profile
61
65
 
@@ -68,7 +72,6 @@ module JSS
68
72
  # How is the category stored in the API data?
69
73
  CATEGORY_DATA_TYPE = Hash
70
74
 
71
-
72
75
  # Attributes
73
76
  ###################################
74
77
 
@@ -78,7 +81,11 @@ module JSS
78
81
  # @return [String] the uuid of this profile. NOT Updatable
79
82
  attr_reader :uuid
80
83
 
81
- # @return [Boolean] Should this profile be redeployed when an inventory update happens?
84
+ # @return [String] When a change is made to the profile, which scoped machines
85
+ # should get the changes? This will always contain REDEPLOY_NEWLY_ASSIGNED
86
+ # when fetched, but can be set to REDEPLOY_ALL via the redeploy_to_all:
87
+ # parameter to #update & #save. After the update is complete, it reverts
88
+ # to REDEPLOY_NEWLY_ASSIGNED
82
89
  attr_reader :redeploy_on_update
83
90
 
84
91
  # @return [String] the plist containing the payloads for this profile. NOT Updatable
@@ -125,12 +132,58 @@ module JSS
125
132
  parsed_payloads['PayloadContent']
126
133
  end
127
134
 
135
+ # @param new_content [Array<Hash>] replace the payload content entirely.
136
+ #
137
+ # The 'payload' of a config profile is an XML Plist. The top-level key
138
+ # of that plist 'PayloadContent' contains an Array of Dicts, each one being
139
+ # a part of the payload for the profile.
140
+ #
141
+ # When replacing the PayloadContent Array, using this method, provide a
142
+ # *ruby* Array full of *ruby* hashes, and they will be converted to a
143
+ # Plist and embedded into the API XML appropriately.
144
+ #
145
+ # WARNING: This is experimental! Editing the Plist Payload of a Config
146
+ # profile may break the profile. Make sure you test on a fake profile
147
+ # before using this method in production.
148
+ #
149
+ # @return [void]
150
+ #
151
+ def payload_content=(new_content)
152
+ payload_plist_data = parsed_payloads
153
+ payload_plist_data['PayloadContent'] = new_content
154
+ @payloads = payload_plist_data.to_plist
155
+ @need_to_update = true
156
+ @update_payloads = true
157
+ end
158
+
128
159
  # @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
129
160
  #
130
161
  def payload_types
131
162
  payload_content.map { |p| p['PayloadType'] }
132
163
  end
133
164
 
165
+ # clear flag after updating
166
+ def update(redeploy_to_all: false)
167
+ @redeploy_on_update = redeploy_to_all ? REDEPLOY_ALL : REDEPLOY_NEWLY_ASSIGNED
168
+ super()
169
+ # always reset to newly assigned
170
+ @redeploy_on_update = REDEPLOY_NEWLY_ASSIGNED
171
+ @update_payloads = nil
172
+ end
173
+
174
+ # wrapper with param
175
+ def save(redeploy_to_all: false)
176
+ if @in_jss
177
+ raise JSS::UnsupportedError, 'Updating this object in the JSS is currently not supported by ruby-jss' unless updatable?
178
+
179
+ update redeploy_to_all: redeploy_to_all
180
+ else
181
+ raise JSS::UnsupportedError, 'Creating this object in the JSS is currently not supported by ruby-jss' unless creatable?
182
+
183
+ create
184
+ end
185
+ end
186
+
134
187
  # Private Instance Methods
135
188
  ###################################
136
189
  private
@@ -142,7 +195,10 @@ module JSS
142
195
  gen = obj.add_element('general')
143
196
  gen.add_element('description').text = @description
144
197
  gen.add_element('redeploy_on_update').text = @redeploy_on_update
145
-
198
+ if @update_payloads
199
+ payloads_plist_xml = JSS.escape_xml(@payloads.gsub(/^\t*/, '').gsub(">\n", '>'))
200
+ gen.add_element('payloads').text = payloads_plist_xml
201
+ end
146
202
  obj << @scope.scope_xml
147
203
  add_self_service_xml doc
148
204
  add_category_to_xml doc
@@ -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,96 @@
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
+
54
+
55
+ # Mix-Ins
56
+ #####################################
57
+
58
+ # Class Methods
59
+ #####################################
60
+
61
+ # Class Constants
62
+ #####################################
63
+
64
+ # The different network protocols supported.
65
+ NETWORK_PROTOCOL = {
66
+ afp: 'AFP',
67
+ smb: 'SMB'
68
+ }.freeze
69
+
70
+ # The different home folder types.
71
+ HOME_FOLDER_TYPE = {
72
+ network: 'Network',
73
+ local: 'Local',
74
+ either: 'Either',
75
+ mobile: 'Mobile'
76
+ }.freeze
77
+
78
+ # Attributes
79
+ #####################################
80
+
81
+ # This is used to properly handle updating the containing object.
82
+ attr_accessor :container
83
+
84
+
85
+ end
86
+
87
+
88
+ end
89
+
90
+ end
91
+
92
+ require 'jss/api_object/directory_binding_type/active_directory'
93
+ require 'jss/api_object/directory_binding_type/open_directory'
94
+ require 'jss/api_object/directory_binding_type/admitmac'
95
+ require 'jss/api_object/directory_binding_type/centrify'
96
+ require 'jss/api_object/directory_binding_type/powerbroker_identity_services'