ruby-jss 1.2.3 → 1.2.4a1

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 (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,190 @@
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 Script < Jamf::CollectionResource
34
+
35
+ # Mix-Ins
36
+ #####################################
37
+
38
+ include Jamf::ChangeLog
39
+ include Jamf::Referable
40
+
41
+ # Constants
42
+ #####################################
43
+
44
+ RSRC_PATH = 'scripts'.freeze
45
+
46
+ RSRC_VERSION = 'v1'.freeze
47
+
48
+ PRIORITY_BEFORE = 'BEFORE'.freeze
49
+ PRIORITY_AFTER = 'AFTER'.freeze
50
+ PRIORITY_AT_REBOOT = 'AT_REBOOT'.freeze
51
+
52
+ PRIORTIES = [
53
+ PRIORITY_BEFORE,
54
+ PRIORITY_AFTER,
55
+ PRIORITY_AT_REBOOT
56
+ ].freeze
57
+
58
+ # Object Model / Attributes
59
+ # See APIObject class documentation for details
60
+ # of how the OBJECT_MODEL hash works.
61
+ #####################################
62
+ OBJECT_MODEL = {
63
+
64
+ # @!attribute [r] id
65
+ # @return [Integer]
66
+ id: {
67
+ class: :integer,
68
+ identifier: :primary,
69
+ readonly: true
70
+ },
71
+
72
+ # @!attribute name
73
+ # @return [String]
74
+ name: {
75
+ class: :string,
76
+ identifier: true
77
+ },
78
+
79
+ # @!attribute info
80
+ # @return [String]
81
+ info: {
82
+ class: :string
83
+ },
84
+
85
+ # @!attribute notes
86
+ # @return [String]
87
+ notes: {
88
+ class: :string
89
+ },
90
+
91
+ # @!attribute priority
92
+ # @return [String]
93
+ priority: {
94
+ class: :string,
95
+ enum: Jamf::Script::PRIORTIES
96
+ },
97
+
98
+ # TODO: Jamf should standardize object references
99
+ # this should be a Category::Reference object
100
+
101
+ # @!attribute categoryId
102
+ # @return [Integer]
103
+ categoryId: {
104
+ class: :integer
105
+ },
106
+
107
+ # @!attribute categoryName
108
+ # @return [String]
109
+ categoryName: {
110
+ class: :string
111
+ },
112
+
113
+ # @!attribute osRequirements
114
+ # @return [String]
115
+ osRequirements: {
116
+ class: :string
117
+ },
118
+
119
+ # @!attribute scriptContents
120
+ # @return [String]
121
+ scriptContents: {
122
+ class: :string,
123
+ validate: :script_contents,
124
+ aliases: %i[code]
125
+ },
126
+
127
+ # @!attribute parameter4
128
+ # @return [String]
129
+ parameter4: {
130
+ class: :string
131
+ },
132
+
133
+ # @!attribute parameter5
134
+ # @return [String]
135
+ parameter5: {
136
+ class: :string
137
+ },
138
+
139
+ # @!attribute parameter6
140
+ # @return [String]
141
+ parameter6: {
142
+ class: :string
143
+ },
144
+
145
+ # @!attribute parameter7
146
+ # @return [String]
147
+ parameter7: {
148
+ class: :string
149
+ },
150
+
151
+ # @!attribute parameter8
152
+ # @return [String]
153
+ parameter8: {
154
+ class: :string
155
+ },
156
+
157
+ # @!attribute parameter9
158
+ # @return [String]
159
+ parameter9: {
160
+ class: :string
161
+ },
162
+
163
+ # @!attribute parameter10
164
+ # @return [String]
165
+ parameter10: {
166
+ class: :string
167
+ },
168
+
169
+ # @!attribute parameter11
170
+ # @return [String]
171
+ parameter11: {
172
+ class: :string
173
+ }
174
+ }.freeze
175
+
176
+ parse_object_model
177
+
178
+
179
+ # Class Methods
180
+ ##################################
181
+
182
+ def self.scriptContents(scr_ident, cnx: Jamf.cnx)
183
+ id = valid_id scr_ident
184
+ raise Jamf::NoSuchItemError, "No script matches '#{scr_ident}'" unless id
185
+ cnx.download "#{RSRC_VERSION}/#{RSRC_PATH}/#{id}/download"
186
+ end
187
+
188
+ end # class
189
+
190
+ end # module
@@ -0,0 +1,77 @@
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 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
@@ -0,0 +1,131 @@
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
+ # The API endpoint for country codes.
29
+ #
30
+ # Probably more useful is the Jamf.app_store_country_codes method
31
+ # which parses this into a hash of Code => Name
32
+ #
33
+ class AppStoreCountryCodes < Jamf::SingletonResource
34
+
35
+ extend Jamf::Immutable
36
+
37
+ # Constants
38
+ #####################################
39
+
40
+ RSRC_VERSION = 'v1'.freeze
41
+
42
+ RSRC_PATH = 'app-store-country-codes'.freeze
43
+
44
+ OBJECT_MODEL = {
45
+
46
+ # @!attribute checkInFrequency
47
+ # @return [integer]
48
+ countryCodes: {
49
+ class: Jamf::Country,
50
+ multi: true,
51
+ read_only: true
52
+ }
53
+
54
+ }.freeze # end OBJECT_MODEL
55
+
56
+ parse_object_model
57
+
58
+ # Class Methods
59
+ #####################################
60
+
61
+ # Class level wrapper for #names
62
+ def self.names(refresh = false, cnx: Jamf.cnx)
63
+ fetch(refresh, cnx: cnx).names
64
+ end
65
+
66
+ # Class level wrapper for #codes
67
+ def self.codes(refresh = false, cnx: Jamf.cnx)
68
+ fetch(refresh, cnx: cnx).codes
69
+ end
70
+
71
+ # Class level wrapper for #codes_by_name
72
+ def self.codes_by_name(refresh = false, cnx: Jamf.cnx)
73
+ fetch(refresh, cnx: cnx).codes_by_name
74
+ end
75
+
76
+ # Class level wrapper for #names_by_code
77
+ def self.names_by_code(refresh = false, cnx: Jamf.cnx)
78
+ fetch(refresh, cnx: cnx).names_by_code
79
+ end
80
+
81
+ # Class level wrapper for #code_for_name
82
+ def self.code_for_name(name, refresh = false, cnx: Jamf.cnx)
83
+ fetch(refresh, cnx: cnx).code_for_name name
84
+ end
85
+
86
+ # Class level wrapper for #name_for_code
87
+ def self.name_for_code(code, refresh = false, cnx: Jamf.cnx)
88
+ fetch(refresh, cnx: cnx).name_for_code code
89
+ end
90
+
91
+ # Instance Methods
92
+ #####################################
93
+
94
+ # @return [Array<String>] the available country names
95
+ def names
96
+ @names ||= countryCodes.map{ |country| country.name }
97
+ end
98
+
99
+ # @return [Array<String>] the available country codes
100
+ def codes
101
+ @codes ||= countryCodes.map{ |country| country.code }
102
+ end
103
+
104
+ # @return [Hash] name => code
105
+ def codes_by_name
106
+ @codes_by_name ||= countryCodes.map{ |country| [country.name, country.code] }.to_h
107
+ end
108
+
109
+ # @return [Hash] code => name
110
+ def names_by_code
111
+ @names_by_code ||= countryCodes.map{ |country| [country.code, country.name] }.to_h
112
+ end
113
+
114
+ # return a country code from its name, case-insensitive
115
+ # @param name[String] the name of a country
116
+ # @return [String]
117
+ def code_for_name(name)
118
+ name = names.select { |n| n.casecmp? name }.first
119
+ codes_by_name[name]
120
+ end
121
+
122
+ # return a country name from its code, case-insensitive
123
+ # @param name[String] the name of a country
124
+ # @return [String]
125
+ def name_for_code(code)
126
+ names_by_code[code.upcase]
127
+ end
128
+
129
+ end # class AppStoreCountryCodes
130
+
131
+ end # module JAMF
@@ -0,0 +1,88 @@
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
+ # 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