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,63 @@
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 PrestageSyncStatus < Jamf::JSONObject
34
+
35
+ extend Jamf::Immutable
36
+
37
+ OBJECT_MODEL = {
38
+
39
+ # @!attribute syncState [r]
40
+ # @return [String]
41
+ syncState: {
42
+ class: :string
43
+ },
44
+
45
+ # @!attribute prestageId [r]
46
+ # @return [Integer]
47
+ prestageId: {
48
+ class: :integer
49
+ },
50
+
51
+ # @!attribute timestamp [r]
52
+ # @return [Jamf::Timestamp]
53
+ timestamp: {
54
+ class: Jamf::Timestamp
55
+ },
56
+
57
+ }.freeze
58
+
59
+ parse_object_model
60
+
61
+ end # class
62
+
63
+ end # module
@@ -0,0 +1,125 @@
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
+ # A 'location' for a managed object in Jamf Pro
30
+ class PurchasingData < Jamf::JSONObject
31
+
32
+ # TODO: setters or an uncreated device?
33
+
34
+ OBJECT_MODEL = {
35
+
36
+ # @!attribute isPurchased
37
+ # @param [String]
38
+ # @return [String]
39
+ isPurchased: {
40
+ class: :boolean
41
+ },
42
+
43
+ # @!attribute isLeased
44
+ # @param [String]
45
+ # @return [String]
46
+ isLeased: {
47
+ class: :boolean
48
+ },
49
+
50
+ # @!attribute poNumber
51
+ # @param [String]
52
+ # @return [String]
53
+ poNumber: {
54
+ class: :string
55
+ },
56
+
57
+ # @!attribute appleCareId
58
+ # @param [String]
59
+ # @return [String]
60
+ appleCareId: {
61
+ class: :string
62
+ },
63
+
64
+ # @!attribute vendor
65
+ # @param [String]
66
+ # @return [String]
67
+ vendor: {
68
+ class: :string
69
+ },
70
+
71
+ # @!attribute purchasePrice
72
+ # @param [String]
73
+ # @return [String]
74
+ purchasePrice: {
75
+ class: :string
76
+ },
77
+
78
+ # @!attribute purchasingAccount
79
+ # @param [String]
80
+ # @return [String]
81
+ purchasingAccount: {
82
+ class: :string
83
+ },
84
+
85
+ # @!attribute poDate
86
+ # @param [String]
87
+ # @return [String]
88
+ poDate: {
89
+ class: Jamf::Timestamp
90
+ },
91
+
92
+ # @!attribute warrantyExpiresDate
93
+ # @param [String]
94
+ # @return [String]
95
+ warrantyExpiresDate: {
96
+ class: Jamf::Timestamp
97
+ },
98
+
99
+ # @!attribute leaseExpiresDate
100
+ # @param [String]
101
+ # @return [String]
102
+ leaseExpiresDate: {
103
+ class: Jamf::Timestamp
104
+ },
105
+
106
+ # @!attribute lifeExpectancy
107
+ # @param [String]
108
+ # @return [String]
109
+ lifeExpectancy: {
110
+ class: :integer
111
+ },
112
+
113
+ # @!attribute purchasingContact
114
+ # @param [String]
115
+ # @return [String]
116
+ purchasingContact: {
117
+ class: :string
118
+ }
119
+ }.freeze
120
+
121
+ parse_object_model
122
+
123
+ end # class location
124
+
125
+ end # module
@@ -0,0 +1,58 @@
1
+ # Copyright 2019 Pixar
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
+ # with the following modification; you may not use this file except in
5
+ # compliance with the Apache License and the following modification to it:
6
+ # Section 6. Trademarks. is deleted and replaced with:
7
+ #
8
+ # 6. Trademarks. This License does not grant permission to use the trade
9
+ # names, trademarks, service marks, or product names of the Licensor
10
+ # and its affiliates, except as required to comply with Section 4(c) of
11
+ # the License and to reproduce the content of the NOTICE file.
12
+ #
13
+ # You may obtain a copy of the Apache License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the Apache License with the above modification is
19
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+ # KIND, either express or implied. See the Apache License for the specific
21
+ # language governing permissions and limitations under the Apache License.
22
+ #
23
+ #
24
+
25
+ module Jamf
26
+
27
+ # This mixin should be extended in abstract class definitions
28
+ # it will raise an error if those classes are instantiated.
29
+ # It also maintains an array of classes that extend themselves this way
30
+ # and are abstract.
31
+ module Abstract
32
+
33
+ # when a class is extended by this module, it
34
+ # gets added to the array of known abstract classes
35
+ def self.extended(by_class)
36
+ abstract_classes << by_class
37
+ end
38
+
39
+ # Classes will be added to this array as they are exteded by Abstract
40
+ def self.abstract_classes
41
+ @abstract_classes ||= []
42
+ end
43
+
44
+ def self.abstract?
45
+ abstract_classes.include? self
46
+ end
47
+
48
+ # when any extended class or subclass of an extended class is instntiated
49
+ # check that it isn't in the abstract list.
50
+ def new(*args, &block)
51
+ raise Jamf::UnsupportedError, "Unsupported: #{self} is an abstract class, cannot be instantiated." if Jamf::Abstract.abstract_classes.include? self
52
+
53
+ super
54
+ end
55
+
56
+ end # module Abstract
57
+
58
+ end # Jamf
@@ -0,0 +1,39 @@
1
+ # Copyright 2019 Pixar
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
+ # with the following modification; you may not use this file except in
5
+ # compliance with the Apache License and the following modification to it:
6
+ # Section 6. Trademarks. is deleted and replaced with:
7
+ #
8
+ # 6. Trademarks. This License does not grant permission to use the trade
9
+ # names, trademarks, service marks, or product names of the Licensor
10
+ # and its affiliates, except as required to comply with Section 4(c) of
11
+ # the License and to reproduce the content of the NOTICE file.
12
+ #
13
+ # You may obtain a copy of the Apache License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the Apache License with the above modification is
19
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
+ # KIND, either express or implied. See the Apache License for the specific
21
+ # language governing permissions and limitations under the Apache License.
22
+ #
23
+ #
24
+
25
+ module Jamf
26
+
27
+ # This mixin overrides JSONObject.mutable? to return false,
28
+ # meaning that no setters are ever defined, and if the
29
+ # object is a Jamf::Resource, #save will raise an error
30
+ #
31
+ module Immutable
32
+
33
+ def mutable?
34
+ false
35
+ end
36
+
37
+ end # Lockable
38
+
39
+ end # Jamf
@@ -0,0 +1,136 @@
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
+ module Jamf
27
+
28
+ # a mix-in module for Jamf::Resource subclasses.
29
+ #
30
+ # Many Jamf resources maintain an 'object history', available in the WebUI via
31
+ # the 'History' button at the bottom of a page. Ad-hoc history entries can
32
+ # be added containing textual notes, which is useful for objects that don't
33
+ # have a real 'notes' or 'description' field, like policies.
34
+ #
35
+ # In the Jamf Pro API, this history is usually available at a resource path
36
+ # ending with '/history'
37
+ #
38
+ # Due to the many kinds of history available in Jamf, like management
39
+ # history, application usage history, and so on, ruby-jss uses the term
40
+ # 'change log' to refer to a Jamf resource's 'object history', and access
41
+ # to the change log is provided by this module.
42
+ #
43
+ # The change log can be available in different places:
44
+ #
45
+ # - instances of a CollectionResources (e.g. individual policies)
46
+ # - mix-in this module by including it, to get instance methods
47
+ # - CollectionResources as a whole (e.g. Inventory Preload Records)
48
+ # - mix-in this module by extending it, to get class methods
49
+ # - SingletonResources (e.g. Client Checkin Settings )
50
+ # - mix-in this module by including AND extending, to get both
51
+ #
52
+ # This module will add two methods:
53
+ #
54
+ # 1) #change_log, will fetch and cache an Array of readonly
55
+ # Jamf::ChangeLogEntry instances. passing any truthy parameter will
56
+ # cause it to re-fetch the Array from the server.
57
+ #
58
+ # 2) #add_history_note(note), which takes a string and adds it to the
59
+ # object's change history as a note and re-fetches & caches the history.
60
+ #
61
+ module ChangeLog
62
+
63
+ # The change and note history for this resource.
64
+ #
65
+ # The history is cached internally and only re-fetched when
66
+ # a truthy parameter is given.
67
+ #
68
+ # @param refresh[Boolean] re-fetch and re-cache the history
69
+ #
70
+ # @return [Array<Jamf::ChangeHistoryEntry>] The change and note history for
71
+ # this resource
72
+ #
73
+ def change_log(refresh = false, cnx: Jamf.cnx)
74
+ # this should only be true for instances of CollectionResources
75
+ cnx = @cnx if @cnx
76
+
77
+ @change_log = nil if refresh
78
+ @change_log ||= cnx.get(change_log_rsrc)[:results].map! do |l|
79
+ #
80
+ # TODO: Report bug in jamf data, sometimes there's no details in the JSON
81
+ # so add an empty string if needed. DO it for note too, just in case
82
+ l[:details] ||= Jamf::BLANK
83
+ l[:note] ||= Jamf::BLANK
84
+
85
+ Jamf::ChangeLogEntry.new l
86
+ end # map!
87
+ end
88
+
89
+ # Add a note to this resource's change log.
90
+ #
91
+ # If the change history has been cached already, it is
92
+ # recached after adding the note.
93
+ #
94
+ # @param note[String] The note to add. It cannot be empty.
95
+ #
96
+ # @return [void]
97
+ #
98
+ def add_change_log_note(note, cnx: Jamf.cnx)
99
+ # this should only be true for instances of CollectionResources
100
+ cnx = @cnx if @cnx
101
+
102
+ note = Jamf::Validate.non_empty_string note
103
+ note_to_send = { note: note }
104
+ cnx.post change_log_rsrc, note_to_send
105
+ # flush the cached data, force reload when next accessed, to get new note
106
+ @change_log = nil
107
+ end
108
+
109
+ # Private methods
110
+ ###########################
111
+ private
112
+
113
+ # TODO: Implement paging
114
+ def change_log_rsrc
115
+ @change_log_rsrc ||= "#{rsrc_path}/history"
116
+ end
117
+
118
+ # def change_log_rsrc(page: nil, size: nil)
119
+ # params = ''
120
+ # params << '?' if page || size
121
+ # if page
122
+ #
123
+ # end
124
+ #
125
+ # if size
126
+ #
127
+ # end
128
+ # params << '?' if page || size
129
+ # params << '?' if page || size
130
+ #
131
+ # @change_log_rsrc ||= "#{rsrc_path}/history"
132
+ # end
133
+
134
+ end # module ChangeHistory
135
+
136
+ end # module
@@ -0,0 +1,75 @@
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
+ module Jamf
27
+
28
+ #
29
+ module Extendable
30
+
31
+ # The Array of extensionAttributes converted to a Hash of
32
+ # 'Name' => value
33
+ def ext_attrs
34
+ extensionAttributes.map { |ea| [ea.name, ea.value] }.to_h.freeze
35
+ end
36
+
37
+ def ext_attr_names
38
+ extensionAttributes.map(&:name).freeze
39
+ end
40
+
41
+ def set_ext_attr(ea_name, new_val)
42
+ raise Jamf::NoSuchItemError, "No ext attr named '#{ea_name}'" unless ext_attr_names.include? ea_name
43
+ eattr = extensionAttributes.select { |ea| ea.name == ea_name }.first
44
+ eattr.send :new_value=, new_val
45
+ end
46
+
47
+ def ext_attrs_to_update
48
+ extensionAttributes.select(&:unsaved_changes?)
49
+ end
50
+
51
+ def ext_attrs_unsaved_changes
52
+ ext_attrs_to_update.map do |ea|
53
+ [ea.name,
54
+ {
55
+ old: ea.unsaved_changes[:value][:old],
56
+ new: ea.unsaved_changes[:value][:new]
57
+ }]
58
+ end.to_h
59
+ end
60
+
61
+ def ext_attrs_unsaved_changes?
62
+ !ext_attrs_to_update.empty?
63
+ end
64
+
65
+ def ext_attrs_clear_unsaved_changes
66
+ ext_attrs_to_update.each(&:clear_unsaved_changes)
67
+ end
68
+
69
+ def ext_attrs_to_jamf
70
+ ext_attrs_to_update.map(&:to_jamf)
71
+ end
72
+
73
+ end # extendable
74
+
75
+ end # module