ruby-jss 1.5.1 → 1.5.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.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +26 -0
  3. data/lib/jamf.rb +8 -13
  4. data/lib/jamf/api/{abstract_classes → base_classes}/collection_resource.rb +6 -5
  5. data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +4 -20
  6. data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +1 -1
  7. data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +6 -2
  8. data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +3 -2
  9. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
  10. data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
  11. data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
  12. data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
  13. data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
  14. data/lib/jamf/api/resources/collection_resources/building.rb +0 -4
  15. data/lib/jamf/api/resources/collection_resources/category.rb +0 -1
  16. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +1 -1
  17. data/lib/jamf/api/resources/collection_resources/department.rb +0 -2
  18. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +1 -1
  19. data/lib/jamf/version.rb +1 -1
  20. data/lib/jss/api_connection.rb +1 -36
  21. data/lib/jss/api_object/computer.rb +13 -0
  22. data/lib/jss/api_object/configuration_profile.rb +28 -3
  23. data/lib/jss/api_object/policy.rb +105 -25
  24. data/lib/jss/api_object/scopable/scope.rb +31 -30
  25. data/lib/jss/utility.rb +142 -37
  26. data/lib/jss/version.rb +1 -1
  27. metadata +8 -41
  28. data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
  29. data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -153
  30. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -147
  31. data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
  32. data/lib/jamf/api/json_objects/android_details.rb +0 -139
  33. data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
  34. data/lib/jamf/api/json_objects/attachment.rb +0 -68
  35. data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
  36. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -80
  37. data/lib/jamf/api/json_objects/criterion.rb +0 -152
  38. data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
  39. data/lib/jamf/api/json_objects/installed_application.rb +0 -59
  40. data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
  41. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
  42. data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
  43. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
  44. data/lib/jamf/api/json_objects/ios_details.rb +0 -244
  45. data/lib/jamf/api/json_objects/location.rb +0 -95
  46. data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
  47. data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
  48. data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
  49. data/lib/jamf/api/mixins/locatable.rb +0 -124
  50. data/lib/jamf/api/mixins/referable.rb +0 -92
  51. data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
  52. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
  53. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
  54. data/lib/jamf/api/resources/collection_resources/computer.rb +0 -49
  55. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +0 -45
  56. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
  57. data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
  58. data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
  59. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
  60. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -1,315 +0,0 @@
1
- # Copyright 2020 Pixar
2
-
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "Apache License")
5
- # with the following modification; you may not use this file except in
6
- # compliance with the Apache License and the following modification to it:
7
- # Section 6. Trademarks. is deleted and replaced with:
8
- #
9
- # 6. Trademarks. This License does not grant permission to use the trade
10
- # names, trademarks, service marks, or product names of the Licensor
11
- # and its affiliates, except as required to comply with Section 4(c) of
12
- # the License and to reproduce the content of the NOTICE file.
13
- #
14
- # You may obtain a copy of the Apache License at
15
- #
16
- # http://www.apache.org/licenses/LICENSE-2.0
17
- #
18
- # Unless required by applicable law or agreed to in writing, software
19
- # distributed under the Apache License with the above modification is
20
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
- # KIND, either express or implied. See the Apache License for the specific
22
- # language governing permissions and limitations under the Apache License.
23
- #
24
- #
25
-
26
- # The module
27
- module Jamf
28
-
29
- # A mobile device in the JSS
30
- class MobileDevice < Jamf::CollectionResource
31
-
32
- # Mix-Ins
33
- #####################################
34
-
35
- include Jamf::Referable
36
- include Jamf::Locatable
37
- include Jamf::Extendable
38
-
39
- # currently not creatable via API
40
- # TODO: remove this when it's time
41
- extend Jamf::UnCreatable
42
-
43
- # currently not creatable via API
44
- # TODO: remove this when it's time
45
- extend Jamf::UnDeletable
46
-
47
- # Class Constants
48
- #####################################
49
-
50
- IOS = 'ios'.freeze
51
- APPLETV = 'appleTv'.freeze
52
- ANDROID = 'android'.freeze
53
- UNKNOWN = 'unknown'.freeze
54
-
55
- IPHONE = 'iPhone'.freeze
56
- IPOD = 'iPod'.freeze
57
- IPAD = 'iPad'.freeze
58
-
59
- # The enum for the 'type' attribute
60
- TYPES = [
61
- IOS,
62
- APPLETV,
63
- ANDROID,
64
- UNKNOWN
65
- ].freeze
66
-
67
- APPLE_TYPES = [IOS, APPLETV].freeze
68
-
69
- RSRC_PATH = '/inventory/obj/mobileDevice'.freeze
70
-
71
- # This has a non-std update resource
72
- # we POST to /inventory/obj/mobileDevice/{id}/update
73
- # instad of the normal PUT to /inventory/obj/mobileDevice/{id}
74
- UPDATE_RESOURCE = { method: :post, path_suffix: 'update' }.freeze
75
-
76
- OBJECT_MODEL = {
77
-
78
- # @!attribute [r] id
79
- # @return [Integer]
80
- id: {
81
- class: :integer,
82
- identifier: :primary,
83
- readonly: true
84
- },
85
-
86
- # @!attribute name
87
- # @param [String]
88
- # @return [String]
89
- name: {
90
- class: :string
91
- },
92
-
93
- # @!attribute [r] serialNumber
94
- # @return [String]
95
- serialNumber: {
96
- class: :string,
97
- identifier: true,
98
- readonly: true
99
- },
100
-
101
- # @!attribute [r] wifiMacAddress
102
- # @return [String]
103
- wifiMacAddress: {
104
- class: :string,
105
- identifier: true,
106
- readonly: true
107
- },
108
-
109
- # @!attribute [r] udid
110
- # @return [String]
111
- udid: {
112
- class: :string,
113
- identifier: true,
114
- readonly: true
115
- },
116
-
117
- # @!attribute [r] phoneNumber
118
- # @return [String]
119
- phoneNumber: {
120
- class: :string,
121
- identifier: true,
122
- readonly: true
123
- },
124
-
125
- # @!attribute [r] model
126
- # @return [String]
127
- model: {
128
- class: :string,
129
- readonly: true
130
- },
131
-
132
- # @!attribute [r] modelIdentifier
133
- # @return [String]
134
- modelIdentifier: {
135
- class: :string,
136
- readonly: true
137
- },
138
-
139
- # @!attribute username
140
- # Has custom setter, is part of Location in Details
141
- # @param [String]
142
- # @return [String]
143
- username: {
144
- class: :string,
145
- readonly: true
146
- },
147
-
148
- # TODO: Will jamf give us isManaged or isSupervised?
149
- # in the non-detail data?
150
- # @!attribute [r] isManaged
151
- # @return [Boolean]
152
- # isManaged: {
153
- # class: :boolean,
154
- # readonly: true
155
- # },
156
-
157
- # @!attribute [r] type
158
- # @return [Symbol]
159
- type: {
160
- class: :string,
161
- readonly: true,
162
- enum: Jamf::MobileDevice::TYPES
163
- }
164
-
165
- }.freeze
166
- parse_object_model
167
-
168
- # Class Methods
169
- #####################################
170
-
171
- # TODO: when jamf gives us isManaged in base object
172
- # @return [Array<Hash>] the list of all managed mobile devices
173
- # def self.all_unmanaged(refresh = false, api: JAMF.api)
174
- # all(refresh, api: api).reject { |d| d[:managed] }
175
- # end
176
-
177
- # TODO: when jamf gives us isManaged in base object
178
- # @return [Array<Hash>] the list of all unmanaged mobile devices
179
- # def self.all_unmanaged(refresh = false, api: JAMF.api)
180
- # all(refresh, api: api).reject { |d| d[:managed] }
181
- # end
182
-
183
- # TODO: when jamf gives us isSupervised in base object
184
- # @return [Array<Hash>] the list of all supervised mobile devices
185
- # def self.all_supervised(refresh = false, api: JAMF.api)
186
- # all(refresh, api: api).select { |d| d[:supervised] }
187
- # end
188
-
189
- # TODO: when jamf gives us isSupervised in base object
190
- # @return [Array<Hash>] the list of all unsupervised mobile devices
191
- # def self.all_unsupervised(refresh = false, api: JAMF.api)
192
- # all(refresh, api: api).reject { |d| d[:supervised] }
193
- # end
194
-
195
- # @return [Array<Hash>] the list of all iPhones
196
- def self.all_iphones(refresh: false, cnx: Jamf.cnx)
197
- all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPHONE }
198
- end
199
-
200
- # @return [Array<Hash>] the list of all iPods
201
- def self.all_ipods(refresh: false, cnx: Jamf.cnx)
202
- all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPOD }
203
- end
204
-
205
- # @return [Array<Hash>] the list of all iPads
206
- def self.all_ipads(refresh: false, cnx: Jamf.cnx)
207
- all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPAD }
208
- end
209
-
210
- # @return [Array<Hash>] the list of all AppleTVs
211
- def self.all_appleTvs(refresh: false, cnx: Jamf.cnx)
212
- all(refresh, cnx: cnx).select { |d| d[:type] == APPLETV }
213
- end
214
-
215
- # @return [Array<Hash>] the list of all Androids
216
- def self.all_androids(refresh: false, cnx: Jamf.cnx)
217
- all(refresh, cnx: cnx).select { |d| d[:type] == ANDROID }
218
- end
219
-
220
- # Instance Methods
221
- # Lots of overriding of standard methods in our metaclasses
222
- # becuase we have a separate @details object, as well as
223
- # a non-standard UPDATE_RESOURCE object model
224
- # If this pattern becomes more common, and is uniform,
225
- # (i.e. for computers) we'll make these methods into a module
226
- #
227
- #######################################
228
-
229
- # This custom method outputs a 'UpdateMobileDevice' object model
230
- # as defined in the API docs
231
- #
232
- def to_jamf
233
- changes = unsaved_changes
234
- data_to_send = {}
235
-
236
- data_to_send[:name] = changes[:name][:new] if changes[:name]
237
-
238
- data_to_send[:assetTag] = changes[:assetTag][:new] if changes[:assetTag]
239
- data_to_send[:siteId] = changes[:site][:new].id if changes[:site]
240
- data_to_send[:location] = details.location.to_jamf if changes[:location]
241
- data_to_send[:updatedExtensionAttributes] = ext_attrs_to_jamf if ext_attrs_unsaved_changes?
242
-
243
- return data_to_send unless APPLE_TYPES.include? @type
244
-
245
- data_to_send[@type] = { purchasing: details.type_details.purchasing.to_jamf } if changes[:type_changes][:purchasing]
246
-
247
- data_to_send[APPLETV][:airplayPassword] = changes[:type_changes][:airplayPassword][:new] if @type == APPLETV && changes[:type_changes][:airplayPassword]
248
-
249
- data_to_send
250
- end # to_jamf
251
-
252
- # TODO - needed? Clean up?
253
- # merge top-level and details changes and type-specific changes
254
- def unsaved_changes
255
- @unsaved_changes ||= {}
256
- # name is the only thing at the top-level that isn't readonly
257
- if @details
258
- changes = details.unsaved_changes
259
- changes[:name] = @unsaved_changes[:name] if @unsaved_changes[:name]
260
- changes[:ext_attrs] = ext_attrs_unsaved_changes if ext_attrs_unsaved_changes?
261
- type_changes = type_details.unsaved_changes
262
- changes[:type_changes] = type_changes unless type_changes.empty?
263
- else
264
- changes = @unsaved_changes
265
- end
266
- changes
267
- end
268
-
269
- # clear changes for details as well as top
270
- def clear_unsaved_changes
271
- @details.clear_unsaved_changes if @details
272
- ext_attrs_clear_unsaved_changes
273
- @unsaved_changes = {}
274
- end
275
-
276
- # Fetch the details as needed
277
- def details
278
- @details ||= MobileDeviceDetails.fetch @id, @cnx
279
- end # details
280
-
281
- # Return the correct part of the details for the
282
- # device type
283
- def type_details
284
- case @type
285
- when :ios then details.ios
286
- when :appleTv then details.appleTv
287
- when :android then details.android
288
- end
289
- end
290
-
291
- # catches the attributes in the details
292
- def method_missing(meth, *args, &block)
293
- if details.respond_to? meth
294
- details.send meth, *args, &block
295
- elsif type_details.respond_to? meth
296
- type_details.send meth, *args, &block
297
- else
298
- super
299
- end
300
- end
301
-
302
- # provides respond_to? for the attributes in the details
303
- def respond_to_missing?(meth, *)
304
- if details.respond_to? meth
305
- true
306
- elsif type_details.respond_to? meth
307
- true
308
- else
309
- super
310
- end
311
- end
312
-
313
- end # class Mobile Device
314
-
315
- end # module
@@ -1,77 +0,0 @@
1
- # Copyright 2020 Pixar
2
-
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "Apache License")
5
- # with the following modification; you may not use this file except in
6
- # compliance with the Apache License and the following modification to it:
7
- # Section 6. Trademarks. is deleted and replaced with:
8
- #
9
- # 6. Trademarks. This License does not grant permission to use the trade
10
- # names, trademarks, service marks, or product names of the Licensor
11
- # and its affiliates, except as required to comply with Section 4(c) of
12
- # the License and to reproduce the content of the NOTICE file.
13
- #
14
- # You may obtain a copy of the Apache License at
15
- #
16
- # http://www.apache.org/licenses/LICENSE-2.0
17
- #
18
- # Unless required by applicable law or agreed to in writing, software
19
- # distributed under the Apache License with the above modification is
20
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
- # KIND, either express or implied. See the Apache License for the specific
22
- # language governing permissions and limitations under the Apache License.
23
- #
24
- #
25
-
26
- # The Module
27
- module Jamf
28
-
29
- # Classes
30
- #####################################
31
-
32
- # A building defined in the JSS
33
- class Site < Jamf::CollectionResource
34
-
35
- # Mix-Ins
36
- #####################################
37
-
38
- include Jamf::ChangeLog
39
- include Jamf::Referable
40
-
41
- # Constants
42
- #####################################
43
-
44
- RSRC_PATH = 'settings/sites'.freeze
45
-
46
- NO_SITE_ID = -1
47
-
48
- NO_SITE_NAME = 'None'.freeze
49
-
50
- # Object Model / Attributes
51
- # See APIObject class documentation for details
52
- # of how the OBJECT_MODEL hash works.
53
- #####################################
54
- OBJECT_MODEL = {
55
-
56
- # @!attribute [r] id
57
- # @return [Integer]
58
- id: {
59
- class: :integer,
60
- identifier: :primary,
61
- readonly: true
62
- },
63
-
64
- # @!attribute name
65
- # @return [String]
66
- name: {
67
- class: :string,
68
- identifier: true,
69
- validator: :non_empty_string,
70
- required: true
71
- }
72
- }.freeze
73
- parse_object_model
74
-
75
- end # class
76
-
77
- end # module
@@ -1,88 +0,0 @@
1
- # Copyright 2020 Pixar
2
-
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "Apache License")
5
- # with the following modification; you may not use this file except in
6
- # compliance with the Apache License and the following modification to it:
7
- # Section 6. Trademarks. is deleted and replaced with:
8
- #
9
- # 6. Trademarks. This License does not grant permission to use the trade
10
- # names, trademarks, service marks, or product names of the Licensor
11
- # and its affiliates, except as required to comply with Section 4(c) of
12
- # the License and to reproduce the content of the NOTICE file.
13
- #
14
- # You may obtain a copy of the Apache License at
15
- #
16
- # http://www.apache.org/licenses/LICENSE-2.0
17
- #
18
- # Unless required by applicable law or agreed to in writing, software
19
- # distributed under the Apache License with the above modification is
20
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
- # KIND, either express or implied. See the Apache License for the specific
22
- # language governing permissions and limitations under the Apache License.
23
- #
24
- #
25
-
26
- module Jamf
27
-
28
- # Authorization Details associated with the current API token
29
- #
30
- class Authorization < Jamf::SingletonResource
31
-
32
- # Constants
33
- #####################################
34
-
35
- RSRC_PATH = 'auth'.freeze
36
-
37
- AUTH_TYPE_JSS = 'JSS'.freeze
38
- AUTH_TYPE_LDAP = 'LDAP'.freeze
39
- AUTH_TYPE_SAML = 'SAML'.freeze
40
- AUTH_TYPE_INVITE = 'INVITE'.freeze
41
- AUTH_TYPE_OAUTH = 'OAUTH'.freeze
42
-
43
- AUTH_TYPES = [
44
- AUTH_TYPE_JSS,
45
- AUTH_TYPE_LDAP,
46
- AUTH_TYPE_SAML,
47
- AUTH_TYPE_INVITE,
48
- AUTH_TYPE_OAUTH
49
- ].freeze
50
-
51
- OBJECT_MODEL = {
52
-
53
- # @!attribute account
54
- # @return [Jamf::Account]
55
- account: {
56
- class: Jamf::Account,
57
- readonly: true
58
- },
59
-
60
- # @!attribute accountGroups
61
- # @return [Array<Jamf::AccountGroup>]
62
- accountGroups: {
63
- class: Jamf::AccountGroup,
64
- multi: true,
65
- readonly: true
66
- },
67
-
68
- # @!attribute sites
69
- # @return [Array<amf::Site>]
70
- sites: {
71
- class: Jamf::Site,
72
- multi: true,
73
- readonly: true
74
- },
75
-
76
- # @!attribute authenticationType
77
- # @return [String]
78
- authenticationType: {
79
- class: :string,
80
- enum: Jamf::Authorization::AUTH_TYPES
81
- }
82
-
83
- }.freeze # end OBJECT_MODEL
84
- parse_object_model
85
-
86
- end # class ReEnrollment
87
-
88
- end # module JAMF