ruby-jss 1.2.3 → 1.2.4a1

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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jamf.rb +169 -0
  3. data/lib/jamf/api/abstract_classes/collection_resource.rb +422 -0
  4. data/lib/jamf/api/abstract_classes/generic_reference.rb +145 -0
  5. data/lib/jamf/api/abstract_classes/json_object.rb +1074 -0
  6. data/lib/jamf/api/abstract_classes/prestage.rb +219 -0
  7. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +126 -0
  8. data/lib/jamf/api/abstract_classes/resource.rb +250 -0
  9. data/lib/jamf/api/abstract_classes/singleton_resource.rb +87 -0
  10. data/lib/jamf/api/attribute_classes/ip_address.rb +66 -0
  11. data/lib/jamf/api/attribute_classes/timestamp.rb +144 -0
  12. data/lib/jamf/api/connection.rb +734 -0
  13. data/lib/jamf/api/connection/api_error.rb +111 -0
  14. data/lib/jamf/api/connection/api_error_styleguide.rb +96 -0
  15. data/lib/jamf/api/connection/token.rb +220 -0
  16. data/lib/jamf/api/json_objects/account_prefs.rb +79 -0
  17. data/lib/jamf/api/json_objects/android_details.rb +139 -0
  18. data/lib/jamf/api/json_objects/appletv_details.rb +110 -0
  19. data/lib/jamf/api/json_objects/attachment.rb +68 -0
  20. data/lib/jamf/api/json_objects/cellular_network.rb +151 -0
  21. data/lib/jamf/api/json_objects/change_log_entry.rb +77 -0
  22. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +67 -0
  23. data/lib/jamf/api/json_objects/country.rb +51 -0
  24. data/lib/jamf/api/json_objects/extension_attribute_value.rb +128 -0
  25. data/lib/jamf/api/json_objects/installed_application.rb +59 -0
  26. data/lib/jamf/api/json_objects/installed_certificate.rb +53 -0
  27. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +67 -0
  28. data/lib/jamf/api/json_objects/installed_ebook.rb +58 -0
  29. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +59 -0
  30. data/lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb +52 -0
  31. data/lib/jamf/api/json_objects/ios_details.rb +244 -0
  32. data/lib/jamf/api/json_objects/location.rb +95 -0
  33. data/lib/jamf/api/json_objects/md_prestage_name.rb +57 -0
  34. data/lib/jamf/api/json_objects/md_prestage_names.rb +82 -0
  35. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +165 -0
  36. data/lib/jamf/api/json_objects/mobile_device_details.rb +219 -0
  37. data/lib/jamf/api/json_objects/mobile_device_security.rb +101 -0
  38. data/lib/jamf/api/json_objects/prestage_assignment.rb +61 -0
  39. data/lib/jamf/api/json_objects/prestage_location.rb +104 -0
  40. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +132 -0
  41. data/lib/jamf/api/json_objects/prestage_scope.rb +54 -0
  42. data/lib/jamf/api/json_objects/prestage_sync_status.rb +63 -0
  43. data/lib/jamf/api/json_objects/purchasing_data.rb +125 -0
  44. data/lib/jamf/api/mixins/abstract.rb +58 -0
  45. data/lib/jamf/api/mixins/bulk_deletable.rb +39 -0
  46. data/lib/jamf/api/mixins/change_log.rb +136 -0
  47. data/lib/jamf/api/mixins/extendable.rb +75 -0
  48. data/lib/jamf/api/mixins/immutable.rb +39 -0
  49. data/lib/jamf/api/mixins/locatable.rb +124 -0
  50. data/lib/jamf/api/mixins/lockable.rb +48 -0
  51. data/lib/jamf/api/mixins/referable.rb +92 -0
  52. data/lib/jamf/api/mixins/searchable.rb +202 -0
  53. data/lib/jamf/api/mixins/uncreatable.rb +40 -0
  54. data/lib/jamf/api/mixins/undeletable.rb +40 -0
  55. data/lib/jamf/api/resources/collection_resources/account.rb +163 -0
  56. data/lib/jamf/api/resources/collection_resources/building.rb +114 -0
  57. data/lib/jamf/api/resources/collection_resources/category.rb +82 -0
  58. data/lib/jamf/api/resources/collection_resources/computer.rb +49 -0
  59. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +80 -0
  60. data/lib/jamf/api/resources/collection_resources/department.rb +79 -0
  61. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +45 -0
  62. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +274 -0
  63. data/lib/jamf/api/resources/collection_resources/md_prestage.rb +139 -0
  64. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +315 -0
  65. data/lib/jamf/api/resources/collection_resources/script.rb +190 -0
  66. data/lib/jamf/api/resources/collection_resources/site.rb +77 -0
  67. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +131 -0
  68. data/lib/jamf/api/resources/singleton_resources/authorization.rb +88 -0
  69. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +139 -0
  70. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +95 -0
  71. data/lib/jamf/client.rb +301 -0
  72. data/lib/jamf/client/jamf_binary.rb +132 -0
  73. data/lib/jamf/client/jamf_helper.rb +298 -0
  74. data/lib/jamf/client/management_action.rb +114 -0
  75. data/lib/jamf/compatibility.rb +88 -0
  76. data/lib/jamf/composer.rb +190 -0
  77. data/lib/jamf/configuration.rb +281 -0
  78. data/lib/jamf/exceptions.rb +107 -0
  79. data/lib/jamf/ruby_extensions.rb +36 -0
  80. data/lib/jamf/ruby_extensions/array.rb +35 -0
  81. data/lib/jamf/ruby_extensions/array/predicates.rb +46 -0
  82. data/lib/jamf/ruby_extensions/array/utils.rb +47 -0
  83. data/lib/jamf/ruby_extensions/filetest.rb +32 -0
  84. data/lib/jamf/ruby_extensions/filetest/predicates.rb +46 -0
  85. data/lib/jamf/ruby_extensions/hash.rb +33 -0
  86. data/lib/jamf/ruby_extensions/hash/backports.rb +92 -0
  87. data/lib/jamf/ruby_extensions/ipaddr.rb +37 -0
  88. data/lib/jamf/ruby_extensions/ipaddr/utils.rb +95 -0
  89. data/lib/jamf/ruby_extensions/object.rb +30 -0
  90. data/lib/jamf/ruby_extensions/object/predicates.rb +51 -0
  91. data/lib/jamf/ruby_extensions/pathname.rb +39 -0
  92. data/lib/jamf/ruby_extensions/pathname/predicates.rb +50 -0
  93. data/lib/jamf/ruby_extensions/pathname/utils.rb +75 -0
  94. data/lib/jamf/ruby_extensions/string.rb +35 -0
  95. data/lib/jamf/ruby_extensions/string/backports.rb +66 -0
  96. data/lib/jamf/ruby_extensions/string/conversions.rb +65 -0
  97. data/lib/jamf/ruby_extensions/string/predicates.rb +47 -0
  98. data/lib/jamf/utility.rb +423 -0
  99. data/lib/jamf/validate.rb +224 -0
  100. data/lib/jamf/version.rb +32 -0
  101. data/lib/jpapi.rb +26 -0
  102. data/lib/jss/version.rb +1 -1
  103. metadata +104 -4
@@ -0,0 +1,80 @@
1
+ # Copyright 2019 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 Computer Prestage
33
+ class ComputerPrestage < Jamf::Prestage
34
+
35
+ # Constants
36
+ #####################################
37
+
38
+ RSRC_VERSION = 'v1'.freeze
39
+
40
+ RSRC_PATH = 'computer-prestages'.freeze
41
+
42
+ # Object Model / Attributes
43
+ # See APIObject class documentation for details
44
+ # of how the OBJECT_MODEL hash works.
45
+ #####################################
46
+ OBJECT_MODEL = superclass::OBJECT_MODEL.merge(
47
+
48
+ # @!attribute skipSetupItems
49
+ # @return [Jamf::ComputerPrestageSkipSetupItems]
50
+ skipSetupItems: {
51
+ class: Jamf::ComputerPrestageSkipSetupItems
52
+ },
53
+
54
+ # @!attribute isInstallProfilesDuringSetup
55
+ # @return [Boolean]
56
+ isInstallProfilesDuringSetup: {
57
+ class: :boolean
58
+ },
59
+
60
+ # @!attribute prestageInstalledProfileIds
61
+ # @return [Array<Integer>]
62
+ prestageInstalledProfileIds: {
63
+ class: :integer,
64
+ multi: true
65
+ },
66
+
67
+ # @!attribute customPackageIds
68
+ # @return [Array<Integer>]
69
+ customPackageIds: {
70
+ class: :integer,
71
+ multi: true
72
+ }
73
+
74
+ ).freeze
75
+
76
+ parse_object_model
77
+
78
+ end # class
79
+
80
+ end # module
@@ -0,0 +1,79 @@
1
+ # Copyright 2019 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 Department < Jamf::CollectionResource
34
+
35
+ # Mix-Ins
36
+ #####################################
37
+
38
+ include Jamf::ChangeLog
39
+ include Jamf::Referable
40
+
41
+ # Constants
42
+ #####################################
43
+
44
+ RSRC_VERSION = 'v1'.freeze
45
+
46
+ RSRC_PATH = 'departments'.freeze
47
+
48
+ # TODO: Jamf - will this be standard for collections?
49
+ BULK_DELETE_RSRC = 'delete-departments'.freeze
50
+
51
+ # Object Model / Attributes
52
+ # See APIObject class documentation for details
53
+ # of how the OBJECT_MODEL hash works.
54
+ #####################################
55
+ OBJECT_MODEL = {
56
+
57
+ # @!attribute [r] id
58
+ # @return [Integer]
59
+ id: {
60
+ class: :integer,
61
+ identifier: :primary,
62
+ readonly: true
63
+ },
64
+
65
+ # @!attribute name
66
+ # @return [String]
67
+ name: {
68
+ class: :string,
69
+ identifier: true,
70
+ validator: :non_empty_string,
71
+ required: true
72
+ }
73
+ }.freeze
74
+ parse_object_model
75
+
76
+
77
+ end # class
78
+
79
+ end # module
@@ -0,0 +1,45 @@
1
+ # Copyright 2019 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
+ # An extension attribute in Jamf Pro
30
+ class ExtensionAttribute < Jamf::CollectionResource
31
+
32
+ VALUE_TYPES = {
33
+ string: 'STRING',
34
+ integer: 'INTEGER',
35
+ date: 'DATE'
36
+ }.freeze
37
+
38
+ OBJECT_MODEL = {
39
+
40
+ }.freeze
41
+ parse_object_model
42
+
43
+ end # class ext attr
44
+
45
+ end # module
@@ -0,0 +1,274 @@
1
+ # Copyright 2019 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
+ # An Inventory Preload record for a Computer or Mobile Device in Jamf.
33
+ #
34
+ # Since the JPAPI offers access to these records via JSON as well as CSV
35
+ # uploads, we are implementing JSON access, to stay in line with the rest
36
+ # of how ruby-jss works, and keep things simple.
37
+ #
38
+ # If you want to use a CSV as your data source, you should use a ruby
39
+ # CSV library, such as the one built in to ruby, and loop thru your CSV
40
+ # records, creating or fetching instances of this class as needed,
41
+ # manipulating them, and saving them.
42
+ #
43
+ #
44
+ class InventoryPreloadRecord < Jamf::CollectionResource
45
+
46
+ # Mix-Ins
47
+ #####################################
48
+
49
+ extend Jamf::ChangeLog
50
+
51
+ # Constants
52
+ #####################################
53
+
54
+ RSRC_VERSION = 'v1'.freeze
55
+
56
+ RSRC_PATH = 'inventory-preload'.freeze
57
+
58
+ DEVICE_TYPE_COMPUTER = 'Computer'.freeze
59
+ DEVICE_TYPE_MOBILE_DEV = 'Mobile Device'.freeze
60
+ DEVICE_TYPE_UNKNOWN = 'Unknown'.freeze
61
+
62
+ DEVICE_TYPES = [
63
+ DEVICE_TYPE_COMPUTER,
64
+ DEVICE_TYPE_MOBILE_DEV,
65
+ DEVICE_TYPE_UNKNOWN
66
+ ].freeze
67
+
68
+ # The 'clear' instance method won't change these attrs
69
+ UNCLEARABLE_ATTRS = %i[id serialNumber deviceType].freeze
70
+
71
+
72
+ # Object Model / Attributes
73
+ # See APIObject class documentation for details
74
+ # of how the OBJECT_MODEL hash works.
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 serialNumber
87
+ # @return [String]
88
+ serialNumber: {
89
+ class: :string,
90
+ identifier: true,
91
+ validator: :non_empty_string,
92
+ required: true
93
+ },
94
+
95
+ # @!attribute deviceType
96
+ # @return [String]
97
+ deviceType: {
98
+ class: :string,
99
+ enum: Jamf::InventoryPreloadRecord::DEVICE_TYPES,
100
+ required: true
101
+ },
102
+
103
+ # @!attribute username
104
+ # @return [String]
105
+ username: {
106
+ class: :string
107
+ },
108
+
109
+ # @!attribute fullName
110
+ # @return [String]
111
+ fullName: {
112
+ class: :string
113
+ },
114
+
115
+ # @!attribute emailAddress
116
+ # @return [String]
117
+ emailAddress: {
118
+ class: :string
119
+ },
120
+
121
+ # @!attribute phoneNumber
122
+ # @return [String]
123
+ phoneNumber: {
124
+ class: :string
125
+ },
126
+
127
+ # @!attribute position
128
+ # @return [String]
129
+ position: {
130
+ class: :string
131
+ },
132
+
133
+ # @!attribute department
134
+ # @return [String]
135
+ department: {
136
+ class: :string
137
+ },
138
+
139
+ # @!attribute building
140
+ # @return [String]
141
+ building: {
142
+ class: :string
143
+ },
144
+
145
+ # @!attribute room
146
+ # @return [String]
147
+ room: {
148
+ class: :string
149
+ },
150
+
151
+ # @!attribute poNumber
152
+ # @return [String]
153
+ poNumber: {
154
+ class: :string
155
+ },
156
+
157
+ # @!attribute poDate
158
+ # @return [String]
159
+ poDate: {
160
+ class: :string
161
+ },
162
+
163
+ # @!attribute warrantyExpiration
164
+ # @return [String]
165
+ warrantyExpiration: {
166
+ class: :string
167
+ },
168
+
169
+ # @!attribute appleCareId
170
+ # @return [String]
171
+ appleCareId: {
172
+ class: :string
173
+ },
174
+
175
+ # @!attribute lifeExpectancy
176
+ # @return [String]
177
+ lifeExpectancy: {
178
+ class: :string
179
+ },
180
+
181
+ # @!attribute purchasePrice
182
+ # @return [String]
183
+ purchasePrice: {
184
+ class: :string
185
+ },
186
+
187
+ # @!attribute purchasingContact
188
+ # @return [String]
189
+ purchasingContact: {
190
+ class: :string
191
+ },
192
+
193
+ # @!attribute purchasingAccount
194
+ # @return [String]
195
+ purchasingAccount: {
196
+ class: :string
197
+ },
198
+
199
+ # @!attribute leaseExpiration
200
+ # @return [String]
201
+ leaseExpiration: {
202
+ class: :string
203
+ },
204
+
205
+ # @!attribute barCode1
206
+ # @return [String]
207
+ barCode1: {
208
+ class: :string
209
+ },
210
+
211
+ # @!attribute barCode2
212
+ # @return [String]
213
+ barCode2: {
214
+ class: :string
215
+ },
216
+
217
+ # @!attribute assetTag
218
+ # @return [String]
219
+ assetTag: {
220
+ class: :string
221
+ },
222
+
223
+ # @!attribute extensionAttributes
224
+ # @return [Jamf::InventoryPreloadExtensionAttribute]
225
+ extensionAttributes: {
226
+ class: Jamf::InventoryPreloadExtensionAttribute,
227
+ multi: true
228
+ }
229
+
230
+ }.freeze
231
+
232
+ parse_object_model
233
+
234
+ # TODO: validation for ea's existance and value data type, once EAs are
235
+ # implemented in JPAPI
236
+ #
237
+ # @param ea_name[String] The name of the EA being set
238
+ #
239
+ # @param new_val[String, Integer, Jamf::Timestamp, Time] The value being set
240
+ #
241
+ # @return [void]
242
+ #
243
+ def set_ext_attr(ea_name, new_val)
244
+ remove_ext_attr(ea_name)
245
+ extensionAttributes_append Jamf::InventoryPreloadExtensionAttribute.new(name: ea_name, value: new_val)
246
+ end
247
+
248
+ # remove an EA value
249
+ def remove_ext_attr(ea_name)
250
+ idx = extensionAttributes.index { |ea| ea.name == ea_name }
251
+ extensionAttributes_delete_at idx if idx
252
+ end
253
+
254
+ # clear all values for this record except id, serialNumber, and deviceType
255
+ def clear
256
+ OBJECT_MODEL.keys.each do |attr|
257
+ next if UNCLEARABLE_ATTRS.include? attr
258
+
259
+ # skip nils
260
+ curr_val = send attr
261
+ next unless curr_val
262
+
263
+ if attr == :extensionAttributes
264
+ extensionAttributes = []
265
+ next
266
+ end
267
+
268
+ send "#{attr}=", nil
269
+ end
270
+ end
271
+
272
+ end # class
273
+
274
+ end # module